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

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

Changes to XTIDE Universal BIOS:

  • Moved 8-bit device support to MODULE_8BIT_IDE.
  • JR-IDE/ISA support requires a lot less bytes.
  • AT builds now always use full operating mode.
File size: 5.8 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
[97]78 ; Fall to .InitializeDriveTranslationAndReturn
[3]79
[97]80;--------------------------------------------------------------------
81; .InitializeDriveTranslationAndReturn
82; Parameters:
83; DS: RAMVARS segment
84; Returns:
85; Nothing
86; Corrupts registers:
87; AX
88;--------------------------------------------------------------------
89.InitializeDriveTranslationAndReturn:
90 pop es
[395]91%ifdef MODULE_HOTKEYS
[97]92 jmp DriveXlate_Reset
[395]93%else
94 ret
95%endif
[33]96
[97]97
[3]98;--------------------------------------------------------------------
99; Returns segment to RAMVARS.
100; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
101; or at the top of system base RAM.
102;
103; RamVars_GetSegmentToDS
104; Parameters:
105; Nothing
106; Returns:
107; DS: RAMVARS segment
108; Corrupts registers:
109; DI
110;--------------------------------------------------------------------
111ALIGN JUMP_ALIGN
112RamVars_GetSegmentToDS:
[368]113
[400]114%ifndef USE_AT ; Always in Full Mode for AT builds
[3]115 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[33]116 jnz SHORT .GetStolenSegmentToDS
[400]117 %ifndef USE_186
118 mov di, LITE_MODE_RAMVARS_SEGMENT
119 mov ds, di
120 %else
121 push LITE_MODE_RAMVARS_SEGMENT
122 pop ds
123 %endif
124 ret
[181]125%endif
[3]126
127ALIGN JUMP_ALIGN
[33]128.GetStolenSegmentToDS:
[3]129 LOAD_BDA_SEGMENT_TO ds, di
130 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
[33]131 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
[3]132ALIGN JUMP_ALIGN
133.LoopStolenKBs:
134 mov ds, di ; EBDA segment to DS
135 add di, BYTE 64 ; DI to next stolen kB
[150]136 cmp WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
[3]137 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
138 ret
139
140
141;--------------------------------------------------------------------
[258]142; RamVars_GetHardDiskCountFromBDAtoAX
[3]143; Parameters:
144; DS: RAMVARS segment
145; Returns:
[258]146; AX: Total hard disk count
[3]147; Corrupts registers:
[258]148; CX
[116]149;--------------------------------------------------------------------
[392]150%ifdef MODULE_BOOT_MENU
[258]151RamVars_GetHardDiskCountFromBDAtoAX:
152 call RamVars_GetCountOfKnownDrivesToAX
[294]153 push ds
154 LOAD_BDA_SEGMENT_TO ds, cx
155 mov cl, [BDA.bHDCount]
[258]156 MAX_U al, cl
[294]157 pop ds
[3]158 ret
[392]159%endif
[32]160
[392]161
[32]162;--------------------------------------------------------------------
[258]163; RamVars_GetCountOfKnownDrivesToAX
[32]164; Parameters:
165; DS: RAMVARS segment
166; Returns:
[258]167; AX: Total hard disk count
[32]168; Corrupts registers:
[258]169; None
[116]170;--------------------------------------------------------------------
[32]171ALIGN JUMP_ALIGN
[258]172RamVars_GetCountOfKnownDrivesToAX:
173 mov ax, [RAMVARS.wDrvCntAndFirst]
174 add al, ah
[368]175 and ax, BYTE 7fh
[32]176 ret
[294]177
[33]178;--------------------------------------------------------------------
179; RamVars_GetIdeControllerCountToCX
180; Parameters:
181; Nothing
182; Returns:
183; CX: Number of IDE controllers to handle
184; Corrupts registers:
185; Nothing
[116]186;--------------------------------------------------------------------
[258]187ALIGN JUMP_ALIGN
[33]188RamVars_GetIdeControllerCountToCX:
[294]189 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
[33]190 ret
[258]191
192%ifdef MODULE_SERIAL_FLOPPY
193;--------------------------------------------------------------------
194; RamVars_UnpackFlopCntAndFirstToAL
195; Parameters:
196; Nothing
197; Returns:
198; AL: First floppy drive number supported
199; CF: Number of floppy drives supported (clear = 1, set = 2)
[270]200; SF: Emulating drives (clear = yes, set = no)
[258]201; Corrupts registers:
202; Nothing
[294]203;--------------------------------------------------------------------
[258]204ALIGN JUMP_ALIGN
205RamVars_UnpackFlopCntAndFirstToAL:
206 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
[294]207 sar al, 1
[258]208 ret
209%endif
Note: See TracBrowser for help on using the repository browser.