source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Main.asm@ 180

Last change on this file since 180 was 179, checked in by gregli@…, 13 years ago

Main checkin, adding virtual IDE drive over serial port connection

File size: 10.1 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Authors : Tomi Tilli
3; : aitotat@gmail.com
4; :
5; : Krister Nordvall
6; : krille_n_@hotmail.com
7; :
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
12ORG 000h ; Code start offset 0000h
13
14
15; Included .inc files
16%include "AssemblyLibrary.inc" ; Assembly Library. Must be included first!
17%include "IntController.inc" ; For Interrupt Controller equates
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
21%ifdef MODULE_EBIOS
22%include "EBIOS.inc" ; Equates for EBIOS functions
23%endif
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
30%include "DeviceIDE.inc" ; For IDE device equates
31
32
33; Section containing code
34SECTION .text
35
36; ROM variables (must start at offset 0)
37CNT_ROM_BLOCKS EQU 16 ; 16 * 512B = 8kB BIOS
38istruc 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
42 at ROMVARS.rgbSign, db "XTIDE120" ; Signature for flash program
43 at ROMVARS.szTitle
44 db "-=XTIDE Universal BIOS"
45%ifdef USE_AT
46 db " (AT)=-",NULL
47%elifdef USE_186
48 db " (XT+)=-",NULL
49%else
50 db " (XT)=-",NULL
51%endif
52 at ROMVARS.szVersion, db "v1.2.0_wip (",__DATE__,")",NULL
53
54;;; For OR'ing into wFlags below
55;;;
56%ifdef MODULE_SERIAL
57MAIN_FLG_MODULE_SERIAL equ FLG_ROMVARS_MODULE_SERIAL
58%else
59MAIN_FLG_MODULE_SERIAL equ 0
60%endif
61
62%ifdef MODULE_EBIOS
63MAIN_FLG_MODULE_EBIOS equ FLG_ROMVARS_MODULE_EBIOS
64%else
65MAIN_FLG_MODULE_EBIOS equ 0
66%endif
67
68;---------------------------;
69; AT Build default settings ;
70;---------------------------;
71%ifdef USE_AT
72 at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS
73 at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
74 at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection timeout
75 at ROMVARS.bIdeCnt, db 4 ; Number of supported controllers
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
82 at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_16BIT_ATA
83 at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0
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
89 at ROMVARS.ideVars1+IDEVARS.bDevice, db DEVICE_16BIT_ATA
90 at ROMVARS.ideVars1+IDEVARS.bIRQ, db 0
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
96 at ROMVARS.ideVars2+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE
97 at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0
98 at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
99 at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
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
103 at ROMVARS.ideVars3+IDEVARS.bDevice, db DEVICE_16BIT_ATA
104 at ROMVARS.ideVars3+IDEVARS.bIRQ, db 0
105 at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
106 at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
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
113%else
114;-----------------------------------;
115; XT and XT+ Build default settings ;
116;-----------------------------------;
117 at ROMVARS.wFlags, dw FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS
118 at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
119 at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection timeout
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
127 at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE
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
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
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
146%endif
147iend
148
149
150; Libraries and data
151%include "AssemblyLibrary.asm"
152%include "Strings.asm" ; For BIOS message strings
153
154; Initialization and drive detection
155%include "Initialize.asm" ; For BIOS initialization
156%include "Interrupts.asm" ; For Interrupt initialization
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
166; Boot menu
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
170%include "BootSector.asm" ; For loading boot sector
171%include "BootPrint.asm" ; For printing boot information
172%include "BootMenuPrint.asm" ; For printing Boot Menu strings
173%include "BootMenuPrintCfg.asm" ; For printing hard disk configuration
174
175; Boot loader
176%ifndef USE_AT
177 %include "Int19hLate.asm" ; For late initialization
178%endif
179%include "Int19hMenu.asm" ; For Int 19h, Boot Loader for Boot Menu
180
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"
188%include "IdeTransfer.asm" ; Must be included after IdeCommand.asm
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
195%ifdef MODULE_SERIAL
196; Serial Port Device support
197%include "SerialCommand.asm"
198%include "SerialDPT.asm"
199%endif
200
201; INT 13h Hard Disk BIOS functions
202%include "DriveXlate.asm" ; For swapping drive numbers
203%include "Address.asm" ; For sector address translations
204%include "CommandLookup.asm" ; For getting correct transfer command
205%include "Int13h.asm" ; For Int 13h, Disk functions
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
221%ifdef MODULE_EBIOS
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"
228%endif
229
230
231; Fill with zeroes until size is what we want
232;times (CNT_ROM_BLOCKS*512)-($-$$) db 0
Note: See TracBrowser for help on using the repository browser.