[90] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Functions for initializing the BIOS.
|
---|
| 3 |
|
---|
| 4 | ; Section containing code
|
---|
| 5 | SECTION .text
|
---|
| 6 |
|
---|
| 7 | ;--------------------------------------------------------------------
|
---|
| 8 | ; Initializes the BIOS.
|
---|
| 9 | ; This function is called from main BIOS ROM search routine.
|
---|
| 10 | ;
|
---|
| 11 | ; Initialize_FromMainBiosRomSearch
|
---|
| 12 | ; Parameters:
|
---|
| 13 | ; Nothing
|
---|
| 14 | ; Returns:
|
---|
| 15 | ; Nothing
|
---|
| 16 | ; Corrupts registers:
|
---|
| 17 | ; Nothing
|
---|
| 18 | ;--------------------------------------------------------------------
|
---|
[229] | 19 | Initialize_FromMainBiosRomSearch: ; unused entrypoint ok
|
---|
[3] | 20 | pushf
|
---|
| 21 | push es
|
---|
| 22 | push ds
|
---|
| 23 | ePUSHA
|
---|
| 24 |
|
---|
[90] | 25 | LOAD_BDA_SEGMENT_TO es, ax
|
---|
[229] | 26 | sti ; Enable interrupts
|
---|
| 27 | test BYTE [es:BDA.bKBFlgs1], (1<<2) ; Clears ZF if CTRL is held down
|
---|
[90] | 28 | jnz SHORT .SkipRomInitialization
|
---|
[3] | 29 |
|
---|
[229] | 30 | ; Install INT 19h handler (boot loader) where drives are detected
|
---|
[258] | 31 | mov al, BIOS_BOOT_LOADER_INTERRUPT_19h
|
---|
[243] | 32 | mov si, Int19h_BootLoaderHandler
|
---|
[258] | 33 | call Interrupts_InstallHandlerToVectorInALFromCSSI
|
---|
[229] | 34 |
|
---|
[90] | 35 | .SkipRomInitialization:
|
---|
[3] | 36 | ePOPA
|
---|
| 37 | pop ds
|
---|
| 38 | pop es
|
---|
| 39 | popf
|
---|
| 40 | retf
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 | ;--------------------------------------------------------------------
|
---|
| 44 | ; Initializes the BIOS variables and detects IDE drives.
|
---|
| 45 | ;
|
---|
| 46 | ; Initialize_AndDetectDrives
|
---|
| 47 | ; Parameters:
|
---|
[90] | 48 | ; ES: BDA Segment
|
---|
[3] | 49 | ; Returns:
|
---|
[97] | 50 | ; DS: RAMVARS segment
|
---|
[3] | 51 | ; Corrupts registers:
|
---|
[97] | 52 | ; All
|
---|
[3] | 53 | ;--------------------------------------------------------------------
|
---|
| 54 | Initialize_AndDetectDrives:
|
---|
[363] | 55 | mov WORD [es:BOOTVARS.wMagicWord], BOOTVARS_MAGIC_WORD
|
---|
[130] | 56 | call BootMenuPrint_InitializeDisplayContext
|
---|
[3] | 57 | call DetectPrint_RomFoundAtSegment
|
---|
| 58 | call RamVars_Initialize
|
---|
[33] | 59 | call Interrupts_InitializeInterruptVectors
|
---|
[3] | 60 | call DetectDrives_FromAllIDEControllers
|
---|
[98] | 61 | ; Fall to .StoreDptPointersToIntVectors
|
---|
[97] | 62 |
|
---|
| 63 | ;--------------------------------------------------------------------
|
---|
[98] | 64 | ; .StoreDptPointersToIntVectors
|
---|
[97] | 65 | ; Parameters:
|
---|
| 66 | ; DS: RAMVARS segment
|
---|
| 67 | ; ES: BDA and interrupt vector segment (zero)
|
---|
| 68 | ; Returns:
|
---|
| 69 | ; Nothing
|
---|
| 70 | ; Corrupts registers:
|
---|
| 71 | ; DX, DI
|
---|
| 72 | ;--------------------------------------------------------------------
|
---|
[98] | 73 | .StoreDptPointersToIntVectors:
|
---|
[97] | 74 | mov dl, 80h
|
---|
[262] | 75 | call FindDPT_ForDriveNumberInDL ; DPT to DS:DI
|
---|
[258] | 76 | jc SHORT .FindForDrive81h ; Store nothing if not our drive
|
---|
[152] | 77 | mov [es:HD0_DPT_POINTER_41h*4], di
|
---|
| 78 | mov [es:HD0_DPT_POINTER_41h*4+2], ds
|
---|
[97] | 79 | .FindForDrive81h:
|
---|
| 80 | inc dx
|
---|
[262] | 81 | call FindDPT_ForDriveNumberInDL
|
---|
[258] | 82 | jc SHORT .ResetDetectedDrives
|
---|
[152] | 83 | mov [es:HD1_DPT_POINTER_46h*4], di
|
---|
| 84 | mov [es:HD1_DPT_POINTER_46h*4+2], ds
|
---|
[33] | 85 | ; Fall to .ResetDetectedDrives
|
---|
[3] | 86 |
|
---|
| 87 | ;--------------------------------------------------------------------
|
---|
[97] | 88 | ; .ResetDetectedDrives
|
---|
[3] | 89 | ; Parameters:
|
---|
| 90 | ; DS: RAMVARS segment
|
---|
[243] | 91 | ; ES: BDA and interrupt vector segment (zero)
|
---|
[3] | 92 | ; Returns:
|
---|
| 93 | ; Nothing
|
---|
| 94 | ; Corrupts registers:
|
---|
[243] | 95 | ; All, except DS and ES
|
---|
[3] | 96 | ;--------------------------------------------------------------------
|
---|
[33] | 97 | .ResetDetectedDrives:
|
---|
[150] | 98 | call Idepack_FakeToSSBP
|
---|
[271] | 99 | call AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization
|
---|
[158] | 100 | add sp, BYTE EXTRA_BYTES_FOR_INTPACK
|
---|
[363] | 101 | mov WORD [es:BOOTVARS.wMagicWord], 0
|
---|
[150] | 102 | ret
|
---|