Working on GitHub - stakach/crystal-kernel: yet another crystal kernel, inspired by ffwff/lilith and it’s coming along quite well however struggling to get the memory address of a function.
When setting up the interrupt table using the code from lilith the lilith implementation does:
However in assembly the
->kernel_cpu_exception0 effectively creates a wrapper function
push rax call kernel_cpu_exception0 pop rax ret
So we actually have the address of this wrapper function instead of the
kernel_cpu_exception0 function. The address of the actual function is important to handle interrupts as we need to preserve CPU state before calling any additional functions (stack needs to be clean too)
I tried doing
fun kernel_cpu_exception0() # ... end lib Kernel $kernel_cpu_exception0 : Int64 end pointerof(Kernel.kernel_cpu_exception0).address
However it looks like the compiler tries to avoid having the symbols clash and mangles the name? so that doesn’t work.