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

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

Changes to XTIDE Universal BIOS:

  • Hotkey Bar and drive translations are now in MODULE_HOTKEYS.
File size: 6.0 KB
RevLine 
[90]1; Project name : XTIDE Universal BIOS
[3]2; Description : Functions for accessings RAMVARS.
3
[376]4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
[3]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Initializes RAMVARS.
25; Drive detection can be started after this function returns.
26;
27; RamVars_Initialize
28; Parameters:
29; Nothing
30; Returns:
[97]31; DS: RAMVARS segment
[3]32; Corrupts registers:
[97]33; AX, CX, DI
[3]34;--------------------------------------------------------------------
35RamVars_Initialize:
[90]36 push es
[97]37 ; Fall to .StealMemoryForRAMVARS
[3]38
39;--------------------------------------------------------------------
[33]40; .StealMemoryForRAMVARS
[3]41; Parameters:
42; Nothing
43; Returns:
44; DS: RAMVARS segment
45; Corrupts registers:
46; AX
47;--------------------------------------------------------------------
[33]48.StealMemoryForRAMVARS:
[364]49 ; Always steal memory when using Advanced ATA module since it
50 ; uses larger DPTs
51%ifndef MODULE_ADVANCED_ATA
[241]52 mov ax, LITE_MODE_RAMVARS_SEGMENT
[3]53 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[97]54 jz SHORT .InitializeRamvars ; No need to steal RAM
[364]55%endif
[3]56
[116]57 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
[3]58 mov al, [cs:ROMVARS.bStealSize]
[33]59 sub [BDA.wBaseMem], ax
60 mov ax, [BDA.wBaseMem]
[97]61 eSHL_IM ax, 6 ; Segment to first stolen kB (*=40h)
[150]62 ; Fall to .InitializeRamvars
[3]63
[33]64;--------------------------------------------------------------------
[97]65; .InitializeRamvars
[33]66; Parameters:
[241]67; AX: RAMVARS segment
[97]68; Returns:
[33]69; DS: RAMVARS segment
70; Corrupts registers:
71; AX, CX, DI, ES
72;--------------------------------------------------------------------
[97]73.InitializeRamvars:
[241]74 mov ds, ax
75 mov es, ax
[97]76 mov cx, RAMVARS_size
77 xor di, di
78 call Memory_ZeroESDIwithSizeInCX
[150]79 mov WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
[97]80 ; Fall to .InitializeDriveTranslationAndReturn
[3]81
[97]82;--------------------------------------------------------------------
83; .InitializeDriveTranslationAndReturn
84; Parameters:
85; DS: RAMVARS segment
86; Returns:
87; Nothing
88; Corrupts registers:
89; AX
90;--------------------------------------------------------------------
91.InitializeDriveTranslationAndReturn:
92 pop es
[395]93%ifdef MODULE_HOTKEYS
[97]94 jmp DriveXlate_Reset
[395]95%else
96 ret
97%endif
[33]98
[97]99
[3]100;--------------------------------------------------------------------
101; Returns segment to RAMVARS.
102; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
103; or at the top of system base RAM.
104;
105; RamVars_GetSegmentToDS
106; Parameters:
107; Nothing
108; Returns:
109; DS: RAMVARS segment
110; Corrupts registers:
111; DI
112;--------------------------------------------------------------------
113ALIGN JUMP_ALIGN
114RamVars_GetSegmentToDS:
[368]115
116%ifndef MODULE_ADVANCED_ATA ; Always in Full Mode when using Advanced ATA Module
[3]117 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[33]118 jnz SHORT .GetStolenSegmentToDS
[181]119%ifndef USE_186
[150]120 mov di, LITE_MODE_RAMVARS_SEGMENT
[3]121 mov ds, di
[181]122%else
123 push LITE_MODE_RAMVARS_SEGMENT
124 pop ds
125%endif
[3]126 ret
[368]127%endif ; MODULE_ADVANCED_ATA
[3]128
129ALIGN JUMP_ALIGN
[33]130.GetStolenSegmentToDS:
[3]131 LOAD_BDA_SEGMENT_TO ds, di
132 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
[33]133 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
[3]134ALIGN JUMP_ALIGN
135.LoopStolenKBs:
136 mov ds, di ; EBDA segment to DS
137 add di, BYTE 64 ; DI to next stolen kB
[150]138 cmp WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
[3]139 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
140 ret
141
142
143;--------------------------------------------------------------------
[258]144; RamVars_GetHardDiskCountFromBDAtoAX
[3]145; Parameters:
146; DS: RAMVARS segment
147; Returns:
[258]148; AX: Total hard disk count
[3]149; Corrupts registers:
[258]150; CX
[116]151;--------------------------------------------------------------------
[392]152%ifdef MODULE_BOOT_MENU
[258]153RamVars_GetHardDiskCountFromBDAtoAX:
154 call RamVars_GetCountOfKnownDrivesToAX
[294]155 push ds
156 LOAD_BDA_SEGMENT_TO ds, cx
157 mov cl, [BDA.bHDCount]
[258]158 MAX_U al, cl
[294]159 pop ds
[3]160 ret
[392]161%endif
[32]162
[392]163
[32]164;--------------------------------------------------------------------
[258]165; RamVars_GetCountOfKnownDrivesToAX
[32]166; Parameters:
167; DS: RAMVARS segment
168; Returns:
[258]169; AX: Total hard disk count
[32]170; Corrupts registers:
[258]171; None
[116]172;--------------------------------------------------------------------
[32]173ALIGN JUMP_ALIGN
[258]174RamVars_GetCountOfKnownDrivesToAX:
175 mov ax, [RAMVARS.wDrvCntAndFirst]
176 add al, ah
[368]177 and ax, BYTE 7fh
[32]178 ret
[294]179
[33]180;--------------------------------------------------------------------
181; RamVars_GetIdeControllerCountToCX
182; Parameters:
183; Nothing
184; Returns:
185; CX: Number of IDE controllers to handle
186; Corrupts registers:
187; Nothing
[116]188;--------------------------------------------------------------------
[258]189ALIGN JUMP_ALIGN
[33]190RamVars_GetIdeControllerCountToCX:
[294]191 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
[33]192 ret
[258]193
194%ifdef MODULE_SERIAL_FLOPPY
195;--------------------------------------------------------------------
196; RamVars_UnpackFlopCntAndFirstToAL
197; Parameters:
198; Nothing
199; Returns:
200; AL: First floppy drive number supported
201; CF: Number of floppy drives supported (clear = 1, set = 2)
[270]202; SF: Emulating drives (clear = yes, set = no)
[258]203; Corrupts registers:
204; Nothing
[294]205;--------------------------------------------------------------------
[258]206ALIGN JUMP_ALIGN
207RamVars_UnpackFlopCntAndFirstToAL:
208 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
[294]209 sar al, 1
[258]210 ret
211%endif
Note: See TracBrowser for help on using the repository browser.