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

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

Changes to XTIDE Universal BIOS:

  • Advanced ATA Module variables are now kept in DPTs.
  • Forced full mode when using Advanced ATA Module.
File size: 5.1 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:
[364]33 ; Always steal memory when using Advanced ATA module since it
34 ; uses larger DPTs
35%ifndef MODULE_ADVANCED_ATA
[241]36 mov ax, LITE_MODE_RAMVARS_SEGMENT
[3]37 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[97]38 jz SHORT .InitializeRamvars ; No need to steal RAM
[364]39%endif
[3]40
[116]41 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
[3]42 mov al, [cs:ROMVARS.bStealSize]
[33]43 sub [BDA.wBaseMem], ax
44 mov ax, [BDA.wBaseMem]
[97]45 eSHL_IM ax, 6 ; Segment to first stolen kB (*=40h)
[150]46 ; Fall to .InitializeRamvars
[3]47
[33]48;--------------------------------------------------------------------
[97]49; .InitializeRamvars
[33]50; Parameters:
[241]51; AX: RAMVARS segment
[97]52; Returns:
[33]53; DS: RAMVARS segment
54; Corrupts registers:
55; AX, CX, DI, ES
56;--------------------------------------------------------------------
[97]57.InitializeRamvars:
[241]58 mov ds, ax
59 mov es, ax
[97]60 mov cx, RAMVARS_size
61 xor di, di
62 call Memory_ZeroESDIwithSizeInCX
[150]63 mov WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
[97]64 ; Fall to .InitializeDriveTranslationAndReturn
[3]65
[97]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
[33]78
[97]79
[3]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 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[33]96 jnz SHORT .GetStolenSegmentToDS
[181]97%ifndef USE_186
[150]98 mov di, LITE_MODE_RAMVARS_SEGMENT
[3]99 mov ds, di
[181]100%else
101 push LITE_MODE_RAMVARS_SEGMENT
102 pop ds
103%endif
[3]104 ret
105
106ALIGN JUMP_ALIGN
[33]107.GetStolenSegmentToDS:
[3]108 LOAD_BDA_SEGMENT_TO ds, di
109 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
[33]110 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
[3]111ALIGN JUMP_ALIGN
112.LoopStolenKBs:
113 mov ds, di ; EBDA segment to DS
114 add di, BYTE 64 ; DI to next stolen kB
[150]115 cmp WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
[3]116 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
117 ret
118
119
120;--------------------------------------------------------------------
[258]121; RamVars_GetHardDiskCountFromBDAtoAX
[3]122; Parameters:
123; DS: RAMVARS segment
124; Returns:
[258]125; AX: Total hard disk count
[3]126; Corrupts registers:
[258]127; CX
[116]128;--------------------------------------------------------------------
[3]129ALIGN JUMP_ALIGN
[258]130RamVars_GetHardDiskCountFromBDAtoAX:
131 call RamVars_GetCountOfKnownDrivesToAX
[294]132 push ds
133 LOAD_BDA_SEGMENT_TO ds, cx
134 mov cl, [BDA.bHDCount]
[258]135 MAX_U al, cl
[294]136 pop ds
[3]137 ret
[32]138
139;--------------------------------------------------------------------
[258]140; RamVars_GetCountOfKnownDrivesToAX
[32]141; Parameters:
142; DS: RAMVARS segment
143; Returns:
[258]144; AX: Total hard disk count
[32]145; Corrupts registers:
[258]146; None
[116]147;--------------------------------------------------------------------
[32]148ALIGN JUMP_ALIGN
[258]149RamVars_GetCountOfKnownDrivesToAX:
150 mov ax, [RAMVARS.wDrvCntAndFirst]
151 add al, ah
152 and al, 7fh
153 cbw
[32]154 ret
[294]155
[33]156;--------------------------------------------------------------------
157; RamVars_GetIdeControllerCountToCX
158; Parameters:
159; Nothing
160; Returns:
161; CX: Number of IDE controllers to handle
162; Corrupts registers:
163; Nothing
[116]164;--------------------------------------------------------------------
[258]165ALIGN JUMP_ALIGN
[33]166RamVars_GetIdeControllerCountToCX:
[294]167 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
[33]168 ret
[258]169
170%ifdef MODULE_SERIAL_FLOPPY
171;--------------------------------------------------------------------
172; RamVars_UnpackFlopCntAndFirstToAL
173; Parameters:
174; Nothing
175; Returns:
176; AL: First floppy drive number supported
177; CF: Number of floppy drives supported (clear = 1, set = 2)
[270]178; SF: Emulating drives (clear = yes, set = no)
[258]179; Corrupts registers:
180; Nothing
[294]181;--------------------------------------------------------------------
[258]182ALIGN JUMP_ALIGN
183RamVars_UnpackFlopCntAndFirstToAL:
184 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
[294]185 sar al, 1
[258]186 ret
187%endif
Note: See TracBrowser for help on using the repository browser.