Changeset af430ce in mainline


Ignore:
Timestamp:
2011-03-02T15:01:47Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
24aa62c
Parents:
37b1651d (diff), 30db06c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Various small fixes

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/kbddev.c

    r37b1651d raf430ce  
    289289
    290290        usb_log_debug2("Sending key %d to the console\n", ev.key);
    291         assert(kbd_dev->console_phone != -1);
     291        if (kbd_dev->console_phone < 0) {
     292                usb_log_warning(
     293                    "Connection to console not ready, key discarded.\n");
     294                return;
     295        }
    292296       
    293297        async_msg_4(kbd_dev->console_phone, KBD_EVENT, ev.type, ev.key,
  • uspace/drv/usbhid/usbhid.ma

    r37b1651d raf430ce  
    1 10 usb&class=hid
    2 10 usb&class=HID
     1100 usb&interface&class=HID&subclass=0x01&protocol=0x01
    3210 usb&interface&class=HID
    4 10 usb&hid
  • uspace/lib/usb/src/request.c

    r37b1651d raf430ce  
    504504 *
    505505 * @param[in] pipe Control endpoint pipe (session must be already started).
    506  * @param[in] index String index (in native endianess).
     506 * @param[in] index String index (in native endianess),
     507 *      first index has number 1 (index from descriptors can be used directly).
    507508 * @param[in] lang String language (in native endianess).
    508509 * @param[out] string_ptr Where to store allocated string in native encoding.
     
    515516                return EBADMEM;
    516517        }
    517         /* Index is actually one byte value. */
    518         if (index > 0xFF) {
     518        /*
     519         * Index is actually one byte value and zero index is used
     520         * to retrieve list of supported languages.
     521         */
     522        if ((index < 1) || (index > 0xFF)) {
    519523                return ERANGE;
    520524        }
  • uspace/srv/hid/console/console.c

    r37b1651d raf430ce  
    4141#include <ipc/ns.h>
    4242#include <errno.h>
     43#include <str_error.h>
    4344#include <ipc/console.h>
    4445#include <unistd.h>
     
    6465#define NAME       "console"
    6566#define NAMESPACE  "term"
     67/** Interval for checking for new keyboard (1/4s). */
     68#define HOTPLUG_WATCH_INTERVAL (1000 * 250)
    6669
    6770/** Phone to the keyboard driver. */
     
    725728        }
    726729       
    727         /* NB: The callback connection is slotted for removal */
    728         sysarg_t phonehash;
    729         sysarg_t taskhash;
    730         int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, SERVICE_CONSOLE,
    731             0, 0, NULL, NULL, NULL, &taskhash, &phonehash);
     730        int rc = async_connect_to_me(phone, SERVICE_CONSOLE, 0, 0,
     731            keyboard_events);
    732732        if (rc != EOK) {
    733                 printf(NAME ": Failed to create callback from input device\n");
     733                printf(NAME ": " \
     734                    "Failed to create callback from input device: %s.\n",
     735                    str_error(rc));
    734736                return rc;
    735737        }
    736738       
    737         async_new_connection(taskhash, phonehash, 0, NULL, keyboard_events);
    738 
    739         printf(NAME ": we got a hit (new keyboard \"%s\").\n", path);
     739        printf(NAME ": found keyboard \"%s\".\n", path);
    740740
    741741        return phone;
    742742}
    743743
    744 /** Try to connect to given keyboard, bypassing provided libc routines.
     744
     745/** Periodically check for new keyboards in /dev/class/.
    745746 *
    746  * @param devmap_path Path to keyboard without /dev prefix.
    747  * @return Phone or error code.
     747 * @param arg Class name.
     748 * @return This function should never exit.
    748749 */
    749 static int connect_keyboard_bypass(char *devmap_path)
    750 {
    751         int devmap_phone = async_connect_me_to_blocking(PHONE_NS,
    752             SERVICE_DEVMAP, DEVMAP_CLIENT, 0);
    753         if (devmap_phone < 0) {
    754                 return devmap_phone;
    755         }
    756         ipc_call_t answer;
    757         aid_t req = async_send_2(devmap_phone, DEVMAP_DEVICE_GET_HANDLE,
    758             0, 0,  &answer);
    759 
    760         sysarg_t retval = async_data_write_start(devmap_phone,
    761             devmap_path, str_size(devmap_path));
    762         if (retval != EOK) {
    763                 async_wait_for(req, NULL);
    764                 async_hangup(devmap_phone);
    765                 return retval;
    766         }
    767 
    768         async_wait_for(req, &retval);
    769 
    770         if (retval != EOK) {
    771                 async_hangup(devmap_phone);
    772                 return retval;
    773         }
    774 
    775         devmap_handle_t handle = (devmap_handle_t) IPC_GET_ARG1(answer);
    776 
    777         async_hangup(devmap_phone);
    778 
    779         int phone = async_connect_me_to(PHONE_NS,
    780             SERVICE_DEVMAP, DEVMAP_CONNECT_TO_DEVICE, handle);
    781         if (phone < 0) {
    782                 return phone;
    783         }
    784 
    785         /* NB: The callback connection is slotted for removal */
    786         sysarg_t phonehash;
    787         sysarg_t taskhash;
    788         int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, SERVICE_CONSOLE,
    789             0, 0, NULL, NULL, NULL, &taskhash, &phonehash);
    790         if (rc != EOK) {
    791                 printf(NAME ": Failed to create callback from input device\n");
    792                 return rc;
    793         }
    794 
    795         async_new_connection(taskhash, phonehash, 0, NULL, keyboard_events);
    796 
    797         printf(NAME ": we got a hit (new keyboard \"/dev/%s\").\n",
    798             devmap_path);
    799 
    800         return phone;
    801 }
    802 
    803 
    804750static int check_new_keyboards(void *arg)
    805751{
    806752        char *class_name = (char *) arg;
    807753
    808         int index = 1;
     754        size_t index = 1;
    809755
    810756        while (true) {
    811                 async_usleep(1 * 500 * 1000);
     757                async_usleep(HOTPLUG_WATCH_INTERVAL);
    812758                char *path;
    813                 int rc = asprintf(&path, "class/%s\\%d", class_name, index);
     759                int rc = asprintf(&path, "/dev/class/%s\\%zu",
     760                    class_name, index);
    814761                if (rc < 0) {
    815762                        continue;
    816763                }
    817764                rc = 0;
    818                 rc = connect_keyboard_bypass(path);
     765                rc = connect_keyboard(path);
    819766                if (rc > 0) {
    820767                        /* We do not allow unplug. */
Note: See TracChangeset for help on using the changeset viewer.