I think I've finally found the solution
sortie wrote:Then don't have any global constructors and the table is empty.
Sortie, you just gave me an excellent idea:
In <def.h> (Main type definitions):
Code: Select all
//...
#define Attribute(attr) __attribute__((__attr__))
//...
#define Inline Attribute(always_inline)
//...
Then all classes will declare
Then I can call global constructors, if any put in there by GCC, call KernelInit(), and problem solved

Thanks to all of you!
By the way...
sortie wrote:As for dependencies between subsystems, I recommend a no-initialization approach. If you can initialize it at compile/link/load time rather than run-time, then great, do that. That removes these initialization dependencies. For instance, my system call table is done at compile time, and so can the GDT, IDT and such be. If everything can be done at that time, there is very, very little initialization code remaining and it can just immediately execute the real code. (Of course, this isn't fully possible in a kernel, and might not in your design, but it's a simplicity goal I aim towards).
Yes, in my design it isn't any practical

. I follow that rule (initialize as little as you can at run-time), but there are still some run-time dependencies (i.e. unpredictable dynamic memory allocation) that I can't remove (by now...)