|
|
#1 |
|
Using mmap() in OSX
I haven't found much information on Mac OSX's memory layout (who am I kidding, I haven't found a darn thing), so I was hoping that someone would be able to shed some light on this.
This is going to be a rather "off the wall" request, but I want to use mmap() to claim the first 4GB of the 64-bit address space in Mac OSX (more specifically, the memory range of 0x10000 - 0xFFFFFFFF). I'm assuming that it may be impossible to get access to that memory range. In Windows, I can at least get that specific base address with a few hacky methods, but I'm still rather new to MacOSX and UNIX altogether. I was thinking of trying something like this: void* memptr = (void*) 0x10000; mmap( memptr, 0xFFFFFFFF, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_FIXED, -1, 0 ); Would this work? |
|
|
|
0
|
|
|
#2 | |
|
Quote:
|
||
|
|
0
|
|
|
#3 |
|
|
0
|
|
|
#4 | ||
|
Quote:
I've already taken multiple precautions into account here (non-encodable instructions, mmio, privileged registers, exception handling, etc.), so now I needed to make sure that the first 4GB of address space are available for usage in 64-bit. Quote:
|
|||
|
|
0
|
|
|
#5 |
|
Forgive me if I am misunderstanding something here but why don't you just write your own memory access functions that take an address in the first 4GBs of memory space and converts it to the actual address that Mac OS X has allocated you? Some sort of memory address translation. That would solve the problem at hand, would work on any operating system and means you don't need to do any sort of hacky stuff.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development Last.fm Profile | Extreme Metal Reviews MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3 |
|
|
|
0
|
|
|
#6 | |
|
Quote:
It sounds like a good idea, but it really creates more hurdles to deal with. |
||
|
|
0
|
|
|
#7 |
|
You aren't quite understanding. Treat the VM as virtual memory. To the VM side, it will see the 32bit address space. But when you store the data in your program, you store it at a base address pus the 32bit address. Then you ask the OS to give you a 4GB block of address space. You don't care where it is. Just store the base address and do translations on every VM access. The is essentially how virtual memory works (with some more complications).
|
|
|
|
0
|
|
|
#8 |
|
How do virtual machines such as virtualbox, parallels and vmware work under Mac OS X?
|
|
|
|
0
|
|
|
#9 |
|
Virtualbox is open source, so you can download the source and take a look. But in that case, they are emulating the x86 processor so there would be a whole lot more complexity in the memory mapping code. The memory mapping the O.P. is describing sounds a lot simpler.
|
|
|
|
0
|
|
|
#10 | |
|
Quote:
They use virtualization instructions (processor specific), such as Intel VMX. VMX is a special instruction set used to create virtual machines, but it's a rather complex instruction set and using it doesn't appear to be very straightforward. |
||
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 07:14 PM.







Linear Mode
