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

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

Changes to XTIDE Universal BIOS:

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