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

Last change on this file since 476 was 474, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

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