OSDev.org

The Place to Start for Operating System Developers
It is currently Wed May 15, 2024 7:42 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Iterface Keyboard - IRQ1
PostPosted: Sun Jan 09, 2005 12:00 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 154
I'm a using bochs emulator, on which i'm testing my tiny test 32bit OS

As per my knowledge goes PIC init is correct, Handler for IRQ1 = int 0x09
is correct... but even then i'm unable to interface KeyBoard...
when bochs boots the OS the KB doesn't function...

Right now the function of int 0x09 (IRQ1) handler is just to display
letter 'K' for any key press i.e, for every int 0x09 (IRQ1) received....

If I manually (in the code) call int 0x09... Handler works as expected...
But KeyBoard button press has no response...

Is there any bochs settings for KB to be enabled?

The KB type is set to mf in .bochsrc

I tried with remap enabled and disabled in .bochsrc..... but no use...

can someone help me......


Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Sun Jan 09, 2005 12:00 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 21, 2004 11:00 pm
Posts: 349
Location: Munich, Germany
Hi,
Bochs should emulate a keyboard by default. Since you can call the IRQ handler in software, I suppose that it might really be your PIC code.
Maybe you could post it ?

regards,
gaf


Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Sun Jan 09, 2005 12:00 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2004 11:00 pm
Posts: 874
Location: WA
also you really should remap the pic to 0x20 (or higher) so that it doesnt overlap the CPU exceptions -- but this prob wont fix your problem

_________________
## ---- ----- ------ Intel Manuals
OSdev wiki


Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Sun Jan 09, 2005 12:00 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 154
Here's the PIC init code
NOTE: Calling int 0x09 in software works...... But KB press has no response.....

;Sending ICW1 to master and slave PIC
mov al,00010001b
out 0x20,al
out 0xA0,al

;Sending base vector number of master and slave PIC
mov al,20h ;base vector number of master PIC
out 0x21,al
mov al,28h ;base vector number of slave PIC
out 0xA1,al

;Sending connection parameters between the PICs to the PICs
mov al,00000100b ;IRQ2 is connected to slave PIC
out 0x21,al
mov al,2h ;IRQ2 of master PIC is used for the slave PIC
out 0xA1,al

;Sending ICW4 to master and slave PIC
mov al,00000001b ;Intel environment, manual EOI
out 0x21,al
out 0xA1,al

;This ends the initialization of the PICs

------------------------------------------------------------------------

;The KB Handler -- Sample Handler, just to check it is invoked or not
KB_HANDLER:

pusha
push gs
mov ax,LINEAR_SEL
mov gs,ax

mov ebx, [KB_LOC] ; KB_LOC is a Double word initialzed to 0xb8000
INC ebx
INC ebx ; Every IRQ1 causes a 'K' to be displayed at consecutive location

mov byte[gs:ebx],'K'

mov al,20h ;EOI command
out 020h,al ;Sending the command to the slave PIC
pop gs
popa
iret


Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Mon Jan 10, 2005 12:00 am 
Offline
Member
Member

Joined: Wed Dec 01, 2004 12:00 am
Posts: 38
Location: New York
srinivasa,

Hey... I just looked over it quickly but it looks like you're masking your PIC to offset 0x20 which means IRQ is firing at 0x21...

Also I didn't see you masked all your ints at the end of your pic initialization outbyte to 0x21 and 0xA1 0xFF to make sure everything is in the correct state

I also didn't see anywhere in which you were turning on IRQ 1

-Christopher

_________________
-Christopher
http://www.ubixos.com/


Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Mon Jan 10, 2005 12:00 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 21, 2004 11:00 pm
Posts: 349
Location: Munich, Germany
You can mask the IRQs like this:

mov al,0xFD ; IRQ #0-7
out 0x21,al
mov al,0xFF ; IRQ #8-15
out 0xA1,al

Every bit stands for an IRQ...
11111111 - all IRQ masked
00011110 - IRQs 0, 5, 6, 7 not masked


Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Mon Jan 10, 2005 12:00 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2004 11:00 pm
Posts: 874
Location: WA
do you have your ISR registered to INT9? because as theubu said it looks like your mapping the IRQs to 20 instead of 8 which makes IRQ1 INT 0x21 not 0x09

_________________
## ---- ----- ------ Intel Manuals
OSdev wiki


Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Mon Jan 10, 2005 12:00 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 154
I'm extremely sorry for that wrong ICW2 code.....
Base vector init code ---- ICW2 is as follows:-

mov al,08h ;08h as interrupt number for IRQ0 of the master PIC
mov 21h,al ;sending ICW2 to the master PIC
mov al,70h ;70h as interrupt number for IRQ0 of the slave PIC
mov 0A1h,al ;sending ICW2 to the slave PIC

I missed the masking code to post..... I'v masked all interrupts
except IRQ1....

Please Note That int 0x09 in software (i.e, when called in code) works
as expected.....


NOTE:- I'M USING USB KEYBOARD..... DOES BOCHS SUPPORT IT...
IS THAT AN ISSUE HERE.....


Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Tue Jan 11, 2005 12:00 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2004 11:00 pm
Posts: 874
Location: WA
shouldnt be a prob with the keyboard(though i dont know for sure)

do you have a reason for putting it at int9? because that can cause serious problems later actualy int9 shouldnt be a prob since its reserved on sys later than 386 but your others will:
int8 (your clock) will be called with any double-fault
int14 (your floppy) will be called on every page-fault
other devices are usually assigned to IRQ5 which maps to int13: your GPF -- the most important exception that there is

just a warning mabey you have a reason for mapping it where you do but mabey you just didnt realise the dangers of this mapping (its typical to map them to 0x20 and 0x28 in pm)

_________________
## ---- ----- ------ Intel Manuals
OSdev wiki


Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Tue Jan 11, 2005 12:00 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 154
Thanks JAAman.....

I'll try ur suggestion today..... I didn't know this. I'm entirely new to this
field.....


Last edited by prajwal on Fri Nov 27, 2020 11:14 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Fri Mar 25, 2005 12:00 am 
Offline

Joined: Sat Feb 05, 2005 12:00 am
Posts: 11
Hi...

There is an important note about keyboard ISR:

For the keyboard ISR to function properly, you MUST read one byte (scancode) from port 60h (keyboard port) , because the keyboard will not send any more interrupt signals until the data is read.


Top
 Profile  
 
 Post subject: Re: Iterface Keyboard - IRQ1
PostPosted: Sat Mar 26, 2005 12:00 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 154
Yes aymanmadkour.... I tried it..... it worked....


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Kaius and 82 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