[3] | 1 | ; File name : Initialize.asm
|
---|
| 2 | ; Project name : IDE BIOS
|
---|
| 3 | ; Created date : 23.3.2010
|
---|
[33] | 4 | ; Last update : 23.8.2010
|
---|
[3] | 5 | ; Author : Tomi Tilli
|
---|
| 6 | ; Description : Functions for initializing the BIOS.
|
---|
| 7 |
|
---|
| 8 | ; Section containing code
|
---|
| 9 | SECTION .text
|
---|
| 10 |
|
---|
| 11 | ;--------------------------------------------------------------------
|
---|
| 12 | ; Initializes the BIOS.
|
---|
| 13 | ; This function is called from main BIOS ROM search routine.
|
---|
| 14 | ;
|
---|
| 15 | ; Initialize_FromMainBiosRomSearch
|
---|
| 16 | ; Parameters:
|
---|
| 17 | ; Nothing
|
---|
| 18 | ; Returns:
|
---|
| 19 | ; Nothing
|
---|
| 20 | ; Corrupts registers:
|
---|
| 21 | ; Nothing
|
---|
| 22 | ;--------------------------------------------------------------------
|
---|
| 23 | ALIGN JUMP_ALIGN
|
---|
| 24 | Initialize_FromMainBiosRomSearch:
|
---|
| 25 | pushf
|
---|
| 26 | push es
|
---|
| 27 | push ds
|
---|
| 28 | ePUSHA
|
---|
| 29 |
|
---|
| 30 | call Initialize_ShouldSkip
|
---|
| 31 | jc SHORT .ReturnFromRomInit
|
---|
| 32 |
|
---|
| 33 | ePUSH_T ax, .ReturnFromRomInit ; Push return address
|
---|
| 34 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_LATE
|
---|
| 35 | jnz SHORT Initialize_PrepareLateInitialization
|
---|
| 36 | jmp SHORT Initialize_AndDetectDrives
|
---|
| 37 |
|
---|
| 38 | ALIGN JUMP_ALIGN
|
---|
| 39 | .ReturnFromRomInit:
|
---|
| 40 | ePOPA
|
---|
| 41 | pop ds
|
---|
| 42 | pop es
|
---|
| 43 | popf
|
---|
| 44 | retf
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | ;--------------------------------------------------------------------
|
---|
| 48 | ; Checks if user wants to skip ROM initialization.
|
---|
| 49 | ;
|
---|
| 50 | ; Initialize_ShouldSkip
|
---|
| 51 | ; Parameters:
|
---|
| 52 | ; Nothing
|
---|
| 53 | ; Returns:
|
---|
| 54 | ; CF: Set if ROM initialization is to be skipped
|
---|
| 55 | ; Cleared to continue ROM initialization
|
---|
| 56 | ; Corrupts registers:
|
---|
| 57 | ; AX, DS
|
---|
| 58 | ;--------------------------------------------------------------------
|
---|
| 59 | ALIGN JUMP_ALIGN
|
---|
| 60 | Initialize_ShouldSkip:
|
---|
| 61 | sti ; Enable interrupts
|
---|
| 62 | LOAD_BDA_SEGMENT_TO ds, ax
|
---|
| 63 | mov al, [BDA.bKBFlgs1] ; Load shift flags
|
---|
| 64 | eSHR_IM al, 3 ; Set CF if CTRL is held down
|
---|
| 65 | ret
|
---|
| 66 |
|
---|
| 67 |
|
---|
| 68 | ;--------------------------------------------------------------------
|
---|
| 69 | ; Installs INT 19h boot loader handler for late initialization.
|
---|
| 70 | ;
|
---|
| 71 | ; Initialize_PrepareLateInitialization
|
---|
| 72 | ; Parameters:
|
---|
| 73 | ; Nothing
|
---|
| 74 | ; Returns:
|
---|
| 75 | ; Nothing
|
---|
| 76 | ; Corrupts registers:
|
---|
| 77 | ; BX, SI, ES
|
---|
| 78 | ;--------------------------------------------------------------------
|
---|
| 79 | ALIGN JUMP_ALIGN
|
---|
| 80 | Initialize_PrepareLateInitialization:
|
---|
| 81 | LOAD_BDA_SEGMENT_TO es, bx
|
---|
| 82 | mov bl, INTV_BOOTSTRAP
|
---|
| 83 | mov si, Int19h_LateInitialization
|
---|
[33] | 84 | jmp Interrupts_InstallHandlerToVectorInBXFromCSSI
|
---|
[3] | 85 |
|
---|
| 86 |
|
---|
| 87 | ;--------------------------------------------------------------------
|
---|
| 88 | ; Initializes the BIOS variables and detects IDE drives.
|
---|
| 89 | ;
|
---|
| 90 | ; Initialize_AndDetectDrives
|
---|
| 91 | ; Parameters:
|
---|
| 92 | ; Nothing
|
---|
| 93 | ; Returns:
|
---|
| 94 | ; Nothing
|
---|
| 95 | ; Corrupts registers:
|
---|
| 96 | ; All, including segments
|
---|
| 97 | ;--------------------------------------------------------------------
|
---|
| 98 | ALIGN JUMP_ALIGN
|
---|
| 99 | Initialize_AndDetectDrives:
|
---|
| 100 | call DetectPrint_RomFoundAtSegment
|
---|
| 101 | call RamVars_Initialize
|
---|
| 102 | call RamVars_GetSegmentToDS
|
---|
| 103 | LOAD_BDA_SEGMENT_TO es, ax
|
---|
[33] | 104 | call Interrupts_InitializeInterruptVectors
|
---|
[3] | 105 | call DetectDrives_FromAllIDEControllers
|
---|
| 106 | call CompatibleDPT_CreateForDrives80hAnd81h
|
---|
[33] | 107 | ; Fall to .ResetDetectedDrives
|
---|
[3] | 108 |
|
---|
| 109 | ;--------------------------------------------------------------------
|
---|
| 110 | ; Resets all hard disks.
|
---|
| 111 | ;
|
---|
| 112 | ; Initialize_ResetDetectedDrives
|
---|
| 113 | ; Parameters:
|
---|
| 114 | ; DS: RAMVARS segment
|
---|
| 115 | ; Returns:
|
---|
| 116 | ; Nothing
|
---|
| 117 | ; Corrupts registers:
|
---|
| 118 | ; AX, BX, CX, DX, DI
|
---|
| 119 | ;--------------------------------------------------------------------
|
---|
[33] | 120 | ;ALIGN JUMP_ALIGN
|
---|
| 121 | .ResetDetectedDrives:
|
---|
[27] | 122 | jmp AH0h_ResetHardDisksHandledByOurBIOS
|
---|