1 /****^  ***********************************************************
  2         *                                                         *
  3         * Copyright, (C) Honeywell Bull Inc., 1987                *
  4         *                                                         *
  5         * Copyright, (C) Honeywell Information Systems Inc., 1984 *
  6         *                                                         *
  7         * Copyright (c) 1972 by Massachusetts Institute of        *
  8         * Technology and Honeywell Information Systems, Inc.      *
  9         *                                                         *
 10         *********************************************************** */
 11 
 12 /* COPY_FDUMP - Make Copy of Information in Dump Partition:
 13 
 14    This program creates a toe-hold into the dump partition.
 15    This partition may contain dump information left by
 16    the bce dump program. This information is copied into
 17    multiple segments in the directory >dumps. These segments
 18    are force-deactivated as a hedge against crashes.
 19 
 20    4/7/71 - N. I. Morris & S. H. Webber
 21    9/28/71 - modified to allow setting erf no and to add error codes - D. M. Jordan
 22    3/2/73 - modified for 6180 and v2pl1 - RE Mullen
 23    7/11/73 - modified to copy dn355 core image out of part dump and added get_erf_no entry - RE Mullen
 24    10/08/75 - modified for multiple 355s - Robert Coren
 25    02/01/79 - modified to allow more than 10 segnos - F. W. Martinson
 26    08/25/80 - Modified to announce copy in syserr log -- W. Olin Sibert
 27    11/11/80 - modified for the DPS8/70M CPU -- J. A. Bush
 28    03/21/81, W. Olin Sibert, for ADP PTWs and ptw_util_.
 29    02/26/82 - J. Bongiovanni, to eliminate use of FSDCT, force deactivate
 30              dump segments.
 31    11/05/84, Keith Loepere to change terminate to terminate_.
 32    01/22/85, Keith Loepere for new find_partition.
 33 
 34    */
 35 
 36 
 37 /****^  HISTORY COMMENTS:
 38   1) change(86-10-23,Fawcett), approve(86-10-23,MCR7517),
 39      audit(86-10-30,Beattie), install(86-11-03,MR12.0-1206):
 40      Changed to remove the word BOS from message.
 41                                                    END HISTORY COMMENTS */
 42 
 43 
 44 copy_fdump: proc (a_code);
 45 
 46           dcl     i                      fixed bin,         /* page table index */
 47                   p                      ptr,               /* handy pointer */
 48                   ptp                    ptr,               /* Pointer to page table of abs-seg */
 49                   (dt, dt_dn355)         char (24),         /* date and time strings */
 50                   (ename, a_ename, xname, ename_dn355, a_ename_dn355) char (32), /* dump segment entry names */
 51                   erf                    char (12),         /* converted ERF number */
 52                   (erf_no, a_erf_no)     fixed bin,         /* number to set next dump to */
 53                   ptsi                   fixed bin,         /* page table size index */
 54                   code                   fixed bin (35),    /* error code */
 55                   a_code                 fixed bin (35),    /* error code to return to caller */
 56                   rb                     (3) fixed bin (6) init (7, 7, 7), /* ring brackets for call to append */
 57                   seqno                  fixed bin,         /* dump sequence number */
 58                   esw                    fixed bin,         /* entry switch */
 59                   dumpadd                fixed bin (18),    /* address within dump partition */
 60                   nrecs                  fixed bin (18),    /* number of records in PART DUMP */
 61                   next_part_add          fixed bin,         /* dumpadd of rec following PART DUMP */
 62                   first                  fixed bin (20),    /* first address within dump partition */
 63                   (length, a_length)     fixed bin (35),    /* length dump info */
 64                   (a_valid, a_valid_dn355) bit (1),         /* = 1 if dumps are valid */
 65                   word_count             fixed bin (18),    /* number of words to copy from dump partition at one time */
 66                   copy                   (word_count) fixed bin (35) based, /* structure to allow copying of dump data */
 67                   dump_pvtx              fixed bin,
 68                   dump_pvid              bit (36) aligned,
 69                   tsdwp                  ptr,               /* pointer to SDW */
 70                   tsdw                   bit (72);          /* temporary for SDW */
 71 
 72           dcl     (max_size, max_pages, dn355_size) fixed bin; /* max for output segs */
 73           dcl     single_dn355_size      fixed bin (35);    /* number of bits in 355 core image */
 74           dcl     words_per_image        fixed bin;
 75           dcl     pg_size                fixed bin;
 76 
 77           dcl     (dumping_Multics, dumping_dn355) bit (1); /* to keep track of what we want to dump */
 78 
 79           dcl     (hdr_size, rest_size)  fixed bin;         /* sizes in words */
 80 
 81           dcl     dn355_copy             bit (single_dn355_size) aligned based; /* for copying 355 dump */
 82 
 83           dcl     1 din                  based aligned,     /* structure of first 64K of PART DUMP */
 84                     2 header             (hdr_size) fixed bin (35), /* registers, rel locs of segs, etc */
 85                     2 dn355_images       (4),
 86                       3 dn355_core       bit (single_dn355_size) aligned, /* dn355 core image put here by FD355 */
 87                     2 rest               (rest_size) fixed bin (35); /* start of segments dumped by FDUMP */
 88 
 89 
 90           dcl     (error_table_$noaccess fixed bin (35),
 91                   error_table_$dmpinvld  fixed bin (35),
 92                   error_table_$noprtdmp  fixed bin (35),
 93                   error_table_$bdprtdmp  fixed bin (35),
 94                   error_table_$dmpvalid  fixed bin (35),
 95                   error_table_$nopart    fixed bin (35),
 96                   sys_info$default_max_length fixed bin (35),
 97                   sys_info$page_size     fixed bin (35),
 98                   pds$process_group_id   char (32) aligned,
 99                   abs_seg$)              ext;
