internal keyboard buffer full, ignoring scancode
Posted: Tue Dec 20, 2011 12:51 pm
I am developing a new os from using help of this tutorial: http://www.jamesmolloy.co.uk/tutorial_h ... setup.html. I developed code for reading keyboard input as follows.
isr.c
My software interrupts are working fine. But keyboard values are not showing. My Bochs log is below.
What is the error. Please not that put function is implemented and working fine. Can anyone help me I am new to OS development. Thanks!
Code: Select all
#include <system.h>
#include <screen.h>
unsigned char kbdus[128] =
{
0, 27, '1', '2', '3', '4', '5', '6', '7', '8','9', '0', '-', '=', '\b',
'\t', 'q', 'w', 'e', 'r','t', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0,
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z',
'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0, '*',
0, /* Alt */
' ', /* Space bar */
0, /* Caps lock */
0, /* 59 - F1 key ... > */
0, 0, 0, 0, 0, 0, 0, 0,
0, /* < ... F10 */
0, /* 69 - Num lock*/
0, /* Scroll Lock */
0, /* Home key */
0, /* Up Arrow */
0, /* Page Up */
'-',
0, /* Left Arrow */
0,
0, /* Right Arrow */
'+',
0, /* 79 - End key*/
0, /* Down Arrow */
0, /* Page Down */
0, /* Insert Key */
0, /* Delete Key */
0, 0, 0,
0, /* F11 Key */
0, /* F12 Key */
0, /* All other keys are undefined */
};
void keyboard_handler(registers_t regs)
{
unsigned char scancode;
/* Read from the keyboard's data buffer */
scancode = inb(0x60);
/* If the top bit of the byte we read from the keyboard is
* set, that means that a key has just been released */
if (scancode & 0x80)
{
/* You can use this one to see if the user released the
* shift, alt, or control keys... */
}
else
{
put(kbdus[scancode]);
}
}
void init_keyboard()
{
register_interrupt_handler(IRQ1, &keyboard_handler);
}
Code: Select all
#include <system.h>
#include <screen.h>
isr_t interrupt_handlers[256];
void register_interrupt_handler(char n, isr_t handler)
{
interrupt_handlers[n] = handler;
}
void isr_handler(registers_t regs)
{
print("recieved interrupt: ");
print_hex(regs.int_no);
put('\n');
}
void irq_handler(registers_t regs)
{
// Send an EOI (end of interrupt) signal to the PICs.
// If this interrupt involved the slave.
if (regs.int_no >= 40)
{
// Send reset signal to slave.
outb(0xA0, 0x20);
}
// Send reset signal to master. (As well as slave, if necessary).
outb(0x20, 0x20);
if (interrupt_handlers[regs.int_no] != 0)
{
isr_t handler = interrupt_handlers[regs.int_no];
handler(regs);
}
}
Code: Select all
00000000000i[ ] Bochs x86 Emulator 2.4.5
00000000000i[ ] Build from CVS snapshot, on April 25, 2010
00000000000i[ ] System configuration
00000000000i[ ] processors: 1 (cores=1, HT threads=1)
00000000000i[ ] A20 line support: yes
00000000000i[ ] CPU configuration
00000000000i[ ] level: 6
00000000000i[ ] SMP support: no
00000000000i[ ] APIC support: yes
00000000000i[ ] FPU support: yes
00000000000i[ ] MMX support: yes
00000000000i[ ] 3dnow! support: no
00000000000i[ ] SEP support: yes
00000000000i[ ] SSE support: sse2
00000000000i[ ] XSAVE support: no
00000000000i[ ] AES support: no
00000000000i[ ] MOVBE support: no
00000000000i[ ] x86-64 support: yes
00000000000i[ ] 1G paging support: no
00000000000i[ ] MWAIT support: no
00000000000i[ ] VMX support: no
00000000000i[ ] Optimization configuration
00000000000i[ ] RepeatSpeedups support: yes
00000000000i[ ] Trace cache support: yes
00000000000i[ ] Fast function calls: yes
00000000000i[ ] Devices configuration
00000000000i[ ] ACPI support: yes
00000000000i[ ] NE2000 support: yes
00000000000i[ ] PCI support: yes, enabled=yes
00000000000i[ ] SB16 support: yes
00000000000i[ ] USB support: yes
00000000000i[ ] VGA extension support: vbe
00000000000i[MEM0 ] allocated memory at 0x7fdafb6c1010. after alignment, vector=0x7fdafb6c2000
00000000000i[MEM0 ] 32.00MB
00000000000i[MEM0 ] mem block size = 0x00100000, blocks=32
00000000000i[MEM0 ] rom at 0xe0000/131072 ('/usr/share/bochs/BIOS-bochs-latest')
00000000000i[MEM0 ] rom at 0xc0000/38400 ('/usr/share/bochs/VGABIOS-lgpl-latest')
00000000000i[VTIME] using 'realtime pit' synchronization method
00000000000i[ ] lt_dlhandle is 0x1c05f30
00000000000i[PLGIN] loaded plugin libbx_cmos.so
00000000000i[ ] lt_dlhandle is 0x1c06930
00000000000i[PLGIN] loaded plugin libbx_dma.so
00000000000i[ ] lt_dlhandle is 0x1c07370
00000000000i[PLGIN] loaded plugin libbx_pic.so
00000000000i[ ] lt_dlhandle is 0x1c07bb0
00000000000i[PLGIN] loaded plugin libbx_pit.so
00000000000i[ ] lt_dlhandle is 0x1c08500
00000000000i[PLGIN] loaded plugin libbx_vga.so
00000000000i[ ] lt_dlhandle is 0x1c08c30
00000000000i[PLGIN] loaded plugin libbx_floppy.so
00000000000i[ ] lt_dlhandle is 0x1c09850
00000000000i[PLGIN] loaded plugin libbx_pci.so
00000000000i[ ] lt_dlhandle is 0x1c0a3d0
00000000000i[PLGIN] loaded plugin libbx_pci2isa.so
00000000000i[ ] lt_dlhandle is 0x1c0ad10
00000000000i[PLGIN] loaded plugin libbx_unmapped.so
00000000000i[ ] lt_dlhandle is 0x1c0b4d0
00000000000i[PLGIN] loaded plugin libbx_biosdev.so
00000000000i[ ] lt_dlhandle is 0x1c0bf10
00000000000i[PLGIN] loaded plugin libbx_speaker.so
00000000000i[ ] lt_dlhandle is 0x1c0c6a0
00000000000i[PLGIN] loaded plugin libbx_extfpuirq.so
00000000000i[ ] lt_dlhandle is 0x1c0cf10
00000000000i[PLGIN] loaded plugin libbx_gameport.so
00000000000i[ ] lt_dlhandle is 0x1c0d880
00000000000i[PLGIN] loaded plugin libbx_pci_ide.so
00000000000i[ ] lt_dlhandle is 0x1c0e230
00000000000i[PLGIN] loaded plugin libbx_acpi.so
00000000000i[ ] lt_dlhandle is 0x1c0eb50
00000000000i[PLGIN] loaded plugin libbx_ioapic.so
00000000000i[ ] lt_dlhandle is 0x1c0f520
00000000000i[PLGIN] loaded plugin libbx_keyboard.so
00000000000i[ ] lt_dlhandle is 0x1c0fd20
00000000000i[PLGIN] loaded plugin libbx_harddrv.so
00000000000i[ ] lt_dlhandle is 0x1c0fc00
00000000000i[PLGIN] loaded plugin libbx_serial.so
00000000000i[ ] lt_dlhandle is 0x1c22c30
00000000000i[PLGIN] loaded plugin libbx_parallel.so
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Tue Dec 20 23:53:20 2011 (time0=1324405400)
00000000000i[DMA ] channel 4 used by cascade
00000000000i[DMA ] channel 2 used by Floppy Drive
00000000000e[FDD ] cannot determine media geometry, trying to use defaults
00000000000i[FDD ] fd0: '/dev/loop1' ro=0, h=2,t=80,spt=18
00000000000i[PCI ] 440FX Host bridge present at device 0, function 0
00000000000i[PCI ] PIIX3 PCI-to-ISA bridge present at device 1, function 0
00000000000i[VGA ] interval=50000
00000000000i[MEM0 ] Register memory access handlers: 0x000a0000 - 0x000bffff
00000000000i[XGUI ] test_alloc_colors: 16 colors available out of 16 colors tried
00000000000i[XGUI ] font 8 wide x 16 high, display depth = 24
00000000000i[MEM0 ] Register memory access handlers: 0xe0000000 - 0xe0ffffff
00000000000i[VGA ] VBE Bochs Display Extension Enabled
00000000000i[PLGIN] init_dev of 'unmapped' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'biosdev' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'speaker' plugin device by virtual method
00000000000i[SPEAK] Open /dev/console successfully
00000000000i[PLGIN] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'gameport' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'pci_ide' plugin device by virtual method
00000000000i[PCI ] PIIX3 PCI IDE controller present at device 1, function 1
00000000000i[PLGIN] init_dev of 'acpi' plugin device by virtual method
00000000000i[PCI ] ACPI Controller present at device 1, function 3
00000000000i[PLGIN] init_dev of 'ioapic' plugin device by virtual method
00000000000i[IOAP ] initializing I/O APIC
00000000000i[MEM0 ] Register memory access handlers: 0xfec00000 - 0xfec00fff
00000000000i[PLGIN] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD ] will paste characters every 1000 keyboard ticks
00000000000i[PLGIN] init_dev of 'harddrv' plugin device by virtual method
00000000000i[HD ] Using boot sequence floppy, none, none
00000000000i[HD ] Floppy boot signature check is enabled
00000000000i[PLGIN] init_dev of 'serial' plugin device by virtual method
00000000000i[SER ] com1 at 0x03f8 irq 4
00000000000i[PLGIN] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
00000000000i[PLGIN] register state of 'unmapped' plugin device by virtual method
00000000000i[PLGIN] register state of 'biosdev' plugin device by virtual method
00000000000i[PLGIN] register state of 'speaker' plugin device by virtual method
00000000000i[PLGIN] register state of 'extfpuirq' plugin device by virtual method
00000000000i[PLGIN] register state of 'gameport' plugin device by virtual method
00000000000i[PLGIN] register state of 'pci_ide' plugin device by virtual method
00000000000i[PLGIN] register state of 'acpi' plugin device by virtual method
00000000000i[PLGIN] register state of 'ioapic' plugin device by virtual method
00000000000i[PLGIN] register state of 'keyboard' plugin device by virtual method
00000000000i[PLGIN] register state of 'harddrv' plugin device by virtual method
00000000000i[PLGIN] register state of 'serial' plugin device by virtual method
00000000000i[PLGIN] register state of 'parallel' plugin device by virtual method
00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00000000000i[CPU0 ] cpu hardware reset
00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0xfee00000
00000000000i[CPU0 ] CPUID[0x00000000]: 00000003 756e6547 6c65746e 49656e69
00000000000i[CPU0 ] CPUID[0x00000001]: 00000f20 00000800 00002000 078bfbff
00000000000i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000101 2a100800
00000000000i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00000000000i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00000000000i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00000000000i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
00000000000i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000008]: 00003020 00000000 00000000 00000000
00000000000i[PLGIN] reset of 'unmapped' plugin device by virtual method
00000000000i[PLGIN] reset of 'biosdev' plugin device by virtual method
00000000000i[PLGIN] reset of 'speaker' plugin device by virtual method
00000000000i[PLGIN] reset of 'extfpuirq' plugin device by virtual method
00000000000i[PLGIN] reset of 'gameport' plugin device by virtual method
00000000000i[PLGIN] reset of 'pci_ide' plugin device by virtual method
00000000000i[PLGIN] reset of 'acpi' plugin device by virtual method
00000000000i[PLGIN] reset of 'ioapic' plugin device by virtual method
00000000000i[PLGIN] reset of 'keyboard' plugin device by virtual method
00000000000i[PLGIN] reset of 'harddrv' plugin device by virtual method
00000000000i[PLGIN] reset of 'serial' plugin device by virtual method
00000000000i[PLGIN] reset of 'parallel' plugin device by virtual method
00000000000i[XGUI ] [x] Mouse off
00000003305i[BIOS ] $Revision: 1.247 $ $Date: 2010/04/04 19:33:50 $
00000316575i[KBD ] reset-disable command received
00000433073i[VBIOS] VGABios $Id$
00000433144i[VGA ] VBE known Display Interface b0c0
00000433176i[VGA ] VBE known Display Interface b0c4
00000433845i[VBIOS] VBE Bios $Id$
00000475000i[XGUI ] charmap update. Font Height is 16
00000525000i[XGUI ] charmap update. Font Height is 16
00000751361i[BIOS ] Starting rombios32
00000751840i[BIOS ] Shutdown flag 0
00000752479i[BIOS ] ram_size=0x02000000
00000752941i[BIOS ] ram_end=32MB
00000788082i[BIOS ] Found 1 cpu(s)
00000804258i[BIOS ] bios_table_addr: 0x000fbc18 end=0x000fcc00
00000804361i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00001132055i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00001459985i[P2I ] PCI IRQ routing: PIRQA# set to 0x0b
00001460006i[P2I ] PCI IRQ routing: PIRQB# set to 0x09
00001460027i[P2I ] PCI IRQ routing: PIRQC# set to 0x0b
00001460048i[P2I ] PCI IRQ routing: PIRQD# set to 0x09
00001460058i[P2I ] write: ELCR2 = 0x0a
00001460905i[BIOS ] PIIX3/PIIX4 init: elcr=00 0a
00001468749i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237 class=0x0600
00001471202i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000 class=0x0601
00001473494i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010 class=0x0101
00001473729i[PIDE ] new BM-DMA address: 0xc000
00001474395i[BIOS ] region 4: 0x0000c000
00001476596i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113 class=0x0680
00001476839i[ACPI ] new irq line = 11
00001476851i[ACPI ] new irq line = 9
00001476882i[ACPI ] new PM base address: 0xb000
00001476896i[ACPI ] new SM base address: 0xb100
00001476924i[PCI ] setting SMRAM control register to 0x4a
00001641015i[CPU0 ] Enter to System Management Mode
00001641025i[CPU0 ] RSM: Resuming from System Management Mode
00001805043i[PCI ] setting SMRAM control register to 0x0a
00001813912i[BIOS ] MP table addr=0x000fbcf0 MPC table addr=0x000fbc20 size=0xd0
00001815789i[BIOS ] SMBIOS table addr=0x000fbd00
00001818875i[BIOS ] Firmware waking vector 0x1ff00cc
00001859857i[BIOS ] ACPI tables: RSDP addr=0x000fbe20 ACPI DATA addr=0x01ff0000 size=0x1f18
00001859894i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00001860686i[BIOS ] bios_table_cur_addr: 0x000fbe44
00053720903i[BIOS ] Booting from 0000:7c00
00055338607i[BIOS ] int13_harddisk: function 41, unmapped device for ELDL=80
00055343384i[BIOS ] int13_harddisk: function 08, unmapped device for ELDL=80
00055348037i[BIOS ] *** int 15h function AX=00c0, BX=0000 not yet supported!
00159100000i[KBD ] internal keyboard buffer full, ignoring scancode.(92)
00162850000i[KBD ] internal keyboard buffer full, ignoring scancode.(12)
00166548500i[KBD ] internal keyboard buffer full, ignoring scancode.(92)
00170557500i[KBD ] internal keyboard buffer full, ignoring scancode.(12)
00174391000i[KBD ] internal keyboard buffer full, ignoring scancode.(92)
00178425000i[KBD ] internal keyboard buffer full, ignoring scancode.(12)
00181725000i[KBD ] internal keyboard buffer full, ignoring scancode.(92)
00194475000i[ ] cpu loop quit, shutting down simulator
00194475000i[CPU0 ] CPU is in protected mode (active)
00194475000i[CPU0 ] CS.d_b = 32 bit
00194475000i[CPU0 ] SS.d_b = 32 bit
00194475000i[CPU0 ] EFER = 0x00000000
00194475000i[CPU0 ] | RAX=0000000000000000 RBX=000000000002d000
00194475000i[CPU0 ] | RCX=0000000000067ec8 RDX=0000000000100ea0
00194475000i[CPU0 ] | RSP=0000000000067ec8 RBP=0000000000067ee0
00194475000i[CPU0 ] | RSI=0000000000053c8e RDI=0000000000053c8f
00194475000i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
00194475000i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
00194475000i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
00194475000i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
00194475000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf sf zf af PF cf
00194475000i[CPU0 ] | SEG selector base limit G D
00194475000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00194475000i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
00194475000i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00194475000i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00194475000i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00194475000i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00194475000i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00194475000i[CPU0 ] | MSR_FS_BASE:0000000000000000
00194475000i[CPU0 ] | MSR_GS_BASE:0000000000000000
00194475000i[CPU0 ] | RIP=0000000000100027 (0000000000100027)
00194475000i[CPU0 ] | CR0=0x60000011 CR2=0x0000000000000000
00194475000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00194475000i[CPU0 ] 0x0000000000100027>> jmp .-5 (0x00100027) : E9FBFFFFFF
00194475000i[CMOS ] Last time is 1324405788 (Tue Dec 20 23:59:48 2011)
00194475000i[XGUI ] Exit
00194475000i[ ] restoring default signal behavior
00194475000i[CTRL ] quit_sim called with exit code 1