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

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

Changes to XTIDE Universal BIOS:

  • Minor fixes and optimizations.
File size: 5.2 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; DS: RAMVARS segment
16; Corrupts registers:
17; AX, CX, DI
18;--------------------------------------------------------------------
19RamVars_Initialize:
20 push es
21 ; Fall to .StealMemoryForRAMVARS
22
23;--------------------------------------------------------------------
24; .StealMemoryForRAMVARS
25; Parameters:
26; Nothing
27; Returns:
28; DS: RAMVARS segment
29; Corrupts registers:
30; AX
31;--------------------------------------------------------------------
32.StealMemoryForRAMVARS:
33 ; Always steal memory when using Advanced ATA module since it
34 ; uses larger DPTs
35%ifndef MODULE_ADVANCED_ATA
36 mov ax, LITE_MODE_RAMVARS_SEGMENT
37 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
38 jz SHORT .InitializeRamvars ; No need to steal RAM
39%endif
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 ; Fall to .InitializeRamvars
47
48;--------------------------------------------------------------------
49; .InitializeRamvars
50; Parameters:
51; AX: RAMVARS segment
52; Returns:
53; DS: RAMVARS segment
54; Corrupts registers:
55; AX, CX, DI, ES
56;--------------------------------------------------------------------
57.InitializeRamvars:
58 mov ds, ax
59 mov es, ax
60 mov cx, RAMVARS_size
61 xor di, di
62 call Memory_ZeroESDIwithSizeInCX
63 mov WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
64 ; Fall to .InitializeDriveTranslationAndReturn
65
66;--------------------------------------------------------------------
67; .InitializeDriveTranslationAndReturn
68; Parameters:
69; DS: RAMVARS segment
70; Returns:
71; Nothing
72; Corrupts registers:
73; AX
74;--------------------------------------------------------------------
75.InitializeDriveTranslationAndReturn:
76 pop es
77 jmp DriveXlate_Reset
78
79
80;--------------------------------------------------------------------
81; Returns segment to RAMVARS.
82; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
83; or at the top of system base RAM.
84;
85; RamVars_GetSegmentToDS
86; Parameters:
87; Nothing
88; Returns:
89; DS: RAMVARS segment
90; Corrupts registers:
91; DI
92;--------------------------------------------------------------------
93ALIGN JUMP_ALIGN
94RamVars_GetSegmentToDS:
95
96%ifndef MODULE_ADVANCED_ATA ; Always in Full Mode when using Advanced ATA Module
97 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
98 jnz SHORT .GetStolenSegmentToDS
99%ifndef USE_186
100 mov di, LITE_MODE_RAMVARS_SEGMENT
101 mov ds, di
102%else
103 push LITE_MODE_RAMVARS_SEGMENT
104 pop ds
105%endif
106 ret
107%endif ; MODULE_ADVANCED_ATA
108
109ALIGN JUMP_ALIGN
110.GetStolenSegmentToDS:
111 LOAD_BDA_SEGMENT_TO ds, di
112 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
113 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
114ALIGN JUMP_ALIGN
115.LoopStolenKBs:
116 mov ds, di ; EBDA segment to DS
117 add di, BYTE 64 ; DI to next stolen kB
118 cmp WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
119 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
120 ret
121
122
123;--------------------------------------------------------------------
124; RamVars_GetHardDiskCountFromBDAtoAX
125; Parameters:
126; DS: RAMVARS segment
127; Returns:
128; AX: Total hard disk count
129; Corrupts registers:
130; CX
131;--------------------------------------------------------------------
132ALIGN JUMP_ALIGN
133RamVars_GetHardDiskCountFromBDAtoAX:
134 call RamVars_GetCountOfKnownDrivesToAX
135 push ds
136 LOAD_BDA_SEGMENT_TO ds, cx
137 mov cl, [BDA.bHDCount]
138 MAX_U al, cl
139 pop ds
140 ret
141
142;--------------------------------------------------------------------
143; RamVars_GetCountOfKnownDrivesToAX
144; Parameters:
145; DS: RAMVARS segment
146; Returns:
147; AX: Total hard disk count
148; Corrupts registers:
149; None
150;--------------------------------------------------------------------
151ALIGN JUMP_ALIGN
152RamVars_GetCountOfKnownDrivesToAX:
153 mov ax, [RAMVARS.wDrvCntAndFirst]
154 add al, ah
155 and ax, BYTE 7fh
156 ret
157
158;--------------------------------------------------------------------
159; RamVars_GetIdeControllerCountToCX
160; Parameters:
161; Nothing
162; Returns:
163; CX: Number of IDE controllers to handle
164; Corrupts registers:
165; Nothing
166;--------------------------------------------------------------------
167ALIGN JUMP_ALIGN
168RamVars_GetIdeControllerCountToCX:
169 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
170 ret
171
172%ifdef MODULE_SERIAL_FLOPPY
173;--------------------------------------------------------------------
174; RamVars_UnpackFlopCntAndFirstToAL
175; Parameters:
176; Nothing
177; Returns:
178; AL: First floppy drive number supported
179; CF: Number of floppy drives supported (clear = 1, set = 2)
180; SF: Emulating drives (clear = yes, set = no)
181; Corrupts registers:
182; Nothing
183;--------------------------------------------------------------------
184ALIGN JUMP_ALIGN
185RamVars_UnpackFlopCntAndFirstToAL:
186 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
187 sar al, 1
188 ret
189%endif
Note: See TracBrowser for help on using the repository browser.