CMOS & QEMU: Total RAM

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
LegendDairy
Member
Member
Posts: 52
Joined: Sat Nov 06, 2010 10:42 am
Location: Antwerp (Belgium)

CMOS & QEMU: Total RAM

Post by LegendDairy »

Hi, sorry for this short and simple post but I really needed some answers to check if my code is all right and not buggy.

I was trying out the CMOS-RAM sample at the wiki, and it gave me 0xffff of total RAM but is this mb or bytes or kilobyte...?

I was also wondering how much RAM does Qemu emulate? Is there some place where I can find it?



Thnx,
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: CMOS & QEMU: Total RAM

Post by Tosi »

The version of QEMU I have (0.13.50) emulates 128 MB of memory by default.
It is reported both in the manual, and by the multiboot header when invoked with the "-kernel" option.

As for the CMOS memory size registers, the wiki has this to say:
(Register 0x16 (high byte) | Register 0x15 (low byte)) << 10 = 640K = size of low memory (without taking the EBDA into account.

(Register 0x18 (high byte) | Register 0x17 (low byte)) << 10 = total memory between 1M and 16M, or maybe 65M ... usually. But this number is extra untrustworthy when the system has more than 64M, it ignores "memory holes", it ignores memory mapped hardware, and it ignores memory reserved for important ACPI system tables.

(Register 0x35 (high byte) | Register 0x34 (low byte)) << 16 = total memory between 16M and 4G ... usually. But this number is untrustworthy when the system has more than 4G, it ignores "memory holes", it ignores memory mapped hardware, and it ignores memory reserved for important ACPI system tables.
User avatar
xenos
Member
Member
Posts: 1123
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: CMOS & QEMU: Total RAM

Post by xenos »

It seems to me that the Multiboot info returned by QEMU using the -kernel option is buggy. As far as I understood the Multiboot specification, the field mem_upper should report only memory above 1MB:
Multiboot wrote:If bit 0 in the ‘flags’ word is set, then the ‘mem_*’ fields are valid. ‘mem_lower’ and ‘mem_upper’ indicate the amount of lower and upper memory, respectively, in kilobytes. Lower memory starts at address 0, and upper memory starts at address 1 megabyte. The maximum possible value for lower memory is 640 kilobytes. The value returned for upper memory is maximally the address of the first upper memory hole minus 1 megabyte. It is not guaranteed to be this value.
However, this field contains 128MB in QEMU's implementation instead of 127MB as one would expect. (GRUB 1 & 2 both report 127MB upper memory.)
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Post Reply