1 /****^  ***********************************************************
  2         *                                                         *
  3         * Copyright, (C) Honeywell Bull Inc., 1987                *
  4         *                                                         *
  5         * Copyright, (C) Honeywell Information Systems Inc., 1984 *
  6         *                                                         *
  7         *********************************************************** */
  8 
  9 
 10 /****^  HISTORY COMMENTS:
 11   1) change(86-06-05,GJohnson), approve(86-06-05,MCR7387),
 12      audit(86-06-10,Martinson), install(86-07-11,MR12.0-1091):
 13      Correct error message documentation.
 14                                                    END HISTORY COMMENTS */
 15 
 16 
 17 disk_reader: proc (data_ptr, data_lth);
 18 
 19 /* Routine to read a specified number of words from the mst area on disk.
 20 This routine replaces tape_reader as far as segment_loader and load_system
 21 are concerned.
 22 Initially coded October 1983 by Keith Loepere. */
 23 
 24 /* format: style4,indattr,ifthenstmt,ifthen,idind33,^indcomtxt */
 25 
 26 dcl  Max_pages                        fixed bin init (256) static options (constant); /* max in a hardware segment */
 27 dcl  addr                             builtin;
 28 dcl  addrel                           builtin;
 29 dcl  data_lth                         fixed bin (18) parameter;/* in words, desired */
 30 dcl  data_ptr                         ptr parameter;        /* to user's area */
 31 dcl  disk_mst_seg$                    external;             /* abs_seg mapped onto mst disk area */
 32 dcl  disk_mst_seg_astep               ptr static;
 33 dcl  disk_mst_seg_sdw                 fixed bin (71);
 34 dcl  divide                           builtin;
 35 dcl  make_sdw$no_pages                entry (fixed bin (15), fixed bin (71), ptr, ptr);
 36 dcl  min                              builtin;
 37 dcl  mst_area_left                    fixed bin (26) static;/* number of words left to read */
 38 dcl  next_mst_word                    fixed bin (26) static;/* next word (within disk_mst_seg) to read */
 39 dcl  page_table                       (0:255) bit (36) aligned based (ptp);
 40 dcl  pc$cleanup                       entry (ptr);
 41 dcl  pmut$camp                        entry;
 42 dcl  pmut$swap_sdw                    entry (ptr, ptr);
 43 dcl  ptp                              ptr static;           /* to page table for disk_mst_seg */
 44 dcl  ptw_num                          fixed bin;            /* loop counter */
 45 dcl  ptw_util_$make_disk              entry (ptr, fixed bin (20));
 46 dcl  pvt$root_pvtx                    fixed bin external;
 47 dcl  segno                            builtin;
 48 dcl  start_partition_record           fixed bin (20) static;/* first record described by disk_mst_seg */
 49 dcl  sys_boot_info$bce_part_frec      fixed bin (20) external;
 50 dcl  sys_boot_info$bce_part_nrec      fixed bin (20) external;
 51 dcl  sys_boot_info$mst_past_bce_frec  fixed bin (20) external;
 52 dcl  syserr                           entry options (variable);
 53 dcl  user_area                        (user_area_lth) bit (36) aligned based (user_area_ptr);
 54 dcl  user_area_lth                    fixed bin (18);
 55 dcl  user_area_ptr                    ptr;
 56 dcl  user_data_lth                    fixed bin (18);       /* space needed yet */
 57 
 58           if mst_area_left < data_lth then call syserr (CRASH, "disk_reader: Attempt to read past end of mst area.");
 59 
 60           user_area_ptr = data_ptr;
 61           user_data_lth = data_lth;
 62           do while (user_data_lth > 0);
 63                user_area_lth = min (user_data_lth, Max_pages * 1024 - next_mst_word);
 64                user_area = addrel (addr (disk_mst_seg$), next_mst_word) -> user_area;
 65                user_data_lth = user_data_lth - user_area_lth;
 66                user_area_ptr = addrel (user_area_ptr, user_area_lth);
 67                mst_area_left = mst_area_left - user_area_lth;
 68                next_mst_word = next_mst_word + user_area_lth;
 69                if next_mst_word = Max_pages * 1024 then do;
 70                     call pc$cleanup (disk_mst_seg_astep);
 71                     call advance_mst_seg;
 72                end;
 73           end;
 74           return;
 75 %page;
 76 init: entry;
 77 
 78 /* Initially set up disk_mst_seg onto the mst area of disk. */
 79 
 80           call make_sdw$no_pages (segno (addr (disk_mst_seg$)), disk_mst_seg_sdw, disk_mst_seg_astep, ptp);
 81           disk_mst_seg_astep -> aste.pvtx = pvt$root_pvtx;
 82           call pmut$swap_sdw (addr (disk_mst_seg$), addr (disk_mst_seg_sdw));
 83           start_partition_record = sys_boot_info$mst_past_bce_frec - Max_pages;
 84           mst_area_left = (sys_boot_info$bce_part_frec + sys_boot_info$bce_part_nrec - sys_boot_info$mst_past_bce_frec) * 1024;
 85           next_mst_word = 0;
 86           call advance_mst_seg;
 87           return;
 88 %page;
 89 final: entry;
 90 
 91 /* free disk_mst_seg */
 92 
 93           call pc$cleanup (disk_mst_seg_astep);   /* free coremap entries */
 94           disk_mst_seg_sdw = 0;
 95           call pmut$swap_sdw (addr (disk_mst_seg$), addr (disk_mst_seg_sdw));
 96           return;
 97 %page;
 98 advance_mst_seg: proc;
 99 
100 /* Map the disk_mst_seg onto the next set of pages in the mst area. */
101 
102           start_partition_record = start_partition_record + Max_pages;
103           next_mst_word = 0;
104           do ptw_num = 0 to min (Max_pages, divide (mst_area_left + 1023, 1024, 20)) - 1;
105                call ptw_util_$make_disk (addr (page_table (ptw_num)), start_partition_record + ptw_num);
106           end;
107           call pmut$camp;
108           return;
109      end;
110 %page; %include aste;
111 %page; %include bce_partition_layout;
112 %page; %include syserr_constants;
113 %page;
114 
115 /* BEGIN MESSAGE DOCUMENTATION
116 
117    Message:
118    disk_reader: Attempt to read past end of mst area.
119 
120    S: $crash
121 
122    T: $init
123 
124    M: An attempt was made to read more data from the mst area of disk than was
125    placed there from the MST.  This is most likely the result of an MST
126    misformed originally.
127 
128    A: $recover
129    $boot_tape
130 
131    END MESSAGE DOCUMENTATION */
132 
133      end;