tags:

views:

88

answers:

1

I would like to dynamically allocate memory from the machine_init function in my arm linux kernel. Calling kalloc can result in a complete failure of the system to boot.

My debugging tools are very limited so I can't give much more information regarding the failure.

Simply put, is it legal to call kalloc from a machine_init function in arm linux, and, if not, is there an alternative?

+3  A: 

I can't see where machine_init is called from, but I can't help thinking you're trying to do the wrong thing.

Device drivers and other subsystems have their own init time, trying to do things very early on is usually a mistake (because something required isn't started yet). You can definitely call kmalloc during the initialisation of a device driver (at least, most. Maybe the console driver is different).

In any case, the fact that your on ARM suggests that it's an embedded system, so you're unlikely to have to deal with a lot of different hardware. Can't you just statically allocate an array with as many elements as could possibly be required (give an error if it is exceeded) ?

MarkR