I hope someone can explain this to me. I write my own OS and write a memory manager. I keep getting a weird warning when I compile my kernel. The warning is paradoxical for me. The function receives the type of parameter that it expects, but complains, as if it were otherwise. Everything is working fine, and I can get the information I need to initialize my memory manager. Can you tell me what that means?
$ HOME / opt / cross / bin / i686-elf-gcc -c -ffreestanding -O2 -Wall -Wextra -std = gnu99 -ggdb -src / h system -o build / kernel.co src / c / kernel.c
src / c / kernel.c: In the function 'kernel_main': src / c / kernel.c: 29: 2: warning: pass argument 1 from 'memory_manager_initialize' from an incompatible pointer type
memory_manager_initialize (mboot_ptr); // wtf triggers this warning?
In the file included from src / h / system.h: 39: 0, from src / h / multiboot.h: 4, from src / c / kernel.c: 1:
src / h / memory.h: 35: 6: note: expected 'struct multiboot *', but the argument is of type 'struct multiboot *'
void memory_manager_initialize (struct multiboot * mboot_ptr);
Here is the code for my bootloader that calls GRUB.
# Declare constants used for the multiboot header
.set ALIGN, 1<<0
.set MEMINFO, 1<<1
.set MAGIC, 0x1BADB002
.set FLAGS, ALIGN | MEMINFO
.set CHECKSUM, -(MAGIC + FLAGS)
.global .multiboot
.extern code
.extern bss
.extern end
.section .multiboot
#.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
.long .multiboot
.long code
.long bss
.long end
.long _start
.section .text
.global _start
.extern kernel_main
.type _start, @function
_start:
push %esp
push %ebx
cli
call kernel_main
.hang:
jmp .hang
.size _start, . - _start
Here's the code from my kernel where the warning comes from.
int kernel_main(struct multiboot *mboot_ptr, u32int initial_stack)
{
initial_esp = initial_stack;
gdt_initialize();
idt_initialize();
memset((u8int *) &interrupt_handler, 0, sizeof(isr) * 256);
enable_interrupts();
timer_initialize(100);
keyboard_initialize();
keyboard_set_handler(kernel_keyboard_handler);
vga_set_handler(kernel_vga_handler);
memset((u8int *) terminal_buffer, 0, MAX_TERMINAL_BUFFER_SIZE);
memory_manager_initialize(mboot_ptr);
And the called function is defined as
void memory_manager_initialize(struct multiboot *mboot_ptr)