mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
The rt0_64 code will load a blank IDT with 256 entries (the max number of supported interrupts in the x86_64 architecture). Each IDT entry is set as *not present* but its handler is set to a dedicated gate entrypoint defined in the rt0 code. A gate entrypoint is defined for each interrupt number using a nasm macro. Each entrypoint will then use the interrupt number to index a list of pointers (defined and managed by the Go assembly code in the irq pkg) to the registered interrupt handlers and push its address on the stack before jumping to one of the two available gate dispatching functions (some interrupts also push an error code to the stack which must be popped before returning from the interrupt handler): - _rt0_64_gate_dispatcher_with_code - _rt0_64_gate_dispatcher_without_code Both dispatchers operate in the same way: - they save the original registers - they invoke the interrupt handler - they restore the original registers - ensure that the stack pointer (rsp) points to the exception frame pushed by the CPU The difference between the dispatchers is that the "with_code" variant will invoke a handler with signature `func(code, &frame, ®s)` and ensure that the code is popped off the stack before returning from the interrupt while the "without_code" variant will invoke a handler with signature `func(&frame, ®s)`
Description
Languages
Go
84.9%
ASL
10.2%
Assembly
4%
Makefile
0.9%