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

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

Changes to XTIDE Universal BIOS:

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