int test_config(void) { unsigned long status; mouse_subscribe_int(); while (mouse_send_command(MOUSE_STATUS) != 0) { }; if (sys_inb(OUT_BUF, &status) == OK) { if (status & BIT(3) & BIT(0)) { printf("1:1 - Linear mode\n"); } else { printf("2:1 - Acceleration mode\n"); } if (status & BIT(5)) { printf("Info Report: ON\n "); } else { printf("Info Report: OFF\n "); } if (status & BIT(6)) { printf("remote: ON\n"); } else { printf("remote: OFF\n"); } sys_inb(OUT_BUF, &status); printf("X Delta: 0x%x\n", status); if (sys_inb(OUT_BUF, &status) == OK) { printf("Y Delta: 0x%x\n", status); } } mouse_unsubscribe_int(); return 0; }
int subscribe_all() { if (timer_subscribe_int() == -1) return -1; if (kbd_subscribe_int() == -1) { timer_unsubscribe_int(); return -1; } if (mouse_subscribe_int() == -1) { kbd_unsubscribe_int(); timer_unsubscribe_int(); return -1; } if (rtc_subscribe_int() == -1) { kbd_unsubscribe_int(); timer_unsubscribe_int(); mouse_unsubscribe_int(); return -1; } if (sp1_subscribe_int() == -1) { kbd_unsubscribe_int(); timer_unsubscribe_int(); mouse_unsubscribe_int(); rtc_unsubscribe_int(); return -1; } if (sp2_subscribe_int() == -1) { kbd_unsubscribe_int(); timer_unsubscribe_int(); mouse_unsubscribe_int(); rtc_unsubscribe_int(); sp1_unsubscribe_int(); return -1; } return 0; }
void leave(){ timer_unsubscribe_int(); kb_unsubscribe_int(); mouse_unsubscribe_int(); empty_out_buf(); vg_exit(); highscore_save(); options_save(); exit(0); }
int test_packet(unsigned short cnt) { unsigned long mouse_byte; int ipc_status, loops = 0,contador = 0; message msg; unsigned char packets[3]; short irq_set = BIT(mouse_subscribe_int()); enable_packets(); while (loops != cnt) { /* Get a request message. */ if (driver_receive(ANY, &msg, &ipc_status) != 0) { printf("driver_receive failed with: %d"); continue; } if (is_ipc_notify(ipc_status)) { /* received notification */ switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: /* hardware interrupt notification */ if (msg.NOTIFY_ARG & irq_set) { mouse_byte = mouse_int_handler(); if (contador == 0) { if (!first_byte(mouse_byte)) { contador = 0; continue; } } packets[contador] = mouse_byte; if (contador == 2) { contador = 0; print_packet(packets); loops++; continue; } contador++; } break; default: break; /* no other notifications expected: do nothing */ } } else { /* received a standard message, not a notification */ /* no standard messages expected: do nothing */ } } return mouse_unsubscribe_int(); }
int unsubscribe_all() { if (timer_unsubscribe_int() != -1 && kbd_unsubscribe_int() != -1 && mouse_unsubscribe_int() != -1 && rtc_unsubscribe_int() != -1) return 0; return -1; }
int racinix_dispatcher() { unsigned rtc_hook_id = RTC_HOOK_BIT; if (rtc_subscribe_int(&rtc_hook_id, false, true, false) < 0) { return 1; } unsigned long seed = racinix_generate_seed(); srand(seed); if (racinix_rtc_reprogram_alarm()) { return 1; } unsigned mouse_hook_id = MOUSE_HOOK_BIT; if (mouse_subscribe_int(&mouse_hook_id) == -1) { return 1; } if (mouse_set_stream_mode(MOUSE_NUM_TRIES)) { return 1; } if (mouse_enable_stream_mode(MOUSE_NUM_TRIES)) { return 1; } mouse_discard_interrupts(MOUSE_NUM_TRIES, MOUSE_HOOK_BIT); if (keyboard_subscribe_int() == -1) { return 1; } unsigned char timer_hook_bit; if ((timer_hook_bit = timer_subscribe_int()) < 0) { return 1; } unsigned serial_hook_id = SERIAL_HOOK_BIT; if (serial_subscribe_int(&serial_hook_id, RACINIX_SERIAL_PORT_NUMBER, RACINIX_SERIAL_TRIGGER_LEVEL) == -1) { return 1; } if (serial_set(RACINIX_SERIAL_PORT_NUMBER, RACINIX_SERIAL_NUM_BITS, RACINIX_SERIAL_NUM_STOP_BITS, RACINIX_SERIAL_PARITY, RACINIX_SERIAL_BAUD_RATE)) { return 1; } mouse_data_packet_t old_mouse_data_packet, new_mouse_data_packet; old_mouse_data_packet.left_button = old_mouse_data_packet.middle_button = old_mouse_data_packet.right_button = false; int r, ipc_status; unsigned fps_counter; message msg; key_t key; while(1) // Main loop { // Get a request message. if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) { // Driver receive fail continue; } if (is_ipc_notify(ipc_status)) { // received notification if (_ENDPOINT_P(msg.m_source) == HARDWARE) // hardware interrupt notification { // Keyboard if (msg.NOTIFY_ARG & BIT(KEYBOARD_HOOK_BIT)) { if ((key = racinix_keyboard_int_handler()) == -1) { return 1; } if (racinix_event_handler(RACINIX_EVENT_KEYSTROKE, kbd_keys[key].makecode, kbd_keys[key].pressed) == -1) { break; } } // Timer if (msg.NOTIFY_ARG & BIT(timer_hook_bit)) { if (racinix_serial_int_handler()) // Sometimes VMWare stops sending interrupts for no reason... { return 1; } if ((fps_counter = racinix_timer_int_handler()) != -1) { if (racinix_event_handler(RACINIX_EVENT_NEW_FRAME, fps_counter) == RACINIX_STATE_END) { break; } } } // Mouse if (msg.NOTIFY_ARG & BIT(MOUSE_HOOK_BIT)) { if (racinix_mouse_int_handler(&new_mouse_data_packet) == 0) // Packet ready { if (racinix_event_handler(RACINIX_EVENT_MOUSE_MOVEMENT, &new_mouse_data_packet) == RACINIX_STATE_END) { break; } if (new_mouse_data_packet.left_button != old_mouse_data_packet.left_button) { if (racinix_event_handler(RACINIX_EVENT_MOUSE_LEFT_BTN, new_mouse_data_packet.left_button) == RACINIX_STATE_END) { break; } } if (new_mouse_data_packet.right_button != old_mouse_data_packet.right_button) { if (racinix_event_handler(RACINIX_EVENT_MOUSE_RIGHT_BTN, new_mouse_data_packet.right_button) == RACINIX_STATE_END) { break; } } old_mouse_data_packet = new_mouse_data_packet; } } // Serial port if (msg.NOTIFY_ARG & BIT(SERIAL_HOOK_BIT)) { if (racinix_serial_int_handler()) { break; } } // RTC if (msg.NOTIFY_ARG & BIT(RTC_HOOK_BIT)) { if (racinix_rtc_int_handler()) { break; } } } } } timer_unsubscribe_int(); keyboard_unsubscribe_int(); mouse_disable_stream_mode(MOUSE_NUM_TRIES); mouse_unsubscribe_int(mouse_hook_id); rtc_unsubscribe_int(rtc_hook_id); return 0; }