Changes in / [bdc8ab1:9445aad] in mainline


Ignore:
Files:
7 added
25 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    rbdc8ab1 r9445aad  
    8989./uspace/drv/usbhid/usbhid
    9090./uspace/drv/usbmid/usbmid
     91./uspace/drv/usbmouse/usbmouse
    9192./uspace/drv/vhc/vhc
    9293./uspace/srv/bd/ata_bd/ata_bd
  • Makefile

    rbdc8ab1 r9445aad  
    4242CONFIG_HEADER = config.h
    4343
    44 .PHONY: all precheck cscope autotool config_auto config_default config distclean clean check
     44.PHONY: all precheck cscope autotool config_auto config_default config distclean clean check distfile dist
    4545
    4646all: $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER)
     
    6464endif
    6565
     66# Autotool (detects compiler features)
     67
    6668$(COMMON_MAKEFILE): autotool
    6769$(COMMON_HEADER): autotool
     
    7072        $(AUTOTOOL)
    7173        -[ -f $(COMMON_HEADER_PREV) ] && diff -q $(COMMON_HEADER_PREV) $(COMMON_HEADER) && mv -f $(COMMON_HEADER_PREV) $(COMMON_HEADER)
     74
     75# Build-time configuration
    7276
    7377$(CONFIG_MAKEFILE): config_default
     
    8488        $(CONFIG) $<
    8589
     90# Distribution files
     91
     92distfile: all
     93        $(MAKE) -C dist distfile
     94
     95dist:
     96        $(MAKE) -C dist dist
     97
     98# Cleaning
     99
    86100distclean: clean
    87         rm -f $(CSCOPE).out $(COMMON_MAKEFILE) $(COMMON_HEADER) $(COMMON_HEADER_PREV) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) tools/*.pyc tools/checkers/*.pyc
     101        rm -f $(CSCOPE).out $(COMMON_MAKEFILE) $(COMMON_HEADER) $(COMMON_HEADER_PREV) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) tools/*.pyc tools/checkers/*.pyc dist/HelenOS-*
    88102
    89103clean:
  • boot/arch/amd64/Makefile.inc

    rbdc8ab1 r9445aad  
    4848        usbhid \
    4949        usbmid \
     50        usbmouse \
    5051        vhc
    5152
  • boot/arch/sparc64/include/arch.h

    rbdc8ab1 r9445aad  
    4141#define STACK_BIAS                   2047
    4242#define STACK_WINDOW_SAVE_AREA_SIZE  (16 * 8)
     43#define STACK_ARG_SAVE_AREA_SIZE     (6 * 8)
    4344
    4445#define NWINDOWS  8
  • boot/arch/sparc64/src/asm.S

    rbdc8ab1 r9445aad  
    152152.global ofw
    153153ofw:
    154         save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
     154        save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp
    155155        set ofw_cif, %l0
    156156        ldx [%l0], %l0
  • boot/arch/sparc64/src/main.c

    rbdc8ab1 r9445aad  
    190190        bootinfo.memmap.zones[0].start += OBP_BIAS;
    191191        bootinfo.memmap.zones[0].size -= OBP_BIAS;
     192        bootinfo.memmap.total -= OBP_BIAS;
    192193}
    193194
     
    204205        bootinfo.physmem_start = ofw_get_physmem_start();
    205206        ofw_memmap(&bootinfo.memmap);
     207
     208        if (arch == ARCH_SUN4V)
     209                sun4v_fixups();
    206210       
    207211        void *bootinfo_pa = ofw_translate(&bootinfo);
     
    253257               
    254258                /*
    255                  * At this point, we claim the physical memory that we are
    256                  * going to use. We should be safe in case of the virtual
     259                 * At this point, we claim and map the physical memory that we
     260                 * are going to use. We should be safe in case of the virtual
    257261                 * address space because the OpenFirmware, according to its
    258                  * SPARC binding, should restrict its use of virtual memory
    259                  * to addresses from [0xffd00000; 0xffefffff] and
    260                  * [0xfe000000; 0xfeffffff].
    261                  *
    262                  * We don't map this piece of memory. We simply rely on
    263                  * SILO to have it done for us already in this case.
    264                  *
    265                  * XXX SILO only maps 8 MB for us here. We should improve
    266                  *     this code to be totally independent on the behavior
    267                  *     of SILO.
    268                  *
     262                 * SPARC binding, should restrict its use of virtual memory to
     263                 * addresses from [0xffd00000; 0xffefffff] and [0xfe000000;
     264                 * 0xfeffffff].
    269265                 */
    270266                ofw_claim_phys(bootinfo.physmem_start + dest[i - 1],
    271267                    ALIGN_UP(components[i - 1].inflated, PAGE_SIZE));
     268               
     269                ofw_map(bootinfo.physmem_start + dest[i - 1], dest[i - 1],
     270                    ALIGN_UP(components[i - 1].inflated, PAGE_SIZE), -1);
    272271               
    273272                int err = inflate(components[i - 1].start, components[i - 1].size,
     
    304303                sun4u_smp();
    305304       
    306         if (arch == ARCH_SUN4V)
    307                 sun4v_fixups();
    308        
    309305        printf("Booting the kernel ...\n");
    310306        jump_to_kernel(bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo, subarch,
  • boot/generic/src/balloc.c

    rbdc8ab1 r9445aad  
    6565void *balloc_rebase(void *ptr)
    6666{
    67         return (void *) ((uintptr_t) ptr - phys_base + ballocs->base);
     67        return (void *) (((uintptr_t) ptr - phys_base) + ballocs->base);
    6868}
  • kernel/arch/sparc64/src/sun4v/asm.S

    rbdc8ab1 r9445aad  
    4141.global switch_to_userspace
    4242switch_to_userspace:
    43         wrpr PSTATE_PRIV_BIT, %pstate
    44         save %o1, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
     43        save %o1, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp
    4544        flushw
    4645        wrpr %g0, 0, %cleanwin          ! avoid information leak
  • tools/toolchain.sh

    rbdc8ab1 r9445aad  
    2828# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2929#
     30
     31GMP_MAIN=<<EOF
     32#define GCC_GMP_VERSION_NUM(a, b, c) \
     33        (((a) << 16L) | ((b) << 8) | (c))
     34
     35#define GCC_GMP_VERSION \
     36        GCC_GMP_VERSION_NUM(__GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL)
     37
     38#if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,3,2)
     39        choke me
     40#endif
     41EOF
     42
     43MPFR_MAIN=<<EOF
     44#if MPFR_VERSION < MPFR_VERSION_NUM(2, 4, 2)
     45choke me
     46        #endif
     47EOF
     48
     49MPC_MAIN=<<EOF
     50#if MPC_VERSION < MPC_VERSION_NUM(0, 8, 1)
     51        choke me
     52#endif
     53EOF
     54
     55#
     56# Check if the library described in the argument
     57# exists and has acceptable version.
     58#
     59check_dependency() {
     60        DEPENDENCY="$1"
     61        HEADER="$2"
     62        BODY="$3"
     63       
     64        FNAME="/tmp/conftest-$$"
     65       
     66        echo "#include ${HEADER}" > "${FNAME}.c"
     67        echo >> "${FNAME}.c"
     68        echo "int main()" >> "${FNAME}.c"
     69        echo "{" >> "${FNAME}.c"
     70        echo "${BODY}" >> "${FNAME}.c"
     71        echo "  return 0;" >> "${FNAME}.c"
     72        echo "}" >> "${FNAME}.c"
     73       
     74        cc -c -o "${FNAME}.o" "${FNAME}.c" 2> "${FNAME}.log"
     75        RC="$?"
     76       
     77        if [ "$RC" -ne "0" ] ; then
     78                echo " ${DEPENDENCY} not found, too old or compiler error."
     79                echo " Please recheck manually the source file \"${FNAME}.c\"."
     80                echo " The compilation of the toolchain is probably going to fail,"
     81                echo " you have been warned."
     82                echo
     83                echo " ===== Compiler output ====="
     84                cat "${FNAME}.log"
     85                echo " ==========================="
     86                echo
     87        else
     88                echo " ${DEPENDENCY} found"
     89                rm -f "${FNAME}.log" "${FNAME}.o" "${FNAME}.c"
     90        fi
     91}
     92
     93check_dependecies() {
     94        echo ">>> Basic dependency check"
     95        check_dependency "GMP" "<gmp.h>" "${GMP_MAIN}"
     96        check_dependency "MPFR" "<mpfr.h>" "${MPFR_MAIN}"
     97        check_dependency "MPC" "<mpc.h>" "${MPC_MAIN}"
     98        echo
     99}
    30100
    31101check_error() {
     
    69139        echo " sparc64    SPARC V9"
    70140        echo " all        build all targets"
     141        echo
     142        echo "The toolchain will be installed to the directory specified by"
     143        echo "the CROSS_PREFIX environment variable. If the variable is not"
     144        echo "defined, /usr/local will be used by default."
    71145        echo
    72146       
     
    118192        echo " - native C library with headers"
    119193        echo
    120        
    121         show_countdown 10
    122194}
    123195
     
    281353
    282354show_dependencies
     355check_dependecies
     356show_countdown 10
    283357
    284358case "$1" in
  • uspace/Makefile

    rbdc8ab1 r9445aad  
    122122                drv/usbhub \
    123123                drv/usbmid \
     124                drv/usbmouse \
    124125                drv/vhc
    125126endif
     
    138139                drv/usbhub \
    139140                drv/usbmid \
     141                drv/usbmouse \
    140142                drv/vhc
    141143endif
  • uspace/app/bdsh/cmds/modules/mount/mount.c

    rbdc8ab1 r9445aad  
    3131#include <vfs/vfs.h>
    3232#include <errno.h>
     33#include <getopt.h>
    3334#include "config.h"
    3435#include "util.h"
     
    4041static const char *cmdname = "mount";
    4142
    42 /* Dispays help for mount in various levels */
     43static struct option const long_options[] = {
     44        { "help", no_argument, 0, 'h' },
     45        { 0, 0, 0, 0 }
     46};
     47
     48
     49/* Displays help for mount in various levels */
    4350void help_cmd_mount(unsigned int level)
    4451{
     
    5966        unsigned int argc;
    6067        const char *mopts = "";
    61         int rc;
     68        int rc, c, opt_ind;
    6269
    6370        argc = cli_count_args(argv);
    6471
     72        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
     73                c = getopt_long(argc, argv, "h", long_options, &opt_ind);
     74                switch (c) {
     75                case 'h':
     76                        help_cmd_mount(HELP_LONG);
     77                        return CMD_SUCCESS;
     78                }
     79        }
     80
    6581        if ((argc < 4) || (argc > 5)) {
    66                 printf("%s: invalid number of arguments.\n",
     82                printf("%s: invalid number of arguments. Try `mount --help'\n",
    6783                    cmdname);
    6884                return CMD_FAILURE;
  • uspace/doc/doxygroups.h

    rbdc8ab1 r9445aad  
    245245
    246246        /**
     247         * @defgroup drvusbmouse USB mouse driver
     248         * @ingroup usb
     249         * @brief USB driver for mouse with boot protocol.
     250         */
     251
     252        /**
    247253         * @defgroup drvusbuhci UHCI driver
    248254         * @ingroup usb
  • uspace/drv/usbhid/hiddev.c

    rbdc8ab1 r9445aad  
    149149        usb_log_info("Processing descriptors...\n");
    150150       
    151         // get the first configuration descriptor
    152         usb_standard_configuration_descriptor_t config_desc;
    153        
    154151        int rc;
    155         rc = usb_request_get_bare_configuration_descriptor(&hid_dev->ctrl_pipe,
    156             0, &config_desc);
    157        
    158         if (rc != EOK) {
    159                 usb_log_error("Failed to get bare config descriptor: %s.\n",
     152
     153        uint8_t *descriptors = NULL;
     154        size_t descriptors_size;
     155        rc = usb_request_get_full_configuration_descriptor_alloc(
     156            &hid_dev->ctrl_pipe, 0, (void **) &descriptors, &descriptors_size);
     157        if (rc != EOK) {
     158                usb_log_error("Failed to retrieve config descriptor: %s.\n",
    160159                    str_error(rc));
    161160                return rc;
    162         }
    163        
    164         // prepare space for all underlying descriptors
    165         uint8_t *descriptors = (uint8_t *)malloc(config_desc.total_length);
    166         if (descriptors == NULL) {
    167                 usb_log_error("No memory!.\n");
    168                 return ENOMEM;
    169         }
    170        
    171         size_t transferred = 0;
    172         // get full configuration descriptor
    173         rc = usb_request_get_full_configuration_descriptor(&hid_dev->ctrl_pipe,
    174             0, descriptors, config_desc.total_length, &transferred);
    175        
    176         if (rc != EOK) {
    177                 usb_log_error("Failed to get full config descriptor: %s.\n",
    178                     str_error(rc));
    179                 free(descriptors);
    180                 return rc;
    181         }
    182        
    183         if (transferred != config_desc.total_length) {
    184                 usb_log_error("Configuration descriptor has wrong size (%u, "
    185                     "expected %u).\n", transferred, config_desc.total_length);
    186                 free(descriptors);
    187                 return ELIMIT;
    188161        }
    189162       
     
    201174       
    202175        rc = usb_endpoint_pipe_initialize_from_configuration(
    203             endpoint_mapping, 1, descriptors, config_desc.total_length,
     176            endpoint_mapping, 1, descriptors, descriptors_size,
    204177            &hid_dev->wire);
    205178       
     
    233206        assert(endpoint_mapping[0].interface != NULL);
    234207       
    235         rc = usbhid_dev_get_report_descriptor(hid_dev, descriptors, transferred,
     208        rc = usbhid_dev_get_report_descriptor(hid_dev,
     209            descriptors, descriptors_size,
    236210            (uint8_t *)endpoint_mapping[0].interface);
    237211       
  • uspace/drv/usbhid/kbddev.c

    rbdc8ab1 r9445aad  
    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

    rbdc8ab1 r9445aad  
    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/drv/usbhub/usbhub.c

    rbdc8ab1 r9445aad  
    149149        }
    150150
    151         //configuration descriptor
    152         /// \TODO check other configurations?
    153         usb_standard_configuration_descriptor_t config_descriptor;
    154         opResult = usb_request_get_bare_configuration_descriptor(
     151        /* Retrieve full configuration descriptor. */
     152        uint8_t *descriptors = NULL;
     153        size_t descriptors_size = 0;
     154        opResult = usb_request_get_full_configuration_descriptor_alloc(
    155155            &hub->endpoints.control, 0,
    156         &config_descriptor);
    157         if(opResult!=EOK){
    158                 dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult);
     156            (void **) &descriptors, &descriptors_size);
     157        if (opResult != EOK) {
     158                usb_log_error("Could not get configuration descriptor: %s.\n",
     159                    str_error(opResult));
    159160                return opResult;
    160161        }
    161         //set configuration
     162        usb_standard_configuration_descriptor_t *config_descriptor
     163            = (usb_standard_configuration_descriptor_t *) descriptors;
     164
     165        /* Set configuration. */
    162166        opResult = usb_request_set_configuration(&hub->endpoints.control,
    163                 config_descriptor.configuration_number);
    164 
    165         if (opResult != EOK) {
    166                 dprintf(USB_LOG_LEVEL_ERROR,
    167                                 "something went wrong when setting hub`s configuration, %d",
    168                                 opResult);
     167            config_descriptor->configuration_number);
     168
     169        if (opResult != EOK) {
     170                usb_log_error("Failed to set hub configuration: %s.\n",
     171                    str_error(opResult));
    169172                return opResult;
    170173        }
    171174        dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",
    172                         config_descriptor.configuration_number);
    173 
    174         //full configuration descriptor
    175         size_t transferred = 0;
    176         uint8_t * descriptors = (uint8_t *)malloc(config_descriptor.total_length);
    177         if (descriptors == NULL) {
    178                 dprintf(USB_LOG_LEVEL_ERROR, "insufficient memory");
    179                 return ENOMEM;
    180         }
    181         opResult = usb_request_get_full_configuration_descriptor(&hub->endpoints.control,
    182             0, descriptors,
    183             config_descriptor.total_length, &transferred);
    184         if(opResult!=EOK){
    185                 free(descriptors);
    186                 dprintf(USB_LOG_LEVEL_ERROR,
    187                                 "could not get full configuration descriptor, %d",opResult);
    188                 return opResult;
    189         }
    190         if (transferred != config_descriptor.total_length) {
    191                 dprintf(USB_LOG_LEVEL_ERROR,
    192                                 "received incorrect full configuration descriptor");
    193                 return ELIMIT;
    194         }
     175                        config_descriptor->configuration_number);
    195176
    196177        usb_endpoint_mapping_t endpoint_mapping[1] = {
     
    204185        opResult = usb_endpoint_pipe_initialize_from_configuration(
    205186            endpoint_mapping, 1,
    206             descriptors, config_descriptor.total_length,
     187            descriptors, descriptors_size,
    207188            &hub->device_connection);
    208189        if (opResult != EOK) {
  • uspace/drv/usbmid/explore.c

    rbdc8ab1 r9445aad  
    4242#include "usbmid.h"
    4343
    44 /** Allocate and retrieve full configuration descriptor.
    45  *
    46  * @param[in] dev USB device.
    47  * @param[in] config_index Configuration index.
    48  * @param[out] size Pointer where to store size of the allocated buffer.
    49  * @return Allocated full configuration descriptor.
    50  * @retval NULL Error occured.
    51  */
    52 static void *get_configuration_descriptor(usbmid_device_t *dev,
    53     size_t config_index, size_t *size)
    54 {
    55         usb_standard_configuration_descriptor_t config_descriptor;
    56         int rc = usb_request_get_bare_configuration_descriptor(&dev->ctrl_pipe,
    57             config_index, &config_descriptor);
    58         if (rc != EOK) {
    59                 usb_log_error("Failed getting configuration descriptor: %s.\n",
    60                     str_error(rc));
    61                 return NULL;
    62         }
    63 
    64         void *full_config_descriptor = malloc(config_descriptor.total_length);
    65         if (full_config_descriptor == NULL) {
    66                 usb_log_fatal("Out of memory (wanted: %zuB).\n",
    67                     (size_t) config_descriptor.total_length);
    68                 return NULL;
    69         }
    70 
    71         size_t full_config_descriptor_size;
    72         rc = usb_request_get_full_configuration_descriptor(&dev->ctrl_pipe,
    73             config_index,
    74             full_config_descriptor, config_descriptor.total_length,
    75             &full_config_descriptor_size);
    76         if (rc != EOK) {
    77                 usb_log_error("Failed getting configuration descriptor: %s.\n",
    78                     str_error(rc));
    79                 free(full_config_descriptor);
    80                 return NULL;
    81         }
    82 
    83         if (full_config_descriptor_size != config_descriptor.total_length) {
    84                 usb_log_error("Failed getting full configuration descriptor.\n");
    85                 free(full_config_descriptor);
    86                 return NULL;
    87         }
    88 
    89         if (size != NULL) {
    90                 *size = full_config_descriptor_size;
    91         }
    92 
    93         return full_config_descriptor;
    94 }
    95 
    9644/** Find starting indexes of all interface descriptors in a configuration.
    9745 *
     
    178126
    179127        size_t config_descriptor_size;
    180         uint8_t *config_descriptor_raw = get_configuration_descriptor(dev, 0,
    181             &config_descriptor_size);
    182         if (config_descriptor_raw == NULL) {
     128        uint8_t *config_descriptor_raw = NULL;
     129        rc = usb_request_get_full_configuration_descriptor_alloc(
     130            &dev->ctrl_pipe, 0,
     131            (void **) &config_descriptor_raw, &config_descriptor_size);
     132        if (rc != EOK) {
     133                usb_log_error("Failed getting full config descriptor: %s.\n",
     134                    str_error(rc));
    183135                return false;
    184136        }
     
    207159        }
    208160
     161        /* Select the first configuration */
     162        rc = usb_request_set_configuration(&dev->ctrl_pipe,
     163            config_descriptor->configuration_number);
     164        if (rc != EOK) {
     165                usb_log_error("Failed to set device configuration: %s.\n",
     166                    str_error(rc));
     167                free(config_descriptor_raw);
     168                free(interface_descriptors);
     169                return false;
     170        }
     171
     172
     173        /* Create control function */
    209174        ddf_fun_t *ctl_fun = ddf_fun_create(dev->dev, fun_exposed, "ctl");
    210175        if (ctl_fun == NULL) {
     
    223188        }
    224189
     190        /* Spawn interface children */
    225191        size_t i;
    226192        for (i = 0; i < interface_descriptors_count; i++) {
  • uspace/lib/c/generic/loader.c

    rbdc8ab1 r9445aad  
    160160        int rc = async_data_write_start(ldr->phone_id, (void *) pa, pa_len);
    161161        if (rc != EOK) {
     162                free(pa);
    162163                async_wait_for(req, NULL);
    163164                return rc;
  • uspace/lib/c/generic/vfs/vfs.c

    rbdc8ab1 r9445aad  
    6969        char *ncwd_path;
    7070        char *ncwd_path_nc;
     71        size_t total_size;
    7172
    7273        fibril_mutex_lock(&cwd_mutex);
     
    7778                        return NULL;
    7879                }
    79                 ncwd_path_nc = malloc(cwd_size + 1 + size + 1);
     80                total_size = cwd_size + 1 + size + 1;
     81                ncwd_path_nc = malloc(total_size);
    8082                if (!ncwd_path_nc) {
    8183                        fibril_mutex_unlock(&cwd_mutex);
    8284                        return NULL;
    8385                }
    84                 str_cpy(ncwd_path_nc, cwd_size + 1 + size + 1, cwd_path);
     86                str_cpy(ncwd_path_nc, total_size, cwd_path);
    8587                ncwd_path_nc[cwd_size] = '/';
    8688                ncwd_path_nc[cwd_size + 1] = '\0';
    8789        } else {
    88                 ncwd_path_nc = malloc(size + 1);
     90                total_size = size + 1;
     91                ncwd_path_nc = malloc(total_size);
    8992                if (!ncwd_path_nc) {
    9093                        fibril_mutex_unlock(&cwd_mutex);
     
    9396                ncwd_path_nc[0] = '\0';
    9497        }
    95         str_append(ncwd_path_nc, cwd_size + 1 + size + 1, path);
     98        str_append(ncwd_path_nc, total_size, path);
    9699        ncwd_path = canonify(ncwd_path_nc, retlen);
    97100        if (!ncwd_path) {
  • uspace/lib/usb/include/usb/request.h

    rbdc8ab1 r9445aad  
    106106int usb_request_get_full_configuration_descriptor(usb_endpoint_pipe_t *, int,
    107107    void *, size_t, size_t *);
     108int usb_request_get_full_configuration_descriptor_alloc(usb_endpoint_pipe_t *,
     109    int, void **, size_t *);
    108110int usb_request_set_configuration(usb_endpoint_pipe_t *, uint8_t);
    109111
  • uspace/lib/usb/src/request.c

    rbdc8ab1 r9445aad  
    412412}
    413413
     414/** Retrieve full configuration descriptor, allocate space for it.
     415 *
     416 * The function takes care that full configuration descriptor is returned
     417 * (i.e. the function will fail when less data then descriptor.totalLength
     418 * is returned).
     419 *
     420 * @param[in] pipe Control endpoint pipe (session must be already started).
     421 * @param[in] index Configuration index.
     422 * @param[out] descriptor_ptr Where to store pointer to allocated buffer.
     423 * @param[out] descriptor_size Where to store the size of the descriptor.
     424 * @return Error code.
     425 */
     426int usb_request_get_full_configuration_descriptor_alloc(
     427    usb_endpoint_pipe_t *pipe, int index,
     428    void **descriptor_ptr, size_t *descriptor_size)
     429{
     430        int rc;
     431
     432        if (descriptor_ptr == NULL) {
     433                return EBADMEM;
     434        }
     435
     436        usb_standard_configuration_descriptor_t bare_config;
     437        rc = usb_request_get_bare_configuration_descriptor(pipe, index,
     438            &bare_config);
     439        if (rc != EOK) {
     440                return rc;
     441        }
     442
     443        if (bare_config.descriptor_type != USB_DESCTYPE_CONFIGURATION) {
     444                return ENOENT;
     445        }
     446        if (bare_config.total_length < sizeof(bare_config)) {
     447                return ELIMIT;
     448        }
     449
     450        void *buffer = malloc(bare_config.total_length);
     451        if (buffer == NULL) {
     452                return ENOMEM;
     453        }
     454
     455        size_t transferred = 0;
     456        rc = usb_request_get_full_configuration_descriptor(pipe, index,
     457            buffer, bare_config.total_length, &transferred);
     458        if (rc != EOK) {
     459                free(buffer);
     460                return rc;
     461        }
     462
     463        if (transferred != bare_config.total_length) {
     464                free(buffer);
     465                return ELIMIT;
     466        }
     467
     468        /* Everything looks okay, copy the pointers. */
     469
     470        *descriptor_ptr = buffer;
     471
     472        if (descriptor_size != NULL) {
     473                *descriptor_size = bare_config.total_length;
     474        }
     475
     476        return EOK;
     477}
     478
    414479/** Set configuration of USB device.
    415480 *
     
    504569 *
    505570 * @param[in] pipe Control endpoint pipe (session must be already started).
    506  * @param[in] index String index (in native endianess).
     571 * @param[in] index String index (in native endianess),
     572 *      first index has number 1 (index from descriptors can be used directly).
    507573 * @param[in] lang String language (in native endianess).
    508574 * @param[out] string_ptr Where to store allocated string in native encoding.
     
    515581                return EBADMEM;
    516582        }
    517         /* Index is actually one byte value. */
    518         if (index > 0xFF) {
     583        /*
     584         * Index is actually one byte value and zero index is used
     585         * to retrieve list of supported languages.
     586         */
     587        if ((index < 1) || (index > 0xFF)) {
    519588                return ERANGE;
    520589        }
  • uspace/srv/devmap/devmap.c

    rbdc8ab1 r9445aad  
    123123static devmap_handle_t last_handle = 0;
    124124static devmap_device_t *null_devices[NULL_DEVICES];
     125
     126/*
     127 * Dummy list for null devices. This is necessary so that null devices can
     128 * be used just as any other devices, e.g. in devmap_device_unregister_core().
     129 */
     130static LIST_INITIALIZE(dummy_null_driver_devices);
    125131
    126132static devmap_handle_t devmap_create_handle(void)
     
    953959        device->name = dev_name;
    954960       
    955         /* Insert device into list of all devices
    956            and into null devices array */
     961        /*
     962         * Insert device into list of all devices and into null devices array.
     963         * Insert device into a dummy list of null driver's devices so that it
     964         * can be safely removed later.
     965         */
    957966        list_append(&device->devices, &devices_list);
     967        list_append(&device->driver_devices, &dummy_null_driver_devices);
    958968        null_devices[i] = device;
    959969       
  • uspace/srv/fs/fat/fat_dentry.c

    rbdc8ab1 r9445aad  
    4242static bool is_d_char(const char ch)
    4343{
    44         if (isalnum(ch) || ch == '_')
     44        if (isalnum(ch) || ch == '_' || ch == '-')
    4545                return true;
    4646        else
  • uspace/srv/fs/fat/fat_ops.c

    rbdc8ab1 r9445aad  
    325325                    uint16_t_le2host(d->firstc));
    326326                if (rc != EOK) {
     327                        (void) block_put(b);
    327328                        (void) fat_node_put(FS_NODE(nodep));
    328329                        return rc;
     
    811812        fibril_mutex_unlock(&childp->idx->lock);
    812813        childp->lnkcnt = 0;
     814        childp->refcnt++;       /* keep the node in memory until destroyed */
    813815        childp->dirty = true;
    814816        fibril_mutex_unlock(&childp->lock);
     
    14881490        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
    14891491        fs_node_t *fn;
     1492        fat_node_t *nodep;
    14901493        int rc;
    14911494
     
    14991502                return;
    15001503        }
     1504
     1505        nodep = FAT_NODE(fn);
     1506        /*
     1507         * We should have exactly two references. One for the above
     1508         * call to fat_node_get() and one from fat_unlink().
     1509         */
     1510        assert(nodep->refcnt == 2);
    15011511
    15021512        rc = fat_destroy_node(fn);
  • uspace/srv/hid/console/console.c

    rbdc8ab1 r9445aad  
    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. */
     
    712715}
    713716
    714 static int connect_keyboard(char *path)
     717static int connect_keyboard_or_mouse(const char *devname,
     718    async_client_conn_t handler, const char *path)
    715719{
    716720        int fd = open(path, O_RDONLY);
     
    725729        }
    726730       
    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);
     731        int rc = async_connect_to_me(phone, SERVICE_CONSOLE, 0, 0, handler);
    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 %s \"%s\".\n", devname, path);
    740740
    741741        return phone;
    742742}
    743743
    744 /** Try to connect to given keyboard, bypassing provided libc routines.
     744static int connect_keyboard(const char *path)
     745{
     746        return connect_keyboard_or_mouse("keyboard", keyboard_events, path);
     747}
     748
     749static int connect_mouse(const char *path)
     750{
     751        return connect_keyboard_or_mouse("mouse", mouse_events, path);
     752}
     753
     754struct hid_class_info {
     755        char *classname;
     756        int (*connection_func)(const char *);
     757};
     758
     759/** Periodically check for new keyboards in /dev/class/.
    745760 *
    746  * @param devmap_path Path to keyboard without /dev prefix.
    747  * @return Phone or error code.
     761 * @param arg Class name.
     762 * @return This function should never exit.
    748763 */
    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 
    804 static int check_new_keyboards(void *arg)
    805 {
    806         char *class_name = (char *) arg;
    807 
    808         int index = 1;
     764static int check_new_device_fibril(void *arg)
     765{
     766        struct hid_class_info *dev_info = arg;
     767
     768        size_t index = 1;
    809769
    810770        while (true) {
    811                 async_usleep(1 * 500 * 1000);
     771                async_usleep(HOTPLUG_WATCH_INTERVAL);
    812772                char *path;
    813                 int rc = asprintf(&path, "class/%s\\%d", class_name, index);
     773                int rc = asprintf(&path, "/dev/class/%s\\%zu",
     774                    dev_info->classname, index);
    814775                if (rc < 0) {
    815776                        continue;
    816777                }
    817778                rc = 0;
    818                 rc = connect_keyboard_bypass(path);
     779                rc = dev_info->connection_func(path);
    819780                if (rc > 0) {
    820781                        /* We do not allow unplug. */
     
    831792/** Start a fibril monitoring hot-plugged keyboards.
    832793 */
    833 static void check_new_keyboards_in_background()
    834 {
    835         fid_t fid = fibril_create(check_new_keyboards, (void *)"keyboard");
     794static void check_new_devices_in_background(int (*connection_func)(const char *),
     795    const char *classname)
     796{
     797        struct hid_class_info *dev_info = malloc(sizeof(struct hid_class_info));
     798        if (dev_info == NULL) {
     799                printf(NAME ": " \
     800                    "out of memory, will not start hot-plug-watch fibril.\n");
     801                return;
     802        }
     803        int rc;
     804
     805        rc = asprintf(&dev_info->classname, "%s", classname);
     806        if (rc < 0) {
     807                printf(NAME ": failed to format classname: %s.\n",
     808                    str_error(rc));
     809                return;
     810        }
     811        dev_info->connection_func = connection_func;
     812
     813        fid_t fid = fibril_create(check_new_device_fibril, (void *)dev_info);
    836814        if (!fid) {
    837                 printf(NAME ": failed to create hot-plug-watch fibril.\n");
     815                printf(NAME
     816                    ": failed to create hot-plug-watch fibril for %s.\n",
     817                    classname);
    838818                return;
    839819        }
     
    849829        }
    850830
    851         /* Connect to mouse device */
    852         mouse_phone = -1;
    853         int mouse_fd = open("/dev/hid_in/mouse", O_RDONLY);
    854        
    855         if (mouse_fd < 0) {
    856                 printf(NAME ": Notice - failed opening %s\n", "/dev/hid_in/mouse");
    857                 goto skip_mouse;
    858         }
    859        
    860         mouse_phone = fd_phone(mouse_fd);
     831        mouse_phone = connect_mouse("/dev/hid_in/mouse");
    861832        if (mouse_phone < 0) {
    862                 printf(NAME ": Failed to connect to mouse device\n");
    863                 goto skip_mouse;
    864         }
    865        
    866         if (async_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, mouse_events)
    867             != 0) {
    868                 printf(NAME ": Failed to create callback from mouse device\n");
    869                 mouse_phone = -1;
    870                 goto skip_mouse;
    871         }
    872        
    873 skip_mouse:
     833                printf(NAME ": Failed to connect to mouse device: %s.\n",
     834                    str_error(mouse_phone));
     835        }
    874836       
    875837        /* Connect to framebuffer driver */
     
    955917       
    956918        /* Start fibril for checking on hot-plugged keyboards. */
    957         check_new_keyboards_in_background();
     919        check_new_devices_in_background(connect_keyboard, "keyboard");
     920        check_new_devices_in_background(connect_mouse, "mouse");
    958921
    959922        return true;
Note: See TracChangeset for help on using the changeset viewer.