source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm@ 91

Last change on this file since 91 was 90, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • Removed INT 13h format and diagnostics functions.
  • Removed INT 18h callback handler.
  • Removed configuration for early/late initialization. Now XT builds always use late and AT build early initialization.
  • Reduced number of supported IDE controllers from 5 to 4.
  • Removed reserved configuration bytes.
  • Removed simple and system boot loaders.
File size: 6.9 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for accessings RAMVARS.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Initializes RAMVARS.
9; Drive detection can be started after this function returns.
10;
11; RamVars_Initialize
12; Parameters:
13; Nothing
14; Returns:
15; Nothing
16; Corrupts registers:
17; AX, CX, DI, DS
18;--------------------------------------------------------------------
19ALIGN JUMP_ALIGN
20RamVars_Initialize:
21 push es
22 call .StealMemoryForRAMVARS ; Get RAMVARS segment to DS even if no stealing
23 call .ClearRamvarsFromDS
24 pop es
25 jmp DriveXlate_Reset
26
27;--------------------------------------------------------------------
28; .StealMemoryForRAMVARS
29; Parameters:
30; Nothing
31; Returns:
32; DS: RAMVARS segment
33; Corrupts registers:
34; AX
35;--------------------------------------------------------------------
36ALIGN JUMP_ALIGN
37.StealMemoryForRAMVARS:
38 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
39 jz SHORT RamVars_GetSegmentToDS
40
41 LOAD_BDA_SEGMENT_TO ds, ax ; Zero AX
42 mov al, [cs:ROMVARS.bStealSize]
43 sub [BDA.wBaseMem], ax
44 mov ax, [BDA.wBaseMem]
45 eSHL_IM ax, 6 ; Segment to first stolen kB (*=40h)
46 mov ds, ax
47 ret
48
49;--------------------------------------------------------------------
50; .ClearRamvarsFromDS
51; Parameters:
52; DS: RAMVARS segment
53; Returns:
54; Nothing
55; Corrupts registers:
56; AX, CX, DI, ES
57;--------------------------------------------------------------------
58ALIGN JUMP_ALIGN
59.ClearRamvarsFromDS:
60 call FindDPT_PointToFirstDPT ; Get RAMVARS/FULLRAMVARS size to DI
61 mov cx, di ; Copy byte count to CX
62 push ds
63 pop es
64 xor di, di ; ES:DI now points to RAMVARS/FULLRAMVARS
65 xor ax, ax ; Store zeroes
66 rep stosb
67 mov WORD [FULLRAMVARS.wSign], W_SIGN_FULLRAMVARS
68 ret
69
70
71;--------------------------------------------------------------------
72; Returns segment to RAMVARS.
73; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
74; or at the top of system base RAM.
75;
76; RamVars_GetSegmentToDS
77; Parameters:
78; Nothing
79; Returns:
80; DS: RAMVARS segment
81; Corrupts registers:
82; DI
83;--------------------------------------------------------------------
84ALIGN JUMP_ALIGN
85RamVars_GetSegmentToDS:
86 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
87 jnz SHORT .GetStolenSegmentToDS
88 mov di, SEGMENT_RAMVARS_TOP_OF_INTERRUPT_VECTORS
89 mov ds, di
90 ret
91
92ALIGN JUMP_ALIGN
93.GetStolenSegmentToDS:
94 LOAD_BDA_SEGMENT_TO ds, di
95 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
96 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
97ALIGN JUMP_ALIGN
98.LoopStolenKBs:
99 mov ds, di ; EBDA segment to DS
100 add di, BYTE 64 ; DI to next stolen kB
101 cmp WORD [FULLRAMVARS.wSign], W_SIGN_FULLRAMVARS
102 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
103 ret
104
105
106;--------------------------------------------------------------------
107; Checks if INT 13h function is handled by this BIOS.
108;
109; RamVars_IsFunctionHandledByThisBIOS
110; Parameters:
111; AH: INT 13h function number
112; DL: Drive number
113; DS: RAMVARS segment
114; Returns:
115; CF: Set if function is handled by this BIOS
116; Cleared if function belongs to some other BIOS
117; Corrupts registers:
118; DI
119;--------------------------------------------------------------------
120ALIGN JUMP_ALIGN
121RamVars_IsFunctionHandledByThisBIOS:
122 test ah, ah ; Reset for all floppy and hard disk drives?
123 jz SHORT .FunctionIsHandledByOurBIOS
124 cmp ah, 08h ; Read Disk Drive Parameters?
125 jne SHORT RamVars_IsDriveHandledByThisBIOS
126 test dl, 80h ; We dot not handle floppy drives
127 jz SHORT .FunctionIsNotHandledByOurBIOS
128ALIGN JUMP_ALIGN
129.FunctionIsHandledByOurBIOS:
130 stc
131.FunctionIsNotHandledByOurBIOS:
132 ret
133
134;--------------------------------------------------------------------
135; Checks if drive is handled by this BIOS.
136;
137; RamVars_IsDriveHandledByThisBIOS
138; Parameters:
139; DL: Drive number
140; DS: RAMVARS segment
141; Returns:
142; CF: Set if drive is handled by this BIOS
143; Cleared if drive belongs to some other BIOS
144; Corrupts registers:
145; DI
146;--------------------------------------------------------------------
147ALIGN JUMP_ALIGN
148RamVars_IsDriveHandledByThisBIOS:
149 xchg di, ax ; Backup AX
150 mov ax, [RAMVARS.wDrvCntAndFirst] ; Drive count to AL, First number to AH
151 add al, ah ; One past last drive to AL
152 cmp dl, al ; Above last supported?
153 jae SHORT .DriveNotHandledByThisBIOS
154 cmp dl, ah ; Below first supported?
155 jb SHORT .DriveNotHandledByThisBIOS
156 xchg ax, di
157 stc
158 ret
159ALIGN JUMP_ALIGN
160.DriveNotHandledByThisBIOS:
161 xchg ax, di
162 clc
163 ret
164
165
166;--------------------------------------------------------------------
167; Increments hard disk count to RAMVARS.
168;
169; RamVars_IncrementHardDiskCount
170; Parameters:
171; DL: Drive number for new drive
172; DS: RAMVARS segment
173; Returns:
174; Nothing
175; Corrupts registers:
176; Nothing
177;--------------------------------------------------------------------
178ALIGN JUMP_ALIGN
179RamVars_IncrementHardDiskCount:
180 inc BYTE [RAMVARS.bDrvCnt] ; Increment drive count to RAMVARS
181 cmp BYTE [RAMVARS.bFirstDrv], 0 ; First drive set?
182 ja SHORT .Return ; If so, return
183 mov [RAMVARS.bFirstDrv], dl ; Store first drive number
184ALIGN JUMP_ALIGN
185.Return:
186 ret
187
188
189;--------------------------------------------------------------------
190; RamVars_GetHardDiskCountFromBDAtoCX
191; Parameters:
192; DS: RAMVARS segment
193; Returns:
194; CX: Total hard disk count
195; Corrupts registers:
196; Nothing
197;--------------------------------------------------------------------
198ALIGN JUMP_ALIGN
199RamVars_GetHardDiskCountFromBDAtoCX:
200 push es
201 push dx
202
203 LOAD_BDA_SEGMENT_TO es, cx ; Zero CX
204 call RamVars_GetCountOfKnownDrivesToDL
205 MAX_U dl, [es:BDA.bHDCount]
206 mov cl, dl
207
208 pop dx
209 pop es
210 ret
211
212;--------------------------------------------------------------------
213; RamVars_GetCountOfKnownDrivesToDL
214; Parameters:
215; DS: RAMVARS segment
216; Returns:
217; DL: Total hard disk count
218; Corrupts registers:
219; Nothing
220;--------------------------------------------------------------------
221ALIGN JUMP_ALIGN
222RamVars_GetCountOfKnownDrivesToDL:
223 mov dl, [RAMVARS.bFirstDrv] ; Number for our first drive
224 add dl, [RAMVARS.bDrvCnt] ; Our drives
225 and dl, 7Fh ; Clear HD bit for drive count
226 ret
227
228
229;--------------------------------------------------------------------
230; RamVars_GetIdeControllerCountToCX
231; Parameters:
232; Nothing
233; Returns:
234; CX: Number of IDE controllers to handle
235; Corrupts registers:
236; Nothing
237;--------------------------------------------------------------------
238ALIGN JUMP_ALIGN
239RamVars_GetIdeControllerCountToCX:
240 mov cx, 1 ; Assume lite mode (one controller)
241 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
242 jz SHORT .Return
243 mov cl, [cs:ROMVARS.bIdeCnt]
244ALIGN JUMP_ALIGN, ret
245.Return:
246 ret
Note: See TracBrowser for help on using the repository browser.