Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Operating System (http://www.go4expert.com/forums/operating-system-forum/)
-   -   what happens internally (http://www.go4expert.com/forums/what-happens-internally-t18944/)

anchitjindal07 9Aug2009 19:16

what happens internally
 
Friends please tell me what happens internally when we press any key on keyboard
i know that it saves the value of certai registers and taKES ON INTERRUPT handler. upto this point its ok. what happen after that???????
What is interrupt handler instructed to do???????????

Thanks

Seema786 9Aug2009 19:27

Re: what happens internally
 
anyone know what he/she is telling ?

anchitjindal07 9Aug2009 19:38

Re: what happens internally
 
yaar i am asking u how the operatring system knows which key has been pressed and what to do when a particular key is pressed

xpi0t0s 9Aug2009 23:36

Re: what happens internally
 
Which OS?

anchitjindal07 10Aug2009 06:55

Re: what happens internally
 
Any oerating system. Ok take your own example (of OS) and please explain

indiansword 10Aug2009 08:19

Re: what happens internally
 
Input > Process > Output. THere is a RUBBER NOTCH beneath ur keyboard key. When u push the key the NOTCH is pushed and the circuit on the keyboard is completed, which send a msg to CPU [PROCESSOR] and the key is recorded, and output on application along with monitor :) .

anchitjindal07 10Aug2009 17:37

Re: what happens internally
 
Thankyou friend for ur reply but I am asking in terms of interrupt. Would you please explain

_eb75_ 20Feb2013 12:33

Re: what happens internally
 
Quote:

Originally Posted by anchitjindal07 (Post 54645)
Friends please tell me what happens internally when we press any key on keyboard
i know that it saves the value of certai registers and taKES ON INTERRUPT handler. upto this point its ok. what happen after that???????
What is interrupt handler instructed to do???????????

Thanks

I like questions with the word internally.
To my mind it would be good to give an answer with a full exact code, to be at a concrete level. Unfortunately this is impossible, because we have too much code. Is it really? This question is easy because it don't specify any kernel by name. So, I can use my own! I did write it 1994 when Intel 386, protected mode, was new. It is small and simple enough (some 1000-1500 c-code whole thing). I tested it also taking a connection to a server by the serial line modem (telnet port at server).

Code:

char  KBDSub()
{ static short code;
  static short xl, xh;
  static char scan[]={  /* Scan code conversion table for most usual codes */
  0,033,'1','2','3','4','5','6','7','8','9','0','+','x','\b','\t',
  'q','w','e','r','t','y','u','i','o','p','?',012,015,015,
  'a','s','d','f','g','h','j','k','l','&','?',0,
  '\\',',','z','x','c','v','b','n','m',',','.','-','/',0,' ',' ',' ',' '};

  code = inportb(0x060)  ;
  xh = xl = inportb(0x061);    /* Read scan code*/
  xl = xl | 0x080        ;
    outportb( 0x61 , xl)    ;
  outportb( 0x061, xh)    ;
  if(code >=0 && code <=0x040 ) return(scan[ code]);
  else return( 0);
}

void  KBDIntHandler()
{      outportb(PIC1_CMND,PIC_EOI);
              Send(0,KBD_BOX,KBDSub()); // send message to mailbox- hopefully keyboard task is waiting!
}

************************************************** ********

Outside the question presented:

Yes, saving on entry must be done:

Code:

#define Save()      asm volatile ("pusha");
#define Restore() asm ("popa;leave;iret;");

Where this saving/restoring is?

Interrupt call gate.

Code:

void InterruptHandler()
{
  short store;
 Save();
 enter_int_gate(store);
      KBDIntHandler();
 leave_int_gate(store);
 Restore();
}

Code:

(#define  leave_int_gate(STORE)  asm("movw %0,%%bx;movw %%bx,%%ds;"\
                                    :\
                    :"m"(STORE));)


A KBD task:


Code:

void main(void) {
 while(TRUE) {
................
  kbd_char = receive(KBD_BOX,TIMEOUT);
 ................
 }
}


and so on................................I used mainly c and some inline assembly, only floppy disk (see history of computers) boot sector was written using assembly...........


All times are GMT +5.5. The time now is 20:08.