Annotation of coherent/d/conf/tboot/Startup.s, revision 1.1.1.1

1.1       root        1: / Startup.s -- initilization code for any tertiary boot program.
                      2: /
                      3: / La Monte H. Yarroll <[email protected]>, September 1991
                      4: /
                      5: 
                      6: / RBOOTS is set exactly 128K below the top of 640K.
                      7: / One day, RBOOTS should be dynamicly determined based on the size of
                      8: / available memory.  If you modify RBOOTS, be sure to update it in tboot.h
                      9: / as well.
                     10:        RBOOTS  = 0x8000                / New segement for boot program.
                     11:        JMPF    = 0xEA                  / jump far, direct
                     12:        SEGSIZ  = 0xffff                / Size of a whole segment.
                     13:        NSTK    = 0x2000                / # of bytes of stack.
                     14:        BLOCK   = 0x200                 / # of bytes in a disk block
                     15:        DIRSIZE = 14                    / Size of a file name.
                     16:        SIZEOFSDAT = 23                 / sizeof(seconddat)
                     17:        SECONDDAT = 0x01E7              / Offset of useful data in secondary boot.
                     18:        CR      = 0x0d                  / Carriage return
                     19:        LF      = 0x0a                  / Line Feed
                     20:        NUL     = 0x00                  / NUL (for terminating strings)
                     21: 
                     22:        / Interrupts.
                     23:        MON     = 0x00          / Invoke BIOS monitor.
                     24:        KEYBD   = 0x16          / Keyboard software interrupt.
                     25:        REBOOT  = 0x19          / Reboot through BIOS.
                     26:        
                     27:        
                     28:        NTRK    = 40            / Number of tracks on a floppy.
                     29:        NSPT    = 9             / Number of sectors per track on a floppy.
                     30:        NHD     = 1             / Number of heads per drive on a floppy.
                     31: 
                     32:        .bssd
                     33: stack: .blkb   NSTK    / Local Stack
                     34: 
                     35:        .shri
                     36:        .blkb   0x100   / Symbol "begin" must be at offset 0x100 from
                     37: begin:                 / the beginning of the code segment--secondary
                     38:                        / boot jumps here.
                     39:        / Upon entry ds points at the secondary boot data segment,
                     40:        / si points at the data we want,
                     41:        / and es points at our data segment.
                     42: 
                     43:        mov     di, $seconddat
                     44:        mov     cx, $SIZEOFSDAT
                     45:        cld
                     46:        rep
                     47:        movsb   / Copy disk configuration information to our own segment.
                     48: 
                     49:        / Create a nice, safe stack.
                     50:        mov     bp, $stack+NSTK
                     51:        mov     ax, es
                     52:        mov     ss, ax
                     53:        mov     sp, bp
                     54:        
                     55:        push    es      / Save location of data segment from secondary boot.
                     56: 
                     57:        / Move the tertiary boot to high memory.
                     58:        call    moveme
                     59:        
                     60:        add     sp, $2  / Throw away old data segment.
                     61: 
                     62:        / Set up the new stack.
                     63: 
                     64:        mov     bp, $stack+NSTK
                     65:        mov     ax, es
                     66:        mov     ss, ax
                     67:        mov     sp, bp
                     68: 
                     69: 
                     70:        .byte   JMPF            / Jump to the relocated code.
                     71:        .word   entry
                     72:        .word   RBOOTS
                     73: 
                     74: entry: call    main_
                     75: 
                     76: / Aargh!  main() returned!  Wait for a keystroke and then reboot.
                     77: 
                     78:        push    $keymsg
                     79:        call    puts_
                     80: 0:     movb    ah, $1  /       while (!iskey()) {
                     81:        int     KEYBD   /               /* Scan the keyboard.  */
                     82:        je      0b      /       }
                     83: 
                     84:                        /       do {
                     85: 1:     movb    ah, $0  /               getch();
                     86:        int     KEYBD   /               /* Read the key.  */
                     87:        movb    ah, $1  /       } while (iskey())
                     88:        int     KEYBD   /               /* Scan the keyboard for another key. */
                     89:        jne     1b      /       
                     90: 
                     91:        int     REBOOT  / Reboot through the BIOS. 
                     92: 
                     93:        .shrd
                     94: keymsg:        
                     95:        .byte   CR
                     96:        .byte   LF
                     97:        .ascii  "Press any key to reboot."
                     98:        .byte   CR
                     99:        .byte   LF
                    100:        .byte   NUL
                    101: 
                    102: ////////
                    103: /
                    104: / Move tertiary boot to high memory.
                    105: / Take one parameter--a word on the stack pointing to the current
                    106: / data segment.
                    107: /
                    108: / As a side effect, this sets ds to the new data segment in high memory.
                    109: /
                    110: ////////
                    111:        .shri
                    112: moveme:
                    113:        mov     bp, sp  / For parameter lookups.
                    114: 
                    115:        / Move the code segment.
                    116:        push    cs
                    117:        pop     ds
                    118:        xor     si, si          / Point ds:si at loaded code segment.
                    119:        mov     ax, $RBOOTS
                    120:        mov     es, ax
                    121:        xor     di, di          / Point es:di at where we want to be.
                    122:        mov     cx, $SEGSIZ     / Move a maximal segment.
                    123:        cld
                    124:        rep
                    125:        movsb
                    126: 
                    127:        / Calculate location of new data segment.
                    128:        mov     ax, 2(bp)
                    129:        push    cs              / Fetch the code segment.
                    130:        pop     bx
                    131:        sub     ax, bx          / Calculate offset to data segment.
                    132:        add     ax, $RBOOTS     / Calculate the new data segment.
                    133:        
                    134:        / Move the data segment.
                    135:        mov     ds, 2(bp)
                    136:        xor     si, si          / Point ds:si at loaded data segment
                    137:        mov     es, ax
                    138:        xor     di, di          / Point es:di at where we want to be.
                    139:        mov     cx, $SEGSIZ     / Move a maximal segment.
                    140:        cld
                    141:        rep
                    142:        movsb
                    143: 
                    144:        / Set the new data segment appropriately.
                    145:        push    es
                    146:        pop     ds
                    147:        mov     myds_, ds
                    148:        ret     / routine moveme
                    149: 
                    150: / Shared data segment (initialized)
                    151:        .shrd
                    152: 
                    153:        .globl  myds_
                    154: myds_: .word   0       / Place to communicate ds to C programs.
                    155: 
                    156: / Variables nbuf, traks, sects, and heads MUST appear in this order.
                    157:        .globl  seconddat
                    158: seconddat:     / Data extracted from secondary boot data segment.
                    159:        .globl  nbuf_
                    160: nbuf_:
                    161: nbuf:  .blkb   DIRSIZE
                    162: 
                    163: / Defaults for all the following parameters match a floppy disk.
                    164:        .globl  traks
                    165:        .globl  traks_
                    166: traks_:
                    167: traks: .word   NTRK    / Number of cylinders on drive we're booting off of.
                    168:        .globl  sects
                    169:        .globl  sects_
                    170: sects_:
                    171: sects: .byte   NSPT    / Number of sectors per track for our drive.
                    172:        .globl  heads
                    173:        .globl  heads_
                    174: heads_:
                    175: heads: .byte   NHD     / Number of heads on drive we're booting off of.
                    176: 
                    177:        .globl  drive
                    178:        .globl  drive_
                    179: drive_:
                    180: drive: .byte   0       / Drive our partition resides upon.
                    181:        .globl  first
                    182:        .globl  first_
                    183: first_:
                    184: first: .word   0       / First block of our partition (?)
                    185:        .word   0

unix.superglobalmegacorp.com

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