C++ function pointer in class, func need data in class
Posted: Wed Apr 25, 2007 10:34 am
Hello, I'm (re)starting an OS project done in C++ from ground up.
The system is divided in 3 layers (by the way, I don't even know the kernel type of my system):
SystemLib: Upper-level system (VFS, power ,network, etc.) not done
CoreKernel: Architecture independent but close to hardware part (Task scheduling, IRQ upper-level management, memory management) not done
SysCore: Low-level part which plays with hardware (IDT,GDT) partial
SysCore itself is portable because of the way it is designed. It is a generic framework which uses (and needs) system handlers. These contain the code to initialize the system (x86 ex: Setup IDT,GDT, Remap IRQ,), and the code to access system vital hardware (MMU, PIC, basic IO mechanism). The system is also designed to be multiprocessing (not necessarily symmetric, but that's something I'm gonna do after).
Here is the definition of a Core (CPU, MMU, PIC, IO):
(If you find syntax errors, please say me, it is my first C++ big coding experience (appart hello world)).
In Interrupts_c, InterruptsRouteTable needs to be accessed from the external handler. How can I do this, as the external handler's code is not in the class ?
I thank anybody to answer this question.
The system is divided in 3 layers (by the way, I don't even know the kernel type of my system):
SystemLib: Upper-level system (VFS, power ,network, etc.) not done
CoreKernel: Architecture independent but close to hardware part (Task scheduling, IRQ upper-level management, memory management) not done
SysCore: Low-level part which plays with hardware (IDT,GDT) partial
SysCore itself is portable because of the way it is designed. It is a generic framework which uses (and needs) system handlers. These contain the code to initialize the system (x86 ex: Setup IDT,GDT, Remap IRQ,), and the code to access system vital hardware (MMU, PIC, basic IO mechanism). The system is also designed to be multiprocessing (not necessarily symmetric, but that's something I'm gonna do after).
Here is the definition of a Core (CPU, MMU, PIC, IO):
(If you find syntax errors, please say me, it is my first C++ big coding experience (appart hello world)).
Code: Select all
/* SysCore Core[] interface */
namespace SysCore {
enum CPUInfoIndex_l {
SpeedMHz = 0,
SpeedMIPS,
CPUID
};
enum Architecture_l {
X86 = 0,
PowerPC,
ARM,
};
class CPUInfo_c {
public:
Architecture_l GetCPUArch();
unsigned long GetCPUInfo(CPUInfoIndex_l CPUInfoNum);
private:
Architecture_l CPUArch;
unsigned int CPUSpeedMHz;
unsigned int CPUSpeedMIPS;
unsigned long CPU_CPUID;
};
class CPU_c {
public:
SC_CPUInfo_c Info;
void Jump(void (*Address2JumpTo));
unsigned long (*GetRegister)(unsigned char Register);
bool (*SetRegister)(unsigned char Register, unsigned long Value);
bool (*GetFlag)(unsigned char FlagBit);
bool (*SetFlag)(unsigned char FlagBit, bool FlagStatus);
};
class Interrupts_c {
public:
bool (*RegisterInt)(unsigned char IntNum, unsigned long CodeAddress, bool SupervisorMode);
bool (*UnregisterInt)(unsigned char IntNum);
private:
bool (*IntsSetStatus)(bool Active);
bool *InterruptsRouteTable[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
class MMU_c {
public:
bool MapLinear(void *RealBase, void *MapBase, unsigned long MapLenght, unsigned long *PageDir);
bool (*MapPage)(unsigned long RealPageNum, unsigned VirtMapAddress);
unsigned long FindFreePages(unsigned long PageNum);
unsigned long FindFreePage();
}
class Core_c {
public:
Core_c(unsigned long (*CPUGetRegister)(unsigned char Register), bool (*CPUSetRegister)(unsigned char Register, unsigned long Value), bool (*CPUGetFlag)(unsigned char FlagBit), bool (*CPUSetFlag)(unsigned char FlagBit, bool FlagStatus), bool (*MMUHMapPage)(unsigned long RealPageNum, unsigned VirtMapAddress), bool (*IntsSetStatus)(bool Active), bool (*SystemInitializer));
CPU_c CPU;
MMU_c *MMU;
IO_c GIOSys;
Interrupts_c *ISR;
};
}
I thank anybody to answer this question.