OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:23 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Can't get keyboard working when booting with GRUB
PostPosted: Wed Sep 12, 2018 3:57 am 
Offline

Joined: Tue Sep 11, 2018 9:42 am
Posts: 7
Hi!
I'm trying to get my toy-os working with GRUB since i want to use it on real hardware.
For this reason i implemented a multiboot header (as described here) and a minimal grub.cfg file.

All seems to works fine(IRSs and IRQs are correctly loaded) except for the keyboard driver:
for some reason i can't type nothing into the console.
The weird thing is that, without GRUB(loading the bootsector as a floppy image in QEMU), the keyboard driver works and i can type things on it.

Here on the forum i read that this can be a problem related with the GDT, but i've implemented it and it is loaded successfully before actually loading the kernel, and,as i said before,it works without QEMU.

What could be the cause of this problem?

If it can be helpful i post the source code of the GDT:

Code:
gdt_start:
    dd 0x0
    dd 0x0

; code segment descriptor
gdt_code:
    dw 0xffff
    dw 0x0
    db 0x0
    db 10011010b
    db 11001111b
    db 0x0

; data segment descriptor
gdt_data:
    dw 0xffff
    dw 0x0
    db 0x0
    db 10010010b
    db 11001111b
    db 0x0 )

gdt_end:


gdt_descriptor:
    dw gdt_end - gdt_start - 1 ; the size

    dd gdt_start ; start address of the gdt

CODE_SEG equ gdt_code - gdt_start
DATA_SEG equ gdt_data - gdt_start


Top
 Profile  
 
 Post subject: Re: Can't get keyboard working when booting with GRUB
PostPosted: Wed Sep 12, 2018 4:04 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
You really need to provide a link to an online repository of sour source code before anyone can make sensible suggestions. Posting random selections is unlikely to pinpoint the problem.


Top
 Profile  
 
 Post subject: Re: Can't get keyboard working when booting with GRUB
PostPosted: Wed Sep 12, 2018 4:23 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

KSMb wrote:
All seems to works fine(IRSs and IRQs are correctly loaded) except for the keyboard driver:
for some reason i can't type nothing into the console.
The weird thing is that, without GRUB(loading the bootsector as a floppy image in QEMU), the keyboard driver works and i can type things on it.


Consider this:
  • Computer starts, GRUB displays a menu to select which OS to boot
  • User presses the enter key to start booting something
  • GRUB loads the kernel and disables IRQs with CLI
  • The user takes their finger off of the enter key, causing PS/2 controller to send an IRQ that remains "pending" because IRQs were disabled with CLI
  • The OS reconfigures the PIC chip, causing that pending IRQ to be forgotten

The end result is that the PS/2 controller is left in a "one-byte buffer full" state waiting for an IRQ handler to read from its buffer, where the IRQ was lost so nothing will read the buffer, and where the PS/2 controller can't accept any more bytes from the keyboard because that buffer is full.

To work around this; you can do a few dummy "in al,0x60" instructions to clear the buffer (the "Step 4" mentioned here).


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: Can't get keyboard working when booting with GRUB
PostPosted: Wed Sep 12, 2018 9:05 am 
Offline

Joined: Tue Sep 11, 2018 9:42 am
Posts: 7
Quote:
To work around this; you can do a few dummy "in al,0x60" instructions to clear the buffer (the "Step 4" mentioned here).


Thanks for your reply.

I've just tried to clear the buffer on the port 0x60 but the situation still the same...from the wiki page about the PS/2 Controller i also tried to implement the Cpu Reset but without any success.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 63 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