Re:Keyboard Handler
Posted: Fri Jul 29, 2005 6:02 am
Yes, I read it and the papers/documents at BonaFide too.Solar wrote: You checked the FAQ? (Too lazy to c&p the link, just click on the mega-tokyo.com banner...)
Yes, I read it and the papers/documents at BonaFide too.Solar wrote: You checked the FAQ? (Too lazy to c&p the link, just click on the mega-tokyo.com banner...)
Thanks Kim, but when I wrote "(...) where to continue (...)" I meant that relating to the keyboard issueKim wrote: You could add paging support with a higherhalf kernel.
And maybe try out multitasking.
Code: Select all
.globl _irq1_wrapper
.align 4
_irq1_wrapper: NOP
IRET
That's the reason why I asked here for helpAR wrote: I cannot make sense of your IDT code, by casting the various fields to "word" you are truncating the high 16 bits. Also 1 != 0x21.
Code: Select all
void lidt(void *base, dword size)
{
dword i[2];
i[0] = size;
i[1] = (dword) base;
asm ("lidt (%0)" :: "p" (((char *)i)+2));
}
Code: Select all
/* target segment selector (31-16) + offset in target segment low (15-0) */
idt[IRQ1*2] = (word)(0x08<<16) + (word)((*_irq1_wrapper) & 0x0000FFFF);
/* offset in target segment high (31-16) + present (15) + DPL (14-13) +
0 (12) + type (interrupt gate) (11-8) + 000 (7-5) + dword-count (4-0) */
idt[IRQ1*2+1] = (word)((*_irq1_wrapper) & 0xFFFF0000) + (1<<15) + (0<<13) + \
(0<<12) + (0xE<<8) + (0<<5) + 0;
Code: Select all
#define IRQ1 0x21
idt[IRQ1*2] = (0x08<<16) + ((*_irq1_wrapper) & 0x0000FFFF);
idt[IRQ1*2+1] = ((*_irq1_wrapper) & 0xFFFF0000) + (1<<15) + (0<<13) + (0<<12) + (0xE<<8) + (0<<5) + 0;
If I remove the '*' like this:AR wrote: (...) I think you're dereferencing the IRQ handler (instead of the address you're actually using the first opcode)
Code: Select all
idt[IRQ1*2] = (0x08<<16) + ((_irq1_wrapper) & 0x0000FFFF);
idt[IRQ1*2+1] = ((_irq1_wrapper) & 0xFFFF0000) + (1<<15) + (0<<13) + (0<<12) + (0xE<<8) + (0<<5) + 0;
Code: Select all
kernel.c: In function `_main':
kernel.c:133: error: invalid operands to binary &
kernel.c:137: error: invalid operands to binary &
Creating this struct:I suggest you use an array of IDT structs instead of that as it is just confusing.
Code: Select all
struct _idt_entry
{
word offset_low;
word selector;
byte dword_count:5;
byte unused:3;
byte type:5;
byte dpl:2;
byte present:1;
word offset_high;
} __attribute__((__packed__));
typedef struct _idt_entry idt_entry;
Code: Select all
kernel.c:104: warning: type of bit-field `dword_count' is a GCC extension
kernel.c:105: warning: type of bit-field `unused' is a GCC extension
kernel.c:106: warning: type of bit-field `type' is a GCC extension
kernel.c:107: warning: type of bit-field `dpl' is a GCC extension
kernel.c:108: warning: type of bit-field `present' is a GCC extension
make: *** [kernel.o] Error 1
Code: Select all
extern void _irq1_wrapper();
... ((dword)&_irq1_wrapper) ...
Code: Select all
extern void _irq1_wrapper();
(...)
idt[IRQ1*2] = (0x08<<16) + (((dword)&_irq1_wrapper) & 0x0000FFFF);
idt[IRQ1*2+1] = (((dword)&_irq1_wrapper) & 0xFFFF0000) + (1<<15) + (0<<13) + (0<<12) + (0xE<<8) + (0<<5) + 0;