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

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

Interrupt controllers are now unmasked during drive reset.

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