Changes in / [1924bd43:6fe0bf8d] in mainline


Ignore:
Files:
2 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/include/asm.h

    r1924bd43 r6fe0bf8d  
    4444#define IA64_IOSPACE_ADDRESS  0xE001000000000000ULL
    4545
    46 #define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
    47 
    4846NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
    4947{
    50         if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
    51                 uintptr_t prt = (uintptr_t) port;
    52        
    53                 *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
    54                     ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    55         } else {
    56                 *port = v;
    57         }
     48        uintptr_t prt = (uintptr_t) port;
     49       
     50        *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
     51            ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    5852       
    5953        asm volatile (
     
    6559NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v)
    6660{
    67         if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
    68                 uintptr_t prt = (uintptr_t) port;
    69        
    70                 *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
    71                     ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    72         } else {
    73                 *port = v;
    74         }
     61        uintptr_t prt = (uintptr_t) port;
     62       
     63        *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
     64            ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    7565       
    7666        asm volatile (
     
    8272NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v)
    8373{
    84         if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
    85                 uintptr_t prt = (uintptr_t) port;
    86        
    87                 *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
    88                     ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    89         } else {
    90                 *port = v;
    91         }
     74        uintptr_t prt = (uintptr_t) port;
     75       
     76        *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
     77            ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    9278       
    9379        asm volatile (
     
    9985NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
    10086{
    101         uint8_t v;
    102 
    103         asm volatile (
    104                 "mf\n"
    105                 ::: "memory"
    106         );
    107 
    108         if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
    109                 uintptr_t prt = (uintptr_t) port;
    110 
    111                 v = *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
    112                     ((prt & 0xfff) | ((prt >> 2) << 12))));
    113         } else {
    114                 v = *port;
    115         }
    116        
    117         return v;
     87        uintptr_t prt = (uintptr_t) port;
     88       
     89        asm volatile (
     90                "mf\n"
     91                ::: "memory"
     92        );
     93       
     94        return *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
     95            ((prt & 0xfff) | ((prt >> 2) << 12))));
    11896}
    11997
    12098NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
    12199{
    122         uint16_t v;
    123 
    124         asm volatile (
    125                 "mf\n"
    126                 ::: "memory"
    127         );
    128 
    129         if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
    130                 uintptr_t prt = (uintptr_t) port;
    131 
    132                 v = *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
    133                     ((prt & 0xfff) | ((prt >> 2) << 12))));
    134         } else {
    135                 v = *port;
    136         }
    137        
    138         return v;
     100        uintptr_t prt = (uintptr_t) port;
     101       
     102        asm volatile (
     103                "mf\n"
     104                ::: "memory"
     105        );
     106       
     107        return *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
     108            ((prt & 0xfff) | ((prt >> 2) << 12))));
    139109}
    140110
    141111NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
    142112{
    143         uint32_t v;
    144        
    145         asm volatile (
    146                 "mf\n"
    147                 ::: "memory"
    148         );
    149        
    150         if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
    151                 uintptr_t prt = (uintptr_t) port;
    152                
    153                 v = *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
    154                     ((prt & 0xfff) | ((prt >> 2) << 12))));
    155         } else {
    156                 v = *port;
    157         }
    158 
    159         return v;
     113        uintptr_t prt = (uintptr_t) port;
     114       
     115        asm volatile (
     116                "mf\n"
     117                ::: "memory"
     118        );
     119       
     120        return *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
     121            ((prt & 0xfff) | ((prt >> 2) << 12))));
    160122}
    161123
  • kernel/generic/src/adt/btree.c

    r1924bd43 r6fe0bf8d  
    3838 *
    3939 * The B+tree has the following properties:
    40  * @li it is a balanced 3-4-5 tree (i.e. BTREE_M = 5)
     40 * @li it is a ballanced 3-4-5 tree (i.e. BTREE_M = 5)
    4141 * @li values (i.e. pointers to values) are stored only in leaves
    4242 * @li leaves are linked in a list
    4343 *
    44  * Be careful when using these trees. They need to allocate
     44 * Be carefull when using these trees. They need to allocate
    4545 * and deallocate memory for their index nodes and as such
    4646 * can sleep.
     
    146146 * also makes use of this feature.
    147147 *
    148  * @param node     B-tree node into which the new key is to be inserted.
     148 * @param node     B-tree node into wich the new key is to be inserted.
    149149 * @param key      The key to be inserted.
    150150 * @param value    Pointer to value to be inserted.
     
    270270 * This feature is used during insert by right rotation.
    271271 *
    272  * @param node     B-tree node into which the new key is to be inserted.
     272 * @param node     B-tree node into wich the new key is to be inserted.
    273273 * @param key      The key to be inserted.
    274274 * @param value    Pointer to value to be inserted.
     
    463463        if (rnode->keys < BTREE_MAX_KEYS) {
    464464                /*
    465                  * The rotation can be done. The right sibling has free space.
     465                 * The rotaion can be done. The right sibling has free space.
    466466                 */
    467467                node_insert_key_and_rsubtree(node, inskey, insvalue, rsubtree);
     
    484484 * the median will be copied there.
    485485 *
    486  * @param node     B-tree node which is going to be split.
     486 * @param node     B-tree node wich is going to be split.
    487487 * @param key      The key to be inserted.
    488488 * @param value    Pointer to the value to be inserted.
     
    562562        if (node->keys < BTREE_MAX_KEYS) {
    563563                /*
    564                  * Node contains enough space, the key can be stored immediately.
     564                 * Node conatins enough space, the key can be stored immediately.
    565565                 */
    566566                node_insert_key_and_rsubtree(node, key, value, rsubtree);
     
    806806               
    807807                /*
    808                  * The key can be immediately removed.
     808                 * The key can be immediatelly removed.
    809809                 *
    810810                 * Note that the right subtree is removed because when
  • kernel/generic/src/adt/list.c

    r1924bd43 r6fe0bf8d  
    3333/**
    3434 * @file
    35  * @brief       Functions completing doubly linked circular list implementation.
     35 * @brief       Functions completing doubly linked circular list implementaion.
    3636 *
    3737 * This file contains some of the functions implementing doubly linked circular lists.
  • uspace/app/vuhid/Makefile

    r1924bd43 r6fe0bf8d  
    4747
    4848SOURCES_INTERFACES = \
    49         hids/bootkbd.c \
    50         hids/logitech_wireless.c
     49        hids/bootkbd.c
    5150
    5251SOURCES = \
     
    5453        device.c \
    5554        ifaces.c \
    56         life.c \
    5755        stdreq.c \
    5856        $(SOURCES_INTERFACES)
  • uspace/app/vuhid/hids/bootkbd.c

    r1924bd43 r6fe0bf8d  
    9393             0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    9494};
    95 static vuhid_interface_life_t boot_life = {
    96         .data_in = in_data,
    97         .data_in_count = sizeof(in_data)/INPUT_SIZE,
    98         .data_in_pos_change_delay = 500,
    99         .msg_born = "Boot keyboard comes to life...",
    100         .msg_die = "Boot keyboard died."
    101 };
     95static size_t in_data_count = sizeof(in_data)/INPUT_SIZE;
     96// FIXME - locking
     97static size_t in_data_position = 0;
     98
     99static int on_data_in(vuhid_interface_t *iface,
     100    void *buffer, size_t buffer_size, size_t *act_buffer_size)
     101{
     102        static size_t last_pos = (size_t) -1;
     103        size_t pos = in_data_position;
     104        if (pos >= in_data_count) {
     105                return EBADCHECKSUM;
     106        }
     107
     108        if (last_pos == pos) {
     109                return ENAK;
     110        }
     111
     112        if (buffer_size > INPUT_SIZE) {
     113                buffer_size = INPUT_SIZE;
     114        }
     115
     116        if (act_buffer_size != NULL) {
     117                *act_buffer_size = buffer_size;
     118        }
     119
     120        memcpy(buffer, in_data + pos * INPUT_SIZE, buffer_size);
     121        last_pos = pos;
     122
     123        return EOK;
     124}
    102125
    103126static int on_data_out(vuhid_interface_t *iface,
     
    118141}
    119142
     143
     144static void live(vuhid_interface_t *iface)
     145{
     146        async_usleep(1000 * 1000 * 5);
     147        usb_log_debug("Boot keyboard comes to life...\n");
     148        while (in_data_position < in_data_count) {
     149                async_usleep(1000 * 500);
     150                in_data_position++;
     151        }
     152        usb_log_debug("Boot keyboard died.\n");
     153}
     154
     155
    120156vuhid_interface_t vuhid_interface_bootkbd = {
    121157        .id = "boot",
     
    128164
    129165        .in_data_size = INPUT_SIZE,
    130         .on_data_in = interface_live_on_data_in,
     166        .on_data_in = on_data_in,
    131167
    132168        .out_data_size = 1,
    133169        .on_data_out = on_data_out,
    134170
    135         .live = interface_life_live,
     171        .live = live,
    136172
    137         .interface_data = &boot_life,
    138173        .vuhid_data = NULL
    139174};
  • uspace/app/vuhid/ifaces.c

    r1924bd43 r6fe0bf8d  
    3838
    3939extern vuhid_interface_t vuhid_interface_bootkbd;
    40 extern vuhid_interface_t vuhid_interface_logitech_wireless_1;
    4140
    4241vuhid_interface_t *available_hid_interfaces[] = {
    4342        &vuhid_interface_bootkbd,
    44         &vuhid_interface_logitech_wireless_1,
    4543        NULL
    4644};
  • uspace/app/vuhid/virthid.h

    r1924bd43 r6fe0bf8d  
    8282
    8383typedef struct {
    84         /** Buffer with data from device to the host. */
    85         uint8_t *data_in;
    86         /** Number of items in @c data_in.
    87          * The total size of @c data_in buffer shall be
    88          * <code>data_in_count * vuhid_interface_t.in_data_size</code>.
    89          */
    90         size_t data_in_count;
    91 
    92         /** Current position in the data buffer. */
    93         size_t data_in_pos;
    94         /** Previous position. */
    95         size_t data_in_last_pos;
    96 
    97         /** Delay between transition to "next" input buffer (in ms). */
    98         size_t data_in_pos_change_delay;
    99 
    100         /** Message to print when interface becomes alive. */
    101         const char *msg_born;
    102         /** Message to print when interface dies. */
    103         const char *msg_die;
    104 } vuhid_interface_life_t;
    105 
    106 typedef struct {
    10784        uint8_t length;
    10885        uint8_t type;
     
    11794void wait_for_interfaces_death(usbvirt_device_t *);
    11895
    119 void interface_life_live(vuhid_interface_t *);
    120 int interface_live_on_data_in(vuhid_interface_t *, void *, size_t, size_t *);
    121 
    122 
    12396#endif
    12497/**
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.c

    r1924bd43 r6fe0bf8d  
    7575/** Default idle rate for mouses. */
    7676static const uint8_t IDLE_RATE = 0;
     77static const size_t USB_MOUSE_BUTTON_COUNT = 3;
    7778
    7879/*----------------------------------------------------------------------------*/
     
    396397/*----------------------------------------------------------------------------*/
    397398
    398 /** Get highest index of a button mentioned in given report.
    399  *
    400  * @param report HID report.
    401  * @param report_id Report id we are interested in.
    402  * @return Highest button mentioned in the report.
    403  * @retval 1 No button was mentioned.
    404  *
    405  */
    406 static size_t usb_mouse_get_highest_button(usb_hid_report_t *report, uint8_t report_id)
    407 {
    408         size_t highest_button = 0;
    409 
    410         usb_hid_report_path_t *path = usb_hid_report_path();
    411         usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_BUTTON, 0);
    412         usb_hid_report_path_set_report_id(path, report_id);
    413 
    414         usb_hid_report_field_t *field = NULL;
    415 
    416         /* Break from within. */
    417         while (1) {
    418                 field = usb_hid_report_get_sibling(
    419                     report, field, path,
    420                     USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    421                     USB_HID_REPORT_TYPE_INPUT);
    422                 /* No more buttons? */
    423                 if (field == NULL) {
    424                         break;
    425                 }
    426 
    427                 size_t current_button = field->usage - field->usage_minimum;
    428                 if (current_button > highest_button) {
    429                         highest_button = current_button;
    430                 }
    431         }
    432 
    433         usb_hid_report_path_free(path);
    434 
    435         return highest_button;
    436 }
    437 
    438 /*----------------------------------------------------------------------------*/
    439 
    440399int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data)
    441400{
     
    455414        }
    456415       
    457         // FIXME: This may not be optimal since stupid hardware vendor may
    458         // use buttons 1, 2, 3 and 6000 and we would allocate array of
    459         // 6001*4B and use only 4 items in it.
    460         // Since I doubt that hardware producers would do that, I think
    461         // that the current solution is good enough.
    462         /* Adding 1 because we will be accessing buttons[highest]. */
    463         mouse_dev->buttons_count = usb_mouse_get_highest_button(hid_dev->report,
    464             hid_dev->report_id) + 1;
    465         mouse_dev->buttons = calloc(mouse_dev->buttons_count, sizeof(int32_t));
     416        mouse_dev->buttons = (int32_t *)calloc(USB_MOUSE_BUTTON_COUNT,
     417            sizeof(int32_t));
    466418       
    467419        if (mouse_dev->buttons == NULL) {
    468                 usb_log_error(NAME ": out of memory, giving up on device!\n");
     420                usb_log_fatal("No memory!\n");
    469421                free(mouse_dev);
    470422                return ENOMEM;
    471423        }
    472 
    473 
     424       
    474425        // save the Mouse device structure into the HID device structure
    475426        *data = mouse_dev;
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.h

    r1924bd43 r6fe0bf8d  
    5050        async_sess_t *wheel_sess;
    5151       
    52         /* Mouse buttons statuses. */
    5352        int32_t *buttons;
    54         size_t buttons_count;
    5553       
    5654        ddf_dev_ops_t ops;
  • uspace/drv/bus/usb/vhc/connhost.c

    r1924bd43 r6fe0bf8d  
    440440        int rc = vhc_virtdev_add_transfer(vhc, transfer);
    441441        if (rc != EOK) {
    442                 if (transfer->setup_buffer != NULL) {
    443                         free(transfer->setup_buffer);
    444                 }
     442                free(transfer->setup_buffer);
    445443                free(transfer);
    446444                return rc;
  • uspace/lib/c/arch/ia64/include/ddi.h

    r1924bd43 r6fe0bf8d  
    5252static inline void pio_write_8(ioport8_t *port, uint8_t v)
    5353{
    54         if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
    55                 uintptr_t prt = (uintptr_t) port;
     54        uintptr_t prt = (uintptr_t) port;
    5655
    57                 *((ioport8_t *)(IA64_IOSPACE_ADDRESS +
    58                     ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    59         } else {
    60                 *port = v;
    61         }
     56        *((ioport8_t *)(IA64_IOSPACE_ADDRESS +
     57            ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    6258
    6359        asm volatile ("mf\n" ::: "memory");
     
    6662static inline void pio_write_16(ioport16_t *port, uint16_t v)
    6763{
    68         if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
    69                 uintptr_t prt = (uintptr_t) port;
     64        uintptr_t prt = (uintptr_t) port;
    7065
    71                 *((ioport16_t *)(IA64_IOSPACE_ADDRESS +
    72                     ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    73         } else {
    74                 *port = v;
    75         }
     66        *((ioport16_t *)(IA64_IOSPACE_ADDRESS +
     67            ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    7668
    7769        asm volatile ("mf\n" ::: "memory");
     
    8072static inline void pio_write_32(ioport32_t *port, uint32_t v)
    8173{
    82         if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
    83                 uintptr_t prt = (uintptr_t) port;
     74        uintptr_t prt = (uintptr_t) port;
    8475
    85                 *((ioport32_t *)(IA64_IOSPACE_ADDRESS +
    86                     ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    87         } else {
    88                 *port = v;
    89         }
     76        *((ioport32_t *)(IA64_IOSPACE_ADDRESS +
     77            ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    9078
    9179        asm volatile ("mf\n" ::: "memory");
     
    9482static inline uint8_t pio_read_8(ioport8_t *port)
    9583{
    96         uint8_t v;
     84        uintptr_t prt = (uintptr_t) port;
    9785
    9886        asm volatile ("mf\n" ::: "memory");
    9987
    100         if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
    101                 uintptr_t prt = (uintptr_t) port;
    102 
    103                 v = *((ioport8_t *)(IA64_IOSPACE_ADDRESS +
    104                     ((prt & 0xfff) | ((prt >> 2) << 12))));
    105         } else {
    106                 v = *port;
    107         }
    108 
    109         return v;
     88        return *((ioport8_t *)(IA64_IOSPACE_ADDRESS +
     89            ((prt & 0xfff) | ((prt >> 2) << 12))));
    11090}
    11191
    11292static inline uint16_t pio_read_16(ioport16_t *port)
    11393{
    114         uint16_t v;
     94        uintptr_t prt = (uintptr_t) port;
    11595
    11696        asm volatile ("mf\n" ::: "memory");
    11797
    118         if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
    119                 uintptr_t prt = (uintptr_t) port;
    120 
    121                 v = *((ioport16_t *)(IA64_IOSPACE_ADDRESS +
    122                     ((prt & 0xfff) | ((prt >> 2) << 12))));
    123         } else {
    124                 v = *port;
    125         }
    126 
    127         return v;
     98        return *((ioport16_t *)(IA64_IOSPACE_ADDRESS +
     99            ((prt & 0xfff) | ((prt >> 2) << 12))));
    128100}
    129101
    130102static inline uint32_t pio_read_32(ioport32_t *port)
    131103{
    132         uint32_t v;
     104        uintptr_t prt = (uintptr_t) port;
    133105
    134106        asm volatile ("mf\n" ::: "memory");
    135107
    136         if (port < (ioport32_t *) port) {
    137                 uintptr_t prt = (uintptr_t) port;
    138 
    139                 v = *((ioport32_t *)(IA64_IOSPACE_ADDRESS +
    140                     ((prt & 0xfff) | ((prt >> 2) << 12))));
    141         } else {
    142                 v = *port;
    143         }
    144 
    145         return v;
     108        return *((ioport32_t *)(IA64_IOSPACE_ADDRESS +
     109            ((prt & 0xfff) | ((prt >> 2) << 12))));
    146110}
    147111
  • uspace/lib/c/generic/adt/hash_table.c

    r1924bd43 r6fe0bf8d  
    190190}
    191191
    192 /** Apply function to all items in hash table.
     192/** Apply fucntion to all items in hash table.
    193193 *
    194194 * @param h   Hash table.
  • uspace/lib/c/generic/adt/list.c

    r1924bd43 r6fe0bf8d  
    3333/**
    3434 * @file
    35  * @brief       Functions completing doubly linked circular list implementation.
     35 * @brief       Functions completing doubly linked circular list implementaion.
    3636 *
    3737 * This file contains some of the functions implementing doubly linked circular lists.
  • uspace/lib/fs/libfs.c

    r1924bd43 r6fe0bf8d  
    877877}
    878878
    879 static FIBRIL_MUTEX_INITIALIZE(instances_mutex);
    880 static LIST_INITIALIZE(instances_list);
    881 
    882 typedef struct {
    883         service_id_t service_id;
    884         link_t link;
    885         void *data;
    886 } fs_instance_t;
    887 
    888 int fs_instance_create(service_id_t service_id, void *data)
    889 {
    890         fs_instance_t *inst = malloc(sizeof(fs_instance_t));
    891         if (!inst)
    892                 return ENOMEM;
    893 
    894         link_initialize(&inst->link);
    895         inst->service_id = service_id;
    896         inst->data = data;
    897 
    898         fibril_mutex_lock(&instances_mutex);
    899         list_foreach(instances_list, link) {
    900                 fs_instance_t *cur = list_get_instance(link, fs_instance_t,
    901                     link);
    902 
    903                 if (cur->service_id == service_id) {
    904                         fibril_mutex_unlock(&instances_mutex);
    905                         free(inst);
    906                         return EEXIST;
    907                 }
    908 
    909                 /* keep the list sorted */
    910                 if (cur->service_id < service_id) {
    911                         list_insert_before(&inst->link, &cur->link);
    912                         fibril_mutex_unlock(&instances_mutex);
    913                         return EOK;
    914                 }
    915         }
    916         list_append(&inst->link, &instances_list);
    917         fibril_mutex_unlock(&instances_mutex);
    918 
    919         return EOK;
    920 }
    921 
    922 int fs_instance_get(service_id_t service_id, void **idp)
    923 {
    924         fibril_mutex_lock(&instances_mutex);
    925         list_foreach(instances_list, link) {
    926                 fs_instance_t *inst = list_get_instance(link, fs_instance_t,
    927                     link);
    928 
    929                 if (inst->service_id == service_id) {
    930                         *idp = inst->data;
    931                         fibril_mutex_unlock(&instances_mutex);
    932                         return EOK;
    933                 }
    934         }
    935         fibril_mutex_unlock(&instances_mutex);
    936         return ENOENT;
    937 }
    938 
    939 int fs_instance_destroy(service_id_t service_id)
    940 {
    941         fibril_mutex_lock(&instances_mutex);
    942         list_foreach(instances_list, link) {
    943                 fs_instance_t *inst = list_get_instance(link, fs_instance_t,
    944                     link);
    945 
    946                 if (inst->service_id == service_id) {
    947                         list_remove(&inst->link);
    948                         fibril_mutex_unlock(&instances_mutex);
    949                         free(inst);
    950                         return EOK;
    951                 }
    952         }
    953         fibril_mutex_unlock(&instances_mutex);
    954         return ENOENT;
    955 }
    956 
    957879/** @}
    958880 */
  • uspace/lib/fs/libfs.h

    r1924bd43 r6fe0bf8d  
    105105extern void fs_node_initialize(fs_node_t *);
    106106
    107 extern int fs_instance_create(service_id_t, void *);
    108 extern int fs_instance_get(service_id_t, void **);
    109 extern int fs_instance_destroy(service_id_t);
    110 
    111107#endif
    112108
  • uspace/lib/usbhid/src/hidpath.c

    r1924bd43 r6fe0bf8d  
    7676                                    int32_t usage_page, int32_t usage)
    7777{       
    78         usb_hid_report_usage_path_t *item
    79                 = malloc(sizeof(usb_hid_report_usage_path_t));
    80 
    81         if (item == NULL) {
     78        usb_hid_report_usage_path_t *item;
     79
     80        if(!(item=malloc(sizeof(usb_hid_report_usage_path_t)))) {
    8281                return ENOMEM;
    8382        }
  • uspace/srv/fs/fat/fat.h

    r1924bd43 r6fe0bf8d  
    230230} fat_node_t;
    231231
    232 typedef struct {
    233         bool lfn_enabled;
    234 } fat_instance_t;
    235 
    236232extern vfs_out_ops_t fat_ops;
    237233extern libfs_ops_t fat_libfs_ops;
  • uspace/srv/fs/fat/fat_directory.c

    r1924bd43 r6fe0bf8d  
    262262{
    263263        int rc;
    264         void *data;
    265         fat_instance_t *instance;
    266 
    267         rc = fs_instance_get(di->nodep->idx->service_id, &data);
    268         assert(rc == EOK);
    269         instance = (fat_instance_t *) data;
     264        bool enable_lfn = true; /* TODO: make this a mount option */
    270265       
    271266        if (fat_valid_short_name(name)) {
     
    282277                rc = fat_directory_write_dentry(di, de);
    283278                return rc;
    284         } else if (instance->lfn_enabled && fat_valid_name(name)) {
     279        } else if (enable_lfn && fat_valid_name(name)) {
    285280                /* We should create long entries to store name */
    286281                int long_entry_count;
     
    297292                if (lfn_size % FAT_LFN_ENTRY_SIZE)
    298293                        long_entry_count++;
    299                 rc = fat_directory_lookup_free(di, long_entry_count + 1);
     294                rc = fat_directory_lookup_free(di, long_entry_count+1);
    300295                if (rc != EOK)
    301296                        return rc;
     
    333328                FAT_LFN_ORDER(d) |= FAT_LFN_LAST;
    334329
    335                 rc = fat_directory_seek(di, start_pos + long_entry_count);
     330                rc = fat_directory_seek(di, start_pos+long_entry_count);
    336331                return rc;
    337332        }
  • uspace/srv/fs/fat/fat_ops.c

    r1924bd43 r6fe0bf8d  
    871871    aoff64_t *size, unsigned *linkcnt)
    872872{
    873         enum cache_mode cmode = CACHE_MODE_WB;
     873        enum cache_mode cmode;
    874874        fat_bs_t *bs;
    875         fat_instance_t *instance;
    876         int rc;
    877 
    878         instance = malloc(sizeof(fat_instance_t));
    879         if (!instance)
    880                 return ENOMEM;
    881         instance->lfn_enabled = true;
    882 
    883         /* Parse mount options. */
    884         char *mntopts = (char *) opts;
    885         char *saveptr;
    886         char *opt;
    887         while ((opt = strtok_r(mntopts, " ,", &saveptr)) != NULL) {
    888                 if (str_cmp(opt, "wtcache") == 0)
    889                         cmode = CACHE_MODE_WT;
    890                 else if (str_cmp(opt, "nolfn") == 0)
    891                         instance->lfn_enabled = false;
    892                 mntopts = NULL;
    893         }
     875        int rc;
     876
     877        /* Check for option enabling write through. */
     878        if (str_cmp(opts, "wtcache") == 0)
     879                cmode = CACHE_MODE_WT;
     880        else
     881                cmode = CACHE_MODE_WB;
    894882
    895883        /* initialize libblock */
    896884        rc = block_init(EXCHANGE_SERIALIZE, service_id, BS_SIZE);
    897         if (rc != EOK) {
    898                 free(instance);
    899                 return rc;
    900         }
     885        if (rc != EOK)
     886                return rc;
    901887
    902888        /* prepare the boot block */
    903889        rc = block_bb_read(service_id, BS_BLOCK);
    904890        if (rc != EOK) {
    905                 free(instance);
    906891                block_fini(service_id);
    907892                return rc;
     
    912897       
    913898        if (BPS(bs) != BS_SIZE) {
    914                 free(instance);
    915899                block_fini(service_id);
    916900                return ENOTSUP;
     
    920904        rc = block_cache_init(service_id, BPS(bs), 0 /* XXX */, cmode);
    921905        if (rc != EOK) {
    922                 free(instance);
    923906                block_fini(service_id);
    924907                return rc;
     
    928911        rc = fat_sanity_check(bs, service_id);
    929912        if (rc != EOK) {
    930                 free(instance);
    931913                (void) block_cache_fini(service_id);
    932914                block_fini(service_id);
     
    936918        rc = fat_idx_init_by_service_id(service_id);
    937919        if (rc != EOK) {
    938                 free(instance);
    939920                (void) block_cache_fini(service_id);
    940921                block_fini(service_id);
     
    945926        fs_node_t *rfn = (fs_node_t *)malloc(sizeof(fs_node_t));
    946927        if (!rfn) {
    947                 free(instance);
    948928                (void) block_cache_fini(service_id);
    949929                block_fini(service_id);
     
    955935        fat_node_t *rootp = (fat_node_t *)malloc(sizeof(fat_node_t));
    956936        if (!rootp) {
    957                 free(instance);
    958937                free(rfn);
    959938                (void) block_cache_fini(service_id);
     
    966945        fat_idx_t *ridxp = fat_idx_get_by_pos(service_id, FAT_CLST_ROOTPAR, 0);
    967946        if (!ridxp) {
    968                 free(instance);
    969947                free(rfn);
    970948                free(rootp);
     
    986964                rc = fat_clusters_get(&clusters, bs, service_id, rootp->firstc);
    987965                if (rc != EOK) {
    988                         fibril_mutex_unlock(&ridxp->lock);
    989                         free(instance);
    990966                        free(rfn);
    991967                        free(rootp);
     
    998974        } else
    999975                rootp->size = RDE(bs) * sizeof(fat_dentry_t);
    1000 
    1001         rc = fs_instance_create(service_id, instance);
    1002         if (rc != EOK) {
    1003                 fibril_mutex_unlock(&ridxp->lock);
    1004                 free(instance);
    1005                 free(rfn);
    1006                 free(rootp);
    1007                 (void) block_cache_fini(service_id);
    1008                 block_fini(service_id);
    1009                 fat_idx_fini_by_service_id(service_id);
    1010                 return rc;
    1011         }
    1012976
    1013977        rootp->idx = ridxp;
     
    10601024        (void) block_cache_fini(service_id);
    10611025        block_fini(service_id);
    1062 
    1063         void *data;
    1064         if (fs_instance_get(service_id, &data) == EOK) {
    1065                 fs_instance_destroy(service_id);
    1066                 free(data);
    1067         }
    10681026
    10691027        return EOK;
  • uspace/srv/fs/mfs/mfs.h

    r1924bd43 r6fe0bf8d  
    131131
    132132struct mfs_instance {
     133        link_t link;
    133134        service_id_t service_id;
    134135        struct mfs_sb_info *sbi;
  • uspace/srv/fs/mfs/mfs_ops.c

    r1924bd43 r6fe0bf8d  
    7373
    7474
     75static LIST_INITIALIZE(inst_list);
     76static FIBRIL_MUTEX_INITIALIZE(inst_list_mutex);
    7577static hash_table_t open_nodes;
    7678static FIBRIL_MUTEX_INITIALIZE(open_nodes_lock);
     
    177179                return ENOMEM;
    178180        }
     181
     182        instance->open_nodes_cnt = 0;
    179183
    180184        sb = malloc(MFS_SUPERBLOCK_SIZE);
     
    264268                free(instance);
    265269                free(sbi);
     270                free(sb);
    266271                block_cache_fini(service_id);
    267272                block_fini(service_id);
     
    270275        }
    271276
    272         /*Initialize the instance structure and remember it*/
     277        /*Initialize the instance structure and add it to the list*/
     278        link_initialize(&instance->link);
    273279        instance->service_id = service_id;
    274280        instance->sbi = sbi;
    275         instance->open_nodes_cnt = 0;
    276         rc = fs_instance_create(service_id, instance);
    277         if (rc != EOK) {
    278                 free(instance);
    279                 free(sbi);
    280                 block_cache_fini(service_id);
    281                 block_fini(service_id);
    282                 mfsdebug("fs instance creation failed\n");
    283                 return rc;
    284         }
     281
     282        fibril_mutex_lock(&inst_list_mutex);
     283        list_append(&instance->link, &inst_list);
     284        fibril_mutex_unlock(&inst_list_mutex);
    285285
    286286        mfsdebug("mount successful\n");
     
    315315        block_fini(service_id);
    316316
    317         /* Remove and destroy the instance */
    318         (void) fs_instance_destroy(service_id);
     317        /* Remove the instance from the list */
     318        fibril_mutex_lock(&inst_list_mutex);
     319        list_remove(&inst->link);
     320        fibril_mutex_unlock(&inst_list_mutex);
     321
    319322        free(inst->sbi);
    320323        free(inst);
     
    10091012mfs_instance_get(service_id_t service_id, struct mfs_instance **instance)
    10101013{
    1011         void *data;
    1012         int rc;
    1013 
    1014         rc = fs_instance_get(service_id, &data);
    1015         if (rc == EOK) {
    1016                 *instance = (struct mfs_instance *) data;
    1017         } else {
    1018                 mfsdebug("instance not found\n");
    1019         }
    1020 
    1021         return rc;
     1014        struct mfs_instance *instance_ptr;
     1015
     1016        fibril_mutex_lock(&inst_list_mutex);
     1017
     1018        if (list_empty(&inst_list)) {
     1019                fibril_mutex_unlock(&inst_list_mutex);
     1020                return EINVAL;
     1021        }
     1022
     1023        list_foreach(inst_list, link) {
     1024                instance_ptr = list_get_instance(link, struct mfs_instance,
     1025                                                 link);
     1026
     1027                if (instance_ptr->service_id == service_id) {
     1028                        *instance = instance_ptr;
     1029                        fibril_mutex_unlock(&inst_list_mutex);
     1030                        return EOK;
     1031                }
     1032        }
     1033
     1034        mfsdebug("Instance not found\n");
     1035
     1036        fibril_mutex_unlock(&inst_list_mutex);
     1037        return EINVAL;
    10221038}
    10231039
  • uspace/srv/hid/console/console.c

    r1924bd43 r6fe0bf8d  
    344344}
    345345
    346 static console_t *cons_get_active_uspace(void)
    347 {
    348         fibril_mutex_lock(&switch_mtx);
    349 
    350         console_t *active_uspace = active_console;
    351         if (active_uspace == kernel_console) {
    352                 active_uspace = prev_console;
    353         }
    354         assert(active_uspace != kernel_console);
    355 
    356         fibril_mutex_unlock(&switch_mtx);
    357 
    358         return active_uspace;
    359 }
    360 
    361346static ssize_t limit(ssize_t val, ssize_t lo, ssize_t hi)
    362347{
     
    481466                                event->c = c;
    482467                               
    483                                 /* Kernel console does not read events
    484                                  * from us, so we will redirect them
    485                                  * to the (last) active userspace console
    486                                  * if necessary.
    487                                  */
    488                                 console_t *target_console = cons_get_active_uspace();
    489 
    490                                 prodcons_produce(&target_console->input_pc,
    491                                     &event->link);
     468                                prodcons_produce(&active_console->input_pc, &event->link);
    492469                        }
    493470                       
     
    927904                atomic_set(&consoles[i].refcnt, 0);
    928905                fibril_mutex_initialize(&consoles[i].mtx);
    929                 prodcons_initialize(&consoles[i].input_pc);
    930906               
    931907                if (graphics_state == GRAPHICS_FULL) {
     
    966942                }
    967943               
     944                prodcons_initialize(&consoles[i].input_pc);
    968945                cons_redraw_state(&consoles[i]);
    969946               
Note: See TracChangeset for help on using the changeset viewer.