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