C++ class layout for memory mapped io

78 Views Asked by At

I want to use a mmio device in a C++ environment. Is there a way for me to create a class that represents the layout of the devices registers, such that reading and writing to the fields will read and write to the registers?

Say that the offset 0x0 contains reg0 and 0x04 contains reg1. Could I create class:

class MyDevice {
    public:
        int reg0;
        int reg1;

};

such that accessing reg0 or reg1 would act as register accesses?

0

There are 0 best solutions below