[3] | 1 | ; File name : Main.asm
|
---|
| 2 | ; Project name : XTIDE Universal BIOS
|
---|
| 3 | ; Created date : 28.7.2007
|
---|
| 4 | ; Last update : 2.5.2010
|
---|
| 5 | ; Author : Tomi Tilli
|
---|
| 6 | ; Description : Main file for BIOS. This is the only file that needs
|
---|
| 7 | ; to be compiled since other files are included to this
|
---|
| 8 | ; file (so no linker needed, Nasm does it all).
|
---|
| 9 | ;
|
---|
| 10 | ; Tomi Tilli
|
---|
| 11 | ; aitotat@gmail.com
|
---|
| 12 |
|
---|
| 13 | ORG 000h ; Code start offset 0000h
|
---|
| 14 |
|
---|
| 15 | ; Included .inc files
|
---|
| 16 | %include "emulate.inc" ; Must be included first!
|
---|
| 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
|
---|
| 40 | at ROMVARS.rgbDate, db "05/02/10" ; Build data (mm/dd/yy)
|
---|
| 41 | at ROMVARS.rgbSign, db "XTIDE110" ; Signature for flash program
|
---|
| 42 | at ROMVARS.szTitle
|
---|
| 43 | db "-=XTIDE Universal BIOS"
|
---|
| 44 | %ifdef USE_AT
|
---|
| 45 | db " (AT)=-",STOP
|
---|
| 46 | %elifdef USE_186
|
---|
| 47 | db " (XT+)=-",STOP
|
---|
| 48 | %else
|
---|
| 49 | db " (XT)=-",STOP
|
---|
| 50 | %endif
|
---|
| 51 | at ROMVARS.szVersion, db "v1.1.0 (05/02/10)",STOP
|
---|
| 52 |
|
---|
| 53 | ;---------------------------;
|
---|
| 54 | ; AT Build default settings ;
|
---|
| 55 | ;---------------------------;
|
---|
| 56 | %ifdef USE_AT
|
---|
| 57 | at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | FLG_ROMVARS_DRVNFO | FLG_ROMVARS_MAXSIZE
|
---|
| 58 | at ROMVARS.bIdeCnt, db 3 ; Number of supported controllers
|
---|
| 59 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
| 60 | at ROMVARS.bBootMnuH, db 20 ; Boot Menu maximum height
|
---|
| 61 | at ROMVARS.bBootDelay, db 30 ; Boot Menu selection delay (secs)
|
---|
| 62 | at ROMVARS.bBootLdrType, db BOOTLOADER_TYPE_MENU ; Boot loader type
|
---|
| 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
|
---|
| 68 | at ROMVARS.ideVars0+IDEVARS.bBusType, db BUS_TYPE_16 ; Bus type
|
---|
| 69 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 14 ; IRQ
|
---|
| 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
|
---|
| 75 | at ROMVARS.ideVars1+IDEVARS.bBusType, db BUS_TYPE_16 ; Bus type
|
---|
| 76 | at ROMVARS.ideVars1+IDEVARS.bIRQ, db 15 ; IRQ
|
---|
| 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
|
---|
| 82 | at ROMVARS.ideVars2+IDEVARS.bBusType, db BUS_TYPE_8_DUAL ; Bus type
|
---|
| 83 | at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0 ; IRQ
|
---|
| 84 | at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 85 | at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 86 | %else
|
---|
| 87 | ;-----------------------------------;
|
---|
| 88 | ; XT and XT+ Build default settings ;
|
---|
| 89 | ;-----------------------------------;
|
---|
| 90 | at ROMVARS.wFlags, dw FLG_ROMVARS_LATE | FLG_ROMVARS_DRVXLAT | FLG_ROMVARS_ROMBOOT | FLG_ROMVARS_DRVNFO | FLG_ROMVARS_MAXSIZE
|
---|
| 91 | at ROMVARS.bIdeCnt, db 1 ; Number of supported controllers
|
---|
| 92 | at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
|
---|
| 93 | at ROMVARS.bBootMnuH, db 20 ; Boot Menu maximum height
|
---|
| 94 | at ROMVARS.bBootDelay, db 30 ; Boot Menu selection delay (secs)
|
---|
| 95 | at ROMVARS.bBootLdrType, db BOOTLOADER_TYPE_MENU ; Boot loader type
|
---|
| 96 | at ROMVARS.bMinFddCnt, db 1 ; Assume at least 1 floppy drive present if autodetect fails
|
---|
| 97 | at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory in full mode
|
---|
| 98 |
|
---|
| 99 | at ROMVARS.ideVars0+IDEVARS.wPort, dw 300h ; Controller Command Block base port
|
---|
| 100 | at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port
|
---|
| 101 | at ROMVARS.ideVars0+IDEVARS.bBusType, db BUS_TYPE_8_DUAL ; Bus type
|
---|
| 102 | at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0 ; IRQ
|
---|
| 103 | at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 104 | at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
|
---|
| 105 | %endif
|
---|
| 106 | iend
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | ; Include .asm files (static data and libraries)
|
---|
| 110 | %include "Strings.asm" ; For BIOS message strings
|
---|
| 111 | %include "math.asm" ; For Math library
|
---|
| 112 | %include "string.asm" ; For String library
|
---|
| 113 | %include "print.asm" ; For Print library
|
---|
| 114 | %include "keys.asm" ; For keyboard library (required by menu library)
|
---|
| 115 | %include "menu.asm" ; For menu library
|
---|
| 116 | %include "PrintString.asm" ; Customized printing for this BIOS
|
---|
| 117 | %include "SoftDelay.asm" ; For software delay loops
|
---|
| 118 |
|
---|
| 119 | ; Include .asm files (Initialization and drive detection)
|
---|
| 120 | %include "Initialize.asm" ; For BIOS initialization
|
---|
| 121 | %include "RamVars.asm" ; For RAMVARS initialization and access
|
---|
| 122 | %include "CreateDPT.asm" ; For creating DPTs
|
---|
| 123 | %include "FindDPT.asm" ; For finding DPTs
|
---|
| 124 | %include "AccessDPT.asm" ; For accessing DPTs
|
---|
| 125 | %include "CompatibleDPT.asm" ; For creating compatible DPTs
|
---|
| 126 | %include "BootInfo.asm" ; For creating BOOTNFO structs
|
---|
| 127 | %include "AtaID.asm" ; For ATA Identify Device information
|
---|
| 128 | %include "DetectDrives.asm" ; For detecting IDE drives
|
---|
| 129 | %include "DetectPrint.asm" ; For printing drive detection strings
|
---|
| 130 |
|
---|
| 131 | ; Include .asm files (boot menu)
|
---|
| 132 | %include "BootVars.asm" ; For accessing BOOTVARS struct
|
---|
| 133 | %include "BootMenu.asm" ; For Boot Menu operations
|
---|
| 134 | %include "BootMenuEvent.asm" ; For menu library event handling
|
---|
| 135 | %include "FloppyDrive.asm" ; Floppy Drive related functions
|
---|
| 136 | %include "BootMenuPrint.asm" ; For printing Boot Menu strings
|
---|
| 137 | %include "BootMenuPrintCfg.asm" ; For printing hard disk configuration
|
---|
| 138 |
|
---|
| 139 | ; Include .asm files (general drive accessing)
|
---|
| 140 | %include "DriveXlate.asm" ; For swapping drive numbers
|
---|
| 141 | %include "HAddress.asm" ; For sector address translations
|
---|
| 142 | %include "HCapacity.asm" ; For calculating drive capacity
|
---|
| 143 | %include "HError.asm" ; For error checking
|
---|
| 144 | %include "HPIO.asm" ; For PIO transfers
|
---|
| 145 | %include "HIRQ.asm" ; For IRQ handling
|
---|
| 146 | %include "HStatus.asm" ; For reading hard disk status
|
---|
| 147 | %include "HDrvSel.asm" ; For selecting drive to access
|
---|
| 148 | %include "HCommand.asm" ; For outputting command and parameters
|
---|
| 149 |
|
---|
| 150 | ; Include .asm files (Interrupt handlers)
|
---|
| 151 | %include "Int13h.asm" ; For Int 13h, Disk functions
|
---|
| 152 | %include "Int18h.asm" ; For Int 18h, ROM Boot and Boot error
|
---|
| 153 | %include "Int19h.asm" ; For Int 19h, Boot Loader
|
---|
| 154 | %include "Int19hMenu.asm" ; For Int 19h, Boot Loader for Boot Menu
|
---|
| 155 | %include "BootPrint.asm" ; For printing boot information
|
---|
| 156 |
|
---|
| 157 | ; Include .asm files (Hard Disk BIOS functions)
|
---|
| 158 | %include "AH0h_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
| 159 | %include "AH1h_HStatus.asm" ; Required by Int13h_Jump.asm
|
---|
| 160 | %include "AH2h_HRead.asm" ; Required by Int13h_Jump.asm
|
---|
| 161 | %include "AH3h_HWrite.asm" ; Required by Int13h_Jump.asm
|
---|
| 162 | %include "AH4h_HVerify.asm" ; Required by Int13h_Jump.asm
|
---|
| 163 | %include "AH5h_HFormat.asm" ; Required by Int13h_Jump.asm
|
---|
| 164 | %include "AH8h_HParams.asm" ; Required by Int13h_Jump.asm
|
---|
| 165 | %include "AH9h_HInit.asm" ; Required by Int13h_Jump.asm
|
---|
| 166 | %include "AHCh_HSeek.asm" ; Required by Int13h_Jump.asm
|
---|
| 167 | %include "AHDh_HReset.asm" ; Required by Int13h_Jump.asm
|
---|
| 168 | %include "AH10h_HReady.asm" ; Required by Int13h_Jump.asm
|
---|
| 169 | %include "AH11h_HRecal.asm" ; Required by Int13h_Jump.asm
|
---|
| 170 | %include "AH14h_HDiag.asm" ; Required by Int13h_Jump.asm
|
---|
| 171 | %include "AH15h_HSize.asm" ; Required by Int13h_Jump.asm
|
---|
| 172 | %include "AH23h_HFeatures.asm" ; Required by Int13h_Jump.asm
|
---|
| 173 | %include "AH24h_HSetBlocks.asm" ; Required by Int13h_Jump.asm
|
---|
| 174 | %include "AH25h_HDrvID.asm" ; Required by Int13h_Jump.asm
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 |
|
---|
| 178 | ; Fill with zeroes until size is what we want
|
---|
| 179 | times (CNT_ROM_BLOCKS*512)-($-$$) db 0
|
---|