Page 1 of 1

Virtual memory layout

Posted: Thu Jul 14, 2005 6:16 am
by Kemp
My OS is going to lie to the applications about memory, much as is standard practice. My current thoughts for actual physical memory layout are:

0 - 1Mb = Untouchable as of the end of boot in case I need anything from there
1 - 16Mb = Reserved for old-school DMA transfers
16 - Whatever = OS
Whatever - EndOfMemory = Application space

I'm probably going to go with the roughly usual layout for virtual memory (OS gets a 1Gb, apps get 2Gb, whatever), but I was wondering if it would be any benefit to map in the 0 - 1Mb range (probably in the OS's Gb) or if any apps that want data from the EBDA or somewhere should have to go through the OS to get it.

I can't see any circumstances in which an app would need to be able to read the data from there, but then I don't want to be too restrictive either, so I'm a bit torn. Drivers might need to, but they can have it mapped anyway even if apps don't.

My current thought is to not map it into the app memory space and to give them a set of API calls if they need specific data. Does anyone have thoughts on this?

Re:Virtual memory layout

Posted: Thu Jul 14, 2005 8:20 am
by JoeKayzA
Hi!
I can't see any circumstances in which an app would need to be able to read the data from there, but then I don't want to be too restrictive either, so I'm a bit torn. Drivers might need to, but they can have it mapped anyway even if apps don't.

My current thought is to not map it into the app memory space and to give them a set of API calls if they need specific data. Does anyone have thoughts on this?
Well, with virtual memory enabled you normally give every application its own private address space, so you shouldn't have anything special mapped in there from the beginning on. You rather map in free pages when the application requests memory to use, and special pages (mmapped devices or special information filled in by the os) when it requests to access these regions explicitly (and has proper privileges to access them). The first MB falls, IMHO, into the latter category.

Hope I could help you!

cheers
Joe

Re:Virtual memory layout

Posted: Thu Jul 14, 2005 8:59 am
by Kemp
Well there will be certain things that are permanently mapped in to every application's space, such as the OS itself for convenience purposes, so I could easily map in the 1st Mb as well. At the moment I'm just considering that to be unnecessary work though so I'm tending towards the (real) 1st Mb not existing for the apps.

Re:Virtual memory layout

Posted: Thu Jul 14, 2005 9:57 am
by JoeKayzA
Still haven't got what you mean exactly (wheter you need to map it in or not), but I think when an application requests access to the 1st MB, it should be trivial to map it into the target address space at the requested location, provided that you haven't overwritten this data already (according to you physical memory layout, you won't touch it).

My current thought is to not map it into the app memory space and to give them a set of API calls if they need specific data. Does anyone have thoughts on this?
This is actually what I meant. Sorry, I must have missed this paragraph at the time of my first reading ::).

cheers
Joe

Re:Virtual memory layout

Posted: Thu Jul 14, 2005 3:16 pm
by AR
Programs shouldn't need access to the BIOS data, once the OS is running drivers the BIOS' functions are unnecessary, and even if they are (eg. VESA) they should definitely be regulated by the OS. The BIOS shouldn't know anything the OS doesn't provided you have a full initalization (reading the MP tables, Get entrypoints for the PCI32 BIOS, memory size, full list of VESA card capabilities, etc).

Re:Virtual memory layout

Posted: Fri Jul 15, 2005 11:37 am
by Kemp
AR, that sounds about right. Make sure the OS knows anything useful and let the programs go to it for the info. I guess it would make app programming easier as well if you don't have to know anything about the system in order to get the info, make it a bit more portable and all that.