Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

Keyboard
[Device Drivers]


Functions

void keyb_wait ()
 Wait after a keyboard operation.

void update_leds ()
 Update keyboard leds.

word scan_key ()
 Get the hitten key keyboard code.
Returns:
The hitten key scan code.


void init_keyboard ()
 Initialize the low-level keyboard driver.

int kgetchar ()
 Wait for keypressed and return the hitten character ASCII code.
Returns:
The hitten character ASCII code.


int keyb_read ()
 Return the first key in the buffer, without waiting if the buffer is empty.
Returns:
The hitten character ASCII code if a character has been hitten or NULL otherwise.



Variables

word regular [128]
 US keyboard keymap :: regular keys.

word with_shift [128]
 US keyboard keymap :: "with SHIFT" keys.

word with_alt [128]
 US keyboard keymap :: "with ALT" keys.

word with_control [128]
 US keyboard keymap :: "with CTRL" keys.

byte keypad_char [] = {'7','8','9','-','4','5','6','+','1','2','3','0','.'}
 The keypad map.

byte shift = 0
 SHIFT flag.

byte ctrl = 0
 CTRL flag.

byte alt = 0
 ALT flag.

queue_tkeyb_queue = NULL
 Queue for the task that are waiting for the keyboard.


Detailed Description

The floppy disk driver.

Function Documentation

void init_keyboard  
 

Initialize the low-level keyboard driver.

Definition at line 280 of file keyboard.c.

00281 {
00282         // Install the keyboard handler                                 //
00283         install_irq_handler( KEYBOARD_IRQ, (void *)&keyboard_handler );
00284 
00285         // Set typematic delay as short as possible                     //
00286         outportb(KEYB_PORT, KEYB_SET_TYPEMATIC);
00287         keyb_wait();
00288         // typematic 0 means "MODE CON RATE=30 DELAY=1"                 //
00289         outportb(KEYB_PORT, 0);
00290 
00291         // Initialize leds //
00292         update_leds();
00293 }

int keyb_read  
 

Return the first key in the buffer, without waiting if the buffer is empty.

Returns:
The hitten character ASCII code if a character has been hitten or NULL otherwise.

Definition at line 341 of file keyboard.c.

00342 {
00343         console_t *cons = get_console_addr( get_curr_task()->console );
00344         word key;
00345         dword IF = GET_IF();
00346 
00347         // If the task's console is not the current console return      //
00348         while ( get_curr_task()->console != get_curr_console() )
00349                 return(NULL);
00350 
00351         // If the keyboard buffer is empty return NULL                  //
00352         if (cons->keyb_buf_count==0) return(NULL);
00353 
00354         disable();
00355 
00356         // Update keyboard buffer in mutual exclusion                   //
00357         (cons->keyb_buf_count)--;
00358         if ( ++(cons->keyb_buf_read) >= KEYB_BUF_DIM )
00359                 cons->keyb_buf_read = 0;
00360         key = cons->keyb_buffer[cons->keyb_buf_read];
00361 
00362         SET_IF(IF);
00363 
00364         return(key);
00365 }

void keyb_wait  
 

Wait after a keyboard operation.

Todo:
Put here a timeout!

Definition at line 90 of file keyboard.c.

00091 {
00092         uint32_t retries=500000L;
00093 
00094         while (((inportb(KEYB_STATUS) & KEYB_BUSY) == KEYB_BUSY) && retries!=0)
00095         {
00096                 retries--;
00097         }
00098 }

int kgetchar  
 

Wait for keypressed and return the hitten character ASCII code.

Returns:
The hitten character ASCII code.

Definition at line 298 of file keyboard.c.

