[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 |
|
---|
| 54 | ;---------------------------;
|
---|
| 55 | ; AT Build default settings ;
|
---|
| 56 | ;---------------------------;
|
---|
| 57 | %ifdef USE_AT
|
---|
[176] | 58 | at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | FLG_ROMVARS_MODULE_SERIAL | FLG_ROMVARS_MODULE_EBIOS
|
---|
[143] | 59 | at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
|
---|
[137] | 60 | at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection timeout
|
---|
[150] | 61 | at ROMVARS.bIdeCnt, db 4 ; Number of supported controllers
|
---|
[3] | 62 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
| 63 | at ROMVARS.bMinFddCnt, db 0 ; Do not force minimum number of floppy drives
|
---|
| 64 | at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory
|
---|
| 65 |
|
---|
| 66 | at ROMVARS.ideVars0+IDEVARS.wPort, dw 1F0h ; Controller Command Block base port
|
---|
| 67 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 3F0h ; Controller Control Block base port
|
---|
[150] | 68 | at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_16BIT_ATA
|
---|
[160] | 69 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0
|
---|
[3] | 70 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 71 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 72 |
|
---|
| 73 | at ROMVARS.ideVars1+IDEVARS.wPort, dw 170h ; Controller Command Block base port
|
---|
| 74 | at ROMVARS.ideVars1+IDEVARS.wPortCtrl, dw 370h ; Controller Control Block base port
|
---|
[150] | 75 | at ROMVARS.ideVars1+IDEVARS.bDevice, db DEVICE_16BIT_ATA
|
---|
[160] | 76 | at ROMVARS.ideVars1+IDEVARS.bIRQ, db 0
|
---|
[3] | 77 | at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 78 | at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 79 |
|
---|
| 80 | at ROMVARS.ideVars2+IDEVARS.wPort, dw 300h ; Controller Command Block base port
|
---|
| 81 | at ROMVARS.ideVars2+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port
|
---|
[150] | 82 | at ROMVARS.ideVars2+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE
|
---|
| 83 | at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0
|
---|
[3] | 84 | at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 85 | at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[143] | 86 |
|
---|
| 87 | at ROMVARS.ideVars3+IDEVARS.wPort, dw 168h ; Controller Command Block base port
|
---|
| 88 | at ROMVARS.ideVars3+IDEVARS.wPortCtrl, dw 368h ; Controller Control Block base port
|
---|
[150] | 89 | at ROMVARS.ideVars3+IDEVARS.bDevice, db DEVICE_16BIT_ATA
|
---|
| 90 | at ROMVARS.ideVars3+IDEVARS.bIRQ, db 0
|
---|
[143] | 91 | at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 92 | at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[175] | 93 |
|
---|
| 94 | %ifdef MODULE_SERIAL
|
---|
| 95 | at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
|
---|
| 96 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 97 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 98 | %endif
|
---|
[3] | 99 | %else
|
---|
| 100 | ;-----------------------------------;
|
---|
| 101 | ; XT and XT+ Build default settings ;
|
---|
| 102 | ;-----------------------------------;
|
---|
[176] | 103 | at ROMVARS.wFlags, dw FLG_ROMVARS_DRVXLAT | FLG_ROMVARS_MODULE_SERIAL | FLG_ROMVARS_MODULE_EBIOS
|
---|
[143] | 104 | at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
|
---|
[137] | 105 | at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection timeout
|
---|
[3] | 106 | at ROMVARS.bIdeCnt, db 1 ; Number of supported controllers
|
---|
| 107 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
| 108 | at ROMVARS.bMinFddCnt, db 1 ; Assume at least 1 floppy drive present if autodetect fails
|
---|
| 109 | at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory in full mode
|
---|
| 110 |
|
---|
| 111 | at ROMVARS.ideVars0+IDEVARS.wPort, dw 300h ; Controller Command Block base port
|
---|
| 112 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port
|
---|
[150] | 113 | at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE
|
---|
[3] | 114 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0 ; IRQ
|
---|
| 115 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 116 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[143] | 117 |
|
---|
| 118 | at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 119 | at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 120 |
|
---|
| 121 | at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 122 | at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 123 |
|
---|
| 124 | at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 125 | at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
[175] | 126 |
|
---|
| 127 | %ifdef MODULE_SERIAL
|
---|
| 128 | at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
|
---|
| 129 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 130 | at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 131 | %endif
|
---|
[3] | 132 | %endif
|
---|
| 133 | iend
|
---|
| 134 |
|
---|
| 135 |
|
---|
[155] | 136 | ; Libraries and data
|
---|
[88] | 137 | %include "AssemblyLibrary.asm"
|
---|
[3] | 138 | %include "Strings.asm" ; For BIOS message strings
|
---|
| 139 |
|
---|
[155] | 140 | ; Initialization and drive detection
|
---|
[3] | 141 | %include "Initialize.asm" ; For BIOS initialization
|
---|
[33] | 142 | %include "Interrupts.asm" ; For Interrupt initialization
|
---|
[3] | 143 | %include "RamVars.asm" ; For RAMVARS initialization and access
|
---|
| 144 | %include "CreateDPT.asm" ; For creating DPTs
|
---|
| 145 | %include "FindDPT.asm" ; For finding DPTs
|
---|
| 146 | %include "AccessDPT.asm" ; For accessing DPTs
|
---|
| 147 | %include "BootInfo.asm" ; For creating BOOTNFO structs
|
---|
| 148 | %include "AtaID.asm" ; For ATA Identify Device information
|
---|
| 149 | %include "DetectDrives.asm" ; For detecting IDE drives
|
---|
| 150 | %include "DetectPrint.asm" ; For printing drive detection strings
|
---|
| 151 |
|
---|
[155] | 152 | ; Boot menu
|
---|
[3] | 153 | %include "BootMenu.asm" ; For Boot Menu operations
|
---|
| 154 | %include "BootMenuEvent.asm" ; For menu library event handling
|
---|
| 155 | %include "FloppyDrive.asm" ; Floppy Drive related functions
|
---|
[96] | 156 | %include "BootSector.asm" ; For loading boot sector
|
---|
| 157 | %include "BootPrint.asm" ; For printing boot information
|
---|
[3] | 158 | %include "BootMenuPrint.asm" ; For printing Boot Menu strings
|
---|
| 159 | %include "BootMenuPrintCfg.asm" ; For printing hard disk configuration
|
---|
| 160 |
|
---|
[155] | 161 | ; Boot loader
|
---|
[90] | 162 | %ifndef USE_AT
|
---|
| 163 | %include "Int19hLate.asm" ; For late initialization
|
---|
| 164 | %endif
|
---|
[3] | 165 | %include "Int19hMenu.asm" ; For Int 19h, Boot Loader for Boot Menu
|
---|
| 166 |
|
---|
[155] | 167 | ; For all device types
|
---|
| 168 | %include "Device.asm"
|
---|
| 169 | %include "Idepack.asm"
|
---|
| 170 | %include "Timer.asm" ; For timeout and delay
|
---|
| 171 |
|
---|
| 172 | ; IDE Device support
|
---|
| 173 | %include "IdeCommand.asm"
|
---|
[158] | 174 | %include "IdeTransfer.asm" ; Must be included after IdeCommand.asm
|
---|
[155] | 175 | %include "IdeDPT.asm"
|
---|
| 176 | %include "IdeIO.asm"
|
---|
| 177 | %include "IdeIrq.asm"
|
---|
| 178 | %include "IdeWait.asm"
|
---|
| 179 | %include "IdeError.asm" ; Must be included after IdeWait.asm
|
---|
| 180 |
|
---|
[175] | 181 | %ifdef MODULE_SERIAL
|
---|
[155] | 182 | ; Serial Port Device support
|
---|
| 183 | %include "SerialCommand.asm"
|
---|
| 184 | %include "SerialDPT.asm"
|
---|
[175] | 185 | %endif
|
---|
[155] | 186 |
|
---|
| 187 | ; INT 13h Hard Disk BIOS functions
|
---|
| 188 | %include "DriveXlate.asm" ; For swapping drive numbers
|
---|
| 189 | %include "Address.asm" ; For sector address translations
|
---|
[165] | 190 | %include "CommandLookup.asm" ; For getting correct transfer command
|
---|
[155] | 191 | %include "Int13h.asm" ; For Int 13h, Disk functions
|
---|
[3] | 192 | %include "AH0h_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
| 193 | %include "AH1h_HStatus.asm" ; Required by Int13h_Jump.asm
|
---|
| 194 | %include "AH2h_HRead.asm" ; Required by Int13h_Jump.asm
|
---|
| 195 | %include "AH3h_HWrite.asm" ; Required by Int13h_Jump.asm
|
---|
| 196 | %include "AH4h_HVerify.asm" ; Required by Int13h_Jump.asm
|
---|
| 197 | %include "AH8h_HParams.asm" ; Required by Int13h_Jump.asm
|
---|
| 198 | %include "AH9h_HInit.asm" ; Required by Int13h_Jump.asm
|
---|
| 199 | %include "AHCh_HSeek.asm" ; Required by Int13h_Jump.asm
|
---|
| 200 | %include "AHDh_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
| 201 | %include "AH10h_HReady.asm" ; Required by Int13h_Jump.asm
|
---|
| 202 | %include "AH11h_HRecal.asm" ; Required by Int13h_Jump.asm
|
---|
| 203 | %include "AH15h_HSize.asm" ; Required by Int13h_Jump.asm
|
---|
| 204 | %include "AH23h_HFeatures.asm" ; Required by Int13h_Jump.asm
|
---|
| 205 | %include "AH24h_HSetBlocks.asm" ; Required by Int13h_Jump.asm
|
---|
| 206 | %include "AH25h_HDrvID.asm" ; Required by Int13h_Jump.asm
|
---|
[176] | 207 | %ifdef MODULE_EBIOS
|
---|
[165] | 208 | %include "AH41h_CheckIfExtensionsPresent.asm"
|
---|
| 209 | %include "AH42h_ExtendedReadSectors.asm"
|
---|
| 210 | %include "AH43h_ExtendedWriteSectors.asm"
|
---|
| 211 | %include "AH44h_ExtendedVerifySectors.asm"
|
---|
| 212 | %include "AH47h_ExtendedSeek.asm"
|
---|
| 213 | %include "AH48h_GetExtendedDriveParameters.asm"
|
---|
[176] | 214 | %endif
|
---|
[3] | 215 |
|
---|
| 216 |
|
---|
| 217 | ; Fill with zeroes until size is what we want
|
---|
[88] | 218 | ;times (CNT_ROM_BLOCKS*512)-($-$$) db 0
|
---|