Page 1 of 1
keyboard interrupt
Posted: Wed Feb 22, 2012 3:59 pm
by spaghettios
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.
Re: keyboard interrupt
Posted: Wed Feb 22, 2012 6:12 pm
by Combuster
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.
Re: keyboard interrupt
Posted: Thu Feb 23, 2012 3:12 am
by spaghettios
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!
Re: keyboard interrupt
Posted: Thu Feb 23, 2012 3:34 am
by spaghettios
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.
Re: keyboard interrupt
Posted: Thu Feb 23, 2012 3:50 am
by spaghettios
I've tried Qemu but is the opposite. It gets a lot of keyboard interrupt and crashes.
Re: keyboard interrupt
Posted: Thu Feb 23, 2012 4:54 am
by spaghettios
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
Re: keyboard interrupt
Posted: Thu Feb 23, 2012 5:38 pm
by JamesM
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!
Switch to C99. (-std=c99). Job done.
Re: keyboard interrupt
Posted: Fri Feb 24, 2012 2:56 am
by spaghettios
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".
Re: keyboard interrupt
Posted: Fri Feb 24, 2012 3:15 am
by turdus
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:
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");
This is the rough C version of what I have in assembly. This the original:
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
It's tested on qemu, bochs, virtualbox and real hardware, works fine everywhere.
Re: keyboard interrupt
Posted: Fri Feb 24, 2012 7:50 am
by spaghettios
I' ll reinstall bochs because also in this way doesn't work.
Thanks for help!
Re: keyboard interrupt
Posted: Mon Feb 27, 2012 12:37 pm
by Nable
Just a small note:
was it really what you want: for(i=1000;i>0;i++)
?
Re: keyboard interrupt
Posted: Mon Feb 27, 2012 12:54 pm
by turdus
Nable wrote:Just a small note:
was it really what you want: for(i=1000;i>0;i++)
?
Somebody pay attention
Yep, it should be i--