/* ** The puts family */ void c_puts_at( unsigned int x, unsigned int y, char *str ){ unsigned int ch; while( (ch = *str++) != '\0' && x <= max_x ){ c_putchar_at( x, y, ch ); x += 1; } }
void _ps2_mouse_isr( int vec, int code ){ static int byte_c = 0; static char mouse_p = '+'; static char m_bytes[3]; // temp vars char button_change = 0; if(_init) m_bytes[byte_c++] = __inb(PS2_PORT); // Only dump information once we have everything the mouse sent if(byte_c == 3){ if( (m_bytes[0] & 0x80) || (m_bytes[0] & 0x40) ){ // overflow! throw away packet c_puts( "Mouse overflow!\n" ); } else{ // Check left-button status if( m_bytes[0] & 0x1 ){ if( _left_button != 1) //c_puts( "Left Button Pressed!\n" ); _left_button = 1; button_change = 1; } else if( _left_button ){ //c_puts( "Left Button Released!\n" ); _left_button = 0; button_change = 1; } // check right-button status if( m_bytes[0] & 0x2 ){ if(_right_button != 1) //c_puts( "Right Button Pressed!\n" ); _right_button = 1; button_change = 1; } else if( _right_button ){ //c_puts( "Right Button Released!\n" ); _right_button = 0; button_change = 1; } // check middle-button status if( m_bytes[0] & 0x4 ){ if(_middle_button != 1) //c_puts( "Middle Button Pressed!\n" ); _middle_button = 1; button_change = 1; } else if( _middle_button ){ //c_puts( "Middle Button Released!\n" ); _middle_button = 0; button_change = 1; } _x_move = m_bytes[1]; if( (m_bytes[0] & 0x8) == 0 ){ _x_move *= -1; } if( (m_bytes[0] & 0x20) != 0 ){ _y_move *= -1; } _y_move = m_bytes[2]; //c_printf( "X: %dmm\n", _x_move ); //c_printf( "Y: %dmm\n", _y_move ); } byte_c = 0; } // remove the mouse cursor at the previous location c_putchar_at(_x_pos, _y_pos, ' '); // limit total possible movement _x_move = _x_move > 80 ? 80 : _x_move; _x_move = _x_move < -80 ? -80 : _x_move; _y_move = _y_move > 64 ? 64 : _y_move; _y_move = _y_move < -64 ? -64 : _y_move; // move mouse cursor _x_t_move += ( _x_move / 2 ); _y_t_move += ( _y_move / 6 ); /* // apply a minimum bound of movement if( _x_move < 0 && _x_move > -16 ) _x_t_move -= 1; else if( _x_move > 0 && _x_move < 16 ) _x_t_move += 1; if( _y_move < 0 && _y_move > -16 ) _y_t_move += 1; else if( _y_move > 0 && _y_move < 16 ) _y_t_move -= 1; */ if(_x_t_move > 6){ _x_pos++; _x_t_move = 0; } else if(_x_t_move < -6){ _x_pos--; _x_t_move = 0; } if(_y_t_move > 8){ _y_pos--; _y_t_move = 0; } else if(_y_t_move < -8){ _y_pos++; _y_t_move = 0; } // enforce boundaries if( _x_pos > 79 ) _x_pos = 79; if( _x_pos < 0 ) _x_pos = 0; if( _y_pos > 24) _y_pos = 24; if( _y_pos < 0) _y_pos = 0; if(_left_button) mouse_p = 'x'; else if(_right_button) mouse_p = '#'; else if(_middle_button) mouse_p = '|'; else mouse_p = '+'; c_putchar_at( _x_pos, _y_pos, mouse_p ); update_cursor_pos( _x_pos, _y_pos ); if( button_change == 1 ) update_mouse_button( _left_button, _right_button, _middle_button ); // indicate that we have read the interrupt __outb( 0x20, 0x20 ); __outb( 0xA0, 0x20 ); }
static void _clock_isr( int vector, int code ) { (void)(vector); (void)(code); pcb_t *pcb; // spin the pinwheel ++_pinwheel; if( _pinwheel == (CLOCK_FREQUENCY / 10) ) { _pinwheel = 0; ++_pindex; c_putchar_at( 79, 0, "|/-\\"[ _pindex & 3 ] ); } // increment the system time ++_system_time; /* ** wake up any sleeper whose time has come ** ** we give awakened processes preference over the ** current process (when it is scheduled again) */ while( !_queue_empty(_sleeping) && (uint32_t) _queue_kpeek(_sleeping) <= _system_time ) { // time to wake up! remove it from the queue pcb = (pcb_t *) _queue_remove( _sleeping ); if( pcb == NULL ) { #ifdef DEBUG _kpanic( "_clock_isr", "NULL from sleep queue remove" ); #else c_puts( "*** _clock_isr: NULL from sleep queue\n" ); break; #endif } // and schedule it for dispatch _schedule( pcb ); } // check the current process to see if it needs to be scheduled // sanity check! _current->quantum -= 1; if( _current->quantum < 1 ) { _schedule( _current ); _dispatch(); } #ifdef DUMP_QUEUES // Approximately every 10 seconds, dump the queues, and // print the contents of the SIO buffers. if( (_system_time % SECONDS_TO_TICKS(10)) == 0 ) { c_printf( "Queue contents @%08x\n", _system_time ); _queue_dump( "ready[0]", _ready[0] ); _queue_dump( "ready[1]", _ready[1] ); _queue_dump( "ready[2]", _ready[2] ); _queue_dump( "ready[3]", _ready[3] ); _queue_dump( "sleep", _sleeping ); _sio_dump(); } #endif // tell the PIC we're done __outb( PIC_MASTER_CMD_PORT, PIC_EOI ); }