📄 rxdosbio.asm
字号:
cli
mov di, 522h ; destination address (0:522)
mov word ptr es:[ 1Eh * 4 ][ _segment ], es
mov word ptr es:[ 1Eh * 4 ][ _pointer ], di
lds si, dword ptr cs:[ diskParameterTable ] ; where to copy table
mov cx, 11
rep movsb
sti
mov bx, 522H + _mdtHeadSettleTime
mov byte ptr es:[ bx ], 2
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; relocate this loader up to the high end of lower memory
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov ax, cs
mov ds, ax
mov es, ax
int 12h ; get memory configuration
mov word ptr [ RxDOSBIOS_INITBLOCK. initMemParagraphs ], ax
shl ax, 1
shl ax, 1
shl ax, 1
shl ax, 1
shl ax, 1
shl ax, 1 ; shl ax, 6
sub ax, 64 * (1024 / sizePARAGRAPH) ; subtract 64k in segment form
mov word ptr [ _FATbuffer. _segment ], ax ; address of FAT buffer
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; switch stacks so it doesn't get clobbered during load
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cli
mov ss, ax ; new stack
mov sp, 0FE00h
nop
sti
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; initialize and load
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
xor ax, ax
mov al, byte ptr [ BootDrive_BPB. _bpbNumCopiesFAT ]
mul word ptr [ BootDrive_BPB. _bpbSectorsPerFat ]
add ax, word ptr [ BootDrive_BPB. _bpbResSectors ]
adc dx, 0000
mov word ptr [ RootDirSector. _low ], ax
mov word ptr [ RootDirSector. _high ], dx
; read first sector of Root Directory
mov cx, word ptr [ BootDrive_BPB. _bpbMaxAllocRootDir ]
shr cx, 1
shr cx, 1
shr cx, 1
shr cx, 1
add ax, cx
adc dx, 0000
mov word ptr [ ReservedBeforeDataSector. _low ], ax
mov word ptr [ ReservedBeforeDataSector. _high ], dx
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Reset Interrupts
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov al, 20h
out 20h, al
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Display startup banner
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov si, offset RXDOSBIO_MSGLoadingRxDOS
call _DisplayMsg ; Loading RxDOS ...
IFDEF RxDOS_DEBUG
mov si, offset RXDOSBIO_MSGDEBUG_CANTLOAD
call _DisplayMsg ; Can't Load Debug Image
RxDOSBIOS_InitHalt:
jmp RxDOSBIOS_InitHalt
ENDIF
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; load the remainder of rxdosbio.sys and rxdos.sys
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov di, 600h ; reload starts at 600h
mov dx, word ptr [ RXDOSBIO_ClusterAddr ]
call _LoadProgram ; Load RxDOSBIO
ifc RxDOSBIOS_Error
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Load Protection ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Everything above this line must reside in the first 600 hex ;
; bytes of the file. This is the minimal portion loaded by the ;
; bootstarp loader. ;
; ;
; The code below causes an error message in compile if the ;
; file size at this location will exceed 600 hex bytes. ;
;...............................................................;
IF1
IF ($ GE 600h)
error "RxDOSBIO minimal section exceeds 600h (3 sectors) bytes."
ENDIF
ENDIF
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Hardware Evaluation and Startup ;
;...............................................................;
RxDOSBIOS_EvaluateHardware:
mov dl, byte ptr BootDrive ; physical drive
mov byte ptr [ RxDOSBIOS_INITBLOCK. initBootDrive ], dl
mov word ptr [ RxDOSBIOS_INITBLOCK. initDeviceChain. _segment ], cs
mov word ptr [ RxDOSBIOS_INITBLOCK. initDeviceChain. _pointer ], offset CON
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Determine the amount of actual memory
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int 12h ; get memory size
mov word ptr [ RxDOSBIOS_INITBLOCK. initMemParagraphs ], ax
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Determine number of floppy drives
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int 11h ; read hardware configuration
mov word ptr [ _floppyDrives ], 0000 ; number of floppy disks
test ax, 1 ; floppy disks listed ?
jz RxDOSBIOS_EvalHardware_08 ; if no -->
shr ax, 1 ; floppy bit
shr ax, 1 ; math coprocessor
shr ax, 1 ; memory (xt only)
shr ax, 1 ;
shr ax, 1 ; video mode bits
shr ax, 1 ;
and ax, 0003h
inc ax
jmp short RxDOSBIOS_EvalHardware_12
RxDOSBIOS_EvalHardware_08:
mov ah, 8 ; read parameters
mov dl, 0 ; unit 0
int 13h
mov al, dl
mov ah, 0 ; number of drives (if any )
jnc RxDOSBIOS_EvalHardware_12 ; if drives reported -->
xor ax, ax
RxDOSBIOS_EvalHardware_12:
mov word ptr [ _floppyDrives ], ax ; number of floppy disks
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Determine number of hard disk drives
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
xor bx, bx
mov ax, 40h
mov es, ax
mov al, byte ptr es:[ _BIOS_NumFixedDrives ][ bx ]
mov word ptr [ _fixedDrives ], ax ; number of fixed drives
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; determine (manufacture) floppy drives
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov ax, word ptr [ _fixedDrives ] ; get number of fixed drives
or ax, ax ; if no hard disk, total is fine
jnz RxDOSBIOS_EvalHardware_20 ; make sure we add 2 floppy drives -->
cmp word ptr [ _floppyDrives ], 0000 ; number of floppy disks
jz RxDOSBIOS_EvalHardware_22 ; if diskless system -->
RxDOSBIOS_EvalHardware_20:
mov word ptr [ _floppyDrives ], 2 ; if hard disk or one floppy
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Setup remainder of INIT Block
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOSBIOS_EvalHardware_22:
mov word ptr [ RxDOSBIOS_INITBLOCK. initRelocHighBegAddress. _segment ], cs
mov word ptr [ RxDOSBIOS_INITBLOCK. initRelocHighBegAddress. _pointer ], offset RxDOSBIOS_Start
mov word ptr [ RxDOSBIOS_INITBLOCK. initRelocHighSize ], RxDOSBIOS_LastAddress - RxDOSBIOS_Start
mov word ptr [ RxDOSBIOS_INITBLOCK. initRelocHighNotify ], -1
mov word ptr [ RxDOSBIOS_INITBLOCK. initRelocLowBegAddress. _segment ], 0000
mov word ptr [ RxDOSBIOS_INITBLOCK. initRelocLowBegAddress. _pointer ], 0000
mov word ptr [ RxDOSBIOS_INITBLOCK. initRelocLowSize ], 0000
mov word ptr [ RxDOSBIOS_INITBLOCK. initRelocHighNotify ], -1
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; fix-up device driver chain
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov si, offset con
RxDOSBIOS_InitDeviceChain:
mov word ptr _segment [ si ], cs
mov si, word ptr _pointer [ si ]
cmp si, -1
jnz RxDOSBIOS_InitDeviceChain
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Set Interrupt Vectors
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
xor ax, ax
mov es, ax
mov dx, word ptr es:[ 0h * 4 ][ _segment ] ; divide by zero int
mov ax, word ptr es:[ 0h * 4 ][ _pointer ]
mov word ptr cs:[ DivideByZero. _segment ], dx
mov word ptr cs:[ DivideByZero. _pointer ], ax
mov word ptr es:[ 0h * 4 ][ _segment ], cs
mov word ptr es:[ 0h * 4 ][ _pointer ], offset Interrupt_0
mov word ptr es:[ _segment ][ 29h * 4 ], cs
mov word ptr es:[ _pointer ][ 29h * 4 ], offset Interrupt_29
mov cx, 6
mov bx, 0001 * 4 ; int 01h - int 07h
call InitInterruptVectors
mov bx, 33h * 4 ; int 33h
mov word ptr es:[ _segment ][ bx ], cs
mov word ptr es:[ _pointer ][ bx ], offset IntReturn
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Initialize Disk Parameter Tables
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setDS cs
mov cx, word ptr [ _fixedDrives ] ; number of fixed drives
mov dx, word ptr [ _floppyDrives ] ; number of floppy disks
call initDiskParameterBlocks ; returns actual # devices
mov word ptr [ RxDOSBIOS_INITBLOCK. initTotalDrives ], cx
mov byte ptr [ block. devUnits ], cl ; block device header
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Load remainder of RxDOS ;
;...............................................................;
mov ax, sizeDISKBLOCK ; number of block devices
mul cx ; size required by table
add ax, offset RxDOSBIOS_LastAddress + (sizeParagraph - 1)
shr ax, 1
shr ax, 1
shr ax, 1
shr ax, 1 ; paragraphs size
mov dx, cs ; current segment
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -