Page 1 of 1

Magic problems in the memory manager.

Posted: Tue Apr 28, 2020 12:05 pm
by mrjbom
Hi.
To display text on the screen, I use Scalable Screen Font, it needs a memory manager.
I wrote code that outputs text, in qemu it works as it should and outputs everything. But when trying to run the kernel in Virtual Box, the library reported errors in my memory Manager. Later, I noticed that in virtual box the test machine has 5120 MB of RAM, so I lowered this number to 1024 and everything worked fine.
I thought I found an error, I thought that when working with more than 4 GB of RAM in the memory Manager there is a problem.
Then I put 4100 MB to test my guess, but everything worked.
Experimentally, I found out that if I put 4132 MB or higher I get a problem. At 4131 MB, everything works well.

I did not apply the source code of the memory Manager because the comments are not written in English(I will translate them later). But if someone wants to look at them, you can find them all here.

What could be the reason for this problem?
Thanks.

Re: Magic problems in the memory manager.

Posted: Tue Apr 28, 2020 12:16 pm
by iansjack
Are you asking why your 32-bit os doesn't work with more than 4GB of RAM?

Re: Magic problems in the memory manager.

Posted: Tue Apr 28, 2020 12:25 pm
by Octocontrabass
Your problem is here. You are casting memory_map->addr and memory_map->len to uint32_t, but they do not fit in 32 bits.

Re: Magic problems in the memory manager.

Posted: Tue Apr 28, 2020 12:32 pm
by Octocontrabass
iansjack wrote:Are you asking why your 32-bit os doesn't work with more than 4GB of RAM?
With PAE, a 32-bit OS may access the entire physical address space (up to 52 bits on current processors).

Of course, if you're using anywhere near that many physical address bits, you'd probably be better off in long mode.

Re: Magic problems in the memory manager.

Posted: Tue Apr 28, 2020 1:48 pm
by mrjbom
Octocontrabass wrote:Your problem is here. You are casting memory_map->addr and memory_map->len to uint32_t, but they do not fit in 32 bits.
Thanks for the help. I was surprised why when installing for example 4131 MB everything works, and if a little more, everything breaks. Now I understand.

Love you.

Re: Magic problems in the memory manager.

Posted: Tue Apr 28, 2020 2:09 pm
by iansjack
Octocontrabass wrote:
iansjack wrote:Are you asking why your 32-bit os doesn't work with more than 4GB of RAM?
With PAE, a 32-bit OS may access the entire physical address space (up to 52 bits on current processors).
Well, yes. But that rather supposes that you are using PAE.

Re: Magic problems in the memory manager.

Posted: Fri May 08, 2020 9:08 am
by iProgramInCpp
Isn't that supposed to be 4096? I mean 4096 MiBytes (p.c.) = 4194304 KiBytes = 4294967296 (1 over the max value for a uint32_t)