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

Last change on this file since 155 was 155, checked in by aitotat, 13 years ago

Changes to XTIDE Universal BIOS:

  • AH=4h again uses VERIFY command (copy-pasting had changed it to WRITE).
  • Timeout should now work on all overflow situations.
  • Cleaned code a bit.
File size: 6.2 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:
[3]33    test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[97]34    jz      SHORT .InitializeRamvars    ; No need to steal RAM
[3]35
[116]36    LOAD_BDA_SEGMENT_TO ds, ax, !       ; Zero AX
[3]37    mov     al, [cs:ROMVARS.bStealSize]
[33]38    sub     [BDA.wBaseMem], ax
39    mov     ax, [BDA.wBaseMem]
[97]40    eSHL_IM ax, 6                       ; Segment to first stolen kB (*=40h)
[33]41    mov     ds, ax
[150]42    mov     WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
43    ; Fall to .InitializeRamvars
[3]44
[33]45;--------------------------------------------------------------------
[97]46; .InitializeRamvars
[33]47;   Parameters:
[97]48;       Nothing
49;   Returns:
[33]50;       DS:     RAMVARS segment
51;   Corrupts registers:
52;       AX, CX, DI, ES
53;--------------------------------------------------------------------
[97]54.InitializeRamvars:
55    call    RamVars_GetSegmentToDS
56    mov     cx, RAMVARS_size
57    xor     di, di
[33]58    push    ds
59    pop     es
[97]60    call    Memory_ZeroESDIwithSizeInCX
[150]61    mov     WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
[97]62    ; Fall to .InitializeDriveTranslationAndReturn
[3]63
[97]64;--------------------------------------------------------------------
65; .InitializeDriveTranslationAndReturn
66;   Parameters:
67;       DS:     RAMVARS segment
68;   Returns:
69;       Nothing
70;   Corrupts registers:
71;       AX
72;--------------------------------------------------------------------
73.InitializeDriveTranslationAndReturn:
74    pop     es
75    jmp     DriveXlate_Reset
[33]76
[97]77
[3]78;--------------------------------------------------------------------
79; Returns segment to RAMVARS.
80; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
81; or at the top of system base RAM.
82;
83; RamVars_GetSegmentToDS
84;   Parameters:
85;       Nothing
86;   Returns:
87;       DS:     RAMVARS segment
88;   Corrupts registers:
89;       DI
90;--------------------------------------------------------------------
91ALIGN JUMP_ALIGN
92RamVars_GetSegmentToDS:
93    test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[33]94    jnz     SHORT .GetStolenSegmentToDS
[150]95    mov     di, LITE_MODE_RAMVARS_SEGMENT
[3]96    mov     ds, di
97    ret
98
99ALIGN JUMP_ALIGN
[33]100.GetStolenSegmentToDS:
[3]101    LOAD_BDA_SEGMENT_TO ds, di
102    mov     di, [BDA.wBaseMem]      ; Load available base memory size in kB
[33]103    eSHL_IM di, 6                   ; Segment to first stolen kB (*=40h)
[3]104ALIGN JUMP_ALIGN
105.LoopStolenKBs:
106    mov     ds, di                  ; EBDA segment to DS
107    add     di, BYTE 64             ; DI to next stolen kB
[150]108    cmp     WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
[3]109    jne     SHORT .LoopStolenKBs    ; Loop until sign found (always found eventually)
110    ret
111
112
113;--------------------------------------------------------------------
114; Checks if INT 13h function is handled by this BIOS.
115;
116; RamVars_IsFunctionHandledByThisBIOS
117;   Parameters:
118;       AH:     INT 13h function number
119;       DL:     Drive number
120;       DS:     RAMVARS segment
121;   Returns:
122;       CF:     Set if function is handled by this BIOS
123;               Cleared if function belongs to some other BIOS
124;   Corrupts registers:
[155]125;       Nothing
[3]126;--------------------------------------------------------------------
127ALIGN JUMP_ALIGN
128RamVars_IsFunctionHandledByThisBIOS:
129    test    ah, ah          ; Reset for all floppy and hard disk drives?
[32]130    jz      SHORT .FunctionIsHandledByOurBIOS
131    cmp     ah, 08h         ; Read Disk Drive Parameters?
132    jne     SHORT RamVars_IsDriveHandledByThisBIOS
[128]133    test    dl, dl          ; We do not handle floppy drives
134    jns     SHORT .FunctionIsNotHandledByOurBIOS
[32]135ALIGN JUMP_ALIGN
136.FunctionIsHandledByOurBIOS:
[3]137    stc
[32]138.FunctionIsNotHandledByOurBIOS:
[3]139    ret
140
141;--------------------------------------------------------------------
142; Checks if drive is handled by this BIOS.
143;
144; RamVars_IsDriveHandledByThisBIOS
145;   Parameters:
146;       DL:     Drive number
147;       DS:     RAMVARS segment
148;   Returns:
149;       CF:     Set if drive is handled by this BIOS
150;               Cleared if drive belongs to some other BIOS
151;   Corrupts registers:
[148]152;       Nothing
[3]153;--------------------------------------------------------------------
154ALIGN JUMP_ALIGN
155RamVars_IsDriveHandledByThisBIOS:
[148]156    push    ax
[3]157    mov     ax, [RAMVARS.wDrvCntAndFirst]       ; Drive count to AL, First number to AH
158    add     al, ah                              ; One past last drive to AL
159    cmp     dl, al                              ; Above last supported?
160    jae     SHORT .DriveNotHandledByThisBIOS
[145]161    cmp     ah, dl                              ; Below first supported?
162    ja      SHORT .DriveNotHandledByThisBIOS
[3]163    stc
164.DriveNotHandledByThisBIOS:
[148]165    pop     ax
[3]166    ret
167
168
169;--------------------------------------------------------------------
[32]170; RamVars_GetHardDiskCountFromBDAtoCX
[3]171;   Parameters:
172;       DS:     RAMVARS segment
173;   Returns:
[32]174;       CX:     Total hard disk count
[3]175;   Corrupts registers:
[32]176;       Nothing
[116]177;--------------------------------------------------------------------
[3]178ALIGN JUMP_ALIGN
[32]179RamVars_GetHardDiskCountFromBDAtoCX:
[3]180    push    es
[32]181    push    dx
182
[116]183    LOAD_BDA_SEGMENT_TO es, cx, !       ; Zero CX
[32]184    call    RamVars_GetCountOfKnownDrivesToDL
185    MAX_U   dl, [es:BDA.bHDCount]
186    mov     cl, dl
187
188    pop     dx
[3]189    pop     es
190    ret
[32]191
192;--------------------------------------------------------------------
193; RamVars_GetCountOfKnownDrivesToDL
194;   Parameters:
195;       DS:     RAMVARS segment
196;   Returns:
197;       DL:     Total hard disk count
198;   Corrupts registers:
199;       Nothing
[116]200;--------------------------------------------------------------------
[32]201ALIGN JUMP_ALIGN
202RamVars_GetCountOfKnownDrivesToDL:
203    mov     dl, [RAMVARS.bFirstDrv]     ; Number for our first drive
204    add     dl, [RAMVARS.bDrvCnt]       ; Our drives
205    and     dl, 7Fh                     ; Clear HD bit for drive count
206    ret
[33]207
208
209;--------------------------------------------------------------------
210; RamVars_GetIdeControllerCountToCX
211;   Parameters:
212;       Nothing
213;   Returns:
214;       CX:     Number of IDE controllers to handle
215;   Corrupts registers:
216;       Nothing
[116]217;--------------------------------------------------------------------
[33]218RamVars_GetIdeControllerCountToCX:
[99]219    eMOVZX  cx, BYTE [cs:ROMVARS.bIdeCnt]
[33]220    ret
Note: See TracBrowser for help on using the repository browser.