What header file do I need to include to get printk () in the kernel source file?

Let's say I want to use printk() inside arch/x86/boot/string.c before compiling the kernel. What header file do I need to include so that the linker knows where to find printk() ? I tried #include <linux/kernel.h> and #include <linux/printk.h> , but I always get errors during make bzImage , telling me that the linker does not find printk :

 arch/x86/boot/compressed/string.o: In function `memcmp`: string.c:(.text+0x19): undefined reference to `printk` 
+6
source share
1 answer

You are trying to configure the kernel boot phase. It has its own really small library and there are no headers like linux/printk.h . This function is called printf() and is implemented in arch / x86 / boot / printf.c.

The output of this function goes to the channel defined in the BIOS ( int 10h ), and, if necessary, to the legacy (you cannot use UART, which has 32-bit I / O, for example). See the printf.c source file for more details.

+4
source

All Articles