Line 2... |
Line 2... |
; mbr.s -- the master boot record
|
; mbr.s -- the master boot record
|
;
|
;
|
|
|
; Runtime environment:
|
; Runtime environment:
|
;
|
;
|
; This code must be loaded and started at 0xC0000000.
|
; This code must be loaded and started at 0xC0010000.
|
; It allocates a stack from 0xC0001000 downwards. So
|
; It allocates a stack from 0xC0011000 downwards. So
|
; it must run within 4K (code + data + stack).
|
; it must run within 4K (code + data + stack).
|
;
|
;
|
; This code expects the disk number of the boot disk
|
; This code expects the disk number of the boot disk
|
; in $16, the start sector of the disk or partition
|
; in $16, the start sector of the disk or partition
|
; to be booted in $17 and its size in $18.
|
; to be booted in $17 and its size in $18.
|
;
|
;
|
; The boot manager, which is loaded by this code,
|
; The boot manager, which is loaded by this code,
|
; must be in standalone (headerless) executable
|
; must be in standalone (headerless) executable
|
; format, stored at absolute disk sectors 2..31,
|
; format, stored at absolute disk sectors 2..31,
|
; and gets loaded and started at 0xC0001000.
|
; and gets loaded and started at 0xC0011000.
|
|
|
.set stacktop,0xC0001000 ; top of stack
|
.set stacktop,0xC0011000 ; top of stack
|
.set loadaddr,0xC0001000 ; where to load the boot manager
|
.set loadaddr,0xC0011000 ; where to load the boot manager
|
|
|
.set cout,0xE0000018 ; ROM console output
|
.set cout,0xC0000018 ; the monitor's console output
|
.set dskio,0xE0000030 ; ROM disk I/O
|
.set dskio,0xC0000030 ; the monitor's disk I/O
|
|
|
; reset arrives here
|
|
reset:
|
|
j start
|
|
|
|
; interrupts arrive here
|
|
intrpt:
|
|
j userMiss
|
|
|
|
; user TLB misses arrive here
|
|
userMiss:
|
|
add $4,$0,intmsg ; we do not expect any interrupt
|
|
jal msgout
|
|
j halt
|
|
|
|
; load the boot manager and start it
|
; load the boot manager and start it
|
start:
|
start:
|
add $29,$0,stacktop ; setup stack
|
add $29,$0,stacktop ; setup stack
|
add $4,$0,strtmsg ; say what is going on
|
add $4,$0,strtmsg ; say what is going on
|
Line 111... |
Line 97... |
jal msgout
|
jal msgout
|
halt1:
|
halt1:
|
j halt1
|
j halt1
|
|
|
; messages
|
; messages
|
intmsg:
|
|
.byte "unexpected interrupt", 0x0D, 0x0A, 0
|
|
strtmsg:
|
strtmsg:
|
.byte "MBR executing...", 0x0D, 0x0A, 0
|
.byte "MBR executing...", 0x0D, 0x0A, 0
|
dremsg:
|
dremsg:
|
.byte "disk read error", 0x0D, 0x0A, 0
|
.byte "disk read error", 0x0D, 0x0A, 0
|
hltmsg:
|
hltmsg:
|