[3] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[86] | 2 | ; Authors : Tomi Tilli
|
---|
| 3 | ; : aitotat@gmail.com
|
---|
| 4 | ; :
|
---|
| 5 | ; : Krister Nordvall
|
---|
| 6 | ; : krille_n_@hotmail.com
|
---|
| 7 | ; :
|
---|
[3] | 8 | ; Description : Main file for BIOS. This is the only file that needs
|
---|
| 9 | ; to be compiled since other files are included to this
|
---|
| 10 | ; file (so no linker needed, Nasm does it all).
|
---|
| 11 |
|
---|
| 12 | ORG 000h ; Code start offset 0000h
|
---|
| 13 |
|
---|
[97] | 14 |
|
---|
[3] | 15 | ; Included .inc files
|
---|
[88] | 16 | %include "AssemblyLibrary.inc" ; Assembly Library. Must be included first!
|
---|
[152] | 17 | %include "IntController.inc" ; For Interrupt Controller equates
|
---|
[3] | 18 | %include "ATA_ID.inc" ; For ATA Drive Information structs
|
---|
| 19 | %include "IdeRegisters.inc" ; For ATA Registers, flags and commands
|
---|
| 20 | %include "Int13h.inc" ; Equates for INT 13h functions
|
---|
[176] | 21 | %ifdef MODULE_EBIOS
|
---|
[165] | 22 | %include "EBIOS.inc" ; Equates for EBIOS functions
|
---|
[176] | 23 | %endif
|
---|
[3] | 24 | %include "CustomDPT.inc" ; For Disk Parameter Table
|
---|
| 25 | %include "RomVars.inc" ; For ROMVARS and IDEVARS structs
|
---|
| 26 | %include "RamVars.inc" ; For RAMVARS struct
|
---|
| 27 | %include "BootVars.inc" ; For BOOTVARS and BOOTNFO structs
|
---|
| 28 | %include "BootMenu.inc" ; For Boot Menu
|
---|
| 29 | %include "IDE_8bit.inc" ; For IDE 8-bit data port macros
|
---|
[150] | 30 | %include "DeviceIDE.inc" ; For IDE device equates
|
---|
[3] | 31 |
|
---|
| 32 |
|
---|
| 33 | ; Section containing code
|
---|
| 34 | SECTION .text
|
---|
| 35 |
|
---|
| 36 | ; ROM variables (must start at offset 0)
|
---|
| 37 | CNT_ROM_BLOCKS EQU 16 ; 16 * 512B = 8kB BIOS
|
---|
| 38 | istruc ROMVARS
|
---|
| 39 | at ROMVARS.wRomSign, dw 0AA55h ; PC ROM signature
|
---|
| 40 | at ROMVARS.bRomSize, db CNT_ROM_BLOCKS ; ROM size in 512B blocks
|
---|
| 41 | at ROMVARS.rgbJump, jmp Initialize_FromMainBiosRomSearch
|
---|
[88] | 42 | at ROMVARS.rgbSign, db "XTIDE120" ; Signature for flash program
|
---|
[3] | 43 | at ROMVARS.szTitle
|
---|
| 44 | db "-=XTIDE Universal BIOS"
|
---|
| 45 | %ifdef USE_AT
|
---|
[88] | 46 | db " (AT)=-",NULL
|
---|
[3] | 47 | %elifdef USE_186
|
---|
[88] | 48 | db " (XT+)=-",NULL
|
---|
[3] | 49 | %else
|
---|
[88] | 50 | db " (XT)=-",NULL
|
---|
[3] | 51 | %endif
|
---|
[97] | 52 | at ROMVARS.szVersion, db "v1.2.0_wip (",__DATE__,")",NULL
|
---|
[3] | 53 |
|
---|
[179] | 54 | ;;; For OR'ing into wFlags below
|
---|
| 55 | ;;;
|
---|
| 56 | %ifdef MODULE_SERIAL
|
---|
| 57 | MAIN_FLG_MODULE_SERIAL equ FLG_ROMVARS_MODULE_SERIAL
|
---|
| 58 | %else
|
---|
| 59 | MAIN_FLG_MODULE_SERIAL equ 0
|
---|
| 60 | %endif
|
---|
| 61 |
|
---|
| 62 | %ifdef MODULE_EBIOS
|
---|
| 63 | MAIN_FLG_MODULE_EBIOS equ FLG_ROMVARS_MODULE_EBIOS
|
---|
| 64 | %else
|
---|
| 65 | MAIN_FLG_MODULE_EBIOS equ 0
|
---|
| 66 | %endif
|
---|
| 67 |
|
---|
[3] | 68 | ;---------------------------;
|
---|
| 69 | ; AT Build default settings ;
|
---|
| 70 | ;---------------------------;
|
---|
| 71 | %ifdef USE_AT
|
---|
[179] | 72 | at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS
|
---|
[143] | 73 | at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
|
---|
[137] | 74 | at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection timeout
|
---|
[150] | 75 | at ROMVARS.bIdeCnt, db 4 ; Number of supported controllers
|
---|
[3] | 76 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
| 77 | at ROMVARS.bMinFddCnt, db 0 ; Do not force minimum number of floppy drives
|
---|
| 78 | at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory
|
---|
| 79 |
|
---|
| 80 | at ROMVARS.ideVars0+IDEVARS.wPort, dw 1F0h ; Controller Command Block base port
|
---|
| 81 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 3F0h ; Controller Control Block base port
|
---|
[150] | 82 | at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_16BIT_ATA
|
---|
[160] | 83 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0
|
---|
[3] | 84 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 85 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 86 |
|
---|
| 87 | at ROMVARS.ideVars1+IDEVARS.wPort, dw 170h ; Controller Command Block base port
|
---|
| 88 | at ROMVARS.ideVars1+IDEVARS.wPortCtrl, dw 370h ; Controller Control Block base port
|
---|
[150] | 89 | at ROMVARS.ideVars1+IDEVARS.bDevice, db DEVICE_16BIT_ATA
|
---|
[160] | 90 | at ROMVARS.ideVars1+IDEVARS.bIRQ, db 0
|
---|
[3] | 91 | at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 92 | at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 93 |
|
---|
| 94 | at ROMVARS.ideVars2+IDEVARS.wPort, dw 300h ; Controller Command Block base port
|
---|
| 95 | at ROMVARS.ideVars2+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port
|
---|
[150] | 96 | at ROMVARS.ideVars2+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE
|
---|
| 97 | at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0
|
---|
[3] | 98 | at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 99 | at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[143] | 100 |
|
---|
| 101 | at ROMVARS.ideVars3+IDEVARS.wPort, dw 168h ; Controller Command Block base port
|
---|
| 102 | at ROMVARS.ideVars3+IDEVARS.wPortCtrl, dw 368h ; Controller Control Block base port
|
---|
[150] | 103 | at ROMVARS.ideVars3+IDEVARS.bDevice, db DEVICE_16BIT_ATA
|
---|
| 104 | at ROMVARS.ideVars3+IDEVARS.bIRQ, db 0
|
---|
[143] | 105 | at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 106 | at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[175] | 107 |
|
---|
| 108 | %ifdef MODULE_SERIAL
|
---|
| 109 | at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
|
---|
| 110 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 111 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 112 | %endif
|
---|
[3] | 113 | %else
|
---|
| 114 | ;-----------------------------------;
|
---|
| 115 | ; XT and XT+ Build default settings ;
|
---|
| 116 | ;-----------------------------------;
|
---|
[179] | 117 | at ROMVARS.wFlags, dw FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS
|
---|
[143] | 118 | at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
|
---|
[137] | 119 | at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection timeout
|
---|
[3] | 120 | at ROMVARS.bIdeCnt, db 1 ; Number of supported controllers
|
---|
| 121 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
| 122 | at ROMVARS.bMinFddCnt, db 1 ; Assume at least 1 floppy drive present if autodetect fails
|
---|
| 123 | at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory in full mode
|
---|
| 124 |
|
---|
| 125 | at ROMVARS.ideVars0+IDEVARS.wPort, dw 300h ; Controller Command Block base port
|
---|
| 126 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port
|
---|
[150] | 127 | at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE
|
---|
[3] | 128 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0 ; IRQ
|
---|
| 129 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 130 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[143] | 131 |
|
---|
| 132 | at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 133 | at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 134 |
|
---|
| 135 | at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 136 | at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 137 |
|
---|
| 138 | at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 139 | at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[175] | 140 |
|
---|
| 141 | %ifdef MODULE_SERIAL
|
---|
| 142 | at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
|
---|
| 143 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 144 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 145 | %endif
|
---|
[3] | 146 | %endif
|
---|
| 147 | iend
|
---|
| 148 |
|
---|
| 149 |
|
---|
[155] | 150 | ; Libraries and data
|
---|
[88] | 151 | %include "AssemblyLibrary.asm"
|
---|
[3] | 152 | %include "Strings.asm" ; For BIOS message strings
|
---|
| 153 |
|
---|
[155] | 154 | ; Initialization and drive detection
|
---|
[3] | 155 | %include "Initialize.asm" ; For BIOS initialization
|
---|
[33] | 156 | %include "Interrupts.asm" ; For Interrupt initialization
|
---|
[3] | 157 | %include "RamVars.asm" ; For RAMVARS initialization and access
|
---|
| 158 | %include "CreateDPT.asm" ; For creating DPTs
|
---|
| 159 | %include "FindDPT.asm" ; For finding DPTs
|
---|
| 160 | %include "AccessDPT.asm" ; For accessing DPTs
|
---|
| 161 | %include "BootInfo.asm" ; For creating BOOTNFO structs
|
---|
| 162 | %include "AtaID.asm" ; For ATA Identify Device information
|
---|
| 163 | %include "DetectDrives.asm" ; For detecting IDE drives
|
---|
| 164 | %include "DetectPrint.asm" ; For printing drive detection strings
|
---|
| 165 |
|
---|
[155] | 166 | ; Boot menu
|
---|
[3] | 167 | %include "BootMenu.asm" ; For Boot Menu operations
|
---|
| 168 | %include "BootMenuEvent.asm" ; For menu library event handling
|
---|
| 169 | %include "FloppyDrive.asm" ; Floppy Drive related functions
|
---|
[96] | 170 | %include "BootSector.asm" ; For loading boot sector
|
---|
| 171 | %include "BootPrint.asm" ; For printing boot information
|
---|
[3] | 172 | %include "BootMenuPrint.asm" ; For printing Boot Menu strings
|
---|
| 173 | %include "BootMenuPrintCfg.asm" ; For printing hard disk configuration
|
---|
| 174 |
|
---|
[155] | 175 | ; Boot loader
|
---|
[90] | 176 | %ifndef USE_AT
|
---|
| 177 | %include "Int19hLate.asm" ; For late initialization
|
---|
| 178 | %endif
|
---|
[3] | 179 | %include "Int19hMenu.asm" ; For Int 19h, Boot Loader for Boot Menu
|
---|
| 180 |
|
---|
[155] | 181 | ; For all device types
|
---|
| 182 | %include "Device.asm"
|
---|
| 183 | %include "Idepack.asm"
|
---|
| 184 | %include "Timer.asm" ; For timeout and delay
|
---|
| 185 |
|
---|
| 186 | ; IDE Device support
|
---|
| 187 | %include "IdeCommand.asm"
|
---|
[158] | 188 | %include "IdeTransfer.asm" ; Must be included after IdeCommand.asm
|
---|
[155] | 189 | %include "IdeDPT.asm"
|
---|
| 190 | %include "IdeIO.asm"
|
---|
| 191 | %include "IdeIrq.asm"
|
---|
| 192 | %include "IdeWait.asm"
|
---|
| 193 | %include "IdeError.asm" ; Must be included after IdeWait.asm
|
---|
| 194 |
|
---|
[175] | 195 | %ifdef MODULE_SERIAL
|
---|
[155] | 196 | ; Serial Port Device support
|
---|
| 197 | %include "SerialCommand.asm"
|
---|
| 198 | %include "SerialDPT.asm"
|
---|
[175] | 199 | %endif
|
---|
[155] | 200 |
|
---|
| 201 | ; INT 13h Hard Disk BIOS functions
|
---|
| 202 | %include "DriveXlate.asm" ; For swapping drive numbers
|
---|
| 203 | %include "Address.asm" ; For sector address translations
|
---|
[165] | 204 | %include "CommandLookup.asm" ; For getting correct transfer command
|
---|
[155] | 205 | %include "Int13h.asm" ; For Int 13h, Disk functions
|
---|
[3] | 206 | %include "AH0h_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
| 207 | %include "AH1h_HStatus.asm" ; Required by Int13h_Jump.asm
|
---|
| 208 | %include "AH2h_HRead.asm" ; Required by Int13h_Jump.asm
|
---|
| 209 | %include "AH3h_HWrite.asm" ; Required by Int13h_Jump.asm
|
---|
| 210 | %include "AH4h_HVerify.asm" ; Required by Int13h_Jump.asm
|
---|
| 211 | %include "AH8h_HParams.asm" ; Required by Int13h_Jump.asm
|
---|
| 212 | %include "AH9h_HInit.asm" ; Required by Int13h_Jump.asm
|
---|
| 213 | %include "AHCh_HSeek.asm" ; Required by Int13h_Jump.asm
|
---|
| 214 | %include "AHDh_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
| 215 | %include "AH10h_HReady.asm" ; Required by Int13h_Jump.asm
|
---|
| 216 | %include "AH11h_HRecal.asm" ; Required by Int13h_Jump.asm
|
---|
| 217 | %include "AH15h_HSize.asm" ; Required by Int13h_Jump.asm
|
---|
| 218 | %include "AH23h_HFeatures.asm" ; Required by Int13h_Jump.asm
|
---|
| 219 | %include "AH24h_HSetBlocks.asm" ; Required by Int13h_Jump.asm
|
---|
| 220 | %include "AH25h_HDrvID.asm" ; Required by Int13h_Jump.asm
|
---|
[176] | 221 | %ifdef MODULE_EBIOS
|
---|
[165] | 222 | %include "AH41h_CheckIfExtensionsPresent.asm"
|
---|
| 223 | %include "AH42h_ExtendedReadSectors.asm"
|
---|
| 224 | %include "AH43h_ExtendedWriteSectors.asm"
|
---|
| 225 | %include "AH44h_ExtendedVerifySectors.asm"
|
---|
| 226 | %include "AH47h_ExtendedSeek.asm"
|
---|
| 227 | %include "AH48h_GetExtendedDriveParameters.asm"
|
---|
[176] | 228 | %endif
|
---|
[3] | 229 |
|
---|
| 230 |
|
---|
| 231 | ; Fill with zeroes until size is what we want
|
---|
[88] | 232 | ;times (CNT_ROM_BLOCKS*512)-($-$$) db 0
|
---|