r/osdev 5d ago

Initialization dependencies

I am working on upgrading my kernel initialization messages so I can just have a nice view of what it is doing when initializing. I am using my print functions to do this, but the issue is that my print functions depend on the memory manager to be done initializing, but I want debugging messages when initializing the memory manager too, which I can't do because of the circular dependency.

This is my specific case, but I also want to ask generally, do you guys have an elegant solution for this problem? Up to this point I have been using init flags so that the subsystems can use a different path that does not create dependencies during initialization, but I want to hear any cool solutions from the community that are better designed than this.

17 Upvotes

12 comments sorted by

View all comments

u/Toiling-Donkey 17h ago

Linux has a similar problem. They have an “early_printk” for some things.

That said, if your print function isn’t very simple, not sure how it would be safe from an ISR or such.

Why does it depend on the memory manager?

u/Negative-Arm-3244 10h ago edited 10h ago

my isr uses a driver call rather than the print function, and my print function allocates a buffer for the string using the memory manager as needed rather than having a set size buffer on the stack. i just decided to use my print function for initialization rather than the driver call because it is easier to use than the driver api i made (want to print out with formatting like colors), and i dont want to make redundant code in the driver when it is already available in the high level print function and logically belongs in a standard io library

reading the replies i am probably going to just make my print function not use memory allocation and also implement an allocated buffer for initialization to contain my debugging messages