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

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

Changes to XTIDE Universal BIOS:

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