Device init
Posted: Sun Mar 18, 2007 11:15 am
I have my kernel in which after all the baisic init it does the hardware init like fdc,hdd,lpt etc.. Whenever i write code for a new hardware i have to make an entry into the inits if that code requires an init. Though not an optimal solution and not required i came up with a solution for this problem.
I defined a macro called DEVICE_INIT that declares a global string "devinit" earlier to the init function of the device. My init manager searches for the string in the kernel on physical memory and when it finds it computes the init function pointer by adding 8 to the string pointer (length of "devinit" + null). It then calls the function.
I know this is a stupid idea and it never worked except for some cases where no local string inside the function was declared. Could there be any other alternative solution?
I defined a macro called DEVICE_INIT that declares a global string "devinit" earlier to the init function of the device. My init manager searches for the string in the kernel on physical memory and when it finds it computes the init function pointer by adding 8 to the string pointer (length of "devinit" + null). It then calls the function.
I know this is a stupid idea and it never worked except for some cases where no local string inside the function was declared. Could there be any other alternative solution?