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

Last change on this file since 245 was 243, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

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