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