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

Last change on this file since 182 was 181, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

  • Size optimizations.
  • Added a define (EXCLUDE_FROM_XTIDECFG) to exclude unused library code from XTIDECFG.
  • Tried to minimize time spent with interrupts disabled.
  • Some minor attempts to improve speed (reordering instructions etc).
  • Tried to improve readability, did some cleanup and fixed some errors in comments.
File size: 10.2 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
18 ; Included .inc files
19 %include "AssemblyLibrary.inc" ; Assembly Library. Must be included first!
20 %include "IntController.inc" ; For Interrupt Controller equates
21 %include "ATA_ID.inc" ; For ATA Drive Information structs
22 %include "IdeRegisters.inc" ; For ATA Registers, flags and commands
23 %include "Int13h.inc" ; Equates for INT 13h functions
24%ifdef MODULE_EBIOS
25 %include "EBIOS.inc" ; Equates for EBIOS functions
26%endif
27 %include "CustomDPT.inc" ; For Disk Parameter Table
28 %include "RomVars.inc" ; For ROMVARS and IDEVARS structs
29 %include "RamVars.inc" ; For RAMVARS struct
30 %include "BootVars.inc" ; For BOOTVARS and BOOTNFO structs
31 %include "BootMenu.inc" ; For Boot Menu
32 %include "IDE_8bit.inc" ; For IDE 8-bit data port macros
33 %include "DeviceIDE.inc" ; For IDE device equates
34
35
36; Section containing code
37SECTION .text
38
39; ROM variables (must start at offset 0)
40CNT_ROM_BLOCKS EQU 16 ; 16 * 512B = 8kB BIOS
41istruc ROMVARS
42 at ROMVARS.wRomSign, dw 0AA55h ; PC ROM signature
43 at ROMVARS.bRomSize, db CNT_ROM_BLOCKS ; ROM size in 512B blocks
44 at ROMVARS.rgbJump, jmp Initialize_FromMainBiosRomSearch
45 at ROMVARS.rgbSign, db "XTIDE120" ; Signature for flash program
46 at ROMVARS.szTitle
47 db "-=XTIDE Universal BIOS"
48%ifdef USE_AT
49 db " (AT)=-",NULL
50%elifdef USE_186
51 db " (XT+)=-",NULL
52%else
53 db " (XT)=-",NULL
54%endif
55 at ROMVARS.szVersion, db "v1.2.0_wip (",__DATE__,")",NULL
56
57;;; For OR'ing into wFlags below
58;;;
59%ifdef MODULE_SERIAL
60 MAIN_FLG_MODULE_SERIAL equ FLG_ROMVARS_MODULE_SERIAL
61%else
62 MAIN_FLG_MODULE_SERIAL equ 0
63%endif
64
65%ifdef MODULE_EBIOS
66 MAIN_FLG_MODULE_EBIOS equ FLG_ROMVARS_MODULE_EBIOS
67%else
68 MAIN_FLG_MODULE_EBIOS equ 0
69%endif
70
71;---------------------------;
72; AT Build default settings ;
73;---------------------------;
74%ifdef USE_AT
75 at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS
76 at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
77 at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection timeout
78 at ROMVARS.bIdeCnt, db 4 ; Number of supported controllers
79 at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
80 at ROMVARS.bMinFddCnt, db 0 ; Do not force minimum number of floppy drives
81 at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory
82
83 at ROMVARS.ideVars0+IDEVARS.wPort, dw 1F0h ; Controller Command Block base port
84 at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 3F0h ; Controller Control Block base port
85 at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_16BIT_ATA
86 at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0
87 at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
88 at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
89
90 at ROMVARS.ideVars1+IDEVARS.wPort, dw 170h ; Controller Command Block base port
91 at ROMVARS.ideVars1+IDEVARS.wPortCtrl, dw 370h ; Controller Control Block base port
92 at ROMVARS.ideVars1+IDEVARS.bDevice, db DEVICE_16BIT_ATA
93 at ROMVARS.ideVars1+IDEVARS.bIRQ, db 0
94 at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
95 at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
96
97 at ROMVARS.ideVars2+IDEVARS.wPort, dw 300h ; Controller Command Block base port
98 at ROMVARS.ideVars2+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port
99 at ROMVARS.ideVars2+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE
100 at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0
101 at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
102 at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
103
104 at ROMVARS.ideVars3+IDEVARS.wPort, dw 168h ; Controller Command Block base port
105 at ROMVARS.ideVars3+IDEVARS.wPortCtrl, dw 368h ; Controller Control Block base port
106 at ROMVARS.ideVars3+IDEVARS.bDevice, db DEVICE_16BIT_ATA
107 at ROMVARS.ideVars3+IDEVARS.bIRQ, db 0
108 at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
109 at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
110
111%ifdef MODULE_SERIAL
112 at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
113 at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
114 at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
115%endif
116%else
117;-----------------------------------;
118; XT and XT+ Build default settings ;
119;-----------------------------------;
120 at ROMVARS.wFlags, dw FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS
121 at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE
122 at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection timeout
123 at ROMVARS.bIdeCnt, db 1 ; Number of supported controllers
124 at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive
125 at ROMVARS.bMinFddCnt, db 1 ; Assume at least 1 floppy drive present if autodetect fails
126 at ROMVARS.bStealSize, db 1 ; Steal 1kB from base memory in full mode
127
128 at ROMVARS.ideVars0+IDEVARS.wPort, dw 300h ; Controller Command Block base port
129 at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port
130 at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE
131 at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0 ; IRQ
132 at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
133 at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
134
135 at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
136 at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
137
138 at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
139 at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
140
141 at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
142 at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
143
144%ifdef MODULE_SERIAL
145 at ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice, db DEVICE_SERIAL_PORT
146 at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
147 at ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE
148%endif
149%endif
150iend
151
152
153 ; Libraries and data
154 %include "AssemblyLibrary.asm"
155 %include "Strings.asm" ; For BIOS message strings
156
157 ; Initialization and drive detection
158 %include "Initialize.asm" ; For BIOS initialization
159 %include "Interrupts.asm" ; For Interrupt initialization
160 %include "RamVars.asm" ; For RAMVARS initialization and access
161 %include "CreateDPT.asm" ; For creating DPTs
162 %include "FindDPT.asm" ; For finding DPTs
163 %include "AccessDPT.asm" ; For accessing DPTs
164 %include "BootInfo.asm" ; For creating BOOTNFO structs
165 %include "AtaID.asm" ; For ATA Identify Device information
166 %include "DetectDrives.asm" ; For detecting IDE drives
167 %include "DetectPrint.asm" ; For printing drive detection strings
168
169 ; Boot menu
170 %include "BootMenu.asm" ; For Boot Menu operations
171 %include "BootMenuEvent.asm" ; For menu library event handling
172 %include "FloppyDrive.asm" ; Floppy Drive related functions
173 %include "BootSector.asm" ; For loading boot sector
174 %include "BootPrint.asm" ; For printing boot information
175 %include "BootMenuPrint.asm" ; For printing Boot Menu strings
176 %include "BootMenuPrintCfg.asm" ; For printing hard disk configuration
177
178 ; Boot loader
179%ifndef USE_AT
180 %include "Int19hLate.asm" ; For late initialization
181%endif
182 %include "Int19hMenu.asm" ; For Int 19h, Boot Loader for Boot Menu
183
184 ; For all device types
185 %include "Device.asm"
186 %include "Idepack.asm"
187 %include "Timer.asm" ; For timeout and delay
188
189 ; IDE Device support
190 %include "IdeCommand.asm"
191 %include "IdeTransfer.asm" ; Must be included after IdeCommand.asm
192 %include "IdeDPT.asm"
193 %include "IdeIO.asm"
194 %include "IdeIrq.asm"
195 %include "IdeWait.asm"
196 %include "IdeError.asm" ; Must be included after IdeWait.asm
197
198%ifdef MODULE_SERIAL ; Serial Port Device support
199 %include "SerialCommand.asm"
200 %include "SerialDPT.asm"
201%endif
202
203 ; INT 13h Hard Disk BIOS functions
204 %include "DriveXlate.asm" ; For swapping drive numbers
205 %include "Address.asm" ; For sector address translations
206 %include "CommandLookup.asm" ; For getting correct transfer command
207 %include "Int13h.asm" ; For Int 13h, Disk functions
208 %include "AH0h_HReset.asm" ; Required by Int13h_Jump.asm
209 %include "AH1h_HStatus.asm" ; Required by Int13h_Jump.asm
210 %include "AH2h_HRead.asm" ; Required by Int13h_Jump.asm
211 %include "AH3h_HWrite.asm" ; Required by Int13h_Jump.asm
212 %include "AH4h_HVerify.asm" ; Required by Int13h_Jump.asm
213 %include "AH8h_HParams.asm" ; Required by Int13h_Jump.asm
214 %include "AH9h_HInit.asm" ; Required by Int13h_Jump.asm
215 %include "AHCh_HSeek.asm" ; Required by Int13h_Jump.asm
216 %include "AHDh_HReset.asm" ; Required by Int13h_Jump.asm
217 %include "AH10h_HReady.asm" ; Required by Int13h_Jump.asm
218 %include "AH11h_HRecal.asm" ; Required by Int13h_Jump.asm
219 %include "AH15h_HSize.asm" ; Required by Int13h_Jump.asm
220 %include "AH23h_HFeatures.asm" ; Required by Int13h_Jump.asm
221 %include "AH24h_HSetBlocks.asm" ; Required by Int13h_Jump.asm
222 %include "AH25h_HDrvID.asm" ; Required by Int13h_Jump.asm
223%ifdef MODULE_EBIOS
224 %include "AH41h_CheckIfExtensionsPresent.asm"
225 %include "AH42h_ExtendedReadSectors.asm"
226 %include "AH43h_ExtendedWriteSectors.asm"
227 %include "AH44h_ExtendedVerifySectors.asm"
228 %include "AH47h_ExtendedSeek.asm"
229 %include "AH48h_GetExtendedDriveParameters.asm"
230%endif
231
232
233; Fill with zeroes until size is what we want
234;times (CNT_ROM_BLOCKS*512)-($-$$) db 0
Note: See TracBrowser for help on using the repository browser.