Skip to content

Commit 2e31b0b

Browse files
committed
[cmos] Implement extmem reporting for low-memory systems
1 parent b284930 commit 2e31b0b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

devices/x86/cmos.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,25 @@ static uint8 cmos_inb(struct io_handler *hdl,uint16 port) {
155155
else ret = 0;
156156
LOG("Returned CENTURY=%u",ret);
157157
ret = bin2bcd(pCtx,ret);
158-
return ret;
158+
return ret;
159+
} else if( pCtx->indexreg == 0x30 ) { // ExtMem (in K) Low Byte
160+
uint64 rs;
161+
if( pCtx->pSystemCtx->ramsize > 0xE0000000 ) {
162+
rs = 0xE0000000;
163+
} else {
164+
rs = pCtx->pSystemCtx->ramsize;
165+
}
166+
rs -= 1024LL * 1024LL * 16LL;
167+
return (rs>>10);
168+
} else if( pCtx->indexreg == 0x31 ) { // ExtMem (in K) High Byte
169+
uint64 rs;
170+
if( pCtx->pSystemCtx->ramsize > 0xE0000000 ) {
171+
rs = 0xE0000000;
172+
} else {
173+
rs = pCtx->pSystemCtx->ramsize;
174+
}
175+
rs -= 1024LL * 1024LL * 16LL;
176+
return (rs>>18);
159177
} else if( pCtx->indexreg == 0x34 ) { // ExtMem Low Byte
160178
uint64 rs;
161179

0 commit comments

Comments
 (0)