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-2013 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 ; To store IF
|
---|
37 | push ds
|
---|
38 |
|
---|
39 | %ifndef USE_186
|
---|
40 | push ax
|
---|
41 | LOAD_BDA_SEGMENT_TO ds, ax
|
---|
42 | %else
|
---|
43 | push BYTE 0
|
---|
44 | pop ds
|
---|
45 | %endif
|
---|
46 |
|
---|
47 | sti ; Enable interrupts for keystrokes
|
---|
48 | test BYTE [BDA.bKBFlgs1], (1<<2) ; Clears ZF if CTRL is held down
|
---|
49 | jnz SHORT .SkipRomInitialization
|
---|
50 |
|
---|
51 | ; Install INT 19h handler (boot loader) where drives are detected
|
---|
52 | mov WORD [BIOS_BOOT_LOADER_INTERRUPT_19h*4], Int19h_BootLoaderHandler
|
---|
53 | mov [BIOS_BOOT_LOADER_INTERRUPT_19h*4+2], cs
|
---|
54 |
|
---|
55 | ; Install special INT 13h hander that initializes XTIDE Universal BIOS
|
---|
56 | ; when our INT 19h is not called
|
---|
57 | les ax, [BIOS_DISK_INTERRUPT_13h*4] ; Load system INT 13h handler
|
---|
58 | mov [TEMPORARY_VECTOR_FOR_SYSTEM_INT13h*4], ax
|
---|
59 | mov [TEMPORARY_VECTOR_FOR_SYSTEM_INT13h*4+2], es
|
---|
60 | mov WORD [BIOS_DISK_INTERRUPT_13h*4], Int13hBiosInit_Handler
|
---|
61 | mov [BIOS_DISK_INTERRUPT_13h*4+2], cs
|
---|
62 |
|
---|
63 | .SkipRomInitialization:
|
---|
64 | %ifndef USE_186
|
---|
65 | pop ax
|
---|
66 | %endif
|
---|
67 | pop ds
|
---|
68 | popf
|
---|
69 | retf
|
---|
70 |
|
---|
71 |
|
---|
72 | ;--------------------------------------------------------------------
|
---|
73 | ; Initializes the BIOS variables and detects IDE drives.
|
---|
74 | ;
|
---|
75 | ; Initialize_AndDetectDrives
|
---|
76 | ; Parameters:
|
---|
77 | ; ES: BDA Segment
|
---|
78 | ; Returns:
|
---|
79 | ; DS: RAMVARS segment
|
---|
80 | ; Corrupts registers:
|
---|
81 | ; All, except ES
|
---|
82 | ;--------------------------------------------------------------------
|
---|
83 | Initialize_AndDetectDrives:
|
---|
84 | call DetectPrint_InitializeDisplayContext
|
---|
85 | call DetectPrint_RomFoundAtSegment
|
---|
86 | call RamVars_Initialize
|
---|
87 | call BootVars_Initialize
|
---|
88 | call Interrupts_InitializeInterruptVectors ; HotkeyBar requires INT 40h so install handlers before drive detection
|
---|
89 | call DetectDrives_FromAllIDEControllers
|
---|
90 | ; Fall to .StoreDptPointersToIntVectors
|
---|
91 |
|
---|
92 |
|
---|
93 | %ifdef MODULE_COMPATIBLE_TABLES
|
---|
94 | ;--------------------------------------------------------------------
|
---|
95 | ; .StoreDptPointersToIntVectors
|
---|
96 | ; Parameters:
|
---|
97 | ; DS: RAMVARS segment
|
---|
98 | ; ES: BDA and interrupt vector segment (zero)
|
---|
99 | ; Returns:
|
---|
100 | ; Nothing
|
---|
101 | ; Corrupts registers:
|
---|
102 | ; AX, CX, DX, SI, DI
|
---|
103 | ;--------------------------------------------------------------------
|
---|
104 | .StoreDptPointersToIntVectors:
|
---|
105 | %ifndef USE_AT
|
---|
106 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
|
---|
107 | jz SHORT .CompatibleDPTsCreated ; Only Full operating mode has extra RAM to spare
|
---|
108 | %endif
|
---|
109 |
|
---|
110 | mov dl, 80h
|
---|
111 | call FindDPT_ForDriveNumberInDL ; DPT to DS:DI
|
---|
112 | jc SHORT .FindForDrive81h ; Store nothing if not our drive
|
---|
113 |
|
---|
114 | call CompatibleDPT_CreateToAXSIforDriveDL
|
---|
115 | mov [es:HD0_DPT_POINTER_41h*4], si
|
---|
116 | mov [es:HD0_DPT_POINTER_41h*4+2], ax
|
---|
117 |
|
---|
118 | .FindForDrive81h:
|
---|
119 | mov dl, 81h
|
---|
120 | call FindDPT_ForDriveNumberInDL
|
---|
121 | jc SHORT .CompatibleDPTsCreated
|
---|
122 |
|
---|
123 | call CompatibleDPT_CreateToAXSIforDriveDL
|
---|
124 | mov [es:HD1_DPT_POINTER_46h*4], si
|
---|
125 | mov [es:HD1_DPT_POINTER_46h*4+2], ax
|
---|
126 | .CompatibleDPTsCreated:
|
---|
127 | ; Fall to .ResetDetectedDrives
|
---|
128 | %endif ; MODULE_COMPATIBLE_TABLES
|
---|
129 |
|
---|
130 |
|
---|
131 | ;--------------------------------------------------------------------
|
---|
132 | ; .ResetDetectedDrives
|
---|
133 | ; Parameters:
|
---|
134 | ; DS: RAMVARS segment
|
---|
135 | ; ES: BDA and interrupt vector segment (zero)
|
---|
136 | ; Returns:
|
---|
137 | ; Nothing
|
---|
138 | ; Corrupts registers:
|
---|
139 | ; All, except DS and ES
|
---|
140 | ;--------------------------------------------------------------------
|
---|
141 | .ResetDetectedDrives:
|
---|
142 | call Idepack_FakeToSSBP
|
---|
143 | call AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization
|
---|
144 | add sp, BYTE SIZE_OF_IDEPACK_WITHOUT_INTPACK
|
---|
145 | ret
|
---|