Higher half vs Lower half

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
IanSeyler
Member
Member
Posts: 326
Joined: Mon Jul 28, 2008 9:46 am
Location: Ontario, Canada
Contact:

Higher half vs Lower half

Post by IanSeyler »

In BareMetal OS all memory is identity mapped 1:1 and also mapped again to the higher half. In x86 some memory is used for memory-mapped devices like video cards, some network cards, the APIC, etc.. Is it possible to use all memory in the system as real memory instead of losing some of it to devices?

For example writing to 0xB8000 goes to the video memory. If I write to 0xFFFF8000000B8000 does it also go to video memory? What happens if I read from 0xFFFF8000000B8000?

I guess what I am looking for is the possibility of mapping all physical RAM to the higher half and leaving the lower half for memory-mapped devices. Is this possible on x86?

Thanks,
Ian
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Higher half vs Lower half

Post by Combuster »

Paging works on device addresses as well as RAM. if you mapped B8000-BFFFF to some higher half address it works just as reading and writing to B8000 physical.

If you want all RAM in the higherhalf you just need to select all usable ram from the entire physical address space and map it somewhere in there.

Or am I missing something?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
linguofreak
Member
Member
Posts: 510
Joined: Wed Mar 09, 2011 3:55 am

Re: Higher half vs Lower half

Post by linguofreak »

ReturnInfinity wrote:In BareMetal OS all memory is identity mapped 1:1 and also mapped again to the higher half. In x86 some memory is used for memory-mapped devices like video cards, some network cards, the APIC, etc.. Is it possible to use all memory in the system as real memory instead of losing some of it to devices?
You don't lose any "real memory" to devices. Some addresses have memory attached to them, some addresses have devices, but all the "real memory" on the system has an address. There's not any memory, as far as I know, that doesn't have an address because the address it would be mapped to is used by a device.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Higher half vs Lower half

Post by Combuster »

There is often about 160k RAM of wasted unavailable memory at C8000-EFFFF, but you need a chipset-specific driver to get it. And you have to be careful as it might as well be actually used for additional PnP ROMs and larger BIOSes.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Higher half vs Lower half

Post by bluemoon »

ReturnInfinity wrote:In BareMetal OS all memory is identity mapped 1:1 and also mapped again to the higher half. In x86 some memory is used for memory-mapped devices like video cards, some network cards, the APIC, etc.. Is it possible to use all memory in the system as real memory instead of losing some of it to devices?

For example writing to 0xB8000 goes to the video memory. If I write to 0xFFFF8000000B8000 does it also go to video memory? What happens if I read from 0xFFFF8000000B8000?
Yes if the higher half mapping is a clone on identity mapped lower half. Reading from such memory resolve to video memory.
ReturnInfinity wrote: I guess what I am looking for is the possibility of mapping all physical RAM to the higher half and leaving the lower half for memory-mapped devices. Is this possible on x86?
Sure, but that wouldn't be identity mapped. You can map usual memory to the address 0xFFFF8000000B8000(That's the idea of paging).
Post Reply