I was reading the OS theory in which I found that a process have it’s virtual address space (loosely using technique base and limit register for sake of simplicity) But it can’t access any other addresses. But in embedded systems we can use placement new or reinterpret_cast (C++) to access memory mapped IO address’es, but how that can be possible if we can’t access any other address except process’s virtual address space?
class ControlReg {
public:
bool ready() const { return readyBit; }
private:
volatile unsigned readyBit :1;
};
ControlReg *pcr = reinterpret_cast<ControlReg*>(0xFFFF0000); // address 0xFFFF0000 is still virtual or absolute physical mapped address?
Is there some instruction that makes possible for process to access any address? . I’m confused I guess, can anyone please help me view things clearly?
Thanks
This is a purely OS issue, and applies to all languages (including
assembler). Modern, general purpose OS’s map the memory of user
processes, and don’t allow access outside of the mapped memory; a user
process cannot normally access memory mapped IO, or even memory used by
the OS. But this mapping is done by the system: the system may have
special requests that allow going around it; kernel level code definitly
can go around it; and many embedded systems, especially smaller ones,
don’t have memory mapping at all.