1 | ; Project name : XTIDE Universal BIOS |
---|
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 | ;-------------------------------------------------------------------- |
---|
19 | Initialize_FromMainBiosRomSearch: ; unused entrypoint ok |
---|
20 | pushf |
---|
21 | push es |
---|
22 | push ds |
---|
23 | ePUSHA |
---|
24 | |
---|
25 | LOAD_BDA_SEGMENT_TO es, ax |
---|
26 | sti ; Enable interrupts |
---|
27 | test BYTE [es:BDA.bKBFlgs1], (1<<2) ; Clears ZF if CTRL is held down |
---|
28 | jnz SHORT .SkipRomInitialization |
---|
29 | |
---|
30 | ; Install INT 19h handler (boot loader) where drives are detected |
---|
31 | mov al, BIOS_BOOT_LOADER_INTERRUPT_19h |
---|
32 | mov si, Int19h_BootLoaderHandler |
---|
33 | call Interrupts_InstallHandlerToVectorInALFromCSSI |
---|
34 | |
---|
35 | .SkipRomInitialization: |
---|
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: |
---|
48 | ; ES: BDA Segment |
---|
49 | ; Returns: |
---|
50 | ; DS: RAMVARS segment |
---|
51 | ; Corrupts registers: |
---|
52 | ; All |
---|
53 | ;-------------------------------------------------------------------- |
---|
54 | Initialize_AndDetectDrives: |
---|
55 | call BootMenuPrint_InitializeDisplayContext |
---|
56 | call DetectPrint_RomFoundAtSegment |
---|
57 | call RamVars_Initialize |
---|
58 | call Interrupts_InitializeInterruptVectors |
---|
59 | call DetectDrives_FromAllIDEControllers |
---|
60 | ; Fall to .StoreDptPointersToIntVectors |
---|
61 | |
---|
62 | ;-------------------------------------------------------------------- |
---|
63 | ; .StoreDptPointersToIntVectors |
---|
64 | ; Parameters: |
---|
65 | ; DS: RAMVARS segment |
---|
66 | ; ES: BDA and interrupt vector segment (zero) |
---|
67 | ; Returns: |
---|
68 | ; Nothing |
---|
69 | ; Corrupts registers: |
---|
70 | ; DX, DI |
---|
71 | ;-------------------------------------------------------------------- |
---|
72 | .StoreDptPointersToIntVectors: |
---|
73 | mov dl, 80h |
---|
74 | call RamVars_IsDriveHandledByThisBIOS |
---|
75 | jc SHORT .FindForDrive81h ; Store nothing if not our drive |
---|
76 | call FindDPT_ForDriveNumber ; DPT to DS:DI |
---|
77 | mov [es:HD0_DPT_POINTER_41h*4], di |
---|
78 | mov [es:HD0_DPT_POINTER_41h*4+2], ds |
---|
79 | .FindForDrive81h: |
---|
80 | inc dx |
---|
81 | call RamVars_IsDriveHandledByThisBIOS |
---|
82 | jc SHORT .ResetDetectedDrives |
---|
83 | call FindDPT_ForDriveNumber |
---|
84 | mov [es:HD1_DPT_POINTER_46h*4], di |
---|
85 | mov [es:HD1_DPT_POINTER_46h*4+2], ds |
---|
86 | ; Fall to .ResetDetectedDrives |
---|
87 | |
---|
88 | ;-------------------------------------------------------------------- |
---|
89 | ; .ResetDetectedDrives |
---|
90 | ; Parameters: |
---|
91 | ; DS: RAMVARS segment |
---|
92 | ; ES: BDA and interrupt vector segment (zero) |
---|
93 | ; Returns: |
---|
94 | ; Nothing |
---|
95 | ; Corrupts registers: |
---|
96 | ; All, except DS and ES |
---|
97 | ;-------------------------------------------------------------------- |
---|
98 | .ResetDetectedDrives: |
---|
99 | call Idepack_FakeToSSBP |
---|
100 | call AH0h_ResetHardDisksHandledByOurBIOS |
---|
101 | add sp, BYTE EXTRA_BYTES_FOR_INTPACK |
---|
102 | ret |
---|