1/* 2 * Copyright (c) 2007-2013 ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#include <stdlib.h> 11#include <stdio.h> 12#include <string.h> 13 14#include <barrelfish/barrelfish.h> 15#include <barrelfish/nameservice_client.h> 16 17#include <usb/usb.h> 18 19#include "usb_keyboard_driver.h" 20#include "usb_keyboard_service.h" 21 22 23static void keyboard_cb(void* st, usb_error_t uerr) { 24 if (uerr != USB_ERR_OK) { 25 debug_printf("ERROR: Could not initialize the USB driver library: %d\n", uerr); 26 exit(EXIT_FAILURE); 27 } 28 29 uerr = usb_keyboard_init(); 30 31 if (uerr != USB_ERR_OK) { 32 debug_printf("ERROR: Could not initialize the USB keyboard driver library\n"); 33 exit(EXIT_FAILURE); 34 } 35 36 errval_t err = usb_keyboard_service_init(); 37 38 if (err_is_fail(err)) { 39 DEBUG_ERR(err, "failed initializing the keyboard service"); 40 exit(EXIT_FAILURE); 41 } 42 43 uerr = usb_keyboard_start_transfers(); 44 45 if (uerr != USB_ERR_OK) { 46 exit(EXIT_FAILURE); 47 } 48 49 debug_printf("Keyboard initialized.\n"); 50} 51 52int main(int argc, char *argv[]) 53{ 54 USB_DEBUG("####### usb keyboard driver start #######\n"); 55 56 usb_error_t uerr = usb_lib_init(USB_CONFIGURATION_DEFAULT, keyboard_cb, NULL); 57 58 59 if (uerr != USB_ERR_OK) { 60 debug_printf("ERROR: Could not initialize the USB driver library\n"); 61 return (EXIT_FAILURE); 62 } 63 64 messages_handler_loop(); 65 66 USB_DEBUG("####### usb keyboard driver terminated #######\n"); 67} 68