Changeset e1dbcbc in mainline for uspace/app


Ignore:
Timestamp:
2011-04-29T13:43:01Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a81a1d09
Parents:
380e0364 (diff), f19f1b7 (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:

Merge development/ changes

Location:
uspace/app
Files:
5 added
8 edited
4 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r380e0364 re1dbcbc  
    195195                                        wchar_t c = str_decode(buff, &offset, bytes);
    196196                                        if (c == 0) {
    197                                                 // reached end of string
     197                                                /* Reached end of string */
    198198                                                break;
    199199                                        }
     
    228228        int rc;
    229229       
    230         // reset global state
    231         // TODO: move to structure?
     230        /*
     231         * reset global state
     232         * TODO: move to structure?
     233         */
    232234        paging_enabled = false;
    233235        chars_remaining = 0;
  • uspace/app/trace/trace.c

    r380e0364 re1dbcbc  
    5353#include <libc.h>
    5454
    55 // Temporary: service and method names
     55/* Temporary: service and method names */
    5656#include "proto.h"
    5757#include <ipc/services.h>
  • uspace/app/usbinfo/dev.c

    r380e0364 re1dbcbc  
    7777        }
    7878
    79         rc = usb_pipe_start_long_transfer(&dev->ctrl_pipe);
    80         if (rc != EOK) {
    81                 fprintf(stderr,
    82                     NAME ": failed to start transfer on control pipe: %s.\n",
    83                     str_error(rc));
    84                 goto leave;
    85         }
     79        usb_pipe_start_long_transfer(&dev->ctrl_pipe);
    8680        transfer_started = true;
    8781
  • uspace/app/usbinfo/main.c

    r380e0364 re1dbcbc  
    5555        if (str_cmp(devpath, "qemu") == 0) {
    5656                devpath = "/hw/pci0/00:01.2/uhci-rh/usb00_a1";
     57        }
     58
     59        /* Hack for virtual keyboard. */
     60        if (str_cmp(devpath, "virt") == 0) {
     61                devpath = "/virt/usbhc/usb00_a1/usb00_a2";
    5762        }
    5863
  • uspace/app/virtusbkbd/Makefile

    r380e0364 re1dbcbc  
    3232BINARY = vuk
    3333
    34 LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBUSBVIRT_PREFIX)/libusbvirt.a
     34LIBS = $(LIBUSBVIRT_PREFIX)/libusbvirt.a $(LIBUSB_PREFIX)/libusb.a
    3535EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBUSBVIRT_PREFIX)/include -I$(LIBDRV_PREFIX)/include
    3636
  • uspace/app/virtusbkbd/stdreq.c

    r380e0364 re1dbcbc  
    3939#include "kbdconfig.h"
    4040
    41 int stdreq_on_get_descriptor(struct usbvirt_device *dev,
    42     usb_device_request_setup_packet_t *request, uint8_t *data)
     41int req_get_descriptor(usbvirt_device_t *device,
     42    const usb_device_request_setup_packet_t *setup_packet,
     43    uint8_t *data, size_t *act_size)
    4344{
    44         if (request->value_high == USB_DESCTYPE_HID_REPORT) {
     45        if (setup_packet->value_high == USB_DESCTYPE_HID_REPORT) {
    4546                /*
    4647                 * For simplicity, always return the same
    4748                 * report descriptor.
    4849                 */
    49                 int rc = dev->control_transfer_reply(dev, 0,
     50                usbvirt_control_reply_helper(setup_packet,
     51                    data, act_size,
    5052                    report_descriptor, report_descriptor_size);
    51                
    52                 return rc;
     53
     54                return EOK;
    5355        }
    5456       
  • uspace/app/virtusbkbd/stdreq.h

    r380e0364 re1dbcbc  
    3838#include <usbvirt/device.h>
    3939
    40 int stdreq_on_get_descriptor(usbvirt_device_t *,
    41     usb_device_request_setup_packet_t *, uint8_t *);
     40int req_get_descriptor(usbvirt_device_t *device,
     41    const usb_device_request_setup_packet_t *setup_packet,
     42    uint8_t *data, size_t *act_size);
    4243
    4344#endif
  • uspace/app/virtusbkbd/virtusbkbd.c

    r380e0364 re1dbcbc  
    4848#include <usb/descriptor.h>
    4949#include <usb/classes/hid.h>
     50#include <usb/debug.h>
    5051#include <usbvirt/device.h>
    51 #include <usbvirt/hub.h>
    5252
    5353#include "kbdconfig.h"
     
    6767
    6868kb_status_t status;
    69 
    70 static int on_incoming_data(struct usbvirt_device *dev,
    71     usb_endpoint_t endpoint, void *buffer, size_t size)
    72 {
    73         printf("%s: ignoring incomming data to endpoint %d\n", NAME, endpoint);
    74        
    75         return EOK;
    76 }
    77 
    7869
    7970/** Compares current and last status of pressed keys.
     
    10091}
    10192
    102 static int on_request_for_data(struct usbvirt_device *dev,
    103     usb_endpoint_t endpoint, void *buffer, size_t size, size_t *actual_size)
     93static int on_request_for_data(usbvirt_device_t *dev,
     94    usb_endpoint_t endpoint, usb_transfer_type_t transfer_type,
     95    void *buffer, size_t size, size_t *actual_size)
    10496{
    10597        static uint8_t last_data[2 + KB_MAX_KEYS_AT_ONCE];
     
    122114        if (keypress_check_with_last_request(data, last_data,
    123115            2 + KB_MAX_KEYS_AT_ONCE)) {
    124                 *actual_size = 0;
    125                 return EOK;
     116                return ENAK;
    126117        }
    127118
     
    131122}
    132123
    133 static usbvirt_control_transfer_handler_t endpoint_zero_handlers[] = {
    134         {
    135                 .request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(
    136                     USB_DIRECTION_IN,
    137                     USBVIRT_REQUEST_TYPE_STANDARD,
    138                     USBVIRT_REQUEST_RECIPIENT_DEVICE),
     124static usbvirt_control_request_handler_t endpoint_zero_handlers[] = {
     125        {
     126                .req_direction = USB_DIRECTION_IN,
     127                .req_type = USB_REQUEST_TYPE_STANDARD,
     128                .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE,
    139129                .request = USB_DEVREQ_GET_DESCRIPTOR,
    140130                .name = "GetDescriptor",
    141                 .callback = stdreq_on_get_descriptor
     131                .callback = req_get_descriptor
    142132        },
    143133        {
    144                 .request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(
    145                     USB_DIRECTION_IN,
    146                     USBVIRT_REQUEST_TYPE_CLASS,
    147                     USBVIRT_REQUEST_RECIPIENT_DEVICE),
    148                 .request = USB_DEVREQ_GET_DESCRIPTOR,
    149                 .name = "GetDescriptor",
    150                 .callback = stdreq_on_get_descriptor
    151         },
    152         USBVIRT_CONTROL_TRANSFER_HANDLER_LAST
     134                .callback = NULL
     135        }
    153136};
    154137
     
    157140 */
    158141static usbvirt_device_ops_t keyboard_ops = {
    159         .control_transfer_handlers = endpoint_zero_handlers,
    160         .on_data = on_incoming_data,
    161         .on_data_request = on_request_for_data
     142        .control = endpoint_zero_handlers,
     143        .data_in[1] = on_request_for_data
    162144};
    163145
     
    197179        .ops = &keyboard_ops,
    198180        .descriptors = &descriptors,
    199         .lib_debug_level = 3,
    200         .lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL,
    201181        .name = "keyboard"
    202182};
     
    262242       
    263243       
    264         int rc = usbvirt_connect(&keyboard_dev);
     244        int rc = usbvirt_device_plug(&keyboard_dev, "/virt/usbhc/hc");
    265245        if (rc != EOK) {
    266246                printf("%s: Unable to start communication with VHCD (%s).\n",
     
    278258        printf("%s: Terminating...\n", NAME);
    279259       
    280         usbvirt_disconnect(&keyboard_dev);
     260        //usbvirt_disconnect(&keyboard_dev);
    281261       
    282262        return 0;
  • uspace/app/vuhid/Makefile

    r380e0364 re1dbcbc  
    2828
    2929USPACE_PREFIX = ../..
    30 # acronym for virtual USB hub
     30# acronym for virtual USB human input device
    3131# (it is really annoying to write long names)
    3232BINARY = vuh
    3333
    34 LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBUSBVIRT_PREFIX)/libusbvirt.a
    35 EXTRA_CFLAGS = -DSTANDALONE_HUB \
    36         -DHUB_PORT_COUNT=10 \
    37         -I$(LIBUSB_PREFIX)/include -I$(LIBUSBVIRT_PREFIX)/include -I$(LIBDRV_PREFIX)/include
     34LIBS = \
     35        $(LIBUSBVIRT_PREFIX)/libusbvirt.a \
     36        $(LIBUSB_PREFIX)/libusb.a
     37EXTRA_CFLAGS = \
     38        -I$(LIBUSB_PREFIX)/include \
     39        -I$(LIBUSBVIRT_PREFIX)/include \
     40        -I$(LIBDRV_PREFIX)/include
     41
     42
     43SOURCES_INTERFACES = \
     44        hids/bootkbd.c
    3845
    3946SOURCES = \
    4047        main.c \
    41         $(STOLEN_VHC_SOURCES)
    42 
    43 STOLEN_VHC_SOURCES = \
    44         vhc_hub/hub.c \
    45         vhc_hub/virthub.c \
    46         vhc_hub/virthubops.c
    47 STOLEN_VHC_HEADERS = \
    48         vhc_hub/hub.h \
    49         vhc_hub/virthub.h
    50 
    51 PRE_DEPEND = $(STOLEN_VHC_SOURCES) $(STOLEN_VHC_HEADERS)
    52 
    53 EXTRA_CLEAN = $(STOLEN_VHC_SOURCES) $(STOLEN_VHC_HEADERS)
    54 
    55 HUB_IN_VHC = $(USPACE_PREFIX)/drv/vhc/hub
     48        device.c \
     49        ifaces.c \
     50        stdreq.c \
     51        $(SOURCES_INTERFACES)
     52       
    5653
    5754include $(USPACE_PREFIX)/Makefile.common
    58 
    59 vhc_hub/%.h: $(HUB_IN_VHC)/%.h
    60         ln -sfn ../$(HUB_IN_VHC)/$*.h $@
    61 vhc_hub/%.c: $(HUB_IN_VHC)/%.c
    62         ln -sfn ../$(HUB_IN_VHC)/$*.c $@
  • uspace/app/vuhid/ifaces.c

    r380e0364 re1dbcbc  
    11/*
    2  * Copyright (c) 2007 Jan Hudecek
    3  * Copyright (c) 2008 Martin Decky
     2 * Copyright (c) 2011 Vojtech Horky
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 /** @addtogroup genericproc
     29/** @addtogroup usbvirthid
    3130 * @{
    3231 */
    33 /** @file tasklet.c
    34  *  @brief Tasklet implementation
     32/**
     33 * @file
     34 * List of known interfaces.
    3535 */
     36#include <stdlib.h>
     37#include "ifaces.h"
    3638
    37 #include <proc/tasklet.h>
    38 #include <synch/spinlock.h>
    39 #include <mm/slab.h>
    40 #include <config.h>
     39extern vuhid_interface_t vuhid_interface_bootkbd;
    4140
    42 /** Spinlock protecting list of tasklets */
    43 SPINLOCK_INITIALIZE(tasklet_lock);
    44 
    45 /** Array of tasklet lists for every CPU */
    46 tasklet_descriptor_t **tasklet_list;
    47 
    48 void tasklet_init(void)
    49 {
    50         unsigned int i;
    51        
    52         tasklet_list = malloc(sizeof(tasklet_descriptor_t *) * config.cpu_count, 0);
    53         if (!tasklet_list)
    54                 panic("Error initializing tasklets.");
    55        
    56         for (i = 0; i < config.cpu_count; i++)
    57                 tasklet_list[i] = NULL;
    58        
    59         spinlock_initialize(&tasklet_lock, "tasklet_lock");
    60 }
     41vuhid_interface_t *available_hid_interfaces[] = {
     42        &vuhid_interface_bootkbd,
     43        NULL
     44};
    6145
    6246
  • uspace/app/vuhid/stdreq.h

    r380e0364 re1dbcbc  
    11/*
    2  * Copyright (c) 2007 Jan Hudecek
    3  * Copyright (c) 2008 Martin Decky
     2 * Copyright (c) 2011 Vojtech Horky
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 /** @addtogroup genericproc
     29/** @addtogroup usbvirthid
    3130 * @{
    3231 */
    33 /** @file tasklet.h
    34  * @brief Tasklets declarations
     32/** @file
     33 * Device request handlers.
    3534 */
     35#ifndef VUHID_STDREQ_H_
     36#define VUHID_STDREQ_H_
    3637
    37 #ifndef KERN_TASKLET_H_
    38 #define KERN_TASKLET_H_
     38#include <usbvirt/device.h>
    3939
    40 #include <adt/list.h>
     40int req_get_descriptor(usbvirt_device_t *device,
     41    const usb_device_request_setup_packet_t *setup_packet,
     42    uint8_t *data, size_t *act_size);
    4143
    42 /** Tasklet callback type */
    43 typedef void (* tasklet_callback_t)(void *arg);
     44int req_set_protocol(usbvirt_device_t *device,
     45    const usb_device_request_setup_packet_t *setup_packet,
     46    uint8_t *data, size_t *act_size);
    4447
    45 /** Tasklet state */
    46 typedef enum {
    47         NotActive,
    48         Scheduled,
    49         InProgress,
    50         Disabled
    51 } tasklet_state_t;
    52 
    53 /** Structure describing a tasklet */
    54 typedef struct tasklet_descriptor {
    55         link_t link;
    56        
    57         /** Callback to call */
    58         tasklet_callback_t callback;
    59        
    60         /** Argument passed to the callback */
    61         void *arg;
    62        
    63         /** State of the tasklet */
    64         tasklet_state_t state;
    65 } tasklet_descriptor_t;
    66 
    67 
    68 extern void tasklet_init(void);
     48int req_set_report(usbvirt_device_t *device,
     49    const usb_device_request_setup_packet_t *setup_packet,
     50    uint8_t *data, size_t *act_size);
    6951
    7052#endif
    71 
    72 /** @}
     53/**
     54 * @}
    7355 */
  • uspace/app/vuhid/virthid.h

    r380e0364 re1dbcbc  
    2727 */
    2828
    29 /** @addtogroup usbvirthub
     29/** @addtogroup usbvirthid
    3030 * @{
    3131 */
    32 /**
    33  * @file
    34  * @brief Virtual USB hub.
     32/** @file
     33 *
    3534 */
    36 
    37 #include <stdio.h>
    38 #include <stdlib.h>
    39 #include <errno.h>
    40 #include <str_error.h>
    41 #include <bool.h>
     35#ifndef VUHID_VIRTHID_H_
     36#define VUHID_VIRTHID_H_
    4237
    4338#include <usb/usb.h>
    44 #include <usb/descriptor.h>
    45 #include <usb/classes/hub.h>
    4639#include <usbvirt/device.h>
    47 #include <usbvirt/hub.h>
    4840
    49 #include "vhc_hub/virthub.h"
     41#define VUHID_ENDPOINT_MAX USB11_ENDPOINT_MAX
     42#define VUHID_INTERFACE_MAX 8
    5043
    51 #define NAME "vuh"
     44typedef struct vuhid_interface vuhid_interface_t;
    5245
    53 static usbvirt_device_t hub_device;
     46struct vuhid_interface {
     47        const char *name;
     48        const char *id;
     49        int usb_subclass;
     50        int usb_protocol;
    5451
    55 #define VERBOSE_SLEEP(sec, msg, ...) \
    56         do { \
    57                 char _status[HUB_PORT_COUNT + 2]; \
    58                 printf(NAME ": doing nothing for %zu seconds...\n", \
    59                     (size_t) (sec)); \
    60                 fibril_sleep((sec)); \
    61                 virthub_get_status(&hub_device, _status, HUB_PORT_COUNT + 1); \
    62                 printf(NAME ": " msg " [%s]\n" #__VA_ARGS__, _status); \
    63         } while (0)
     52        uint8_t *report_descriptor;
     53        size_t report_descriptor_size;
    6454
    65 static void fibril_sleep(size_t sec)
    66 {
    67         while (sec-- > 0) {
    68                 async_usleep(1000*1000);
    69         }
    70 }
     55        size_t in_data_size;
     56        size_t out_data_size;
    7157
    72 static int dev1 = 1;
     58        int (*on_data_in)(vuhid_interface_t *, void *, size_t, size_t *);
     59        int (*on_data_out)(vuhid_interface_t *, void *, size_t);
     60        void (*live)(vuhid_interface_t *);
    7361
    74 int main(int argc, char * argv[])
    75 {
    76         int rc;
     62        int set_protocol;
    7763
    78         printf(NAME ": virtual USB hub.\n");
     64        void *interface_data;
     65};
    7966
    80         rc = virthub_init(&hub_device);
    81         if (rc != EOK) {
    82                 printf(NAME ": Unable to start communication with VHCD (%s).\n",
    83                     str_error(rc));
    84                 return rc;
    85         }
    86        
    87         while (true) {
    88                 VERBOSE_SLEEP(8, "will pretend device plug-in...");
    89                 virthub_connect_device(&hub_device, &dev1);
     67typedef struct {
     68        vuhid_interface_t *in_endpoints_mapping[VUHID_ENDPOINT_MAX];
     69        size_t in_endpoint_first_free;
     70        vuhid_interface_t *out_endpoints_mapping[VUHID_ENDPOINT_MAX];
     71        size_t out_endpoint_first_free;
     72        vuhid_interface_t *interface_mapping[VUHID_INTERFACE_MAX];
     73} vuhid_data_t;
    9074
    91                 VERBOSE_SLEEP(8, "will pretend device un-plug...");
    92                 virthub_disconnect_device(&hub_device, &dev1);
    93         }
     75typedef struct {
     76        uint8_t length;
     77        uint8_t type;
     78        uint16_t hid_spec_release;
     79        uint8_t country_code;
     80        uint8_t descriptor_count;
     81        uint8_t descriptor1_type;
     82        uint16_t descriptor1_length;
     83} __attribute__ ((packed)) hid_descriptor_t;
    9484
    95         usbvirt_disconnect(&hub_device);
    96        
    97         return 0;
    98 }
     85int add_interface_by_id(vuhid_interface_t **, const char *, usbvirt_device_t *);
    9986
    100 
    101 /** @}
     87#endif
     88/**
     89 * @}
    10290 */
Note: See TracChangeset for help on using the changeset viewer.