[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 |
|
---|
| 14 | ; Included .inc files
|
---|
[88] | 15 | %include "AssemblyLibrary.inc" ; Assembly Library. Must be included first!
|
---|
| 16 | %include "macros.inc" ; General purpose macros
|
---|
[3] | 17 | %include "BiosData.inc" ; For BIOS Data area equates
|
---|
| 18 | %include "Interrupts.inc" ; For interrupt equates
|
---|
| 19 | %include "ATA_ID.inc" ; For ATA Drive Information structs
|
---|
| 20 | %include "IdeRegisters.inc" ; For ATA Registers, flags and commands
|
---|
| 21 | %include "Int13h.inc" ; Equates for INT 13h functions
|
---|
| 22 | %include "CustomDPT.inc" ; For Disk Parameter Table
|
---|
| 23 | %include "CompatibleDPT.inc" ; For standard Disk Parameter Tables
|
---|
| 24 | %include "RomVars.inc" ; For ROMVARS and IDEVARS structs
|
---|
| 25 | %include "RamVars.inc" ; For RAMVARS struct
|
---|
| 26 | %include "BootVars.inc" ; For BOOTVARS and BOOTNFO structs
|
---|
| 27 | %include "BootMenu.inc" ; For Boot Menu
|
---|
| 28 | %include "IDE_8bit.inc" ; For IDE 8-bit data port macros
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | ; Section containing code
|
---|
| 32 | SECTION .text
|
---|
| 33 |
|
---|
| 34 | ; ROM variables (must start at offset 0)
|
---|
| 35 | CNT_ROM_BLOCKS EQU 16 ; 16 * 512B = 8kB BIOS
|
---|
| 36 | istruc ROMVARS
|
---|
| 37 | at ROMVARS.wRomSign, dw 0AA55h ; PC ROM signature
|
---|
| 38 | at ROMVARS.bRomSize, db CNT_ROM_BLOCKS ; ROM size in 512B blocks
|
---|
| 39 | at ROMVARS.rgbJump, jmp Initialize_FromMainBiosRomSearch
|
---|
[88] | 40 | at ROMVARS.rgbSign, db "XTIDE120" ; Signature for flash program
|
---|
[3] | 41 | at ROMVARS.szTitle
|
---|
| 42 | db "-=XTIDE Universal BIOS"
|
---|
| 43 | %ifdef USE_AT
|
---|
[88] | 44 | db " (AT)=-",NULL
|
---|
[3] | 45 | %elifdef USE_186
|
---|
[88] | 46 | db " (XT+)=-",NULL
|
---|
[3] | 47 | %else
|
---|
[88] | 48 | db " (XT)=-",NULL
|
---|
[3] | 49 | %endif
|
---|
[90] | 50 | at ROMVARS.szVersion, db "v1.2.0_wip (01/27/11)",NULL ; mm/dd/yy
|
---|
[3] | 51 |
|
---|
| 52 | ;---------------------------;
|
---|
| 53 | ; AT Build default settings ;
|
---|
| 54 | ;---------------------------;
|
---|
| 55 | %ifdef USE_AT
|
---|
[90] | 56 | at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | FLG_ROMVARS_MAXSIZE
|
---|
[3] | 57 | at ROMVARS.bIdeCnt, db 3 ; Number of supported controllers
|
---|
| 58 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
| 59 | at ROMVARS.bBootDelay, db 30 ; Boot Menu selection delay (secs)
|
---|
| 60 | at ROMVARS.bMinFddCnt, db 0 ; Do not force minimum number of floppy drives
|
---|
| 61 | at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory
|
---|
| 62 |
|
---|
| 63 | at ROMVARS.ideVars0+IDEVARS.wPort, dw 1F0h ; Controller Command Block base port
|
---|
| 64 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 3F0h ; Controller Control Block base port
|
---|
| 65 | at ROMVARS.ideVars0+IDEVARS.bBusType, db BUS_TYPE_16 ; Bus type
|
---|
| 66 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 14 ; IRQ
|
---|
| 67 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 68 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 69 |
|
---|
| 70 | at ROMVARS.ideVars1+IDEVARS.wPort, dw 170h ; Controller Command Block base port
|
---|
| 71 | at ROMVARS.ideVars1+IDEVARS.wPortCtrl, dw 370h ; Controller Control Block base port
|
---|
| 72 | at ROMVARS.ideVars1+IDEVARS.bBusType, db BUS_TYPE_16 ; Bus type
|
---|
| 73 | at ROMVARS.ideVars1+IDEVARS.bIRQ, db 15 ; IRQ
|
---|
| 74 | at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 75 | at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 76 |
|
---|
| 77 | at ROMVARS.ideVars2+IDEVARS.wPort, dw 300h ; Controller Command Block base port
|
---|
| 78 | at ROMVARS.ideVars2+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port
|
---|
| 79 | at ROMVARS.ideVars2+IDEVARS.bBusType, db BUS_TYPE_8_DUAL ; Bus type
|
---|
| 80 | at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0 ; IRQ
|
---|
| 81 | at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 82 | at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 83 | %else
|
---|
| 84 | ;-----------------------------------;
|
---|
| 85 | ; XT and XT+ Build default settings ;
|
---|
| 86 | ;-----------------------------------;
|
---|
[90] | 87 | at ROMVARS.wFlags, dw FLG_ROMVARS_DRVXLAT | FLG_ROMVARS_ROMBOOT | FLG_ROMVARS_MAXSIZE
|
---|
[3] | 88 | at ROMVARS.bIdeCnt, db 1 ; Number of supported controllers
|
---|
| 89 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
| 90 | at ROMVARS.bBootDelay, db 30 ; Boot Menu selection delay (secs)
|
---|
| 91 | at ROMVARS.bMinFddCnt, db 1 ; Assume at least 1 floppy drive present if autodetect fails
|
---|
| 92 | at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory in full mode
|
---|
| 93 |
|
---|
| 94 | at ROMVARS.ideVars0+IDEVARS.wPort, dw 300h ; Controller Command Block base port
|
---|
| 95 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port
|
---|
| 96 | at ROMVARS.ideVars0+IDEVARS.bBusType, db BUS_TYPE_8_DUAL ; Bus type
|
---|
| 97 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0 ; IRQ
|
---|
| 98 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 99 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 100 | %endif
|
---|
| 101 | iend
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | ; Include .asm files (static data and libraries)
|
---|
[88] | 105 | %include "AssemblyLibrary.asm"
|
---|
[3] | 106 | %include "Strings.asm" ; For BIOS message strings
|
---|
| 107 |
|
---|
| 108 | ; Include .asm files (Initialization and drive detection)
|
---|
| 109 | %include "Initialize.asm" ; For BIOS initialization
|
---|
[33] | 110 | %include "Interrupts.asm" ; For Interrupt initialization
|
---|
[3] | 111 | %include "RamVars.asm" ; For RAMVARS initialization and access
|
---|
| 112 | %include "CreateDPT.asm" ; For creating DPTs
|
---|
| 113 | %include "FindDPT.asm" ; For finding DPTs
|
---|
| 114 | %include "AccessDPT.asm" ; For accessing DPTs
|
---|
| 115 | %include "CompatibleDPT.asm" ; For creating compatible DPTs
|
---|
| 116 | %include "BootInfo.asm" ; For creating BOOTNFO structs
|
---|
| 117 | %include "AtaID.asm" ; For ATA Identify Device information
|
---|
| 118 | %include "DetectDrives.asm" ; For detecting IDE drives
|
---|
| 119 | %include "DetectPrint.asm" ; For printing drive detection strings
|
---|
| 120 |
|
---|
| 121 | ; Include .asm files (boot menu)
|
---|
| 122 | %include "BootVars.asm" ; For accessing BOOTVARS struct
|
---|
| 123 | %include "BootMenu.asm" ; For Boot Menu operations
|
---|
| 124 | %include "BootMenuEvent.asm" ; For menu library event handling
|
---|
| 125 | %include "FloppyDrive.asm" ; Floppy Drive related functions
|
---|
| 126 | %include "BootMenuPrint.asm" ; For printing Boot Menu strings
|
---|
| 127 | %include "BootMenuPrintCfg.asm" ; For printing hard disk configuration
|
---|
| 128 |
|
---|
| 129 | ; Include .asm files (general drive accessing)
|
---|
| 130 | %include "DriveXlate.asm" ; For swapping drive numbers
|
---|
| 131 | %include "HAddress.asm" ; For sector address translations
|
---|
| 132 | %include "HCapacity.asm" ; For calculating drive capacity
|
---|
| 133 | %include "HError.asm" ; For error checking
|
---|
| 134 | %include "HPIO.asm" ; For PIO transfers
|
---|
| 135 | %include "HIRQ.asm" ; For IRQ handling
|
---|
| 136 | %include "HStatus.asm" ; For reading hard disk status
|
---|
| 137 | %include "HDrvSel.asm" ; For selecting drive to access
|
---|
| 138 | %include "HCommand.asm" ; For outputting command and parameters
|
---|
| 139 |
|
---|
| 140 | ; Include .asm files (Interrupt handlers)
|
---|
| 141 | %include "Int13h.asm" ; For Int 13h, Disk functions
|
---|
| 142 | %include "Int19h.asm" ; For Int 19h, Boot Loader
|
---|
[90] | 143 | %ifndef USE_AT
|
---|
| 144 | %include "Int19hLate.asm" ; For late initialization
|
---|
| 145 | %endif
|
---|
[3] | 146 | %include "Int19hMenu.asm" ; For Int 19h, Boot Loader for Boot Menu
|
---|
| 147 | %include "BootPrint.asm" ; For printing boot information
|
---|
| 148 |
|
---|
| 149 | ; Include .asm files (Hard Disk BIOS functions)
|
---|
| 150 | %include "AH0h_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
| 151 | %include "AH1h_HStatus.asm" ; Required by Int13h_Jump.asm
|
---|
| 152 | %include "AH2h_HRead.asm" ; Required by Int13h_Jump.asm
|
---|
| 153 | %include "AH3h_HWrite.asm" ; Required by Int13h_Jump.asm
|
---|
| 154 | %include "AH4h_HVerify.asm" ; Required by Int13h_Jump.asm
|
---|
| 155 | %include "AH8h_HParams.asm" ; Required by Int13h_Jump.asm
|
---|
| 156 | %include "AH9h_HInit.asm" ; Required by Int13h_Jump.asm
|
---|
| 157 | %include "AHCh_HSeek.asm" ; Required by Int13h_Jump.asm
|
---|
| 158 | %include "AHDh_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
| 159 | %include "AH10h_HReady.asm" ; Required by Int13h_Jump.asm
|
---|
| 160 | %include "AH11h_HRecal.asm" ; Required by Int13h_Jump.asm
|
---|
| 161 | %include "AH15h_HSize.asm" ; Required by Int13h_Jump.asm
|
---|
| 162 | %include "AH23h_HFeatures.asm" ; Required by Int13h_Jump.asm
|
---|
| 163 | %include "AH24h_HSetBlocks.asm" ; Required by Int13h_Jump.asm
|
---|
| 164 | %include "AH25h_HDrvID.asm" ; Required by Int13h_Jump.asm
|
---|
| 165 |
|
---|
| 166 |
|
---|
| 167 |
|
---|
| 168 | ; Fill with zeroes until size is what we want
|
---|
[88] | 169 | ;times (CNT_ROM_BLOCKS*512)-($-$$) db 0
|
---|