keyboard interrupt
-
- Posts: 7
- Joined: Mon Feb 20, 2012 11:34 am
- Location: Italia
keyboard interrupt
Help! I've a problem with keyboard interrupt. I'm sure that Irq handler is right because the timer interrupt prints its message and when I initialize the keyboard interrupt I can see its message too.
But when I press a key I have nothing. I post files. Thanks.
P.S.: I'm following JamesM tutorial and I'm adding keyboard on his structure.
But when I press a key I have nothing. I post files. Thanks.
P.S.: I'm following JamesM tutorial and I'm adding keyboard on his structure.
- Attachments
-
- keyboard.c
- (1.34 KiB) Downloaded 330 times
-
- descriptor_tables.c
- (3.53 KiB) Downloaded 145 times
-
- isr.c
- (2.61 KiB) Downloaded 210 times
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: keyboard interrupt
I noticed a rather questionable style of C and stopped searching for the actual bug in question when I noticed functions with different prototypes across files. Use header files for anything not defined locally, and pass -Wall -Wextra -pedantic -Werror to the compiler to get at least something in order.
After that, the interrupt handler has to do little more than reading the scancode and storing it somewhere. You seem to do a lot of things that are not necessary, and your lack of comments and sensible names make it rather unobvious what you are intending to do.
After that, the interrupt handler has to do little more than reading the scancode and storing it somewhere. You seem to do a lot of things that are not necessary, and your lack of comments and sensible names make it rather unobvious what you are intending to do.
-
- Posts: 7
- Joined: Mon Feb 20, 2012 11:34 am
- Location: Italia
Re: keyboard interrupt
Thank for your suggest. I'm working to remove all warning with your options and now I've only:
ISO C90 forbids mixed declarations and code
I'll try the code and if something goes wrong I'll well comment the code before posting it.
Thanks a lot!
ISO C90 forbids mixed declarations and code
I'll try the code and if something goes wrong I'll well comment the code before posting it.
Thanks a lot!
-
- Posts: 7
- Joined: Mon Feb 20, 2012 11:34 am
- Location: Italia
Re: keyboard interrupt
I always see "keyboard interrupt recieved" only when I enable it. But when I press a key the interrupt isn't sent and bochs gives me:
"internal keyboard buffer full, ignoring scancode"
This time I've added comments.
"internal keyboard buffer full, ignoring scancode"
This time I've added comments.
- Attachments
-
- keyboard.c
- (1.38 KiB) Downloaded 151 times
-
- keyboard.h
- (293 Bytes) Downloaded 90 times
-
- Posts: 7
- Joined: Mon Feb 20, 2012 11:34 am
- Location: Italia
Re: keyboard interrupt
I've tried Qemu but is the opposite. It gets a lot of keyboard interrupt and crashes.
-
- Posts: 7
- Joined: Mon Feb 20, 2012 11:34 am
- Location: Italia
Re: keyboard interrupt
On qemu keyboard interrupt works right on Bochs not.
Is it possible?
Here is it my .bochrc:
config_interface: textconfig
#display_library: sdl
display_library: x, options="gui_debug"
romimage: file=/usr/share/bochs/BIOS-bochs-latest, #address=0xf0000
megs: 32
vgaromimage: file=/usr/share/vgabios/vgabios.bin
floppya: 1_44=floppy.img, status=inserted
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata1: enabled=0, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata2: enabled=0, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=11
ata3: enabled=0, ioaddr1=0x168, ioaddr2=0x360, irq=9
#ata0-master: type=disk, path="c.img", mode=flat, cylinders=20, heads=16, spt=63
ata0-slave: type=cdrom, path="/dev/cdrom", status=inserted
boot: floppy, disk
cpu: ips=500000
floppy_bootsig_check: disabled=0
log: /dev/stdout
panic: action=ask
error: action=report
info: action=report
debug: action=ignore
debugger_log: -
com1: enabled=1, dev=/dev/ttyS0
#parport1: enabled=1, file="/dev/lp0"
sb16: midimode=1, midi=/dev/midi00, wavemode=1, wave=/dev/dsp, loglevel=2, log=/dev/stdout, dmatimer=600000
vga_update_interval: 300000
keyboard_serial_delay: 250
keyboard_paste_delay: 100000
#floppy_command_delay: 500
mouse: enabled=1
private_colormap: enabled=0
#ne2k: ioaddr=0x240, irq=9, mac=b0:c4:20:00:00:00, ethmod=linux, ethdev=eth0
#keyboard_mapping: enabled=0, map=/usr/share/bochs/keymaps/x11-pc-de.map
#keyboard_type: mf
#user_shortcut: keys=ctrlaltdel
#magic_break: enabled=1
#cmosimage: cmos.img
#load32bitOSImage: os=nullkernel, path=../kernel.img, iolog=../vga_io.log
#load32bitOSImage: os=linux, path=../linux.img, iolog=../vga_io.log, initrd=../initrd.img
#i440fxsupport: enabled=1
#usb_uhci: enabled=1, ioaddr=0xFF80, irq=10
#text_snapshot_check: enable
Is it possible?
Here is it my .bochrc:
config_interface: textconfig
#display_library: sdl
display_library: x, options="gui_debug"
romimage: file=/usr/share/bochs/BIOS-bochs-latest, #address=0xf0000
megs: 32
vgaromimage: file=/usr/share/vgabios/vgabios.bin
floppya: 1_44=floppy.img, status=inserted
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata1: enabled=0, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata2: enabled=0, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=11
ata3: enabled=0, ioaddr1=0x168, ioaddr2=0x360, irq=9
#ata0-master: type=disk, path="c.img", mode=flat, cylinders=20, heads=16, spt=63
ata0-slave: type=cdrom, path="/dev/cdrom", status=inserted
boot: floppy, disk
cpu: ips=500000
floppy_bootsig_check: disabled=0
log: /dev/stdout
panic: action=ask
error: action=report
info: action=report
debug: action=ignore
debugger_log: -
com1: enabled=1, dev=/dev/ttyS0
#parport1: enabled=1, file="/dev/lp0"
sb16: midimode=1, midi=/dev/midi00, wavemode=1, wave=/dev/dsp, loglevel=2, log=/dev/stdout, dmatimer=600000
vga_update_interval: 300000
keyboard_serial_delay: 250
keyboard_paste_delay: 100000
#floppy_command_delay: 500
mouse: enabled=1
private_colormap: enabled=0
#ne2k: ioaddr=0x240, irq=9, mac=b0:c4:20:00:00:00, ethmod=linux, ethdev=eth0
#keyboard_mapping: enabled=0, map=/usr/share/bochs/keymaps/x11-pc-de.map
#keyboard_type: mf
#user_shortcut: keys=ctrlaltdel
#magic_break: enabled=1
#cmosimage: cmos.img
#load32bitOSImage: os=nullkernel, path=../kernel.img, iolog=../vga_io.log
#load32bitOSImage: os=linux, path=../linux.img, iolog=../vga_io.log, initrd=../initrd.img
#i440fxsupport: enabled=1
#usb_uhci: enabled=1, ioaddr=0xFF80, irq=10
#text_snapshot_check: enable
Re: keyboard interrupt
Switch to C99. (-std=c99). Job done.spaghettios wrote:Thank for your suggest. I'm working to remove all warning with your options and now I've only:
ISO C90 forbids mixed declarations and code
I'll try the code and if something goes wrong I'll well comment the code before posting it.
Thanks a lot!
-
- Posts: 7
- Joined: Mon Feb 20, 2012 11:34 am
- Location: Italia
Re: keyboard interrupt
I've moved all declaration up in my functions because I'm tryng to respect more standards and to have a cleaner and more portable code. For exemple SDCC need this convention. So far, after some work I've got a source that compile with -pedantic, -Wall ,-Wextra and -Werror flags.
Another question, now I have my kernel well working both on qemu and my real computer, only bochs seems not to recieve keyboard interrupt. What about it, is it possible? Many people use bochs without troubles so I can't solving the problem by leaving bochs because of a "bug".
Another question, now I have my kernel well working both on qemu and my real computer, only bochs seems not to recieve keyboard interrupt. What about it, is it possible? Many people use bochs without troubles so I can't solving the problem by leaving bochs because of a "bug".
Re: keyboard interrupt
Sometimes irq is fired prior to scancode available, so you should check for that. Also don't forget to acknowledge. This is how I do this:
This is the rough C version of what I have in assembly. This the original:
It's tested on qemu, bochs, virtualbox and real hardware, works fine everywhere.
Code: Select all
int i,scancode;
//get scancode with "timeout"
for(i=1000;i>0;i++) {
if(inb(0x64)&1==0) continue; //check if scancode is ready
scancode=inb(0x60); //get the scancode
outb(inb(0x61)); //acknowledge
break;
}
if(i>0) printf("got scancode=%d\n",scancode); else printf("spuorious irq");
Code: Select all
drv.ps2.event_keyboard:
xor rax, rax
xor rcx, rcx
mov cx, 1000
.waitkey: in al, 64h
dec cx
jz interrupt_irqs.false_irq
and al, 01h
jz .waitkey
in al, 60h
mov cl, al
in al, 61h
out 61h, al
mov al, cl
;scancode in al
-
- Posts: 7
- Joined: Mon Feb 20, 2012 11:34 am
- Location: Italia
Re: keyboard interrupt
I' ll reinstall bochs because also in this way doesn't work.
Thanks for help!
Thanks for help!
Re: keyboard interrupt
Just a small note:
was it really what you want: for(i=1000;i>0;i++)
?
was it really what you want: for(i=1000;i>0;i++)
?
Re: keyboard interrupt
Somebody pay attention Yep, it should be i--Nable wrote:Just a small note:
was it really what you want: for(i=1000;i>0;i++)
?