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

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

Changes to XTIDE Universal BIOS:

  • AT builds now relocate INT 13h stack to top of stolen conventional memory.
  • Some small fixes here and there.
File size: 6.3 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:
[400]49%ifndef USE_AT
[241]50 mov ax, LITE_MODE_RAMVARS_SEGMENT
[3]51 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[97]52 jz SHORT .InitializeRamvars ; No need to steal RAM
[364]53%endif
[3]54
[116]55 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
[3]56 mov al, [cs:ROMVARS.bStealSize]
[33]57 sub [BDA.wBaseMem], ax
58 mov ax, [BDA.wBaseMem]
[97]59 eSHL_IM ax, 6 ; Segment to first stolen kB (*=40h)
[150]60 ; Fall to .InitializeRamvars
[3]61
[33]62;--------------------------------------------------------------------
[97]63; .InitializeRamvars
[33]64; Parameters:
[241]65; AX: RAMVARS segment
[97]66; Returns:
[33]67; DS: RAMVARS segment
68; Corrupts registers:
69; AX, CX, DI, ES
70;--------------------------------------------------------------------
[97]71.InitializeRamvars:
[241]72 mov ds, ax
73 mov es, ax
[97]74 mov cx, RAMVARS_size
75 xor di, di
76 call Memory_ZeroESDIwithSizeInCX
[150]77 mov WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
[417]78 ; Fall to .InitializeInt13hStackChangeVariables
79
80;--------------------------------------------------------------------
81; .InitializeInt13hStackChangeVariables
82; Parameters:
83; DS: RAMVARS segment
84; Returns:
85; Nothing
86; Corrupts registers:
87; AX
88;--------------------------------------------------------------------
89%ifdef RELOCATE_INT13H_STACK
90.InitializeInt13hStackChangeVariables:
91 eMOVZX ax, BYTE [cs:ROMVARS.bStealSize]
92 eSHL_IM ax, 10 ; kiB to Bytes = Top of stack offset
93 mov [RAMVARS.wNewStackOffset], ax
94%endif
[97]95 ; Fall to .InitializeDriveTranslationAndReturn
[3]96
[97]97;--------------------------------------------------------------------
98; .InitializeDriveTranslationAndReturn
99; Parameters:
100; DS: RAMVARS segment
101; Returns:
102; Nothing
103; Corrupts registers:
104; AX
105;--------------------------------------------------------------------
106.InitializeDriveTranslationAndReturn:
107 pop es
[395]108%ifdef MODULE_HOTKEYS
[97]109 jmp DriveXlate_Reset
[395]110%else
111 ret
112%endif
[33]113
[97]114
[3]115;--------------------------------------------------------------------
116; Returns segment to RAMVARS.
117; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
118; or at the top of system base RAM.
119;
120; RamVars_GetSegmentToDS
121; Parameters:
122; Nothing
123; Returns:
124; DS: RAMVARS segment
125; Corrupts registers:
126; DI
127;--------------------------------------------------------------------
128ALIGN JUMP_ALIGN
129RamVars_GetSegmentToDS:
[368]130
[400]131%ifndef USE_AT ; Always in Full Mode for AT builds
[3]132 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[33]133 jnz SHORT .GetStolenSegmentToDS
[400]134 %ifndef USE_186
135 mov di, LITE_MODE_RAMVARS_SEGMENT
136 mov ds, di
137 %else
138 push LITE_MODE_RAMVARS_SEGMENT
139 pop ds
140 %endif
141 ret
[181]142%endif
[3]143
144ALIGN JUMP_ALIGN
[33]145.GetStolenSegmentToDS:
[3]146 LOAD_BDA_SEGMENT_TO ds, di
147 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
[33]148 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
[3]149ALIGN JUMP_ALIGN
150.LoopStolenKBs:
151 mov ds, di ; EBDA segment to DS
152 add di, BYTE 64 ; DI to next stolen kB
[150]153 cmp WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
[3]154 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
155 ret
156
157
158;--------------------------------------------------------------------
[258]159; RamVars_GetHardDiskCountFromBDAtoAX
[3]160; Parameters:
161; DS: RAMVARS segment
162; Returns:
[258]163; AX: Total hard disk count
[3]164; Corrupts registers:
[258]165; CX
[116]166;--------------------------------------------------------------------
[392]167%ifdef MODULE_BOOT_MENU
[258]168RamVars_GetHardDiskCountFromBDAtoAX:
169 call RamVars_GetCountOfKnownDrivesToAX
[294]170 push ds
171 LOAD_BDA_SEGMENT_TO ds, cx
172 mov cl, [BDA.bHDCount]
[258]173 MAX_U al, cl
[294]174 pop ds
[3]175 ret
[392]176%endif
[32]177
[392]178
[32]179;--------------------------------------------------------------------
[258]180; RamVars_GetCountOfKnownDrivesToAX
[32]181; Parameters:
182; DS: RAMVARS segment
183; Returns:
[258]184; AX: Total hard disk count
[32]185; Corrupts registers:
[258]186; None
[116]187;--------------------------------------------------------------------
[32]188ALIGN JUMP_ALIGN
[258]189RamVars_GetCountOfKnownDrivesToAX:
190 mov ax, [RAMVARS.wDrvCntAndFirst]
191 add al, ah
[368]192 and ax, BYTE 7fh
[32]193 ret
[294]194
[33]195;--------------------------------------------------------------------
196; RamVars_GetIdeControllerCountToCX
197; Parameters:
198; Nothing
199; Returns:
200; CX: Number of IDE controllers to handle
201; Corrupts registers:
202; Nothing
[116]203;--------------------------------------------------------------------
[258]204ALIGN JUMP_ALIGN
[33]205RamVars_GetIdeControllerCountToCX:
[294]206 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
[33]207 ret
[258]208
209%ifdef MODULE_SERIAL_FLOPPY
210;--------------------------------------------------------------------
211; RamVars_UnpackFlopCntAndFirstToAL
212; Parameters:
213; Nothing
214; Returns:
215; AL: First floppy drive number supported
216; CF: Number of floppy drives supported (clear = 1, set = 2)
[270]217; SF: Emulating drives (clear = yes, set = no)
[258]218; Corrupts registers:
219; Nothing
[294]220;--------------------------------------------------------------------
[258]221ALIGN JUMP_ALIGN
222RamVars_UnpackFlopCntAndFirstToAL:
223 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
[294]224 sar al, 1
[258]225 ret
226%endif
Note: See TracBrowser for help on using the repository browser.