100 
101           dcl     sst$astsize            fixed bin external static;
102           dcl     1 sst$level            (0:3) aligned external static,
103                     2 ausedp             bit (18) unaligned,
104                     2 no_aste            bit (18) unaligned;
105 
106           dcl     privileged_mode_ut$swap_sdw ext entry (ptr, ptr),
107                   thread$out             entry (ptr, bit (18) unal),
108                   lock$lock_ast          entry,
109                   lock$unlock_ast        entry,
110                   get_ptrs_$given_astep  ext entry (ptr) returns (bit (72) aligned),
111                   syserr                 ext entry options (variable),
112                   condition_             ext entry (char (*), entry),
113                   reversion_             ext entry (char (*)),
114                   date_time_             ext entry (fixed bin (71), char (*)),
115                   append$branchx         ext entry (char (*), char (*), fixed bin (5), (3) fixed bin (6), char (*),
116                                          fixed bin (1), fixed bin (1), fixed bin (24), fixed bin (35)),
117                   initiate               ext entry (char (*), char (*), char (*), fixed bin (1), fixed bin (2), ptr, fixed bin (35)),
118                   pc$cleanup             entry (ptr),
119                   get_aste               ext entry (fixed bin) returns (ptr),
120                   put_aste               ext entry (ptr),
121                   cv_bin_$dec            ext entry (fixed bin (17)) returns (char (12) aligned),
122                   demand_deactivate$force_given_segno entry (ptr, fixed bin (35)),
123                   terminate_$noname      entry (ptr, fixed bin (35)),
124                   find_partition         entry (char (*), fixed bin, bit (36) aligned, fixed bin (18), fixed bin (18), fixed bin (35)),
125                   ptw_util_$make_disk    entry (pointer, fixed bin (20));
126 
127           dcl     (addr, addrel, bit, char, divide, fixed, ltrim, min, null, size, substr) builtin;
128 
129 /* ^L */
130 
131           esw = 0;
132           go to setup;
133 
134 set_erf_no:
135      entry (a_erf_no, a_code);
136           erf_no = a_erf_no;
137           esw = 1;
138           go to setup;
139 
140 get_erf_no:
141      entry (a_length, a_valid, a_ename, a_valid_dn355, a_ename_dn355, a_code);
142           esw = 2;
143           a_length = 0;
144           a_valid, a_valid_dn355 = "0"b;
145           a_ename, a_ename_dn355 = "                                ";
146 
147 setup:
148           a_code = 0;
149           p = null ();                                      /* So any_other handler wins */
150           pg_size = sys_info$page_size;                     /* number of words per page */
151           max_size = sys_info$default_max_length;           /* max number of words in segs copy_fdump creates */
152           max_pages = divide (max_size + pg_size - 1, pg_size, 17, 0);
153           dn355_size = 16384 * 4;                           /* words equaling 32K of 18bit words for up to 4 355s */
154           single_dn355_size = 16384 * 36;                   /* bits for one 355 core image */
155           words_per_image = 16384;                          /* same in words */
156           hdr_size = size (dump);                           /* number of words in dump header */
157 
158 /* Determine location and size of the dump partition. */
159 
160           call find_partition ("dump", dump_pvtx, dump_pvid, dumpadd, nrecs, code);
161           if code ^= 0 then do;
162                     if code = error_table_$nopart then a_code = error_table_$noprtdmp;
163                     else a_code = code;
164                     return;
165                end;
166 
167           first = dumpadd;
168 
169           if nrecs = 0 then do;
170                     a_code = error_table_$bdprtdmp;
171                     return;
172                end;
173 
174           next_part_add = first + nrecs;                    /*  Stop before here */
175 
176 /* Now create an abs_seg through which to look at the dump */
177 
178           dumpptr = addr (abs_seg$);                        /* get pointer to abs_seg */
179           tsdwp = addr (tsdw);                              /* get a pointer to the SDW to be used */
180           call lock$lock_ast;
181           astep = get_aste (max_pages);                     /* get a large page table / ASTE */
182           ptsi = fixed (aste.ptsi, 2);
183           call thread$out (astep, sst$level.ausedp (ptsi));
184           call lock$unlock_ast;
185           ptp = addrel (astep, sst$astsize);                /* get a pointer to the page table */
186           tsdw = get_ptrs_$given_astep (astep);             /* get the actual SDW to use */
187           call privileged_mode_ut$swap_sdw (dumpptr, tsdwp);/* make abs_seg point to the dump seg */
188           aste.pvtx = dump_pvtx;
189           aste.csl = bit (fixed (max_pages,9), 9);                    /* Set correct current length in AST entry. */
190           aste.nqsw = "1"b;                                 /* indicate no quota for this segment */
191                                                             /* ^L */
192                                                             /* Set up a condition in case we bomb out. */
193           call condition_ ("any_other", handler);
194           if esw = 1 then go to set_num;                    /* just set the erf number in the dump partition */
195           if esw = 2 then go to get_num;                    /* just return info in dump header */
196 
197 /* Attempt to copy the dump information into the hierarchy. */
198 
199           do seqno = 0 by 1;                                /* Keep going until we run out of information. */
200                do i = 0 to (max_pages - 1) while (i < next_part_add - dumpadd);
201                     call ptw_util_$make_disk (addrel (ptp, i), (dumpadd + i)); /* The disk record */
202                end;
203                if seqno = 0 then do;                        /* were making our first seg in >dumps */
204                          call check_dump_header;            /* Initialize some variables and see whats in PART DUMP */
205                          length = min (length, nrecs * pg_size - dn355_size - hdr_size);
206                          if dumping_dn355 then do;          /* we want to make a special seg in >dumps for 355core image */
207                                    xname = ename_dn355;     /* will have ".355" suffix */
208                                    word_count = dn355_size; /* clearly */
209                                    call get_branch;         /* get and initiate a branch */
210                                    do i = 1 to 4;           /* copy up to four 355 core images */
211                                         if substr (dumpptr -> dump.dumped_355s, i, 1) /* there is an image for this one */
212                                         then p -> dn355_copy = dumpptr -> din.dn355_images (i).dn355_core; /* copy it */
213                                         else p -> dn355_copy = "0"b;
214 
215                                         p = addrel (p, words_per_image); /* bump to next core image */
216                                    end;
217 
218                                    dumpptr -> dump.valid_355 = "0"b; /*  turn off the valid bit */
219                               end;
220                          if dumping_Multics then do;        /* need to skip over the dn355 stuff */
221                                    call pc$cleanup (astep); /* Force all pages from core. */
222                                    aste.npfs = "0"b;        /* turn off no page fault switch */
223                                    do i = 0 to 1;           /* fill in first 2 ptws */
224                                         call ptw_util_$make_disk (addrel (ptp, i), (dumpadd + i)); /* The disk record */
225                                    end;
226                                    dumpadd = dumpadd + divide (dn355_size, pg_size, 18, 0); /* skip over dn355 data */
227                                    do i = 2 to (max_pages - 1) while (i < next_part_add - dumpadd);
228                                         call ptw_util_$make_disk (addrel (ptp, i), (dumpadd + i)); /* The disk record */
229                                    end;
230                                    rest_size = min (max_size - hdr_size, length); /* does not include header */
231                                    word_count = hdr_size + rest_size; /* the number of words to this branch */
232                                    xname = ename;           /* the name of the branch we will create */
233                                    call get_branch;         /* get and initiate the branch */
234                                    p -> copy = dumpptr -> copy; /* copy the header and some Multics segs */
235                                    length = length - rest_size; /* remaining length is less now */
236                               end;
237                     end;
238                else do;                                     /* no need to worry about dn355 stuff */
239                          substr (ename, 13) = ltrim (char (seqno)) || "." || ltrim (erf);
240                          word_count = min (length, max_size); /* take what we can */
241                          xname = ename;                     /* a standard name */
242                          call get_branch;
243                          p -> copy = dumpptr -> copy;       /* copy the data */
244                          length = length - word_count;      /* shorten remaining length */
245                     end;
246                call pc$cleanup (astep);                     /* Force all pages from core. */
247                aste.npfs = "0"b;                            /* Turn off the no page fault switch. */
248                dumpadd = dumpadd + max_pages;               /* Step partition address to next max_pagesK. */
249                if ^dumping_Multics then go to endup;        /* dn355 core is copied already */
250                if length <= 0 then go to cleanup;           /* Check for completion of Multics dump copying */
251           end;                                              /* Continue loop until dump info exhausted. */
252                                                             /* ^L */
253 cleanup:
254           call ptw_util_$make_disk (ptp, first);            /* Insert toe-hold to first record */
255           dumpptr -> dump.valid = "0"b;                     /* Turn off valid bit. */
256           call syserr (LOG, "copy_fdump: Copied fdump image of erf ^d (^a) for ^a", /* let anyone who cares know about this */
257                dumpptr -> dump.erfno, dt, pds$process_group_id);
258 
259 endup:
260           call pc$cleanup (astep);                          /* Force all pages from core. */
261 
262 exit:
263           call reversion_ ("any_other");
264           if p ^= null () then do;                          /* terminate and force-deactivate */
265                     call demand_deactivate$force_given_segno (p, code);
266                     call terminate_$noname (p, code);
267                end;
268 
269 
270           call lock$lock_ast;
271           call put_aste (astep);                            /* return the AST entry */
272           call lock$unlock_ast;
273           tsdw = ""b;
274           call privileged_mode_ut$swap_sdw (dumpptr, tsdwp);
275           return;
276 
277 set_num:                                                    /* CODE to reset the erf number in PART DUMP */
278           call ptw_util_$make_disk (ptp, first);            /* Establish address for first page */
279 
280           if (dumpptr -> dump.valid | dumpptr -> dump.valid_355)
281           then do;                                          /* Previous dump hasn't been picked up */
282                     a_code = error_table_$dmpvalid;
283                     go to endup;
284                end;
285 
286           dumpptr -> dump.erfno = erf_no - 1;               /* set the dump number */
287           go to endup;
288 
289 get_num:                                                    /* CODE to get the erf number in PART DUMP */
290           call ptw_util_$make_disk (ptp, first);            /* get address of first page */
291 
292           call check_dump_header;                           /* internal proc to decode header info */
293 
294           if dumping_Multics then do;
295                     a_length = length;
296                     a_valid = dumping_Multics;
297                     a_ename = ename;
298                end;
299           if dumping_dn355 then do;
300                     a_valid_dn355 = dumping_dn355;
301                     a_ename_dn355 = ename_dn355;
302                end;
303 
304           go to endup;
305 
306 
307 
308 
309 /* ^L */
310 
311 /* INTERNAL PROC to examine the dump header */
312 check_dump_header: proc;
313           if esw ^= 1 then /* previously checked that it's invalid for set_erf_no entry */
314                if dumpptr -> dump.valid = "0"b then
315                     if dumpptr -> dump.valid_355 = "0"b then do;
316                               a_code = error_table_$dmpinvld; /* No valid dumps so scram */
317                               go to endup;
318                          end;
319           dumping_Multics = dumpptr -> dump.valid;          /* want to copy valid Multics dump */
320           dumping_dn355 = dumpptr -> dump.valid_355;        /* want to copy valid 355 dump */
321           length = dumpptr -> dump.words_dumped;            /* keep this number handy */
322                                                             /* Now fabricate a name for the dump. The names look like ...
323                                                                MMDDYY.TTTT.N.EEE
324                                                                MMDDYY = month, day, year
325                                                                TTTT   = time of day
326                                                                N      = sequence number of dump segment
327                                                                EEE    = ERF number
328                                                                */
329           erf = cv_bin_$dec ((dumpptr -> dump.erfno));      /* Convert the ERF number. */
330           if dumping_Multics then do;
331                     call date_time_ (dumpptr -> dump.time, dt); /* Convert the date and time of dump. */
332                     ename = substr (dt, 1, 2) || substr (dt, 4, 2) || substr (dt, 7, 2) || "."
333                          || substr (dt, 11, 5) || "0." || ltrim (erf);
334                end;
335           if dumping_dn355 then do;
336                     call date_time_ (dumpptr -> dump.time_355, dt_dn355); /* setup name for 355 segs in >dumps similarly */
337                     ename_dn355 = substr (dt_dn355, 1, 2) || substr (dt_dn355, 4, 2) || substr (dt_dn355, 7, 2) || "."
338                          || substr (dt_dn355, 11, 5) || "0." || ltrim (erf) || ".355";
339                end;
340      end check_dump_header;
341 
342 /* INTERNAL PROC to create a seg in >dumps, and initiate it */
343 get_branch: proc;                                           /* share stack frame */
344 append:
345           if p ^= null () then do;                          /* terminate and force-deactivate */
346                     call demand_deactivate$force_given_segno (p, code);
347                     call terminate_$noname (p, code);
348                end;
349 
350           call append$branchx (">dumps", xname, RW_ACCESS_BIN, rb, (pds$process_group_id), 0, 0, 36 * word_count, code);
351           if code ^= 0 then do;
352                     if code = error_table_$noaccess then do;/* >dumps is not there */
353                               call append$branchx (">", "dumps", A_ACCESS_BIN, rb, "*.*.*", 1, 0, 0, code); /* create it */
354                               if code ^= 0 then do;
355                                         a_code = code;
356                                         go to endup;
357                                    end;
358                               go to append;                 /* loop back to try again */
359                          end;
360                     else do;                                /* Branch cannot be created. */
361                               a_code = code;
362                               go to endup;
363                          end;
364                end;
365           call initiate (">dumps", xname, "", 0, 0, p, code); /* get a pointer to the new seg */
366           if p = null then do;                              /* If initiation failed ... */
367                     a_code = code;
368                     go to endup;
369                end;
370      end get_branch;
371                                                             /* ^L */
372 
373 /* INTERNAL PROC to handle unclaimed signals */
374 
375 handler: proc (mc_ptr, name);
376 
377           dcl     mc_ptr                 ptr,               /* pointer to machine conditions (not used) */
378                   name                   char (*);          /* name of the condition */
379 
380 
381           call syserr (ANNOUNCE, "copy_fdump: unexpected ^a signal.", name);
382           go to exit;                                       /* Print comment, and then clean up and exit. */
383      end handler;
384 
385 %page; %include access_mode_values;
386 %page; %include aste;
387 %page; %include bos_dump;
388 %page; %include syserr_constants;
389 /* ^L */
390 
391 /* BEGIN MESSAGE DOCUMENTATION
392 
393    Message:
394    copy_fdump: unexpected NAME signal.
395 
396    S:     $info
397 
398    T:     $run
399 
400    M:     An attempt to copy the dump from the DUMP partition with
401    copy_fdump resulted in an unclaimed signal. This may be due to
402    damage to the DUMP partition contents, a malfunction of the BCE
403    dump command, a supervisor error, or a simple difficulty
404    like running out of space in >dumps. The system continues operation.
405    The copied dump may be only partly valid.
406 
407    A:     $notify
408 
409 
410    Message:
411    copy_fdump: Copied fdump image of erf NNN (MM/DD/YY HHMM.M) for USERNAME
412 
413    S:     $info
414 
415    T:     $run
416 
417    M:     The user identified by USERNAME has successfully copied the
418    FDUMP image for the specified ERF out of the DUMP partition. The time
419    the FDUMP was taken is also included in the message. This message is
420    informational only, and is intended only as an aid in tracking system
421    progress by perusing the syserr log.
422 
423    A:     $ignore
424 
425 
426    END MESSAGE DOCUMENTATION */
427 
428      end copy_fdump;