[90] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Functions for accessings RAMVARS. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
[505] | 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
[526] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. |
---|
[376] | 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. |
---|
[505] | 12 | ; |
---|
[376] | 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 |
---|
[505] | 16 | ; GNU General Public License for more details. |
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
[505] | 18 | ; |
---|
[376] | 19 | |
---|
[3] | 20 | ; Section containing code |
---|
| 21 | SECTION .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: |
---|
[592] | 33 | ; AX, CX, DX, DI |
---|
[3] | 34 | ;-------------------------------------------------------------------- |
---|
| 35 | RamVars_Initialize: |
---|
[90] | 36 | push es |
---|
[3] | 37 | |
---|
[400] | 38 | %ifndef USE_AT |
---|
[241] | 39 | mov ax, LITE_MODE_RAMVARS_SEGMENT |
---|
[3] | 40 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE |
---|
[97] | 41 | jz SHORT .InitializeRamvars ; No need to steal RAM |
---|
[364] | 42 | %endif |
---|
[3] | 43 | |
---|
[116] | 44 | LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX |
---|
[3] | 45 | mov al, [cs:ROMVARS.bStealSize] |
---|
[33] | 46 | sub [BDA.wBaseMem], ax |
---|
[567] | 47 | %ifdef USE_186 |
---|
[592] | 48 | imul ax, [BDA.wBaseMem], 64 |
---|
[567] | 49 | %else |
---|
[592] | 50 | mov al, 64 |
---|
| 51 | mul WORD [BDA.wBaseMem] |
---|
[567] | 52 | %endif |
---|
[3] | 53 | |
---|
[97] | 54 | .InitializeRamvars: |
---|
[592] | 55 | xor di, di |
---|
[241] | 56 | mov ds, ax |
---|
| 57 | mov es, ax |
---|
[97] | 58 | mov cx, RAMVARS_size |
---|
| 59 | call Memory_ZeroESDIwithSizeInCX |
---|
[444] | 60 | mov WORD [RAMVARS.wDrvDetectSignature], RAMVARS_DRV_DETECT_SIGNATURE |
---|
| 61 | mov WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE |
---|
[556] | 62 | %ifdef MODULE_DRIVEXLATE |
---|
| 63 | call DriveXlate_Reset |
---|
| 64 | %endif |
---|
[505] | 65 | |
---|
[97] | 66 | pop es |
---|
[395] | 67 | ret |
---|
[33] | 68 | |
---|
[3] | 69 | ;-------------------------------------------------------------------- |
---|
| 70 | ; Returns segment to RAMVARS. |
---|
| 71 | ; RAMVARS might be located at the top of interrupt vectors (0030:0000h) |
---|
| 72 | ; or at the top of system base RAM. |
---|
| 73 | ; |
---|
| 74 | ; RamVars_GetSegmentToDS |
---|
| 75 | ; Parameters: |
---|
| 76 | ; Nothing |
---|
| 77 | ; Returns: |
---|
| 78 | ; DS: RAMVARS segment |
---|
| 79 | ; Corrupts registers: |
---|
| 80 | ; DI |
---|
| 81 | ;-------------------------------------------------------------------- |
---|
| 82 | ALIGN JUMP_ALIGN |
---|
| 83 | RamVars_GetSegmentToDS: |
---|
[368] | 84 | |
---|
[400] | 85 | %ifndef USE_AT ; Always in Full Mode for AT builds |
---|
[3] | 86 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE |
---|
[33] | 87 | jnz SHORT .GetStolenSegmentToDS |
---|
[400] | 88 | %ifndef USE_186 |
---|
| 89 | mov di, LITE_MODE_RAMVARS_SEGMENT |
---|
| 90 | mov ds, di |
---|
| 91 | %else |
---|
| 92 | push LITE_MODE_RAMVARS_SEGMENT |
---|
| 93 | pop ds |
---|
| 94 | %endif |
---|
| 95 | ret |
---|
[181] | 96 | %endif |
---|
[3] | 97 | |
---|
| 98 | ALIGN JUMP_ALIGN |
---|
[33] | 99 | .GetStolenSegmentToDS: |
---|
[3] | 100 | LOAD_BDA_SEGMENT_TO ds, di |
---|
[592] | 101 | ;%ifdef USE_186 |
---|
| 102 | ; imul di, [BDA.wBaseMem], 64 ; 2 bytes less but slower, especially on 386/486 processors |
---|
| 103 | ;%else |
---|
[3] | 104 | mov di, [BDA.wBaseMem] ; Load available base memory size in kB |
---|
[33] | 105 | eSHL_IM di, 6 ; Segment to first stolen kB (*=40h) |
---|
[592] | 106 | ;%endif |
---|
[3] | 107 | ALIGN JUMP_ALIGN |
---|
| 108 | .LoopStolenKBs: |
---|
| 109 | mov ds, di ; EBDA segment to DS |
---|
| 110 | add di, BYTE 64 ; DI to next stolen kB |
---|
[444] | 111 | cmp WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE |
---|
[3] | 112 | jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually) |
---|
| 113 | ret |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | ;-------------------------------------------------------------------- |
---|
[258] | 117 | ; RamVars_GetHardDiskCountFromBDAtoAX |
---|
[3] | 118 | ; Parameters: |
---|
| 119 | ; DS: RAMVARS segment |
---|
| 120 | ; Returns: |
---|
[258] | 121 | ; AX: Total hard disk count |
---|
[3] | 122 | ; Corrupts registers: |
---|
[492] | 123 | ; BX |
---|
[116] | 124 | ;-------------------------------------------------------------------- |
---|
[392] | 125 | %ifdef MODULE_BOOT_MENU |
---|
[258] | 126 | RamVars_GetHardDiskCountFromBDAtoAX: |
---|
| 127 | call RamVars_GetCountOfKnownDrivesToAX |
---|
[294] | 128 | push ds |
---|
[505] | 129 | LOAD_BDA_SEGMENT_TO ds, bx |
---|
[492] | 130 | mov bl, [BDA.bHDCount] |
---|
| 131 | MAX_U al, bl |
---|
[294] | 132 | pop ds |
---|
[3] | 133 | ret |
---|
[392] | 134 | %endif |
---|
[32] | 135 | |
---|
[392] | 136 | |
---|
[32] | 137 | ;-------------------------------------------------------------------- |
---|
[258] | 138 | ; RamVars_GetCountOfKnownDrivesToAX |
---|
[32] | 139 | ; Parameters: |
---|
| 140 | ; DS: RAMVARS segment |
---|
| 141 | ; Returns: |
---|
[258] | 142 | ; AX: Total hard disk count |
---|
[32] | 143 | ; Corrupts registers: |
---|
[258] | 144 | ; None |
---|
[116] | 145 | ;-------------------------------------------------------------------- |
---|
[32] | 146 | ALIGN JUMP_ALIGN |
---|
[258] | 147 | RamVars_GetCountOfKnownDrivesToAX: |
---|
[433] | 148 | mov ax, [RAMVARS.wFirstDrvAndCount] |
---|
[258] | 149 | add al, ah |
---|
[368] | 150 | and ax, BYTE 7fh |
---|
[32] | 151 | ret |
---|
[294] | 152 | |
---|
[33] | 153 | ;-------------------------------------------------------------------- |
---|
| 154 | ; RamVars_GetIdeControllerCountToCX |
---|
| 155 | ; Parameters: |
---|
| 156 | ; Nothing |
---|
| 157 | ; Returns: |
---|
| 158 | ; CX: Number of IDE controllers to handle |
---|
| 159 | ; Corrupts registers: |
---|
| 160 | ; Nothing |
---|
[116] | 161 | ;-------------------------------------------------------------------- |
---|
[258] | 162 | ALIGN JUMP_ALIGN |
---|
[33] | 163 | RamVars_GetIdeControllerCountToCX: |
---|
[294] | 164 | eMOVZX cx, [cs:ROMVARS.bIdeCnt] |
---|
[33] | 165 | ret |
---|
[258] | 166 | |
---|
[473] | 167 | |
---|
[258] | 168 | %ifdef MODULE_SERIAL_FLOPPY |
---|
| 169 | ;-------------------------------------------------------------------- |
---|
| 170 | ; RamVars_UnpackFlopCntAndFirstToAL |
---|
| 171 | ; Parameters: |
---|
[473] | 172 | ; DS: RAMVARS segment |
---|
[258] | 173 | ; Returns: |
---|
| 174 | ; AL: First floppy drive number supported |
---|
[567] | 175 | ; CF: Number of floppy drives supported (clear = 1, set = 2) |
---|
[270] | 176 | ; SF: Emulating drives (clear = yes, set = no) |
---|
[258] | 177 | ; Corrupts registers: |
---|
| 178 | ; Nothing |
---|
[294] | 179 | ;-------------------------------------------------------------------- |
---|
[258] | 180 | ALIGN JUMP_ALIGN |
---|
| 181 | RamVars_UnpackFlopCntAndFirstToAL: |
---|
| 182 | mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst] |
---|
[294] | 183 | sar al, 1 |
---|
[258] | 184 | ret |
---|
| 185 | %endif |
---|