00299 {
00300         task_t *ct = get_curr_task();
00301         console_t *cons = get_console_addr( ct->console );
00302         word key;
00303         uint32_t IF = GET_IF();
00304 
00305 repeat:
00306         disable();
00307         // If the task's console is not the current console auto-sleep  //
00308         if ( ct->console != get_curr_console() )
00309         {
00310                 add_queue( &keyb_queue, ct );
00311                 sleep_task( ct );
00312                 enable();
00313                 idle();
00314                 goto repeat;
00315         }
00316         // If the keyboard buffer is empty enable interrupts and wait   //
00317         if ( cons->keyb_buf_count==0 )
00318         {
00319                 enable();
00320                 idle();
00321                 goto repeat;
00322         }
00323 
00324         // Update keyboard buffer in mutual exclusion                   //
00325         (cons->keyb_buf_count)--;
00326         if ( ++(cons->keyb_buf_read) >= KEYB_BUF_DIM )
00327                 cons->keyb_buf_read = 0;
00328         key = cons->keyb_buffer[cons->keyb_buf_read];
00329 
00330         SET_IF(IF);
00331 
00332         return( key );
00333 }

word scan_key  
 

Get the hitten key keyboard code.

Returns:
The hitten key scan code.

Definition at line 123 of file keyboard.c.

00124 {
00125         static int code, val;
00126         dword IF = GET_IF();
00127 
00128         disable();
00129 
00130         code = inportb(KEYB_PORT);      // Get scan code
00131         val =  inportb(KEYB_ACK);       // Get keyboard acknowledge
00132         outportb(KEYB_ACK, val | 0x80); // Disable bit 7
00133         outportb(KEYB_ACK, val);        // Send that back
00134 
00135         SET_IF(IF);
00136 
00137         return code;
00138 }

void update_leds  
 

Update keyboard leds.

Definition at line 101 of file keyboard.c.

00102 {
00103         int leds;
00104         console_t *curr_cons = get_console_addr( get_curr_console() );
00105         dword IF = GET_IF();
00106 
00107         leds =  (curr_cons->scroll_lock) |
00108                 (curr_cons->num_lock << 1) |
00109                 (curr_cons->caps_lock << 2);
00110 
00111         disable();
00112 
00113         keyb_wait();
00114         outportb(KEYB_PORT, KEYB_LED_CODE);
00115         keyb_wait();
00116         outportb(KEYB_PORT, leds);
00117 
00118         SET_IF(IF);
00119 }


Variable Documentation

byte alt = 0 [static]
 

ALT flag.

Definition at line 81 of file keyboard.c.

byte ctrl = 0 [static]
 

CTRL flag.

Definition at line 79 of file keyboard.c.

queue_t* keyb_queue = NULL
 

Queue for the task that are waiting for the keyboard.

Definition at line 84 of file keyboard.c.

byte keypad_char[] = {'7','8','9','-','4','5','6','+','1','2','3','0','.'} [static]
 

The keypad map.

Definition at line 74 of file keyboard.c.

word regular[128] [static]
 

Initial value:

 {
  0x0000,0x011B,0x0231,0x0332,0x0433,0x0534,0x0635,0x0736,0x0837,0x0938,0x0A39,0x0B30,0x0C2D,0x0D3D,0x0E08,0x0F09,
  0x1071,0x1177,0x1265,0x1372,0x1474,0x1579,0x1675,0x1769,0x186F,0x1970,0x1A5B,0x1B5D,0x1C0D,0x1D00,0x1E61,0x1F73,
  0x2064,0x2166,0x2267,0x2368,0x246A,0x256B,0x266C,0x273B,0x2827,0x2960,0x2A00,0x2B5C,0x2C7A,0x2D78,0x2E63,0x2F76,
  0x3062,0x316E,0x326D,0x332C,0x342E,0x352F,0x3600,0x372A,0x3800,0x3920,0x3A00,0x3B00,0x3C00,0x3D00,0x3E00,0x3F00,
  0x4000,0x4100,0x4200,0x4300,0x4400,0x4500,0x4600,0x4700,0x4800,0x4900,0x4A2D,0x4B00,0x4C00,0x4D00,0x4E2B,0x4F00,
  0x5000,0x5100,0x5200,0x5300,0x5400,0x5500,0x5600,0x8500,0x8600,0x0000,0x0000,0x5B00,0x5C00,0x5D00
}
US keyboard keymap :: regular keys.

Definition at line 30 of file keyboard.c.

byte shift = 0 [static]
 

SHIFT flag.

Definition at line 77 of file keyboard.c.

word with_alt[128] [static]
 

