IDT+GDT Pointer
Posted: Tue Jan 28, 2003 2:39 pm
Salut messieurs et dames!
I am now in the point in development of operating system, where I have sucessfully loaded Gdt & IDT and also installed some pretty neat irq & exception handlers, and now, i want to move that whole thing to memory location above 1 mb.
I understand, that I have to build according values for the gdt register as well as the idt register, where in both cas3es is as example the idtr in pseudocode:
idtr: unsigned int limit; unsigned long base;
in limit I have to put a value representing the length of the idt: (8 * nr.of entries p.ex. 8*60) In nasm this is idt-end - idt - 1.
In base, i have to put the PHYSICAL address of the which shall be a pointer containing the value of DS-Base & the offset from DS-base to the Location of the idt, sinc in most examples I have studied, there is some Left shift of bits after one hase moved DS-Base to some register, and after that comes a move ?from an other register containing the relative adress of the idt to the register containing DS-Base(already shifted).
So i would code this in nasm:
mov ax,ds
mov bx,[idt]
shl eax,16 -->shift eax by 16 bits to left.
or eax,ebx --> to get the value of ebx to eax, so eax contains the 32 bit physical address.
mov [idtr+6], dword[eax] --> store physical adress in idtr
mov ax,8 (size of idt entries)
mov bx,60 (nr of idt entries)
mul ax,bx
mov [idtr],ax -> store limit in idtr
lidt [idtr]
Is this a correct way to build an appropriate IDT-Register-structure?
would be nice, because I am now to dependent from loading the kernel beneath 1 mb. I am kinda stuck to the butt with an idt fixed in my assembler files. I want to implement multitasking with the aid of the timer interrupt, and I want to add memory management to that thing as soon as possible.
thank you in advance for your help, folks!
I am now in the point in development of operating system, where I have sucessfully loaded Gdt & IDT and also installed some pretty neat irq & exception handlers, and now, i want to move that whole thing to memory location above 1 mb.
I understand, that I have to build according values for the gdt register as well as the idt register, where in both cas3es is as example the idtr in pseudocode:
idtr: unsigned int limit; unsigned long base;
in limit I have to put a value representing the length of the idt: (8 * nr.of entries p.ex. 8*60) In nasm this is idt-end - idt - 1.
In base, i have to put the PHYSICAL address of the which shall be a pointer containing the value of DS-Base & the offset from DS-base to the Location of the idt, sinc in most examples I have studied, there is some Left shift of bits after one hase moved DS-Base to some register, and after that comes a move ?from an other register containing the relative adress of the idt to the register containing DS-Base(already shifted).
So i would code this in nasm:
mov ax,ds
mov bx,[idt]
shl eax,16 -->shift eax by 16 bits to left.
or eax,ebx --> to get the value of ebx to eax, so eax contains the 32 bit physical address.
mov [idtr+6], dword[eax] --> store physical adress in idtr
mov ax,8 (size of idt entries)
mov bx,60 (nr of idt entries)
mul ax,bx
mov [idtr],ax -> store limit in idtr
lidt [idtr]
Is this a correct way to build an appropriate IDT-Register-structure?
would be nice, because I am now to dependent from loading the kernel beneath 1 mb. I am kinda stuck to the butt with an idt fixed in my assembler files. I want to implement multitasking with the aid of the timer interrupt, and I want to add memory management to that thing as soon as possible.
thank you in advance for your help, folks!