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

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

Commit 2/2 (BIOS):

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