My requirement is to emulate an old motorola memory controller.
Basically the controller maps 8 x 8Kbyte memory blocks into a 64Kbyte address space for subsequent access by a CPU. The controller has access to upto 1024 such 8K blocks.
At the moment I have accomplished this by using a large flat array like so:
unsigned char Memory;
short int Address;
unsigned char aByte = Memory[MappedMemoryBank[Address>>13]][Address&0x1FFF];
unsigned char *Memory;
Memory = pointed to first byte of (re-)mapped memory
unsigned char aByte = Memory[Address];
I managed to find in Linux there is the mremap() function.
And in Windows is the AWE Address Windowing Exextensions MapUserPhysicalPages function allows this.
I just tested the AWE functions and they work well. Not sure how efficient they are but they work nicely.