Page 7 of 9
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 12:31 pm
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
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 12:36 pm
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)
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 12:44 pm
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.
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 12:47 pm
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?
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 12:57 pm
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.
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 12:59 pm
by beyondsociety
[attachment deleted by admin]
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 1:00 pm
by jrfritz
So, where do you think I could put my stack (just for testing...i'll think of a better idea later)?
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 1:09 pm
by jrfritz
The boot_pm.asm won't work.
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 1:33 pm
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.
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 1:55 pm
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...
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 2:11 pm
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.
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 2:12 pm
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
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 2:29 pm
by jrfritz
Unexpected, after the IRQ before the IRET you need a
outportb( 0x20, 0x20 );
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 2:30 pm
by Unexpected
Can I do like this:
Code: Select all
IRQ1:
PUSHA
CALL _C_Func
POPA
IRETD
If no then why?
Re:Some IDT Code...in C
Posted: Wed Dec 18, 2002 2:44 pm
by jrfritz
And then in your c function do this:
void getkeyboardirq()
{
int something = inportb( 0x60 );
putch( asciiNonShifted[something] );
outportb( 0x20, 0x20 );
}