[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 |
|
---|
| 15 | ORG 000h ; Code start offset 0000h
|
---|
| 16 |
|
---|
[183] | 17 | %define MENUEVENT_INLINE_OFFSETS ; Only one menu required, save space and inline offsets
|
---|
| 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
|
---|
| 31 | %include "BootVars.inc" ; For BOOTVARS and BOOTNFO structs
|
---|
| 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)
|
---|
| 41 | CNT_ROM_BLOCKS EQU 16 ; 16 * 512B = 8kB BIOS
|
---|
| 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
|
---|
[88] | 46 | at ROMVARS.rgbSign, db "XTIDE120" ; 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
|
---|
[97] | 56 | at ROMVARS.szVersion, db "v1.2.0_wip (",__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 |
|
---|
[3] | 72 | ;---------------------------;
|
---|
| 73 | ; AT Build default settings ;
|
---|
| 74 | ;---------------------------;
|
---|
| 75 | %ifdef USE_AT
|
---|
[179] | 76 | at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS
|
---|
[143] | 77 | at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
|
---|
[137] | 78 | at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection 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 |
|
---|
| 84 | at ROMVARS.ideVars0+IDEVARS.wPort, dw 1F0h ; Controller Command Block base port
|
---|
| 85 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 3F0h ; 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
|
---|
[3] | 88 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 89 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 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
|
---|
[3] | 95 | at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 96 | at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 97 |
|
---|
| 98 | at ROMVARS.ideVars2+IDEVARS.wPort, dw 300h ; Controller Command Block base port
|
---|
| 99 | at ROMVARS.ideVars2+IDEVARS.wPortCtrl, dw 308h ; 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
|
---|
[3] | 102 | at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 103 | at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db 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
|
---|
[143] | 109 | at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 110 | at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[175] | 111 |
|
---|
| 112 | %ifdef MODULE_SERIAL
|
---|
| 113 | at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
|
---|
| 114 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[181] | 115 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 116 | %endif
|
---|
[3] | 117 | %else
|
---|
| 118 | ;-----------------------------------;
|
---|
| 119 | ; XT and XT+ Build default settings ;
|
---|
| 120 | ;-----------------------------------;
|
---|
[179] | 121 | at ROMVARS.wFlags, dw FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS
|
---|
[143] | 122 | at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
|
---|
[137] | 123 | at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection timeout
|
---|
[3] | 124 | at ROMVARS.bIdeCnt, db 1 ; Number of supported controllers
|
---|
| 125 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
| 126 | at ROMVARS.bMinFddCnt, db 1 ; Assume at least 1 floppy drive present if autodetect fails
|
---|
| 127 | at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory in full mode
|
---|
| 128 |
|
---|
| 129 | at ROMVARS.ideVars0+IDEVARS.wPort, dw 300h ; Controller Command Block base port
|
---|
| 130 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port
|
---|
[150] | 131 | at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE
|
---|
[3] | 132 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0 ; IRQ
|
---|
| 133 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 134 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[143] | 135 |
|
---|
| 136 | at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 137 | at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 138 |
|
---|
| 139 | at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 140 | at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 141 |
|
---|
| 142 | at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 143 | at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[175] | 144 |
|
---|
| 145 | %ifdef MODULE_SERIAL
|
---|
| 146 | at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
|
---|
| 147 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[181] | 148 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[3] | 149 | %endif
|
---|
[181] | 150 | %endif
|
---|
[3] | 151 | iend
|
---|
| 152 |
|
---|
[181] | 153 | ; Libraries and data
|
---|
| 154 | %include "AssemblyLibrary.asm"
|
---|
[186] | 155 | %ifdef MODULE_STRINGS_COMPRESSED
|
---|
| 156 | %include "StringsCompressed.asm"
|
---|
| 157 | %else
|
---|
[181] | 158 | %include "Strings.asm" ; For BIOS message strings
|
---|
[186] | 159 | %endif
|
---|
[3] | 160 |
|
---|
[181] | 161 | ; Initialization and drive detection
|
---|
| 162 | %include "Initialize.asm" ; For BIOS initialization
|
---|
| 163 | %include "Interrupts.asm" ; For Interrupt initialization
|
---|
| 164 | %include "RamVars.asm" ; For RAMVARS initialization and access
|
---|
| 165 | %include "CreateDPT.asm" ; For creating DPTs
|
---|
| 166 | %include "FindDPT.asm" ; For finding DPTs
|
---|
| 167 | %include "AccessDPT.asm" ; For accessing DPTs
|
---|
| 168 | %include "BootInfo.asm" ; For creating BOOTNFO structs
|
---|
| 169 | %include "AtaID.asm" ; For ATA Identify Device information
|
---|
| 170 | %include "DetectDrives.asm" ; For detecting IDE drives
|
---|
| 171 | %include "DetectPrint.asm" ; For printing drive detection strings
|
---|
[3] | 172 |
|
---|
[181] | 173 | ; Boot menu
|
---|
| 174 | %include "BootMenu.asm" ; For Boot Menu operations
|
---|
| 175 | %include "BootMenuEvent.asm" ; For menu library event handling
|
---|
[183] | 176 | %include "BootMenuPrint.asm" ; For printing Boot Menu strings (needs to come after BootMenuEvent.asm)
|
---|
[181] | 177 | %include "FloppyDrive.asm" ; Floppy Drive related functions
|
---|
| 178 | %include "BootSector.asm" ; For loading boot sector
|
---|
| 179 | %include "BootPrint.asm" ; For printing boot information
|
---|
| 180 | %include "BootMenuPrintCfg.asm" ; For printing hard disk configuration
|
---|
[3] | 181 |
|
---|
[181] | 182 | ; Boot loader
|
---|
[90] | 183 | %ifndef USE_AT
|
---|
[181] | 184 | %include "Int19hLate.asm" ; For late initialization
|
---|
[90] | 185 | %endif
|
---|
[181] | 186 | %include "Int19hMenu.asm" ; For Int 19h, Boot Loader for Boot Menu
|
---|
[3] | 187 |
|
---|
[181] | 188 | ; For all device types
|
---|
| 189 | %include "Device.asm"
|
---|
| 190 | %include "Idepack.asm"
|
---|
| 191 | %include "Timer.asm" ; For timeout and delay
|
---|
[155] | 192 |
|
---|
[181] | 193 | ; IDE Device support
|
---|
| 194 | %include "IdeCommand.asm"
|
---|
| 195 | %include "IdeTransfer.asm" ; Must be included after IdeCommand.asm
|
---|
| 196 | %include "IdeDPT.asm"
|
---|
| 197 | %include "IdeIO.asm"
|
---|
| 198 | %include "IdeIrq.asm"
|
---|
| 199 | %include "IdeWait.asm"
|
---|
| 200 | %include "IdeError.asm" ; Must be included after IdeWait.asm
|
---|
[155] | 201 |
|
---|
[181] | 202 | %ifdef MODULE_SERIAL ; Serial Port Device support
|
---|
| 203 | %include "SerialCommand.asm"
|
---|
| 204 | %include "SerialDPT.asm"
|
---|
[175] | 205 | %endif
|
---|
[155] | 206 |
|
---|
[181] | 207 | ; INT 13h Hard Disk BIOS functions
|
---|
| 208 | %include "DriveXlate.asm" ; For swapping drive numbers
|
---|
| 209 | %include "Address.asm" ; For sector address translations
|
---|
| 210 | %include "CommandLookup.asm" ; For getting correct transfer command
|
---|
| 211 | %include "Int13h.asm" ; For Int 13h, Disk functions
|
---|
| 212 | %include "AH0h_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
| 213 | %include "AH1h_HStatus.asm" ; Required by Int13h_Jump.asm
|
---|
| 214 | %include "AH2h_HRead.asm" ; Required by Int13h_Jump.asm
|
---|
| 215 | %include "AH3h_HWrite.asm" ; Required by Int13h_Jump.asm
|
---|
| 216 | %include "AH4h_HVerify.asm" ; Required by Int13h_Jump.asm
|
---|
| 217 | %include "AH8h_HParams.asm" ; Required by Int13h_Jump.asm
|
---|
| 218 | %include "AH9h_HInit.asm" ; Required by Int13h_Jump.asm
|
---|
| 219 | %include "AHCh_HSeek.asm" ; Required by Int13h_Jump.asm
|
---|
| 220 | %include "AHDh_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
| 221 | %include "AH10h_HReady.asm" ; Required by Int13h_Jump.asm
|
---|
| 222 | %include "AH11h_HRecal.asm" ; Required by Int13h_Jump.asm
|
---|
| 223 | %include "AH15h_HSize.asm" ; Required by Int13h_Jump.asm
|
---|
| 224 | %include "AH23h_HFeatures.asm" ; Required by Int13h_Jump.asm
|
---|
| 225 | %include "AH24h_HSetBlocks.asm" ; Required by Int13h_Jump.asm
|
---|
| 226 | %include "AH25h_HDrvID.asm" ; Required by Int13h_Jump.asm
|
---|
[176] | 227 | %ifdef MODULE_EBIOS
|
---|
[181] | 228 | %include "AH41h_CheckIfExtensionsPresent.asm"
|
---|
| 229 | %include "AH42h_ExtendedReadSectors.asm"
|
---|
| 230 | %include "AH43h_ExtendedWriteSectors.asm"
|
---|
| 231 | %include "AH44h_ExtendedVerifySectors.asm"
|
---|
| 232 | %include "AH47h_ExtendedSeek.asm"
|
---|
| 233 | %include "AH48h_GetExtendedDriveParameters.asm"
|
---|
[176] | 234 | %endif
|
---|
[3] | 235 |
|
---|
| 236 |
|
---|
| 237 | ; Fill with zeroes until size is what we want
|
---|
[88] | 238 | ;times (CNT_ROM_BLOCKS*512)-($-$$) db 0
|
---|