1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Authors : Tomi Tilli
|
---|
3 | ; : aitotat@gmail.com
|
---|
4 | ; :
|
---|
5 | ; : Greg Lindhorst
|
---|
6 | ; : gregli@hotmail.com
|
---|
7 | ; ;
|
---|
8 | ; : Krister Nordvall
|
---|
9 | ; : krille_n_@hotmail.com
|
---|
10 | ; :
|
---|
11 | ; Description : Main file for BIOS. This is the only file that needs
|
---|
12 | ; to be compiled since other files are included to this
|
---|
13 | ; file (so no linker needed, Nasm does it all).
|
---|
14 |
|
---|
15 | ;
|
---|
16 | ; XTIDE Universal BIOS and Associated Tools
|
---|
17 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
|
---|
18 | ;
|
---|
19 | ; This program is free software; you can redistribute it and/or modify
|
---|
20 | ; it under the terms of the GNU General Public License as published by
|
---|
21 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
22 | ; (at your option) any later version.
|
---|
23 | ;
|
---|
24 | ; This program is distributed in the hope that it will be useful,
|
---|
25 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
26 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
27 | ; GNU General Public License for more details.
|
---|
28 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
29 | ;
|
---|
30 |
|
---|
31 | ORG 0 ; Code start offset 0000h
|
---|
32 |
|
---|
33 | ; We must define included libraries before including "AssemblyLibrary.inc".
|
---|
34 | %define EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS ; Exclude unused library functions
|
---|
35 | %ifdef MODULE_BOOT_MENU
|
---|
36 | %define MENUEVENT_INLINE_OFFSETS ; Only one menu required, save space and inline offsets
|
---|
37 | %define INCLUDE_MENU_LIBRARY
|
---|
38 |
|
---|
39 | %else ; If no boot menu included
|
---|
40 | %define INCLUDE_DISPLAY_LIBRARY
|
---|
41 | %define INCLUDE_KEYBOARD_LIBRARY
|
---|
42 | %define INCLUDE_TIME_LIBRARY
|
---|
43 | %endif
|
---|
44 |
|
---|
45 |
|
---|
46 | ; Included .inc files
|
---|
47 | %include "AssemblyLibrary.inc" ; Assembly Library. Must be included first!
|
---|
48 | %include "Version.inc"
|
---|
49 | %include "IntController.inc" ; For Interrupt Controller equates
|
---|
50 | %include "ATA_ID.inc" ; For ATA Drive Information structs
|
---|
51 | %include "IdeRegisters.inc" ; For ATA Registers, flags and commands
|
---|
52 | %include "Int13h.inc" ; Equates for INT 13h functions
|
---|
53 | %ifdef MODULE_EBIOS
|
---|
54 | %include "EBIOS.inc" ; Equates for EBIOS functions
|
---|
55 | %endif
|
---|
56 | %include "CustomDPT.inc" ; For Disk Parameter Table
|
---|
57 | %include "RomVars.inc" ; For ROMVARS and IDEVARS structs
|
---|
58 | %include "RamVars.inc" ; For RAMVARS struct
|
---|
59 | %include "BootVars.inc" ; For BOOTVARS struct
|
---|
60 | %include "HotkeyBar.inc" ; For Hotkeys
|
---|
61 | %include "BootMenu.inc" ; For Boot Menu
|
---|
62 | %include "IDE_8bit.inc" ; For IDE 8-bit data port macros
|
---|
63 | %include "DeviceIDE.inc" ; For IDE device equates
|
---|
64 | %include "Vision.inc" ; For QDI Vision QD65xx VLB IDE Controllers
|
---|
65 |
|
---|
66 |
|
---|
67 | ; Section containing code
|
---|
68 | SECTION .text
|
---|
69 |
|
---|
70 | ; ROM variables (must start at offset 0)
|
---|
71 | CNT_ROM_BLOCKS EQU ROMSIZE / 512 ; number of 512B blocks, 16 = 8kB BIOS
|
---|
72 | istruc ROMVARS
|
---|
73 | at ROMVARS.wRomSign, dw 0AA55h ; PC ROM signature
|
---|
74 | at ROMVARS.bRomSize, db CNT_ROM_BLOCKS ; ROM size in 512B blocks
|
---|
75 | at ROMVARS.rgbJump, jmp Initialize_FromMainBiosRomSearch
|
---|
76 | at ROMVARS.rgbSign, db FLASH_SIGNATURE
|
---|
77 | at ROMVARS.szTitle, db TITLE_STRING
|
---|
78 | at ROMVARS.szVersion, db ROM_VERSION_STRING
|
---|
79 |
|
---|
80 | ;;; For OR'ing into wFlags below
|
---|
81 | ;;;
|
---|
82 | %ifdef MODULE_SERIAL
|
---|
83 | MAIN_FLG_MODULE_SERIAL equ FLG_ROMVARS_MODULE_SERIAL
|
---|
84 | %else
|
---|
85 | MAIN_FLG_MODULE_SERIAL equ 0
|
---|
86 | %endif
|
---|
87 |
|
---|
88 | %ifdef MODULE_EBIOS
|
---|
89 | MAIN_FLG_MODULE_EBIOS equ FLG_ROMVARS_MODULE_EBIOS
|
---|
90 | %else
|
---|
91 | MAIN_FLG_MODULE_EBIOS equ 0
|
---|
92 | %endif
|
---|
93 |
|
---|
94 | %ifdef MODULE_JRIDE
|
---|
95 | MAIN_FLG_MODULE_JRIDE equ FLG_ROMVARS_MODULE_JRIDE
|
---|
96 | %else
|
---|
97 | MAIN_FLG_MODULE_JRIDE equ 0
|
---|
98 | %endif
|
---|
99 |
|
---|
100 | %ifdef MODULE_ADVANCED_ATA
|
---|
101 | MAIN_FLG_MODULE_ADVATA equ FLG_ROMVARS_MODULE_ADVATA
|
---|
102 | %else
|
---|
103 | MAIN_FLG_MODULE_ADVATA equ 0
|
---|
104 | %endif
|
---|
105 |
|
---|
106 |
|
---|
107 | ;---------------------------;
|
---|
108 | ; AT Build default settings ;
|
---|
109 | ;---------------------------;
|
---|
110 | %ifdef USE_AT
|
---|
111 | at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS | MAIN_FLG_MODULE_JRIDE | MAIN_FLG_MODULE_ADVATA
|
---|
112 | at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
|
---|
113 | at ROMVARS.wBootTimeout, dw BOOT_MENU_DEFAULT_TIMEOUT
|
---|
114 | at ROMVARS.bIdeCnt, db 4 ; Number of supported controllers
|
---|
115 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
116 | at ROMVARS.bMinFddCnt, db 0 ; Do not force minimum number of floppy drives
|
---|
117 | at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory
|
---|
118 | at ROMVARS.bIdleTimeout, db 0 ; Standby timer disabled by default
|
---|
119 |
|
---|
120 | at ROMVARS.ideVars0+IDEVARS.wPort, dw DEVICE_ATA_DEFAULT_PORT ; Controller Command Block base port
|
---|
121 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw DEVICE_ATA_DEFAULT_PORTCTRL ; Controller Control Block base port
|
---|
122 | at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_16BIT_ATA
|
---|
123 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0
|
---|
124 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
125 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
126 |
|
---|
127 | at ROMVARS.ideVars1+IDEVARS.wPort, dw DEVICE_ATA_DEFAULT_SECONDARY_PORT
|
---|
128 | at ROMVARS.ideVars1+IDEVARS.wPortCtrl, dw DEVICE_ATA_DEFAULT_SECONDARY_PORTCTRL
|
---|
129 | at ROMVARS.ideVars1+IDEVARS.bDevice, db DEVICE_16BIT_ATA
|
---|
130 | at ROMVARS.ideVars1+IDEVARS.bIRQ, db 0
|
---|
131 | at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
132 | at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
133 |
|
---|
134 | at ROMVARS.ideVars2+IDEVARS.wPort, dw 1E8h
|
---|
135 | at ROMVARS.ideVars2+IDEVARS.wPortCtrl, dw 3E8h
|
---|
136 | at ROMVARS.ideVars2+IDEVARS.bDevice, db DEVICE_16BIT_ATA
|
---|
137 | at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0
|
---|
138 | at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
139 | at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
140 |
|
---|
141 | at ROMVARS.ideVars3+IDEVARS.wPort, dw 168h
|
---|
142 | at ROMVARS.ideVars3+IDEVARS.wPortCtrl, dw 368h
|
---|
143 | at ROMVARS.ideVars3+IDEVARS.bDevice, db DEVICE_16BIT_ATA
|
---|
144 | at ROMVARS.ideVars3+IDEVARS.bIRQ, db 0
|
---|
145 | at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
146 | at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
147 |
|
---|
148 | %ifdef MODULE_SERIAL
|
---|
149 | at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
|
---|
150 | %endif
|
---|
151 | %else
|
---|
152 | ;-----------------------------------;
|
---|
153 | ; XT and XT+ Build default settings ;
|
---|
154 | ;-----------------------------------;
|
---|
155 | at ROMVARS.wFlags, dw FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS | MAIN_FLG_MODULE_JRIDE | MAIN_FLG_MODULE_ADVATA
|
---|
156 | at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
|
---|
157 | at ROMVARS.wBootTimeout, dw BOOT_MENU_DEFAULT_TIMEOUT
|
---|
158 | at ROMVARS.bIdeCnt, db 1 ; Number of supported controllers
|
---|
159 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
160 | at ROMVARS.bMinFddCnt, db 1 ; Assume at least 1 floppy drive present if autodetect fails
|
---|
161 | at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory in full mode
|
---|
162 | at ROMVARS.bIdleTimeout, db 0 ; Standby timer disabled by default
|
---|
163 |
|
---|
164 | at ROMVARS.ideVars0+IDEVARS.wPort, dw DEVICE_XTIDE_DEFAULT_PORT ; Controller Command Block base port
|
---|
165 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw DEVICE_XTIDE_DEFAULT_PORTCTRL ; Controller Control Block base port
|
---|
166 | %ifdef MODULE_JRIDE
|
---|
167 | at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_JRIDE_ISA
|
---|
168 | %else
|
---|
169 | at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_XTIDE_REV1
|
---|
170 | %endif
|
---|
171 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0 ; IRQ
|
---|
172 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
173 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
174 |
|
---|
175 | at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
176 | at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
177 |
|
---|
178 | at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
179 | at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
180 |
|
---|
181 | at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
182 | at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
|
---|
183 |
|
---|
184 | %ifdef MODULE_SERIAL
|
---|
185 | at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
|
---|
186 | %endif
|
---|
187 | %endif
|
---|
188 | iend
|
---|
189 |
|
---|
190 | ; Strings are first to avoid them moving unnecessarily when code is turned on and off with %ifdef's
|
---|
191 | ; since some groups of strings need to be on the same 256-byte page.
|
---|
192 | ;
|
---|
193 | %ifdef MODULE_STRINGS_COMPRESSED
|
---|
194 | %define STRINGSCOMPRESSED_STRINGS
|
---|
195 | %include "StringsCompressed.asm"
|
---|
196 | %else
|
---|
197 | %include "Strings.asm" ; For BIOS message strings
|
---|
198 | %endif
|
---|
199 |
|
---|
200 | ; Libraries, data, Initialization and drive detection
|
---|
201 |
|
---|
202 | %include "AssemblyLibrary.asm"
|
---|
203 |
|
---|
204 | ; String compression tables need to come after the AssemblyLibrary (since they depend on addresses
|
---|
205 | ; established in the assembly library), and are unnecessary if strings are not compressed.
|
---|
206 | ;
|
---|
207 | %ifdef MODULE_STRINGS_COMPRESSED
|
---|
208 | %undef STRINGSCOMPRESSED_STRINGS
|
---|
209 | %define STRINGSCOMPRESSED_TABLES
|
---|
210 | %include "StringsCompressed.asm"
|
---|
211 | %endif
|
---|
212 |
|
---|
213 | %include "Initialize.asm" ; For BIOS initialization
|
---|
214 | %include "Interrupts.asm" ; For Interrupt initialization
|
---|
215 | %include "RamVars.asm" ; For RAMVARS initialization and access
|
---|
216 | %include "BootVars.asm" ; For initializing variabled used during init and boot
|
---|
217 | %include "FloppyDrive.asm" ; Floppy Drive related functions
|
---|
218 | %include "CreateDPT.asm" ; For creating DPTs
|
---|
219 | %include "FindDPT.asm" ; For finding DPTs
|
---|
220 | %include "AccessDPT.asm" ; For accessing DPTs
|
---|
221 | %include "LbaAssist.asm" ; For generating L-CHS parameters to LBA drives
|
---|
222 | %include "BootMenuInfo.asm" ; For creating BOOTMENUINFO structs
|
---|
223 | %include "AtaID.asm" ; For ATA Identify Device information
|
---|
224 | %include "DetectDrives.asm" ; For detecting IDE drives
|
---|
225 | %include "DetectPrint.asm" ; For printing drive detection strings
|
---|
226 | %include "HotkeyBar.asm" ; For hotkeys during drive detection and boot menu
|
---|
227 |
|
---|
228 | ; Boot menu
|
---|
229 | %ifdef MODULE_BOOT_MENU
|
---|
230 | %include "BootMenu.asm" ; For Boot Menu operations
|
---|
231 | %include "BootMenuEvent.asm" ; For menu library event handling
|
---|
232 | ; NOTE: BootMenuPrint needs to come immediately after BootMenuEvent
|
---|
233 | ; so that jump table entries in BootMenuEvent stay within 8-bits
|
---|
234 | %include "BootMenuPrint.asm" ; For printing Boot Menu strings, also includes "BootMenuPrintCfg.asm"
|
---|
235 | %endif
|
---|
236 |
|
---|
237 | ; Boot loader
|
---|
238 | %include "Int19h.asm" ; For Int 19h, Boot Loader
|
---|
239 | %include "Int19hReset.asm" ; INT 19h handler for proper system reset
|
---|
240 | %include "BootSector.asm" ; For loading boot sector
|
---|
241 |
|
---|
242 | ; For all device types
|
---|
243 | %include "Idepack.asm"
|
---|
244 | %include "Device.asm"
|
---|
245 | %include "Timer.asm" ; For timeout and delay
|
---|
246 |
|
---|
247 | ; IDE Device support
|
---|
248 | %ifdef MODULE_ADVANCED_ATA
|
---|
249 | %include "AdvAtaInit.asm" ; For initializing VLB and PCI controllers
|
---|
250 | %include "Vision.asm" ; QDI Vision QD6500 and QD6580 support
|
---|
251 | %endif
|
---|
252 | %define IDEDEVICE Ide
|
---|
253 | %define ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS
|
---|
254 | %include "IOMappedIDE.inc" ; Assembly IDE support for normal I/O mapped controllers
|
---|
255 | %include "IdeCommand.asm"
|
---|
256 | %include "IdeTransfer.asm" ; Must be included after IdeCommand.asm
|
---|
257 | %include "IdeWait.asm"
|
---|
258 | %include "IdeError.asm" ; Must be included after IdeWait.asm
|
---|
259 | %include "IdeDPT.asm"
|
---|
260 | %include "IdeIO.asm"
|
---|
261 | %include "IdeIrq.asm"
|
---|
262 | %undef IDEDEVICE
|
---|
263 | %undef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS
|
---|
264 |
|
---|
265 | ; JR-IDE support
|
---|
266 | %ifdef MODULE_JRIDE
|
---|
267 | %define IDEDEVICE MemIde
|
---|
268 | %include "MemMappedIDE.inc" ; Assembly IDE support for memory mapped controllers
|
---|
269 | %include "IdeCommand.asm"
|
---|
270 | %include "MemIdeTransfer.asm" ; Must be included after IdeCommand.asm
|
---|
271 | %include "IdeWait.asm"
|
---|
272 | %include "IdeError.asm" ; Must be included after IdeWait.asm
|
---|
273 | %undef IDEDEVICE
|
---|
274 | %endif
|
---|
275 |
|
---|
276 |
|
---|
277 | %ifdef MODULE_SERIAL ; Serial Port Device support
|
---|
278 | %include "SerialCommand.asm"
|
---|
279 | %include "SerialDPT.asm"
|
---|
280 | %endif
|
---|
281 |
|
---|
282 | ; INT 13h Hard Disk BIOS functions
|
---|
283 | %include "Int13h.asm" ; For Int 13h, Disk functions
|
---|
284 | %include "AH0h_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
285 | %include "AH1h_HStatus.asm" ; Required by Int13h_Jump.asm
|
---|
286 | %include "AH2h_HRead.asm" ; Required by Int13h_Jump.asm
|
---|
287 | %include "AH3h_HWrite.asm" ; Required by Int13h_Jump.asm
|
---|
288 | %include "AH4h_HVerify.asm" ; Required by Int13h_Jump.asm
|
---|
289 | %include "AH8h_HParams.asm" ; Required by Int13h_Jump.asm
|
---|
290 | %include "AH9h_HInit.asm" ; Required by Int13h_Jump.asm
|
---|
291 | %include "AHCh_HSeek.asm" ; Required by Int13h_Jump.asm
|
---|
292 | %include "AHDh_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
293 | %include "AH10h_HReady.asm" ; Required by Int13h_Jump.asm
|
---|
294 | %include "AH11h_HRecal.asm" ; Required by Int13h_Jump.asm
|
---|
295 | %include "AH15h_HSize.asm" ; Required by Int13h_Jump.asm
|
---|
296 | %include "AH23h_HFeatures.asm" ; Required by Int13h_Jump.asm
|
---|
297 | %include "AH24h_HSetBlocks.asm" ; Required by Int13h_Jump.asm
|
---|
298 | %include "AH25h_HDrvID.asm" ; Required by Int13h_Jump.asm
|
---|
299 | %include "DriveXlate.asm" ; For swapping drive numbers
|
---|
300 | %include "Address.asm" ; For sector address translations
|
---|
301 | %include "Prepare.asm" ; For buffer pointer normalization
|
---|
302 | %ifdef MODULE_EBIOS
|
---|
303 | %include "AH42h_ExtendedReadSectors.asm"
|
---|
304 | %include "AH43h_ExtendedWriteSectors.asm"
|
---|
305 | %include "AH44h_ExtendedVerifySectors.asm"
|
---|
306 | %include "AH47h_ExtendedSeek.asm"
|
---|
307 | %include "AH48h_GetExtendedDriveParameters.asm"
|
---|
308 | %include "AH41h_CheckIfExtensionsPresent.asm"
|
---|
309 | %endif
|
---|