growlnx wrote:
Any ideas on how to get around this problem without resorting to high level?
You can calculate the IDT entries in run-time instead of using macros. But I'd like to point out that it is very uncommon not to load the kernel at fixed address, therefore chances are good no relocation needed no matter the executable format (elf, pe, coff, aout etc.). In i386 elf (if it's not compiled as shared library) then the program headers tells the loader (GRUB) where to load the segments.
Anyway, if you really want a relocatable kernel, then something like:
Code:
mov edi, idt_start
mov eax, label1 ; relocateable, as it has the entire label
call store_idt
mov eax, label2
call store_idt
; ... etc.
; --- store one IDT entry IN: edi=ptr to idt, eax=label OUT: edi=incremented ---
store_idt:
mov ebx, eax ; do the shifting and masking in run-time
stosw ; store first part in IDT
mov eax, 08e0008
stosd
mov eax, ebx
shr eax, 16
stosw ; store second part in IDT
ret
Note these are not necessarily valid IDT operations, just examples. Do not copy'n'paste
store_idt as-is.
Cheers,
bzt