[90] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Functions for accessings RAMVARS.
|
---|
| 3 |
|
---|
| 4 | ; Section containing code
|
---|
| 5 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
| 19 | RamVars_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 | ;--------------------------------------------------------------------
|
---|
| 93 | ALIGN JUMP_ALIGN
|
---|
| 94 | RamVars_GetSegmentToDS:
|
---|
[368] | 95 |
|
---|
| 96 | %ifndef MODULE_ADVANCED_ATA ; Always in Full Mode when using Advanced ATA Module
|
---|
[3] | 97 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
|
---|
[33] | 98 | jnz SHORT .GetStolenSegmentToDS
|
---|
[181] | 99 | %ifndef USE_186
|
---|
[150] | 100 | mov di, LITE_MODE_RAMVARS_SEGMENT
|
---|
[3] | 101 | mov ds, di
|
---|
[181] | 102 | %else
|
---|
| 103 | push LITE_MODE_RAMVARS_SEGMENT
|
---|
| 104 | pop ds
|
---|
| 105 | %endif
|
---|
[3] | 106 | ret
|
---|
[368] | 107 | %endif ; MODULE_ADVANCED_ATA
|
---|
[3] | 108 |
|
---|
| 109 | ALIGN JUMP_ALIGN
|
---|
[33] | 110 | .GetStolenSegmentToDS:
|
---|
[3] | 111 | LOAD_BDA_SEGMENT_TO ds, di
|
---|
| 112 | mov di, [BDA.wBaseMem] ; Load available base memory size in kB
|
---|
[33] | 113 | eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
|
---|
[3] | 114 | ALIGN JUMP_ALIGN
|
---|
| 115 | .LoopStolenKBs:
|
---|
| 116 | mov ds, di ; EBDA segment to DS
|
---|
| 117 | add di, BYTE 64 ; DI to next stolen kB
|
---|
[150] | 118 | cmp WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
|
---|
[3] | 119 | jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
|
---|
| 120 | ret
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | ;--------------------------------------------------------------------
|
---|
[258] | 124 | ; RamVars_GetHardDiskCountFromBDAtoAX
|
---|
[3] | 125 | ; Parameters:
|
---|
| 126 | ; DS: RAMVARS segment
|
---|
| 127 | ; Returns:
|
---|
[258] | 128 | ; AX: Total hard disk count
|
---|
[3] | 129 | ; Corrupts registers:
|
---|
[258] | 130 | ; CX
|
---|
[116] | 131 | ;--------------------------------------------------------------------
|
---|
[3] | 132 | ALIGN JUMP_ALIGN
|
---|
[258] | 133 | RamVars_GetHardDiskCountFromBDAtoAX:
|
---|
| 134 | call RamVars_GetCountOfKnownDrivesToAX
|
---|
[294] | 135 | push ds
|
---|
| 136 | LOAD_BDA_SEGMENT_TO ds, cx
|
---|
| 137 | mov cl, [BDA.bHDCount]
|
---|
[258] | 138 | MAX_U al, cl
|
---|
[294] | 139 | pop ds
|
---|
[3] | 140 | ret
|
---|
[32] | 141 |
|
---|
| 142 | ;--------------------------------------------------------------------
|
---|
[258] | 143 | ; RamVars_GetCountOfKnownDrivesToAX
|
---|
[32] | 144 | ; Parameters:
|
---|
| 145 | ; DS: RAMVARS segment
|
---|
| 146 | ; Returns:
|
---|
[258] | 147 | ; AX: Total hard disk count
|
---|
[32] | 148 | ; Corrupts registers:
|
---|
[258] | 149 | ; None
|
---|
[116] | 150 | ;--------------------------------------------------------------------
|
---|
[32] | 151 | ALIGN JUMP_ALIGN
|
---|
[258] | 152 | RamVars_GetCountOfKnownDrivesToAX:
|
---|
| 153 | mov ax, [RAMVARS.wDrvCntAndFirst]
|
---|
| 154 | add al, ah
|
---|
[368] | 155 | and ax, BYTE 7fh
|
---|
[32] | 156 | ret
|
---|
[294] | 157 |
|
---|
[33] | 158 | ;--------------------------------------------------------------------
|
---|
| 159 | ; RamVars_GetIdeControllerCountToCX
|
---|
| 160 | ; Parameters:
|
---|
| 161 | ; Nothing
|
---|
| 162 | ; Returns:
|
---|
| 163 | ; CX: Number of IDE controllers to handle
|
---|
| 164 | ; Corrupts registers:
|
---|
| 165 | ; Nothing
|
---|
[116] | 166 | ;--------------------------------------------------------------------
|
---|
[258] | 167 | ALIGN JUMP_ALIGN
|
---|
[33] | 168 | RamVars_GetIdeControllerCountToCX:
|
---|
[294] | 169 | eMOVZX cx, [cs:ROMVARS.bIdeCnt]
|
---|
[33] | 170 | ret
|
---|
[258] | 171 |
|
---|
| 172 | %ifdef MODULE_SERIAL_FLOPPY
|
---|
| 173 | ;--------------------------------------------------------------------
|
---|
| 174 | ; RamVars_UnpackFlopCntAndFirstToAL
|
---|
| 175 | ; Parameters:
|
---|
| 176 | ; Nothing
|
---|
| 177 | ; Returns:
|
---|
| 178 | ; AL: First floppy drive number supported
|
---|
| 179 | ; CF: Number of floppy drives supported (clear = 1, set = 2)
|
---|
[270] | 180 | ; SF: Emulating drives (clear = yes, set = no)
|
---|
[258] | 181 | ; Corrupts registers:
|
---|
| 182 | ; Nothing
|
---|
[294] | 183 | ;--------------------------------------------------------------------
|
---|
[258] | 184 | ALIGN JUMP_ALIGN
|
---|
| 185 | RamVars_UnpackFlopCntAndFirstToAL:
|
---|
| 186 | mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
|
---|
[294] | 187 | sar al, 1
|
---|
[258] | 188 | ret
|
---|
| 189 | %endif
|
---|