Initial value:

 {
  0x0000,0x0100,0x7800,0x7900,0x7A00,0x7B00,0x7C00,0x7D00,0x7E00,0x7F00,0x8000,0x8100,0x8200,0x8300,0x0E00,0xA500,
  0x1000,0x1100,0x1200,0x1300,0x1400,0x1500,0x1600,0x1700,0x1800,0x1900,0x1A00,0x1B00,0x1C00,0x1D00,0x1E00,0x1F00,
  0x2000,0x2100,0x2200,0x2300,0x2400,0x2500,0x2600,0x2700,0x2800,0x2900,0x2A00,0x2B00,0x2C00,0x2D00,0x2E00,0x2F00,
  0x3000,0x3100,0x3200,0x3300,0x3400,0x3500,0x3600,0x3700,0x3800,0x3900,0x3A00,0x6800,0x6900,0x6A00,0x6B00,0x6C00,
  0x6D00,0x6E00,0x6F00,0x7000,0x7100,0x4500,0x4600,0x9700,0x9800,0x9900,0x4A00,0x9B00,0x9C00,0x9D00,0x4E00,0x9F00,
  0xA000,0xA100,0xA200,0xA300,0x5400,0x5500,0x5600,0x8B00,0x8C00
}
US keyboard keymap :: "with ALT" keys.

Definition at line 52 of file keyboard.c.

word with_control[128] [static]
 

Initial value:

 {
  0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x9400,
  0x1011,0x1117,0x1205,0x1312,0x1414,0x1519,0x1615,0x1709,0x180F,0x1910,0x0000,0x0000,0x1C0A,0x1D00,0x1E01,0x1F13,
  0x2004,0x2106,0x2207,0x2308,0x240A,0x250B,0x260C,0x0000,0x0000,0x0000,0x2A00,0x0000,0x2C1A,0x2D18,0x2E03,0x2F16,
  0x3002,0x310E,0x320D,0x0000,0x0000,0x9500,0x3600,0x9600,0x3800,0x3920,0x3A00,0x5E00,0x5F00,0x6000,0x6100,0x6200,
  0x6300,0x6400,0x6500,0x6600,0x6700,0x4500,0x4600,0x7700,0x8D00,0x8400,0x8E00,0x7300,0x8F00,0x7400,0x9000,0x7500,
  0x9100,0x7600,0x9200,0x9300,0x5400,0x5500,0x5600,0x8900,0x8A00
}
US keyboard keymap :: "with CTRL" keys.

Definition at line 63 of file keyboard.c.

word with_shift[128] [static]
 

Initial value:

 {
  0x0000,0x011B,0x0221,0x0340,0x0423,0x0524,0x0625,0x075E,0x0826,0x092A,0x0A28,0x0B29,0x0C5F,0x0D2B,0x0E08,0x0F00,
  0x1051,0x1157,0x1245,0x1352,0x1454,0x1559,0x1655,0x1749,0x184F,0x1950,0x1A7B,0x1B7D,0x1C0D,0x1D00,0x1E41,0x1F53,
  0x2044,0x2146,0x2247,0x2348,0x244A,0x254B,0x264C,0x273A,0x2822,0x297E,0x2A00,0x2B7C,0x2C5A,0x2D58,0x2E43,0x2F56,
  0x3042,0x314E,0x324D,0x333C,0x343E,0x353F,0x3600,0x372A,0x3800,0x3920,0x3A00,0x5400,0x5500,0x5600,0x5700,0x5800,
  0x5900,0x5A00,0x5B00,0x5C00,0x5D00,0x4500,0x4600,0x4700,0x4800,0x4900,0x4A2D,0x4B00,0x4C00,0x4D00,0x4E2B,0x4F00,
  0x5000,0x5100,0x5200,0x5300,0x5400,0x5500,0x5600,0x8700,0x8800,0x0000,0x0000,0x5B00,0x5C00,0x5D00
}
US keyboard keymap :: "with SHIFT" keys.

Definition at line 41 of file keyboard.c.


Generated on Fri Feb 20 15:32:23 2004 for Minirighi by doxygen1.2.18