OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 2:51 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Small nudge in right direction for buggy keyboard handling
PostPosted: Mon Nov 05, 2018 4:14 pm 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
Image

What would cause this bug? I can post my code if you need it, but I am interested in trying to figure out what the issue is myself. So far, I have been reading about the 8259 PIC and "Interrupt Problems" on the OSDev wiki, but I haven't not noticed anything.

The correct characters show up on the left side, but then it inserts that strange text afterwards, and goes to a newline.

Have I missed something? Anyone have a nudge in the right direction?


Top
 Profile  
 
 Post subject: Re: Small nudge in right direction for buggy keyboard handli
PostPosted: Mon Nov 05, 2018 4:49 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 21, 2011 9:47 pm
Posts: 286
Location: Tustin, CA USA
https://wiki.osdev.org/PS/2_Keyboard#Scan_Code_Sets

Are you properly handling the release codes?

As for the extra text, my first thought is an extra format specifier in kprintf() without a matching parameter.

_________________
Adam

The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal

"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber


Top
 Profile  
 
 Post subject: Re: Small nudge in right direction for buggy keyboard handli
PostPosted: Tue Nov 06, 2018 12:16 pm 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
eryjus wrote:
https://wiki.osdev.org/PS/2_Keyboard#Scan_Code_Sets

Are you properly handling the release codes?

As for the extra text, my first thought is an extra format specifier in kprintf() without a matching parameter.


Hm, maybe I forgot to add support for the release codes. This is my code: https://github.com/Bowlslaw/slawOS/blob/master/kernel/arch/i386/interrupts.c

It draws heavily from meaty skeleton and Sortie, Sortix's OS.

Code:

void pic_init() {
  /* ICW1 - begin initialization */
  port_byte_out(PIC1_CMD, 0x11);
  port_byte_out(PIC2_CMD, 0x11);

  /* ICW2 - remap offset address of IDT
   * In x86 protected mode, we have to remap the PICs after 0x20 because
   * Intel has designated the first 32 interrupts as "reserved" for CPU exceptions
   */
  port_byte_out(PIC1_DATA, 0x20);
  port_byte_out(PIC2_DATA, 0x28);

  /* OCW3 - set up cascading */
  port_byte_out(PIC1_DATA, 0x04);
  port_byte_out(PIC2_DATA, 0x02);
  /*
   * port_byte_out(PIC1_DATA, 0x0);
   * port_byte_out(PIC2_DATA, 0x0);
  */

  /* ICW4 - environment info */
  port_byte_out(PIC1_DATA, 0x01);
  port_byte_out(PIC2_DATA, 0x01);

  /* mask interrupts */
  port_byte_out(PIC1_DATA, 0xFF);
  port_byte_out(PIC2_DATA, 0xFF);
}

void isr_handler(struct regs *r) {
  int irqn = (int)r->irqn;
  printf("INT%d\n", irqn);

  /* write EOI */
  port_byte_out(PIC1_CMD, 0x20);

  switch(irqn) {
  case 0x21:
   kbd_isr_main();
   break;

  default:
   printf("Unknown interrupt %d\n", irqn);
   break;
  }
}



EDIT: Funnily enough...about 2 minutes after I posted this, I found my bug: I was the "printf(INT%d\n", irqn);" statement in the wrong spot, so it would print out the interrupt every single time. I moved it to the default case of the switch/case statement, and it works just fine now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 99 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group