1 | ; Project name : XTIDE Universal BIOS |
---|
2 | ; Description : Functions for initializing the BIOS. |
---|
3 | |
---|
4 | ; |
---|
5 | ; XTIDE Universal BIOS and Associated Tools |
---|
6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. |
---|
7 | ; |
---|
8 | ; This program is free software; you can redistribute it and/or modify |
---|
9 | ; it under the terms of the GNU General Public License as published by |
---|
10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
11 | ; (at your option) any later version. |
---|
12 | ; |
---|
13 | ; This program is distributed in the hope that it will be useful, |
---|
14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | ; GNU General Public License for more details. |
---|
17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
18 | ; |
---|
19 | |
---|
20 | ; Section containing code |
---|
21 | SECTION .text |
---|
22 | |
---|
23 | ;-------------------------------------------------------------------- |
---|
24 | ; Initializes the BIOS. |
---|
25 | ; This function is called from main BIOS ROM search routine. |
---|
26 | ; |
---|
27 | ; Initialize_FromMainBiosRomSearch |
---|
28 | ; Parameters: |
---|
29 | ; Nothing |
---|
30 | ; Returns: |
---|
31 | ; Nothing |
---|
32 | ; Corrupts registers: |
---|
33 | ; Nothing |
---|
34 | ;-------------------------------------------------------------------- |
---|
35 | Initialize_FromMainBiosRomSearch: ; unused entrypoint ok |
---|
36 | pushf |
---|
37 | push es |
---|
38 | push ds |
---|
39 | ePUSHA |
---|
40 | |
---|
41 | LOAD_BDA_SEGMENT_TO es, ax |
---|
42 | sti ; Enable interrupts |
---|
43 | test BYTE [es:BDA.bKBFlgs1], (1<<2) ; Clears ZF if CTRL is held down |
---|
44 | jnz SHORT .SkipRomInitialization |
---|
45 | |
---|
46 | ; Install INT 19h handler (boot loader) where drives are detected |
---|
47 | mov al, BIOS_BOOT_LOADER_INTERRUPT_19h |
---|
48 | mov si, Int19h_BootLoaderHandler |
---|
49 | call Interrupts_InstallHandlerToVectorInALFromCSSI |
---|
50 | |
---|
51 | .SkipRomInitialization: |
---|
52 | ePOPA |
---|
53 | pop ds |
---|
54 | pop es |
---|
55 | popf |
---|
56 | retf |
---|
57 | |
---|
58 | |
---|
59 | ;-------------------------------------------------------------------- |
---|
60 | ; Initializes the BIOS variables and detects IDE drives. |
---|
61 | ; |
---|
62 | ; Initialize_AndDetectDrives |
---|
63 | ; Parameters: |
---|
64 | ; ES: BDA Segment |
---|
65 | ; Returns: |
---|
66 | ; DS: RAMVARS segment |
---|
67 | ; Corrupts registers: |
---|
68 | ; All |
---|
69 | ;-------------------------------------------------------------------- |
---|
70 | Initialize_AndDetectDrives: |
---|
71 | call DetectPrint_InitializeDisplayContext |
---|
72 | call DetectPrint_RomFoundAtSegment |
---|
73 | call RamVars_Initialize |
---|
74 | call BootVars_Initialize |
---|
75 | call Interrupts_InitializeInterruptVectors |
---|
76 | call DetectDrives_FromAllIDEControllers |
---|
77 | ; Fall to .StoreDptPointersToIntVectors |
---|
78 | |
---|
79 | ;-------------------------------------------------------------------- |
---|
80 | ; .StoreDptPointersToIntVectors |
---|
81 | ; Parameters: |
---|
82 | ; DS: RAMVARS segment |
---|
83 | ; ES: BDA and interrupt vector segment (zero) |
---|
84 | ; Returns: |
---|
85 | ; Nothing |
---|
86 | ; Corrupts registers: |
---|
87 | ; DX, DI |
---|
88 | ;-------------------------------------------------------------------- |
---|
89 | .StoreDptPointersToIntVectors: |
---|
90 | mov dl, 80h |
---|
91 | call FindDPT_ForDriveNumberInDL ; DPT to DS:DI |
---|
92 | jc SHORT .FindForDrive81h ; Store nothing if not our drive |
---|
93 | mov [es:HD0_DPT_POINTER_41h*4], di |
---|
94 | mov [es:HD0_DPT_POINTER_41h*4+2], ds |
---|
95 | .FindForDrive81h: |
---|
96 | inc dx |
---|
97 | call FindDPT_ForDriveNumberInDL |
---|
98 | jc SHORT .ResetDetectedDrives |
---|
99 | mov [es:HD1_DPT_POINTER_46h*4], di |
---|
100 | mov [es:HD1_DPT_POINTER_46h*4+2], ds |
---|
101 | ; Fall to .ResetDetectedDrives |
---|
102 | |
---|
103 | ;-------------------------------------------------------------------- |
---|
104 | ; .ResetDetectedDrives |
---|
105 | ; Parameters: |
---|
106 | ; DS: RAMVARS segment |
---|
107 | ; ES: BDA and interrupt vector segment (zero) |
---|
108 | ; Returns: |
---|
109 | ; Nothing |
---|
110 | ; Corrupts registers: |
---|
111 | ; All, except DS and ES |
---|
112 | ;-------------------------------------------------------------------- |
---|
113 | .ResetDetectedDrives: |
---|
114 | call Idepack_FakeToSSBP |
---|
115 | call AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization |
---|
116 | add sp, BYTE EXTRA_BYTES_FOR_INTPACK |
---|
117 | ret |
---|