Some IDT Code...in C

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Some IDT Code...in C

Post by df »

this is my keyboard isr

Code: Select all

    .globl   _keyboard_isr
    .align   4
_keyboard_isr:
    pushl   %eax
    pushl   %ds
    pushl   %es
    pushl   %fs
    pushl   %gs

    movl    $0x10, %eax
    movw    %ax, %ds
    movw    %ax, %es
    movw    %ax, %fs
    movw    %ax, %gs

   call   _keyboard

    movl    $0x20, %eax
    outb    %al, $0x20

   popl   %gs
   popl   %fs
   popl   %es
   popl   %ds
    popl   %eax
    iret
-- Stu --
jrfritz

Re:Some IDT Code...in C

Post by jrfritz »

Sorry but I would like know the virtual address thing...

And if you used my inasm("") macro you wouldn't have to have externel modules and you could use NASM code.(mostly)
DarylD

Re:Some IDT Code...in C

Post by DarylD »

I probably didn't explain myself very well, when I say virtual address what I mean is have you got a GDT and page tables set up that will allow access to 0xFFFFFFFF because that address would be 4GB, so unless you have 4GB of ram it will fail, and even then I doubt it would work.

You need to set esp to point to an area of physical memory, where is your stack defined in your boot.asm?

Hang on, let me have a look at your code see if I can suggest anything.
jrfritz

Re:Some IDT Code...in C

Post by jrfritz »

My stack is in the:
mov ax, 0x10
mov ss, ax
mov esp, 0xFFFF

part.

Wait...if I want 0xFFFFFFFF don't I need the a20?
DarylD

Re:Some IDT Code...in C

Post by DarylD »

Yes, but you need to decide where your stack is going. For example in my case, I use _end (which is a symbol created by gcc) to work out the end of my kernel, then I set aside a few pages after this and set esp to end of this region, this way I know that it will not get clobbered and that it also isn't off somewhere strange (which you really don't want because of inexplicable bugs later.)

Basically, try not to use a "guessed" value for esp, it probably won't work at all, if it does, it will be unreliable.
beyondsociety

Re:Some IDT Code...in C

Post by beyondsociety »

[attachment deleted by admin]
jrfritz

Re:Some IDT Code...in C

Post by jrfritz »

So, where do you think I could put my stack (just for testing...i'll think of a better idea later)?
jrfritz

Re:Some IDT Code...in C

Post by jrfritz »

The boot_pm.asm won't work.
jrfritz

Re:Some IDT Code...in C

Post by jrfritz »

Ok...the problem is not my stack.

The problem is that I get a GPF. Why? I'm using the exact same code I posted before.
Unexpected

Re:Some IDT Code...in C

Post by Unexpected »

Thnx df ;)
What is doing this code:

Code: Select all

     movl  $0x10, %eax
     movw  %ax, %ds
     movw  %ax, %es
     movw  %ax, %fs
     movw  %ax, %gs
Why my IRQ calls only one time?
Next time when I pressing a key, IRQ doesn't call...
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Some IDT Code...in C

Post by df »

you realise setting your stack to 0xffff , it should be aligned on 4 byte boundary, so 0x10000 or 0xfffc, etc. since your pushing dwords in pmode, cpu is optimised for dword alignment.

if you need to put kernel stack somewhere.. have some data space in your kernel just for kernel stack, and point your esp to that...

while my kernel is setting up, my esp situated at 512kb mark.
-- Stu --
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Some IDT Code...in C

Post by df »

Unexpected wrote: Thnx df ;)
What is doing this code:

Code: Select all

     movl  $0x10, %eax
     movw  %ax, %ds
     movw  %ax, %es
     movw  %ax, %fs
     movw  %ax, %gs
Why my IRQ calls only one time?
Next time when I pressing a key, IRQ doesn't call...
my gdt selectors = null 0, code32 (8), data32 (0x10)
so its putting data32 into ds/es/fs/gs
-- Stu --
jrfritz

Re:Some IDT Code...in C

Post by jrfritz »

Unexpected, after the IRQ before the IRET you need a

outportb( 0x20, 0x20 );
Unexpected

Re:Some IDT Code...in C

Post by Unexpected »

Can I do like this:

Code: Select all

IRQ1:
PUSHA
CALL _C_Func
POPA
IRETD
If no then why?
jrfritz

Re:Some IDT Code...in C

Post by jrfritz »

And then in your c function do this:

void getkeyboardirq()
{
   int something = inportb( 0x60 );

   putch( asciiNonShifted[something] );

   outportb( 0x20, 0x20 );
}
Post Reply