How do i get my keyboard handler to work?
How do i get my keyboard handler to work?
I'm trying to get my keyboard handler to be able to work properly.
However, I can't seem to get a grip on this.
My tries:
Polling:
Polling is the only one that I can get working and actually go to the next character. However, this puts way too many characters when I hold this for less than a second. This can display upwards of 4 characters when I hold the key for 0.75 seconds, instead of the normal 1 character. This also displayed unwanted spaces/nulls.
Using interrupts:
Using the (proper) normal way that uses Interrupts doesn't help, too. This displays absolutely nothing. Nothing. Nothing happens. It's like it's frozen.
Nothing displays on the screen.
However, I can't seem to get a grip on this.
My tries:
Polling:
Polling is the only one that I can get working and actually go to the next character. However, this puts way too many characters when I hold this for less than a second. This can display upwards of 4 characters when I hold the key for 0.75 seconds, instead of the normal 1 character. This also displayed unwanted spaces/nulls.
Using interrupts:
Using the (proper) normal way that uses Interrupts doesn't help, too. This displays absolutely nothing. Nothing. Nothing happens. It's like it's frozen.
Nothing displays on the screen.
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: How do i get my keyboard handler to work?
By looking at your GitHub repo, you don't know how to properly handle interrupts.
Seriously, why not try to do it yourself once?
Seriously, why not try to do it yourself once?
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: How do i get my keyboard handler to work?
What? I did write most of the code myself.omarrx024 wrote:By looking at your GitHub repo, you don't know how to properly handle interrupts.
Seriously, why not try to do it yourself once?
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: How do i get my keyboard handler to work?
Why don't you read the wiki and then try to write code yourself?DixiumOS wrote:What? I did write most of the code myself.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: How do i get my keyboard handler to work?
I do.omarrx024 wrote:Why don't you read the wiki and then try to write code yourself?DixiumOS wrote:What? I did write most of the code myself.
And seriously, if you want to help someone, don't bring up a completely different topic with no relation to this and then say bad things. Please, don't.
If you don't feel like helping, then don't. Just don't bring up a discussion that never solved anything.
Re: How do i get my keyboard handler to work?
Do you not understand why people are getting frustrated though? You don't really seem to read what people say and make thousands of threads on the same topic.DixiumOS wrote:I do.omarrx024 wrote:Why don't you read the wiki and then try to write code yourself?DixiumOS wrote:What? I did write most of the code myself.
And seriously, if you want to help someone, don't bring up a completely different topic with no relation to this and then say bad things. Please, don't.
If you don't feel like helping, then don't. Just don't bring up a discussion that never solved anything.
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
Compiler Development Forum
Re: How do i get my keyboard handler to work?
Do I? Oh, sorry.zenzizenzicube wrote:snip
Anyway, can we return 0; to our question?
- sleephacker
- Member
- Posts: 97
- Joined: Thu Aug 06, 2015 6:41 am
- Location: Netherlands
Re: How do i get my keyboard handler to work?
Have you tried putting:right at the start of your keyboard handler, or even inside the IRQ handler, just to make sure it actually gets called?
Are you sure the compiler doesn't do anything unexpected/undesired in your ISRs, such as changing the stack pointers (esp/ebp)?
I think the article about ISRs might be of help.
Code: Select all
terminal_writechar("A", ...);
Are you sure the compiler doesn't do anything unexpected/undesired in your ISRs, such as changing the stack pointers (esp/ebp)?
I think the article about ISRs might be of help.
Re: How do i get my keyboard handler to work?
Doesn't work...sleephacker wrote:Have you tried putting:right at the start of your keyboard handler, or even inside the IRQ handler, just to make sure it actually gets called?Code: Select all
terminal_writechar("A", ...);
Are you sure the compiler doesn't do anything unexpected/undesired in your ISRs, such as changing the stack pointers (esp/ebp)?
I think the article about ISRs might be of help.
Ugh, looks like I'll need to fix my IDT code.
EDIT: Nope. The keyboard just went on vacation and forgot to fire IRQ1.
Last edited by DixiumOS on Sat Jan 14, 2017 1:59 pm, edited 1 time in total.
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: How do i get my keyboard handler to work?
If I could offer two pieces of advice: first, if you are using GCC for your compiler, and want to use a C function for an interrupt handler, use the __attribute__ ((interrupt)) function attribute, rather than emitting an IRET manually. It does require a certain amount of GCC-specific and non-portable code, but since this is an interrupt handler that's hardly a concern. Take note that you will need a data structure for representing the interrupt frame, as explained in the GCC documents and the Intel manuals.DixiumOS wrote:Doesn't work...sleephacker wrote:Have you tried putting:right at the start of your keyboard handler, or even inside the IRQ handler, just to make sure it actually gets called?Code: Select all
terminal_writechar("A", ...);
Are you sure the compiler doesn't do anything unexpected/undesired in your ISRs, such as changing the stack pointers (esp/ebp)?
I think the article about ISRs might be of help.
Ugh, looks like I'll need to fix my IDT code.
Second, you should be redirect all of the interrupt vectors to a single IDT entry rather than having several dozen which are repeating the same code. Indeed, I would recommend initializing the entire IDT in this manner (with a default handler that issues a system initialization error message), and then adding the actual entries you need, just as a backstop in case of a programming error.
Code: Select all
void addisrfunctions(void) {
for (int i = 0; i < 256; i++) {
idt_set_gate(i, (unsigned)isr_default, 0x08, 0x8E);
}
// now that you have everything initialized, add the
// actual interrupt handlers to the vectors you want
}
Code: Select all
__attribute__ ((interrupt)) void isr_default(struct interrupt_frame *frame) {
// for now, just put this as a stub that will panic
// the kernel, you can write a more elegant
// default handler later
terminal_clrscr();
terminal_writestring("Fatal error - unsupported interrupt", BLACK, WHITE, 0, 0);
panic(); // you will need to write this function, I guess
}
Last edited by Schol-R-LEA on Sat Jan 14, 2017 2:07 pm, edited 2 times in total.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
-
- Member
- Posts: 501
- Joined: Wed Jun 17, 2015 9:40 am
- Libera.chat IRC: glauxosdever
- Location: Athens, Greece
Re: How do i get my keyboard handler to work?
Hi,
Another problem is that he doesn't send an EOI in interrupt handlers.
Regards,
glauxosdever
Another problem is that he doesn't send an EOI in interrupt handlers.
Regards,
glauxosdever
Re: How do i get my keyboard handler to work?
Optimized my IDT code to work and now it's randomly issuing interrupts before triple faulting (literally 7600 lines of logs from QEMU before it triple faulted). It isn't at executing interrupts, but rather loading the IDT.
The last few lines tell that it's crashing at pop %ds in isr8 and pop %ds in isr13.
EDIT: I also realized as this is getting to the last line, esp decreases.
EDIT: Now it works. And IRQ1 never fires. Dammit.
The last few lines tell that it's crashing at pop %ds in isr8 and pop %ds in isr13.
EDIT: I also realized as this is getting to the last line, esp decreases.
EDIT: Now it works. And IRQ1 never fires. Dammit.
IRQ1 never gets fired
Just to say: the IDT is fine as IRQ0 gets fired constantly by the PIT. It is seen in the QEMU logs.
The IRQ1 is correctly loaded and is the proper example of a keyboard handler.
Resuming to the question:
My IRQ1 handler never gets called by my keyboard. IRQ0, however, gets constantly called, and the QEMU logs report it.
How do i fix this?
seesignatureforcode
The IRQ1 is correctly loaded and is the proper example of a keyboard handler.
Resuming to the question:
My IRQ1 handler never gets called by my keyboard. IRQ0, however, gets constantly called, and the QEMU logs report it.
How do i fix this?
seesignatureforcode
- sleephacker
- Member
- Posts: 97
- Joined: Thu Aug 06, 2015 6:41 am
- Location: Netherlands
Re: IRQ1 never gets fired
Did you unmask IRQ1 when setting up the PIC?
Did you configure the keyboard to send interrupts during initialisation?
Did you configure the keyboard to send interrupts during initialisation?
Re: IRQ1 never gets fired
Nope about unmasking.sleephacker wrote:Did you unmask IRQ1 when setting up the PIC?
Did you configure the keyboard to send interrupts during initialisation?
Now it works except i only get one IRQ, and i do send an EOI.