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

Last change on this file since 377 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

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