Annotation of researchv10no/sys/ml/boot.s, revision 1.1.1.1

1.1       root        1: #
                      2: # primitives to stop the machine
                      3: # with and without rebooting
                      4: # big vax version
                      5: #
                      6: # subtleties:
                      7: # the crash dump is written after a `warm restart',
                      8: # so it will happen if the system mysteriously halts.
                      9: # but registers must be saved before the restart,
                     10: # as restarts often destroy the registers.
                     11: # but they must be saved after the restart too if
                     12: # the system just halted.
                     13: # hence some of the tangle below.
                     14: #
                     15: # the flow:
                     16: # if we are supposed to reboot:
                     17: #      save the registers
                     18: #      cause a warm restart
                     19: # when we restart:
                     20: #      if this wasn't a power failure,
                     21: #      save registers if not already saved,
                     22: #      write a crash dump,
                     23: #      reboot.
                     24: #
                     25:        .text
                     26: 
                     27: #
                     28: # reboot restarts the machine, if possible
                     29: # we ask for an auto-restart
                     30: # which will take a crash dump and then boot
                     31: #
                     32: # if the argument is nonzero, and it seems safe, call update first
                     33: #
                     34: 
                     35:        .globl  _reboot
                     36: _reboot: .word 0x0
                     37:        mfpr    $IPL,rebipl     # merely for debugging
                     38:        tstl    4(ap)
                     39:        beql    1f              # don't want to sync
                     40:        movpsl  r0
                     41:        bbs     $PSLB_IS,r0,1f  # or on interrupt stack, so shouldn't
                     42:        mtpr    $0,$IPL
                     43:        calls   $0,_update
                     44:        mull3   $1000000,_delayfact,r0  # about 1 sec delay to let update finish
                     45: 0:     sobgtr  r0,0b
                     46: 1:     mtpr    $HIGH,$IPL      # from here on, no interruptions!
                     47:        bbss    $0,gotregs,1f
                     48:        movl    sp,rebsp        # save current stack
                     49:        moval   rebsp,sp        # get ptr to register save place
                     50:        pushr   $0x3fff         # save the registers there
                     51:        movl    rebsp,sp        # and get the real stack back
                     52:        mfpr    $PCBB,rebpcb
                     53: 1:
                     54:        mtpr    $0,$MAPEN       # else comet can't find rpb!
                     55:        halt                    # whereupon we shall restart
                     56: 
                     57: #
                     58: # place to call on auto-restart,
                     59: # from the restart parameter block
                     60: #
                     61: 
                     62:        .globl  restart
                     63:        .align  2
                     64: restart:
                     65:        bbss    $0,_rpb+12,0f           # console should do this, but doesn't
                     66: 0:
                     67: #      cmpl    $PFMAGIC,pfmagic        # power fail?
                     68: #      bneq    doadump         # no
                     69: #       clrl   _rpb+12         # yes: flag further restarts ok
                     70: #       jmp    Xpowrec         # and do power recovery
                     71: #
                     72: # here if started at 0x10 -> dump core
                     73: #
                     74:        .globl  doadump
                     75: doadump:
                     76:        mtpr    $HIGH,$IPL      # from here on, no interruptions!
                     77:        bbss    $0,gotregs,1f
                     78:        movl    sp,rebsp        # save current stack
                     79:        moval   rebsp,sp        # get ptr to register save place
                     80:        pushr   $0x3fff         # save the registers there
                     81:        movl    rebsp,sp        # and get the real stack back
                     82:        mfpr    $PCBB,rebpcb
                     83:        mfpr    $MAPEN,rebmapen
                     84: 1:
                     85:        mtpr    $0,$MAPEN       # turn off memory management
                     86:        movab   dumpstack,sp    # set up a clean stack
                     87:        pushab  dumping
                     88:        calls   $1,_printf
                     89:        movl    _time,dumptime
                     90:        movl    _dumpsize,dumplen
                     91:        cmpl    dumplen,_physmem
                     92:        bleq    1f
                     93:         movl   _physmem,dumplen
                     94: 1:     movl    $DUMPMAGIC,dumpmagic
                     95:        pushl   _dumpsize
                     96:        pushl   _dumplow
                     97:        pushl   _dumpunit
                     98:        calls   $3,*_dumprout
                     99:        tstl    r0
                    100:        beql    2f
                    101:         pushab dumpfailed
                    102:         calls  $1,_printf
                    103: 2:
                    104:        clrl    r5              # boot flags; magic: r5 undisturbed in setboot
                    105:        calls   $0,_setboot
                    106:        halt
                    107: 
                    108: dumping: .asciz        "dumping core\n"
                    109: dumpfailed: .asciz "failed\n";
                    110: 
                    111:        .data
                    112:        .align  2
                    113:        .globl  dumpstack
                    114:        .globl  rebregs
                    115:        .globl  rebsp
                    116:        .globl  rebpcb
                    117:        .space  128*4                   # separate stack for dumps
                    118: dumpstack: 
                    119:        .space  4
                    120: rebregs:
                    121:        .space  14*4            # place to store registers from crash
                    122: rebsp: .space  4
                    123: rebpcb:        .space  4               # place for pcbb at crash
                    124: rebipl:        .space  4               # ipl at reboot
                    125: rebmapen: .space 4             # mapen at reboot
                    126: gotregs: .space        4

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.