Page 1 of 1

Bochs memory bug ?

Posted: Wed Oct 22, 2003 4:45 am
by pini
I'm using Bochs 2.0.2 and I want it to allocate 32 MB of RAM.
I'm using a simple algorithm to check the amount of memory available to my OS. It works pretty good, but with bochs, it says that there's only 32 MB - 3 Bytes installed.


Is this due to a bochs bug ? Or Are these 3 bytes used for something special ??

Re:Bochs memory bug ?

Posted: Wed Oct 22, 2003 5:22 am
by Tim
What algorithm are you using? You should be getting a memory map from the BIOS.

Re:Bochs memory bug ?

Posted: Wed Oct 22, 2003 6:50 am
by Pype.Clicker
pini wrote: Is this due to a bochs bug ? Or Are these 3 bytes used for something special ??
Is suspects this come from the fact you're scanning every address (like 0xb8000,0xb8001, 0xb8002, 0xb8003, 0xb8004, etc.) using an integer rather than scanning every multiple-of-four addresses (0xb8000, 0xb8004, 0xb8008) or something.

When you reach the last 4 bytes, the N-4 address works, but at N-3 you have one byte that is off the memory by one ... thus you'll conclude (wrongly) that it did not work from N-3 while the test at N-4 actually proved N-4, N-3, N-2 and N-1 were valid.

Re:Bochs memory bug ?

Posted: Wed Oct 22, 2003 7:52 am
by pini
Pype.Clicker wrote: Is suspects this come from the fact you're scanning every address (like 0xb8000,0xb8001, 0xb8002, 0xb8003, 0xb8004, etc.) using an integer rather than scanning every multiple-of-four addresses (0xb8000, 0xb8004, 0xb8008) or something.

When you reach the last 4 bytes, the N-4 address works, but at N-3 you have one byte that is off the memory by one ... thus you'll conclude (wrongly) that it did not work from N-3 while the test at N-4 actually proved N-4, N-3, N-2 and N-1 were valid.

You're right with the fact that the bytes are outbound at the end of the memory. BTW, i'm not testing each byte (arrg : would be very long).
I'm using dichotomy to find the end of the memory.

Currently, I can't test my algorithm with a byte check rather than a unsigned long check, but I think you're probably right, Pype. I will test this evening.

Thank you !

Re:Bochs memory bug ?

Posted: Wed Oct 22, 2003 8:51 am
by Pype.Clicker
pini wrote: Currently, I can't test my algorithm with a byte check rather than a unsigned long check, but I think you're probably right, Pype. I will test this evening.
An integer check is fine as long as
1. you always check addresses that meets x%4 == 0
2. in case of success, you consider that the highest available address is x+3, and not x itself ...

Note that, afaik, the physical memory is organized in page frames, and i don't think there's something like memory chips that will come with an amount of memory that is lower than 4KB. Thus (theorically), once you found a valid address X, you can assume that (X & 0xffff000)..(X | 0x0000fff) are valid.

Re:Bochs memory bug ?

Posted: Wed Oct 22, 2003 9:55 am
by pini
You're probably right when you say that memory is a multiple of 4KB.
It's true that there's no need to use byte check instead of unsigned long check, as long as you know how the algorithm works, and how to correct the given value.