source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Main.asm@ 397

Last change on this file since 397 was 397, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Cleaned some code concerning recent module changes.
  • Removed drive number translation flag from ROMVARS.
  • BOOTMENUINFO is now DRVDETECTINFO.
  • Makefile now builds tiny binary (XT build with minimal features).
File size: 12.4 KB
Line 
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 "ModuleDependency.inc" ; Dependency checks for optional modules
50 %include "IntController.inc" ; For Interrupt Controller equates
51 %include "ATA_ID.inc" ; For ATA Drive Information structs
52 %include "IdeRegisters.inc" ; For ATA Registers, flags and commands
53 %include "Int13h.inc" ; Equates for INT 13h functions
54 %include "CustomDPT.inc" ; For Disk Parameter Table
55 %include "RomVars.inc" ; For ROMVARS and IDEVARS structs
56 %include "RamVars.inc" ; For RAMVARS struct
57 %include "BootVars.inc" ; For BOOTVARS struct
58 %include "IDE_8bit.inc" ; For IDE 8-bit data port macros
59 %include "DeviceIDE.inc" ; For IDE device equates
60
61
62
63; Section containing code
64SECTION .text
65
66; ROM variables (must start at offset 0)
67CNT_ROM_BLOCKS EQU ROMSIZE / 512 ; number of 512B blocks, 16 = 8kB BIOS
68istruc ROMVARS
69 at ROMVARS.wRomSign, dw 0AA55h ; PC ROM signature
70 at ROMVARS.bRomSize, db CNT_ROM_BLOCKS ; ROM size in 512B blocks
71 at ROMVARS.rgbJump, jmp Initialize_FromMainBiosRomSearch
72 at ROMVARS.rgbSign, db FLASH_SIGNATURE
73 at ROMVARS.szTitle, db TITLE_STRING
74 at ROMVARS.szVersion, db ROM_VERSION_STRING
75
76;---------------------------;
77; AT Build default settings ;
78;---------------------------;
79%ifdef USE_AT
80 at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | MASK_ROMVARS_INCLUDED_MODULES
81 at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
82%ifdef MODULE_BOOT_MENU
83 at ROMVARS.wBootTimeout, dw BOOT_MENU_DEFAULT_TIMEOUT
84%endif
85 at ROMVARS.bIdeCnt, db 4 ; Number of supported controllers
86 at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
87 at ROMVARS.bMinFddCnt, db 0 ; Do not force minimum number of floppy drives
88 at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory
89 at ROMVARS.bIdleTimeout, db 0 ; Standby timer disabled by default
90
91 at ROMVARS.ideVars0+IDEVARS.wPort, dw DEVICE_ATA_DEFAULT_PORT ; Controller Command Block base port
92 at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw DEVICE_ATA_DEFAULT_PORTCTRL ; Controller Control Block base port
93 at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_16BIT_ATA
94 at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0
95 at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
96 at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
97
98 at ROMVARS.ideVars1+IDEVARS.wPort, dw DEVICE_ATA_DEFAULT_SECONDARY_PORT
99 at ROMVARS.ideVars1+IDEVARS.wPortCtrl, dw DEVICE_ATA_DEFAULT_SECONDARY_PORTCTRL
100 at ROMVARS.ideVars1+IDEVARS.bDevice, db DEVICE_16BIT_ATA
101 at ROMVARS.ideVars1+IDEVARS.bIRQ, db 0
102 at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
103 at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
104
105 at ROMVARS.ideVars2+IDEVARS.wPort, dw 1E8h
106 at ROMVARS.ideVars2+IDEVARS.wPortCtrl, dw 3E8h
107 at ROMVARS.ideVars2+IDEVARS.bDevice, db DEVICE_16BIT_ATA
108 at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0
109 at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
110 at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
111
112 at ROMVARS.ideVars3+IDEVARS.wPort, dw 168h
113 at ROMVARS.ideVars3+IDEVARS.wPortCtrl, dw 368h
114 at ROMVARS.ideVars3+IDEVARS.bDevice, db DEVICE_16BIT_ATA
115 at ROMVARS.ideVars3+IDEVARS.bIRQ, db 0
116 at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
117 at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
118
119%ifdef MODULE_SERIAL
120 at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
121%endif
122%else
123;-----------------------------------;
124; XT and XT+ Build default settings ;
125;-----------------------------------;
126 at ROMVARS.wFlags, dw MASK_ROMVARS_INCLUDED_MODULES
127 at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
128%ifdef MODULE_BOOT_MENU
129 at ROMVARS.wBootTimeout, dw BOOT_MENU_DEFAULT_TIMEOUT
130%endif
131 at ROMVARS.bIdeCnt, db 1 ; Number of supported controllers
132 at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
133 at ROMVARS.bMinFddCnt, db 1 ; Assume at least 1 floppy drive present if autodetect fails
134 at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory in full mode
135 at ROMVARS.bIdleTimeout, db 0 ; Standby timer disabled by default
136
137 at ROMVARS.ideVars0+IDEVARS.wPort, dw DEVICE_XTIDE_DEFAULT_PORT ; Controller Command Block base port
138 at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw DEVICE_XTIDE_DEFAULT_PORTCTRL ; Controller Control Block base port
139 at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_XTIDE_REV1
140 at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
141 at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
142
143 at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
144 at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
145
146 at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
147 at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
148
149 at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
150 at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
151
152%ifdef MODULE_SERIAL
153 at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
154%endif
155%endif
156iend
157
158 ; Strings are first to avoid them moving unnecessarily when code is turned on and off with %ifdef's
159 ; since some groups of strings need to be on the same 256-byte page.
160 ;
161%ifdef MODULE_STRINGS_COMPRESSED
162 %define STRINGSCOMPRESSED_STRINGS
163 %include "StringsCompressed.asm"
164%else
165 %include "Strings.asm" ; For BIOS message strings
166%endif
167
168 ; Libraries, data, Initialization and drive detection
169
170 %include "AssemblyLibrary.asm"
171
172 ; String compression tables need to come after the AssemblyLibrary (since they depend on addresses
173 ; established in the assembly library), and are unnecessary if strings are not compressed.
174 ;
175%ifdef MODULE_STRINGS_COMPRESSED
176 %undef STRINGSCOMPRESSED_STRINGS
177 %define STRINGSCOMPRESSED_TABLES
178 %include "StringsCompressed.asm"
179%endif
180
181 %include "Initialize.asm" ; For BIOS initialization
182 %include "Interrupts.asm" ; For Interrupt initialization
183 %include "RamVars.asm" ; For RAMVARS initialization and access
184 %include "BootVars.asm" ; For initializing variabled used during init and boot
185 %include "FloppyDrive.asm" ; Floppy Drive related functions
186 %include "CreateDPT.asm" ; For creating DPTs
187 %include "FindDPT.asm" ; For finding DPTs
188 %include "AccessDPT.asm" ; For accessing DPTs
189 %include "LbaAssist.asm" ; For generating L-CHS parameters to LBA drives
190 %include "DrvDetectInfo.asm" ; For creating DRVDETECTINFO structs
191 %include "AtaID.asm" ; For ATA Identify Device information
192 %include "DetectDrives.asm" ; For detecting IDE drives
193 %include "DetectPrint.asm" ; For printing drive detection strings
194
195 ; Hotkey Bar
196%ifdef MODULE_HOTKEYS
197 %include "HotkeyBar.asm" ; For hotkeys during drive detection and boot menu
198 %include "DriveXlate.asm" ; For swapping drive numbers
199%endif
200
201 ; Boot menu
202%ifdef MODULE_BOOT_MENU
203 %include "BootMenu.asm" ; For Boot Menu operations
204 %include "BootMenuEvent.asm" ; For menu library event handling
205 ; NOTE: BootMenuPrint needs to come immediately after BootMenuEvent
206 ; so that jump table entries in BootMenuEvent stay within 8-bits
207 %include "BootMenuPrint.asm" ; For printing Boot Menu strings, also includes "BootMenuPrintCfg.asm"
208%endif
209
210 ; Boot loader
211 %include "Int19h.asm" ; For Int 19h, Boot Loader
212 %include "Int19hReset.asm" ; INT 19h handler for proper system reset
213 %include "BootSector.asm" ; For loading boot sector
214
215 ; For all device types
216 %include "Idepack.asm"
217 %include "Device.asm"
218 %include "Timer.asm" ; For timeout and delay
219
220 ; IDE Device support
221%ifdef MODULE_ADVANCED_ATA
222 %include "AdvAtaInit.asm" ; For initializing VLB and PCI controllers
223 %include "Vision.asm" ; QDI Vision QD6500 and QD6580 support
224%endif
225%define IDEDEVICE Ide
226%define ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS
227 %include "IOMappedIDE.inc" ; Assembly IDE support for normal I/O mapped controllers
228 %include "IdeCommand.asm"
229 %include "IdeTransfer.asm" ; Must be included after IdeCommand.asm
230 %include "IdeWait.asm"
231 %include "IdeError.asm" ; Must be included after IdeWait.asm
232 %include "IdeDPT.asm"
233 %include "IdeIO.asm"
234 %include "IdeIrq.asm"
235%undef IDEDEVICE
236%undef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS
237
238 ; JR-IDE support
239%ifdef MODULE_JRIDE
240%define IDEDEVICE MemIde
241 %include "MemMappedIDE.inc" ; Assembly IDE support for memory mapped controllers
242 %include "IdeCommand.asm"
243 %include "MemIdeTransfer.asm" ; Must be included after IdeCommand.asm
244 %include "IdeWait.asm"
245 %include "IdeError.asm" ; Must be included after IdeWait.asm
246%undef IDEDEVICE
247%endif
248
249
250%ifdef MODULE_SERIAL ; Serial Port Device support
251 %include "SerialCommand.asm"
252 %include "SerialDPT.asm"
253%endif
254
255 ; INT 13h Hard Disk BIOS functions
256 %include "Int13h.asm" ; For Int 13h, Disk functions
257 %include "AH0h_HReset.asm" ; Required by Int13h_Jump.asm
258 %include "AH1h_HStatus.asm" ; Required by Int13h_Jump.asm
259 %include "AH2h_HRead.asm" ; Required by Int13h_Jump.asm
260 %include "AH3h_HWrite.asm" ; Required by Int13h_Jump.asm
261 %include "AH4h_HVerify.asm" ; Required by Int13h_Jump.asm
262 %include "AH8h_HParams.asm" ; Required by Int13h_Jump.asm
263 %include "AH9h_HInit.asm" ; Required by Int13h_Jump.asm
264 %include "AHCh_HSeek.asm" ; Required by Int13h_Jump.asm
265 %include "AHDh_HReset.asm" ; Required by Int13h_Jump.asm
266 %include "AH10h_HReady.asm" ; Required by Int13h_Jump.asm
267 %include "AH11h_HRecal.asm" ; Required by Int13h_Jump.asm
268 %include "AH15h_HSize.asm" ; Required by Int13h_Jump.asm
269 %include "AH23h_HFeatures.asm" ; Required by Int13h_Jump.asm
270 %include "AH24h_HSetBlocks.asm" ; Required by Int13h_Jump.asm
271 %include "AH25h_HDrvID.asm" ; Required by Int13h_Jump.asm
272 %include "Address.asm" ; For sector address translations
273 %include "Prepare.asm" ; For buffer pointer normalization
274%ifdef MODULE_EBIOS
275 %include "AH42h_ExtendedReadSectors.asm"
276 %include "AH43h_ExtendedWriteSectors.asm"
277 %include "AH44h_ExtendedVerifySectors.asm"
278 %include "AH47h_ExtendedSeek.asm"
279 %include "AH48h_GetExtendedDriveParameters.asm"
280 %include "AH41h_CheckIfExtensionsPresent.asm"
281%endif
Note: See TracBrowser for help on using the repository browser.