Changeset 99c2c69e in mainline for uspace/lib


Ignore:
Timestamp:
2013-09-13T00:36:30Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
67fbd5e
Parents:
7f84430 (diff), 11d41be5 (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:

mainline changes

Location:
uspace/lib
Files:
9 added
50 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/block/block.c

    r7f84430 r99c2c69e  
    9393        fibril_mutex_lock(&dcl_lock);
    9494       
    95         list_foreach(dcl, cur) {
    96                 devcon_t *devcon = list_get_instance(cur, devcon_t, link);
     95        list_foreach(dcl, link, devcon_t, devcon) {
    9796                if (devcon->service_id == service_id) {
    9897                        fibril_mutex_unlock(&dcl_lock);
     
    124123       
    125124        fibril_mutex_lock(&dcl_lock);
    126         list_foreach(dcl, cur) {
    127                 devcon_t *d = list_get_instance(cur, devcon_t, link);
     125        list_foreach(dcl, link, devcon_t, d) {
    128126                if (d->service_id == service_id) {
    129127                        fibril_mutex_unlock(&dcl_lock);
  • uspace/lib/c/Makefile

    r7f84430 r99c2c69e  
    6565        generic/cfg.c \
    6666        generic/clipboard.c \
     67        generic/corecfg.c \
    6768        generic/devman.c \
    6869        generic/device/hw_res.c \
    6970        generic/device/hw_res_parsed.c \
     71        generic/device/pio_window.c \
    7072        generic/device/char_dev.c \
    7173        generic/device/clock_dev.c \
  • uspace/lib/c/arch/sparc64/Makefile.common

    r7f84430 r99c2c69e  
    2727#
    2828
    29 GCC_CFLAGS += -mcpu=ultrasparc -m64 -mcmodel=medlow
     29ifeq ($(PROCESSOR),sun4v)
     30GCC_CFLAGS += -mcpu=niagara -mno-vis
     31else
     32GCC_CFLAGS += -mcpu=ultrasparc
     33endif
     34
     35GCC_CFLAGS += -m64 -mcmodel=medlow
     36
    3037LFLAGS = -no-check-sections
    3138
  • uspace/lib/c/generic/adt/hash_table.c

    r7f84430 r99c2c69e  
    227227       
    228228        /* Check for duplicates. */
    229         list_foreach(h->bucket[idx], cur) {
     229        list_foreach(h->bucket[idx], link, ht_link_t, cur_link) {
    230230                /*
    231231                 * We could filter out items using their hashes first, but
    232232                 * calling equal() might very well be just as fast.
    233233                 */
    234                 ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
    235234                if (h->op->equal(cur_link, item))
    236235                        return false;
     
    258257        size_t idx = h->op->key_hash(key) % h->bucket_cnt;
    259258
    260         list_foreach(h->bucket[idx], cur) {
    261                 ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
     259        list_foreach(h->bucket[idx], link, ht_link_t, cur_link) {
    262260                /*
    263261                 * Is this is the item we are looking for? We could have first
  • uspace/lib/c/generic/adt/list.c

    r7f84430 r99c2c69e  
    102102        unsigned int count = 0;
    103103       
    104         list_foreach(*list, link) {
     104        link_t *link = list_first(list);
     105        while (link != NULL) {
    105106                count++;
     107                link = list_next(link, list);
    106108        }
    107109       
  • uspace/lib/c/generic/cfg.c

    r7f84430 r99c2c69e  
    8383                return true;
    8484       
    85         list_foreach(data->sections, link) {
    86                 const cfg_section_t *section = cfg_section_instance(link);
    87                
     85        cfg_file_foreach(data, section) {
    8886                if (!list_empty(&section->entries))
    8987                        return false;
     
    413411const cfg_section_t *cfg_find_section(const cfg_file_t *data, const char *title)
    414412{
    415         list_foreach(data->sections, link) {
    416                 const cfg_section_t *section = cfg_section_instance(link);
    417                
     413        cfg_file_foreach(data, section) {
    418414                if (str_cmp(section->title, title) == 0)
    419415                        return section;
     
    434430const char *cfg_find_value(const cfg_section_t *section, const char *key)
    435431{
    436         list_foreach(section->entries, link) {
    437                 const cfg_entry_t *entry = cfg_entry_instance(link);
    438                
     432        cfg_section_foreach(section, entry) {
    439433                if (str_cmp(entry->key, key) == 0)
    440434                        return entry->value;
  • uspace/lib/c/generic/ddi.c

    r7f84430 r99c2c69e  
    4242#include <ddi.h>
    4343#include <libarch/ddi.h>
     44#include <device/hw_res.h>
     45#include <device/hw_res_parsed.h>
     46#include <device/pio_window.h>
    4447#include <libc.h>
    4548#include <task.h>
     
    7679 *
    7780 */
    78 int physmem_map(void *phys, size_t pages, unsigned int flags, void **virt)
     81int physmem_map(uintptr_t phys, size_t pages, unsigned int flags, void **virt)
    7982{
    8083        return __SYSCALL5(SYS_PHYSMEM_MAP, (sysarg_t) phys,
     
    8386
    8487int dmamem_map(void *virt, size_t size, unsigned int map_flags,
    85     unsigned int flags, void **phys)
     88    unsigned int flags, uintptr_t *phys)
    8689{
    8790        return (int) __SYSCALL6(SYS_DMAMEM_MAP, (sysarg_t) size,
     
    9093}
    9194
    92 int dmamem_map_anonymous(size_t size, unsigned int map_flags,
    93     unsigned int flags, void **phys, void **virt)
    94 {
     95int dmamem_map_anonymous(size_t size, uintptr_t constraint,
     96    unsigned int map_flags, unsigned int flags, uintptr_t *phys, void **virt)
     97{
     98        *phys = constraint;
     99       
    95100        return (int) __SYSCALL6(SYS_DMAMEM_MAP, (sysarg_t) size,
    96101            (sysarg_t) map_flags, (sysarg_t) flags | DMAMEM_FLAGS_ANONYMOUS,
     
    132137       
    133138        return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg);
     139}
     140
     141/** Enable PIO for specified address range.
     142 *
     143 * @param range I/O range to be enable.
     144 * @param virt  Virtual address for application's PIO operations.
     145 */
     146int pio_enable_range(addr_range_t *range, void **virt)
     147{
     148        return pio_enable(RNGABSPTR(*range), RNGSZ(*range), virt);
     149}
     150
     151/** Enable PIO for specified HW resource wrt. to the PIO window.
     152 *
     153 * @param win      PIO window. May be NULL if the resources are known to be
     154 *                 absolute.
     155 * @param res      Resources specifying the I/O range wrt. to the PIO window.
     156 * @param virt     Virtual address for application's PIO operations.
     157 *
     158 * @return EOK on success.
     159 * @return Negative error code on failure.
     160 *
     161 */
     162int pio_enable_resource(pio_window_t *win, hw_resource_t *res, void **virt)
     163{
     164        uintptr_t addr;
     165        size_t size;
     166
     167        switch (res->type) {
     168        case IO_RANGE:
     169                addr = res->res.io_range.address;
     170                if (res->res.io_range.relative) {
     171                        if (!win)
     172                                return EINVAL;
     173                        addr += win->io.base;
     174                }
     175                size = res->res.io_range.size;
     176                break;
     177        case MEM_RANGE:
     178                addr = res->res.mem_range.address;
     179                if (res->res.mem_range.relative) {
     180                        if (!win)
     181                                return EINVAL;
     182                        addr += win->mem.base;
     183                }
     184                size = res->res.mem_range.size;
     185                break;
     186        default:
     187                return EINVAL;
     188        }
     189
     190        return pio_enable((void *) addr, size, virt);   
    134191}
    135192
     
    158215        if (!virt)
    159216                return EINVAL;
    160 
    161         void *phys_frame =
    162             (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);
    163         size_t offset = pio_addr - phys_frame;
     217       
     218        uintptr_t phys_frame =
     219            ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);
     220        size_t offset = (uintptr_t) pio_addr - phys_frame;
    164221        size_t pages = SIZE2PAGES(offset + size);
    165222       
  • uspace/lib/c/generic/device/hw_res.c

    r7f84430 r99c2c69e  
    4444       
    4545        async_exch_t *exch = async_exchange_begin(sess);
    46         if (exch == NULL)
    47                 return ENOMEM;
     46       
    4847        int rc = async_req_1_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    4948            HW_RES_GET_RESOURCE_LIST, &count);
     
    7978{
    8079        async_exch_t *exch = async_exchange_begin(sess);
    81         if (exch == NULL)
    82                 return false;
     80       
    8381        int rc = async_req_1_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    8482            HW_RES_ENABLE_INTERRUPT);
     
    8886}
    8987
    90 /**
    91  * Setup DMA channel to specified place and mode.
    92  * @param channel DMA Channel 1,2,3 for 8 bit transfers, 5,6,7 for 16 bit.
    93  * @param pa Physical address of the buffer. Must be < 16MB for 16 bit and < 1MB
    94  *           for 8 bit transfers.
    95  * @param size DMA buffer size, limited to 64K.
    96  * @param mode Mode of the DMA channel:
    97  *              - Read or Write
    98  *              - Allow automatic reset
    99  *              - Use address decrement instead of increment
    100  *              - Use SINGLE/BLOCK/ON DEMAND transfer mode
     88/** Setup DMA channel to specified place and mode.
     89 *
     90 * @param channel DMA channel.
     91 * @param pa      Physical address of the buffer.
     92 * @param size    DMA buffer size.
     93 * @param mode    Mode of the DMA channel:
     94 *                 - Read or Write
     95 *                 - Allow automatic reset
     96 *                 - Use address decrement instead of increment
     97 *                 - Use SINGLE/BLOCK/ON DEMAND transfer mode
     98 *
    10199 * @return Error code.
     100 *
    102101 */
    103102int hw_res_dma_channel_setup(async_sess_t *sess,
     
    105104{
    106105        async_exch_t *exch = async_exchange_begin(sess);
    107         if (exch == NULL)
    108                 return ENOMEM;
     106       
    109107        const uint32_t packed = (channel & 0xffff) | (mode << 16);
    110108        const int ret = async_req_4_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    111109            HW_RES_DMA_CHANNEL_SETUP, packed, pa, size);
     110       
    112111        async_exchange_end(exch);
    113 
     112       
    114113        return ret;
    115114}
    116115
    117 /**
    118  * Query remaining bytes in the buffer.
    119  * @param channel DMA Channel 1,2,3 for 8 bit transfers, 5,6,7 for 16 bit.
    120  * @return Number of bytes remaining in the buffer(>=0) or error code(<0).
     116/** Query remaining bytes in the buffer.
     117 *
     118 * @param channel DMA channel.
     119 *
     120 * @return Number of bytes remaining in the buffer if positive.
     121 * @return Error code if negative.
     122 *
    121123 */
    122124int hw_res_dma_channel_remain(async_sess_t *sess, unsigned channel)
    123125{
    124126        async_exch_t *exch = async_exchange_begin(sess);
    125         if (exch == NULL)
    126                 return ENOMEM;
     127       
    127128        sysarg_t remain;
    128129        const int ret = async_req_2_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    129130            HW_RES_DMA_CHANNEL_REMAIN, channel, &remain);
     131       
    130132        async_exchange_end(exch);
     133       
    131134        if (ret == EOK)
    132135                return remain;
     136       
    133137        return ret;
    134138}
  • uspace/lib/c/generic/device/hw_res_parsed.c

    r7f84430 r99c2c69e  
    8080}
    8181
     82static uint64_t absolutize(uint64_t addr, bool relative, uint64_t base)
     83{
     84        if (!relative)
     85                return addr;
     86        else
     87                return addr + base;
     88}
     89
     90static uint64_t relativize(uint64_t addr, bool relative, uint64_t base)
     91{
     92        if (relative)
     93                return addr;
     94        else
     95                return addr - base;
     96}
     97
    8298static void hw_res_parse_add_io_range(hw_res_list_parsed_t *out,
    83     const hw_resource_t *res, int flags)
    84 {
     99    const pio_window_t *win, const hw_resource_t *res, int flags)
     100{
     101        endianness_t endianness;
     102        uint64_t absolute;
     103        uint64_t relative;
     104        size_t size;
     105
    85106        assert(res && (res->type == IO_RANGE));
    86107       
    87         uint64_t address = res->res.io_range.address;
    88         endianness_t endianness = res->res.io_range.endianness;
    89         size_t size = res->res.io_range.size;
     108        absolute = absolutize(res->res.io_range.address,
     109            res->res.io_range.relative, win->io.base);
     110        relative = relativize(res->res.io_range.address,
     111            res->res.io_range.relative, win->io.base);
     112        size = res->res.io_range.size;
     113        endianness = res->res.io_range.endianness;
    90114       
    91115        if ((size == 0) && (!(flags & HW_RES_KEEP_ZERO_AREA)))
     
    97121        if (!keep_duplicit) {
    98122                for (size_t i = 0; i < count; i++) {
    99                         uint64_t s_address = out->io_ranges.ranges[i].address;
    100                         size_t s_size = out->io_ranges.ranges[i].size;
     123                        uint64_t s_address;
     124                        size_t s_size;
     125
     126                        s_address = RNGABS(out->io_ranges.ranges[i]);
     127                        s_size = RNGSZ(out->io_ranges.ranges[i]);
    101128                       
    102                         if ((address == s_address) && (size == s_size))
    103                                 return;
    104                 }
    105         }
    106        
    107         out->io_ranges.ranges[count].address = address;
     129                        if ((absolute == s_address) && (size == s_size))
     130                                return;
     131                }
     132        }
     133       
     134        RNGABS(out->io_ranges.ranges[count]) = absolute;
     135        RNGREL(out->io_ranges.ranges[count]) = relative;
     136        RNGSZ(out->io_ranges.ranges[count]) = size;
    108137        out->io_ranges.ranges[count].endianness = endianness;
    109         out->io_ranges.ranges[count].size = size;
    110138        out->io_ranges.count++;
    111139}
    112140
    113141static void hw_res_parse_add_mem_range(hw_res_list_parsed_t *out,
    114     const hw_resource_t *res, int flags)
    115 {
     142    const pio_window_t *win, const hw_resource_t *res, int flags)
     143{
     144        endianness_t endianness;
     145        uint64_t absolute;
     146        uint64_t relative;
     147        size_t size;
     148       
    116149        assert(res && (res->type == MEM_RANGE));
    117150       
    118         uint64_t address = res->res.mem_range.address;
    119         endianness_t endianness = res->res.mem_range.endianness;
    120         size_t size = res->res.mem_range.size;
     151        absolute = absolutize(res->res.mem_range.address,
     152            res->res.mem_range.relative, win->mem.base);
     153        relative = relativize(res->res.mem_range.address,
     154            res->res.mem_range.relative, win->mem.base);
     155        size = res->res.mem_range.size;
     156        endianness = res->res.mem_range.endianness;
    121157       
    122158        if ((size == 0) && (!(flags & HW_RES_KEEP_ZERO_AREA)))
     
    128164        if (!keep_duplicit) {
    129165                for (size_t i = 0; i < count; ++i) {
    130                         uint64_t s_address = out->mem_ranges.ranges[i].address;
    131                         size_t s_size = out->mem_ranges.ranges[i].size;
     166                        uint64_t s_address;
     167                        size_t s_size;
     168
     169                        s_address = RNGABS(out->mem_ranges.ranges[i]);;
     170                        s_size = RNGSZ(out->mem_ranges.ranges[i]);
    132171                       
    133                         if ((address == s_address) && (size == s_size))
    134                                 return;
    135                 }
    136         }
    137        
    138         out->mem_ranges.ranges[count].address = address;
     172                        if ((absolute == s_address) && (size == s_size))
     173                                return;
     174                }
     175        }
     176       
     177        RNGABS(out->mem_ranges.ranges[count]) = absolute;
     178        RNGREL(out->mem_ranges.ranges[count]) = relative;
     179        RNGSZ(out->mem_ranges.ranges[count]) = size;
    139180        out->mem_ranges.ranges[count].endianness = endianness;
    140         out->mem_ranges.ranges[count].size = size;
    141181        out->mem_ranges.count++;
    142182}
     
    144184/** Parse list of hardware resources
    145185 *
    146  * @param      hw_resources Original structure resource
    147  * @param[out] out          Output parsed resources
    148  * @param      flags        Flags of the parsing.
    149  *                          HW_RES_KEEP_ZERO_AREA for keeping
    150  *                          zero-size areas, HW_RES_KEEP_DUPLICITIES
    151  *                          for keep duplicit areas
     186 * @param      win          PIO window.
     187 * @param      res          Original structure resource.
     188 * @param[out] out          Output parsed resources.
     189 * @param      flags        Flags of the parsing:
     190 *                          HW_RES_KEEP_ZERO_AREA for keeping zero-size areas,
     191 *                          HW_RES_KEEP_DUPLICITIES to keep duplicit areas.
    152192 *
    153193 * @return EOK if succeed, error code otherwise.
    154194 *
    155195 */
    156 int hw_res_list_parse(const hw_resource_list_t *hw_resources,
    157     hw_res_list_parsed_t *out, int flags)
    158 {
    159         if ((!hw_resources) || (!out))
     196int hw_res_list_parse(const pio_window_t *win,
     197    const hw_resource_list_t *res, hw_res_list_parsed_t *out, int flags)
     198{
     199        if (!res || !out)
    160200                return EINVAL;
    161201       
    162         size_t res_count = hw_resources->count;
     202        size_t res_count = res->count;
    163203        hw_res_list_parsed_clean(out);
    164204       
     
    174214       
    175215        for (size_t i = 0; i < res_count; ++i) {
    176                 const hw_resource_t *resource = &(hw_resources->resources[i]);
     216                const hw_resource_t *resource = &res->resources[i];
    177217               
    178218                switch (resource->type) {
     
    181221                        break;
    182222                case IO_RANGE:
    183                         hw_res_parse_add_io_range(out, resource, flags);
     223                        hw_res_parse_add_io_range(out, win, resource, flags);
    184224                        break;
    185225                case MEM_RANGE:
    186                         hw_res_parse_add_mem_range(out, resource, flags);
     226                        hw_res_parse_add_mem_range(out, win, resource, flags);
    187227                        break;
    188228                case DMA_CHANNEL_8:
     
    216256    hw_res_list_parsed_t *hw_res_parsed, int flags)
    217257{
     258        pio_window_t pio_window;
     259        int rc;
     260
    218261        if (!hw_res_parsed)
    219262                return EBADMEM;
     
    222265        hw_res_list_parsed_clean(hw_res_parsed);
    223266        memset(&hw_resources, 0, sizeof(hw_resource_list_t));
    224        
    225         int rc = hw_res_get_resource_list(sess, &hw_resources);
     267
     268        rc = pio_window_get(sess, &pio_window);
     269        if (rc != EOK)
     270                return rc;
     271       
     272        rc = hw_res_get_resource_list(sess, &hw_resources);
    226273        if (rc != EOK)
    227274                return rc;
    228        
    229         rc = hw_res_list_parse(&hw_resources, hw_res_parsed, flags);
     275
     276        rc = hw_res_list_parse(&pio_window, &hw_resources, hw_res_parsed,
     277            flags);
    230278        hw_res_clean_resource_list(&hw_resources);
    231279       
  • uspace/lib/c/generic/devman.c

    r7f84430 r99c2c69e  
    11/*
    22 * Copyright (c) 2007 Josef Cejka
    3  * Copyright (c) 2011 Jiri Svoboda
     3 * Copyright (c) 2013 Jiri Svoboda
    44 * Copyright (c) 2010 Lenka Trochtova
    55 * All rights reserved.
     
    230230        }
    231231       
    232         match_id_t *match_id = NULL;
    233        
    234         list_foreach(match_ids->ids, link) {
    235                 match_id = list_get_instance(link, match_id_t, link);
    236                
     232        list_foreach(match_ids->ids, link, match_id_t, match_id) {
    237233                ipc_call_t answer2;
    238234                aid_t req2 = async_send_1(exch, DEVMAN_ADD_MATCH_ID,
     
    405401}
    406402
    407 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf,
    408     size_t buf_size)
     403static int devman_get_str_internal(sysarg_t method, sysarg_t arg1,
     404    sysarg_t arg2, sysarg_t *r1, char *buf, size_t buf_size)
    409405{
    410406        async_exch_t *exch;
     
    416412       
    417413        ipc_call_t answer;
    418         aid_t req = async_send_1(exch, method, arg1, &answer);
     414        aid_t req = async_send_2(exch, method, arg1, arg2, &answer);
    419415        aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply);
    420416        async_wait_for(dreq, &dretval);
     
    434430        }
    435431       
     432        if (r1 != NULL)
     433                *r1 = IPC_GET_ARG1(answer);
    436434        act_size = IPC_GET_ARG2(dreply);
    437435        assert(act_size <= buf_size - 1);
     
    443441int devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size)
    444442{
    445         return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, buf,
    446             buf_size);
     443        return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, 0, NULL,
     444            buf, buf_size);
     445}
     446
     447int devman_fun_get_match_id(devman_handle_t handle, size_t index, char *buf,
     448    size_t buf_size, unsigned int *rscore)
     449{
     450        int rc;
     451        sysarg_t score = 0;
     452
     453        rc = devman_get_str_internal(DEVMAN_FUN_GET_MATCH_ID, handle, index,
     454            &score, buf, buf_size);
     455        if (rc != EOK)
     456                return rc;
     457
     458        *rscore = score;
     459        return rc;
    447460}
    448461
    449462int devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size)
    450463{
    451         return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf,
    452             buf_size);
     464        return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, 0, NULL,
     465            buf, buf_size);
    453466}
    454467
    455468int devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size)
    456469{
    457         return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, buf,
    458             buf_size);
     470        return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, 0,
     471            NULL, buf, buf_size);
    459472}
    460473
     
    583596}
    584597
     598int devman_dev_get_parent(devman_handle_t devh, devman_handle_t *funh)
     599{
     600        async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
     601        if (exch == NULL)
     602                return ENOMEM;
     603       
     604        sysarg_t retval = async_req_1_1(exch, DEVMAN_DEV_GET_PARENT,
     605            devh, funh);
     606       
     607        devman_exchange_end(exch);
     608        return (int) retval;
     609}
     610
    585611int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle)
    586612{
     
    596622}
    597623
     624int devman_get_drivers(devman_handle_t **drvs,
     625    size_t *count)
     626{
     627        return devman_get_handles_internal(DEVMAN_GET_DRIVERS, 0, drvs, count);
     628}
     629
     630int devman_driver_get_devices(devman_handle_t drvh, devman_handle_t **devs,
     631    size_t *count)
     632{
     633        return devman_get_handles_internal(DEVMAN_DRIVER_GET_DEVICES,
     634            drvh, devs, count);
     635}
     636
     637int devman_driver_get_handle(const char *drvname, devman_handle_t *handle)
     638{
     639        async_exch_t *exch;
     640
     641        exch = devman_exchange_begin(DEVMAN_CLIENT);
     642        if (exch == NULL)
     643                return ENOMEM;
     644       
     645        ipc_call_t answer;
     646        aid_t req = async_send_0(exch, DEVMAN_DRIVER_GET_HANDLE, &answer);
     647        sysarg_t retval = async_data_write_start(exch, drvname,
     648            str_size(drvname));
     649       
     650        devman_exchange_end(exch);
     651       
     652        if (retval != EOK) {
     653                async_forget(req);
     654                return retval;
     655        }
     656       
     657        async_wait_for(req, &retval);
     658       
     659        if (retval != EOK) {
     660                if (handle != NULL)
     661                        *handle = (devman_handle_t) -1;
     662               
     663                return retval;
     664        }
     665       
     666        if (handle != NULL)
     667                *handle = (devman_handle_t) IPC_GET_ARG1(answer);
     668       
     669        return retval;
     670}
     671
     672int devman_driver_get_match_id(devman_handle_t handle, size_t index, char *buf,
     673    size_t buf_size, unsigned int *rscore)
     674{
     675        int rc;
     676        sysarg_t score = 0;
     677
     678        rc = devman_get_str_internal(DEVMAN_DRIVER_GET_MATCH_ID, handle, index,
     679            &score, buf, buf_size);
     680        if (rc != EOK)
     681                return rc;
     682
     683        *rscore = score;
     684        return rc;
     685}
     686
     687int devman_driver_get_name(devman_handle_t handle, char *buf, size_t buf_size)
     688{
     689        return devman_get_str_internal(DEVMAN_DRIVER_GET_NAME, handle, 0, NULL,
     690            buf, buf_size);
     691}
     692
     693int devman_driver_get_state(devman_handle_t drvh, driver_state_t *rstate)
     694{
     695        sysarg_t state;
     696        async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
     697        if (exch == NULL)
     698                return ENOMEM;
     699       
     700        int rc = async_req_1_1(exch, DEVMAN_DRIVER_GET_STATE, drvh,
     701            &state);
     702       
     703        devman_exchange_end(exch);
     704        if (rc != EOK)
     705                return rc;
     706
     707        *rstate = state;
     708        return rc;
     709}
     710
     711int devman_driver_load(devman_handle_t drvh)
     712{
     713        async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
     714        if (exch == NULL)
     715                return ENOMEM;
     716       
     717        int rc = async_req_1_0(exch, DEVMAN_DRIVER_LOAD, drvh);
     718       
     719        devman_exchange_end(exch);
     720        return rc;
     721}
     722
    598723/** @}
    599724 */
  • uspace/lib/c/generic/futex.c

    r7f84430 r99c2c69e  
    3535#include <futex.h>
    3636#include <atomic.h>
     37#include <libarch/barrier.h>
    3738#include <libc.h>
    3839#include <sys/types.h>
     
    5960int futex_trydown(futex_t *futex)
    6061{
    61         return cas(futex, 1, 0);
     62        int rc;
     63
     64        rc = cas(futex, 1, 0);
     65        CS_ENTER_BARRIER();
     66
     67        return rc;
    6268}
    6369
     
    7379int futex_down(futex_t *futex)
    7480{
    75         if ((atomic_signed_t) atomic_predec(futex) < 0)
     81        atomic_signed_t nv;
     82
     83        nv = (atomic_signed_t) atomic_predec(futex);
     84        CS_ENTER_BARRIER();
     85        if (nv < 0)
    7686                return __SYSCALL1(SYS_FUTEX_SLEEP, (sysarg_t) &futex->count);
    7787       
     
    8999int futex_up(futex_t *futex)
    90100{
     101        CS_LEAVE_BARRIER();
     102
    91103        if ((atomic_signed_t) atomic_postinc(futex) < 0)
    92104                return __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &futex->count);
  • uspace/lib/c/generic/inet.c

    r7f84430 r99c2c69e  
    111111       
    112112        ipc_call_t answer;
    113         aid_t req = async_send_3(exch, INET_SEND, dgram->tos, ttl, df,
    114             &answer);
     113        aid_t req = async_send_4(exch, INET_SEND, dgram->iplink, dgram->tos,
     114            ttl, df, &answer);
    115115       
    116116        int rc = async_data_write_start(exch, &dgram->src, sizeof(inet_addr_t));
  • uspace/lib/c/generic/inet/addr.c

    r7f84430 r99c2c69e  
    4747        #error The architecture must be either big-endian or little-endian.
    4848#endif
     49
     50const addr32_t addr32_broadcast_all_hosts = 0xffffffff;
    4951
    5052const addr48_t addr48_broadcast = {
  • uspace/lib/c/generic/net/socket_client.c

    r7f84430 r99c2c69e  
    923923 *                      message.
    924924 */
    925 int send(int socket_id, void *data, size_t datalength, int flags)
     925int send(int socket_id, const void *data, size_t datalength, int flags)
    926926{
    927927        /* Without the address */
  • uspace/lib/c/generic/pio_trace.c

    r7f84430 r99c2c69e  
    9595        pio_regions_t *regions = get_regions();
    9696        fibril_rwlock_read_lock(&regions->guard);
    97         list_foreach(regions->list, it) {
    98                 assert(it);
    99                 region_t *reg = region_instance(it);
    100                 assert(reg);
     97        list_foreach(regions->list, link, region_t, reg) {
    10198                if ((r >= reg->base) && (r < reg->base + reg->size)) {
    10299                        if (reg->log)
     
    131128        fibril_rwlock_write_lock(&regions->guard);
    132129        list_foreach_safe(regions->list, it, next) {
    133                 assert(it);
    134130                region_t *reg = region_instance(it);
    135                 assert(reg);
    136131                if (r >= reg->base && (r < reg->base + reg->size)) {
    137                                 list_remove(&reg->link);
    138                                 region_destroy(reg);
     132                        list_remove(&reg->link);
     133                        region_destroy(reg);
    139134                }
    140135        }
  • uspace/lib/c/generic/time.c

    r7f84430 r99c2c69e  
    556556               
    557557                void *addr;
    558                 rc = physmem_map((void *) faddr, 1,
    559                     AS_AREA_READ | AS_AREA_CACHEABLE, &addr);
     558                rc = physmem_map(faddr, 1, AS_AREA_READ | AS_AREA_CACHEABLE,
     559                    &addr);
    560560                if (rc != EOK) {
    561561                        as_area_destroy(addr);
  • uspace/lib/c/generic/vfs/vfs.c

    r7f84430 r99c2c69e  
    4343#include <stdio.h>
    4444#include <sys/stat.h>
     45#include <sys/statfs.h>
    4546#include <sys/types.h>
    4647#include <ipc/services.h>
     
    892893}
    893894
     895int statfs(const char *path, struct statfs *statfs)
     896{
     897        sysarg_t rc;
     898        sysarg_t rc_orig;
     899        aid_t req;
     900        size_t pa_size;
     901       
     902        char *pa = absolutize(path, &pa_size);
     903        if (!pa)
     904                return ENOMEM;
     905        async_exch_t *exch = vfs_exchange_begin();
     906       
     907        req = async_send_0(exch, VFS_IN_STATFS, NULL);
     908        rc = async_data_write_start(exch, pa, pa_size);
     909        if (rc != EOK) {
     910                vfs_exchange_end(exch);
     911                free(pa);
     912                async_wait_for(req, &rc_orig);
     913                if (rc_orig == EOK)
     914                        return (int) rc;
     915                else
     916                        return (int) rc_orig;
     917        }
     918        rc = async_data_read_start(exch, (void *) statfs, sizeof(struct statfs));
     919        if (rc != EOK) {
     920                vfs_exchange_end(exch);
     921                free(pa);
     922                async_wait_for(req, &rc_orig);
     923                if (rc_orig == EOK)
     924                        return (int) rc;
     925                else
     926                        return (int) rc_orig;
     927        }
     928        vfs_exchange_end(exch);
     929        free(pa);
     930        async_wait_for(req, &rc);
     931        return rc;
     932}
     933
    894934/** @}
    895935 */
  • uspace/lib/c/include/adt/list.h

    r7f84430 r99c2c69e  
    11/*
    22 * Copyright (c) 2001-2004 Jakub Jermar
    3  * Copyright (c) 2011 Jiri Svoboda
     3 * Copyright (c) 2013 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    6565
    6666#define list_get_instance(link, type, member) \
    67         ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
    68 
    69 #define list_foreach(list, iterator) \
    70         for (link_t *iterator = (list).head.next; \
    71             iterator != &(list).head; iterator = iterator->next)
     67        ((type *) (((void *)(link)) - list_link_to_void(&(((type *) NULL)->member))))
     68
     69#define list_foreach(list, member, itype, iterator) \
     70        for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \
     71            for (link_t *_link = (list).head.next; \
     72            iterator = list_get_instance(_link, itype, member), \
     73            _link != &(list).head; _link = _link->next)
    7274
    7375/** Unlike list_foreach(), allows removing items while traversing a list.
    74  * 
     76 *
    7577 * @code
    7678 * list_t mylist;
     
    238240static inline link_t *list_last(list_t *list)
    239241{
    240         return ((list->head.prev == &list->head) ? NULL : list->head.prev);
     242        return (list->head.prev == &list->head) ? NULL : list->head.prev;
     243}
     244
     245/** Get next item in list.
     246 *
     247 * @param link Current item link
     248 * @param list List containing @a link
     249 *
     250 * @return Next item or NULL if @a link is the last item.
     251 *
     252 */
     253static inline link_t *list_next(link_t *link, const list_t *list)
     254{
     255        return (link->next == &list->head) ? NULL : link->next;
     256}
     257
     258/** Get previous item in list.
     259 *
     260 * @param link Current item link
     261 * @param list List containing @a link
     262 *
     263 * @return Previous item or NULL if @a link is the first item.
     264 *
     265 */
     266static inline link_t *list_prev(link_t *link, const list_t *list)
     267{
     268        return (link->prev == &list->head) ? NULL : link->prev;
    241269}
    242270
     
    308336        unsigned int cnt = 0;
    309337       
    310         list_foreach(*list, link) {
     338        link_t *link = list_first(list);
     339        while (link != NULL) {
    311340                if (cnt == n)
    312341                        return link;
    313342               
    314343                cnt++;
     344                link = list_next(link, list);
    315345        }
    316346       
    317347        return NULL;
     348}
     349
     350/** Verify that argument type is a pointer to link_t (at compile time).
     351 *
     352 * This can be used to check argument type in a macro.
     353 */
     354static inline const void *list_link_to_void(const link_t *link)
     355{
     356        return link;
    318357}
    319358
  • uspace/lib/c/include/cfg.h

    r7f84430 r99c2c69e  
    8080
    8181#define cfg_file_foreach(file, cur) \
    82         list_foreach((file)->sections, (cur))
     82        list_foreach((file)->sections, link, const cfg_section_t, (cur))
    8383
    8484#define cfg_section_instance(cur) \
     
    8686
    8787#define cfg_section_foreach(section, cur) \
    88         list_foreach((section)->entries, (cur))
     88        list_foreach((section)->entries, link, const cfg_entry_t, (cur))
    8989
    9090#define cfg_entry_instance(cur) \
  • uspace/lib/c/include/ddi.h

    r7f84430 r99c2c69e  
    4040#include <sys/time.h>
    4141#include <abi/ddi/irq.h>
     42#include <device/hw_res.h>
     43#include <device/hw_res_parsed.h>
     44#include <device/pio_window.h>
    4245#include <task.h>
     46
     47#define DMAMEM_16MiB  ((uintptr_t) UINT64_C(0xffffffffff000000))
     48#define DMAMEM_4GiB   ((uintptr_t) UINT64_C(0xffffffff00000000))
    4349
    4450extern int device_assign_devno(void);
    4551
    46 extern int physmem_map(void *, size_t, unsigned int, void **);
     52extern int physmem_map(uintptr_t, size_t, unsigned int, void **);
    4753
    48 extern int dmamem_map(void *, size_t, unsigned int, unsigned int, void **);
    49 extern int dmamem_map_anonymous(size_t, unsigned int, unsigned int, void **,
    50     void **);
     54extern int dmamem_map(void *, size_t, unsigned int, unsigned int, uintptr_t *);
     55extern int dmamem_map_anonymous(size_t, uintptr_t, unsigned int, unsigned int,
     56    uintptr_t *, void **);
    5157extern int dmamem_unmap(void *, size_t);
    5258extern int dmamem_unmap_anonymous(void *);
    5359
     60extern int pio_enable_range(addr_range_t *, void **);
     61extern int pio_enable_resource(pio_window_t *, hw_resource_t *, void **);
    5462extern int pio_enable(void *, size_t, void **);
    5563
     
    6977extern uint32_t pio_read_32(const ioport32_t *);
    7078
    71 static inline uint8_t pio_change_8(
    72     ioport8_t *reg, uint8_t val, uint8_t mask, useconds_t delay)
     79static inline uint8_t pio_change_8(ioport8_t *reg, uint8_t val, uint8_t mask,
     80    useconds_t delay)
    7381{
    7482        uint8_t v = pio_read_8(reg);
     
    7886}
    7987
    80 static inline uint16_t pio_change_16(
    81     ioport16_t *reg, uint16_t val, uint16_t mask, useconds_t delay)
     88static inline uint16_t pio_change_16(ioport16_t *reg, uint16_t val,
     89    uint16_t mask, useconds_t delay)
    8290{
    8391        uint16_t v = pio_read_16(reg);
     
    8795}
    8896
    89 static inline uint32_t pio_change_32(
    90     ioport32_t *reg, uint32_t val, uint32_t mask, useconds_t delay)
     97static inline uint32_t pio_change_32(ioport32_t *reg, uint32_t val,
     98    uint32_t mask, useconds_t delay)
    9199{
    92100        uint32_t v = pio_read_32(reg);
  • uspace/lib/c/include/device/hw_res.h

    r7f84430 r99c2c69e  
    7676                struct {
    7777                        uint64_t address;
     78                        size_t size;
     79                        bool relative;
    7880                        endianness_t endianness;
    79                         size_t size;
    8081                } mem_range;
    8182               
    8283                struct {
    8384                        uint64_t address;
     85                        size_t size;
     86                        bool relative;
    8487                        endianness_t endianness;
    85                         size_t size;
    8688                } io_range;
    8789               
  • uspace/lib/c/include/device/hw_res_parsed.h

    r7f84430 r99c2c69e  
    3737
    3838#include <device/hw_res.h>
     39#include <device/pio_window.h>
    3940#include <str.h>
    4041
     
    4546#define HW_RES_KEEP_DUPLICIT   0x2
    4647
     48
     49#define RNGABS(rng)     (rng).address.absolute
     50#define RNGREL(rng)     (rng).address.relative
     51#define RNGSZ(rng)      (rng).size
     52
     53#define RNGABSPTR(rng)  ((void *) ((uintptr_t) RNGABS((rng))))
     54
     55typedef struct address64 {
     56        /** Aboslute address. */
     57        uint64_t absolute;
     58        /** PIO window base relative address. */
     59        uint64_t relative;
     60} address64_t;
     61
    4762/** Address range structure */
    4863typedef struct addr_range {
    4964        /** Start address */
    50         uint64_t address;
    51        
    52         /** Endianness */
    53         endianness_t endianness;
     65        address64_t address;
    5466       
    5567        /** Area size */
    5668        size_t size;
     69
     70        /** Endianness */
     71        endianness_t endianness;
    5772} addr_range_t;
    5873
     
    139154}
    140155
    141 extern int hw_res_list_parse(const hw_resource_list_t *,
     156extern int hw_res_list_parse(const pio_window_t *, const hw_resource_list_t *,
    142157    hw_res_list_parsed_t *, int);
    143158extern int hw_res_get_list_parsed(async_sess_t *, hw_res_list_parsed_t *, int);
  • uspace/lib/c/include/devman.h

    r7f84430 r99c2c69e  
    6161    unsigned int);
    6262extern int devman_fun_get_child(devman_handle_t, devman_handle_t *);
     63extern int devman_dev_get_parent(devman_handle_t, devman_handle_t *);
    6364extern int devman_dev_get_functions(devman_handle_t, devman_handle_t **,
    6465    size_t *);
     66extern int devman_fun_get_match_id(devman_handle_t, size_t, char *, size_t,
     67    unsigned int *);
    6568extern int devman_fun_get_name(devman_handle_t, char *, size_t);
    6669extern int devman_fun_get_driver_name(devman_handle_t, char *, size_t);
     
    7174extern int devman_add_device_to_category(devman_handle_t, const char *);
    7275extern int devman_fun_sid_to_handle(service_id_t, devman_handle_t *);
     76extern int devman_get_drivers(devman_handle_t **, size_t *);
     77extern int devman_driver_get_devices(devman_handle_t, devman_handle_t **,
     78    size_t *);
     79extern int devman_driver_get_handle(const char *, devman_handle_t *);
     80extern int devman_driver_get_match_id(devman_handle_t, size_t, char *, size_t,
     81    unsigned int *);
     82extern int devman_driver_get_name(devman_handle_t, char *, size_t);
     83extern int devman_driver_get_state(devman_handle_t, driver_state_t *);
     84extern int devman_driver_load(devman_handle_t);
    7385
    7486#endif
  • uspace/lib/c/include/inet/addr.h

    r7f84430 r99c2c69e  
    6868} inet_naddr_t;
    6969
     70extern const addr32_t addr32_broadcast_all_hosts;
    7071extern const addr48_t addr48_broadcast;
    7172
  • uspace/lib/c/include/inet/inet.h

    r7f84430 r99c2c69e  
    3737
    3838#include <inet/addr.h>
     39#include <ipc/loc.h>
    3940#include <sys/types.h>
    4041
     
    4243
    4344typedef struct {
     45        /** Local IP link service ID (optional) */
     46        service_id_t iplink;
    4447        inet_addr_t src;
    4548        inet_addr_t dest;
  • uspace/lib/c/include/ipc/dev_iface.h

    r7f84430 r99c2c69e  
    3636typedef enum {
    3737        HW_RES_DEV_IFACE = 0,
     38        PIO_WINDOW_DEV_IFACE,
    3839
    3940        /** Character device interface */
  • uspace/lib/c/include/ipc/devman.h

    r7f84430 r99c2c69e  
    4242
    4343typedef sysarg_t devman_handle_t;
     44
     45typedef enum {
     46        /** Driver has not been started. */
     47        DRIVER_NOT_STARTED = 0,
     48       
     49        /**
     50         * Driver has been started, but has not registered as running and ready
     51         * to receive requests.
     52         */
     53        DRIVER_STARTING,
     54       
     55        /** Driver is running and prepared to serve incomming requests. */
     56        DRIVER_RUNNING
     57} driver_state_t;
    4458
    4559typedef enum {
     
    155169        DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD,
    156170        DEVMAN_DEV_GET_FUNCTIONS,
     171        DEVMAN_DEV_GET_PARENT,
    157172        DEVMAN_FUN_GET_CHILD,
     173        DEVMAN_FUN_GET_MATCH_ID,
    158174        DEVMAN_FUN_GET_NAME,
    159175        DEVMAN_FUN_GET_DRIVER_NAME,
     
    161177        DEVMAN_FUN_OFFLINE,
    162178        DEVMAN_FUN_GET_PATH,
    163         DEVMAN_FUN_SID_TO_HANDLE
     179        DEVMAN_FUN_SID_TO_HANDLE,
     180        DEVMAN_GET_DRIVERS,
     181        DEVMAN_DRIVER_GET_DEVICES,
     182        DEVMAN_DRIVER_GET_HANDLE,
     183        DEVMAN_DRIVER_GET_MATCH_ID,
     184        DEVMAN_DRIVER_GET_NAME,
     185        DEVMAN_DRIVER_GET_STATE,
     186        DEVMAN_DRIVER_LOAD
    164187} client_to_devman_t;
    165188
  • uspace/lib/c/include/ipc/services.h

    r7f84430 r99c2c69e  
    5353} services_t;
    5454
     55#define SERVICE_NAME_CORECFG    "corecfg"
    5556#define SERVICE_NAME_DNSR       "net/dnsr"
    5657#define SERVICE_NAME_INET       "net/inet"
  • uspace/lib/c/include/ipc/socket.h

    r7f84430 r99c2c69e  
    198198#define SOCKET_GET_OPT_NAME(call) \
    199199        ({ \
    200                 int opt_name = (int) IPC_GET_ARG4(call); \
     200                int opt_name = (int) IPC_GET_ARG2(call); \
    201201                opt_name; \
    202202        })
  • uspace/lib/c/include/ipc/vfs.h

    r7f84430 r99c2c69e  
    8282        VFS_IN_WAIT_HANDLE,
    8383        VFS_IN_MTAB_GET,
     84        VFS_IN_STATFS
    8485} vfs_in_request_t;
    8586
     
    9899        VFS_OUT_LOOKUP,
    99100        VFS_OUT_DESTROY,
     101        VFS_OUT_STATFS,
    100102        VFS_OUT_LAST
    101103} vfs_out_request_t;
  • uspace/lib/c/include/net/socket.h

    r7f84430 r99c2c69e  
    5757extern int connect(int, const struct sockaddr *, socklen_t);
    5858extern int closesocket(int);
    59 extern int send(int, void *, size_t, int);
     59extern int send(int, const void *, size_t, int);
    6060extern int sendto(int, const void *, size_t, int, const struct sockaddr *,
    6161    socklen_t);
  • uspace/lib/c/include/net/socket_codes.h

    r7f84430 r99c2c69e  
    7575typedef int32_t socklen_t;
    7676
     77/* Socket options */
     78
     79enum {
     80        SOL_SOCKET = 1,
     81
     82        /* IP link to transmit on */
     83        SO_IPLINK
     84};
     85
    7786#endif
    7887
  • uspace/lib/c/include/vfs/vfs.h

    r7f84430 r99c2c69e  
    4444#include "vfs_mtab.h"
    4545
     46
    4647enum vfs_change_state_type {
    4748        VFS_PASS_HANDLE
    4849};
     50
    4951
    5052extern char *absolutize(const char *, size_t *);
     
    6163extern async_exch_t *vfs_exchange_begin(void);
    6264extern void vfs_exchange_end(async_exch_t *);
    63 
    6465#endif
    6566
  • uspace/lib/draw/drawctx.c

    r7f84430 r99c2c69e  
    188188         * transferred to the original surface. */
    189189
    190         list_foreach(*((list_t *) path), link) {
    191                 path_step_t *step = (path_step_t *) link;
     190        list_foreach(*((list_t *) path), link, path_step_t, step) {
    192191                switch (step->type) {
    193192                case PATH_STEP_MOVETO:
  • uspace/lib/drv/Makefile

    r7f84430 r99c2c69e  
    4141        generic/remote_audio_pcm.c \
    4242        generic/remote_hw_res.c \
     43        generic/remote_pio_window.c \
    4344        generic/remote_char_dev.c \
    4445        generic/remote_graph_dev.c \
  • uspace/lib/drv/generic/dev_iface.c

    r7f84430 r99c2c69e  
    4040#include "dev_iface.h"
    4141#include "remote_hw_res.h"
     42#include "remote_pio_window.h"
    4243#include "remote_char_dev.h"
    4344#include "remote_clock_dev.h"
     
    5859                [AUDIO_PCM_BUFFER_IFACE] = &remote_audio_pcm_iface,
    5960                [HW_RES_DEV_IFACE] = &remote_hw_res_iface,
     61                [PIO_WINDOW_DEV_IFACE] = &remote_pio_window_iface,
    6062                [CHAR_DEV_IFACE] = &remote_char_dev_iface,
    6163                [GRAPH_DEV_IFACE] = &remote_graph_dev_iface,
  • uspace/lib/drv/generic/driver.c

    r7f84430 r99c2c69e  
    9898static ddf_dev_t *driver_get_device(devman_handle_t handle)
    9999{
    100         ddf_dev_t *dev = NULL;
    101        
    102100        assert(fibril_mutex_is_locked(&devices_mutex));
    103101       
    104         list_foreach(devices, link) {
    105                 dev = list_get_instance(link, ddf_dev_t, link);
     102        list_foreach(devices, link, ddf_dev_t, dev) {
    106103                if (dev->handle == handle)
    107104                        return dev;
     
    113110static ddf_fun_t *driver_get_function(devman_handle_t handle)
    114111{
    115         ddf_fun_t *fun = NULL;
    116        
    117112        assert(fibril_mutex_is_locked(&functions_mutex));
    118113       
    119         list_foreach(functions, link) {
    120                 fun = list_get_instance(link, ddf_fun_t, link);
     114        list_foreach(functions, link, ddf_fun_t, fun) {
    121115                if (fun->handle == handle)
    122116                        return fun;
  • uspace/lib/drv/generic/interrupt.c

    r7f84430 r99c2c69e  
    138138    interrupt_context_list_t *list, int id)
    139139{
    140         interrupt_context_t *ctx;
    141        
    142         fibril_mutex_lock(&list->mutex);
    143        
    144         list_foreach(list->contexts, link) {
    145                 ctx = list_get_instance(link, interrupt_context_t, link);
     140        fibril_mutex_lock(&list->mutex);
     141       
     142        list_foreach(list->contexts, link, interrupt_context_t, ctx) {
    146143                if (ctx->id == id) {
    147144                        fibril_mutex_unlock(&list->mutex);
     
    157154    interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
    158155{
    159         interrupt_context_t *ctx;
    160        
    161         fibril_mutex_lock(&list->mutex);
    162        
    163         list_foreach(list->contexts, link) {
    164                 ctx = list_get_instance(link, interrupt_context_t, link);
     156        fibril_mutex_lock(&list->mutex);
     157       
     158        list_foreach(list->contexts, link, interrupt_context_t, ctx) {
    165159                if (ctx->irq == irq && ctx->dev == dev) {
    166160                        fibril_mutex_unlock(&list->mutex);
  • uspace/lib/fs/libfs.c

    r7f84430 r99c2c69e  
    4545#include <mem.h>
    4646#include <sys/stat.h>
     47#include <sys/statfs.h>
    4748#include <stdlib.h>
    4849
     
    7475static void libfs_open_node(libfs_ops_t *, fs_handle_t, ipc_callid_t,
    7576    ipc_call_t *);
     77static void libfs_statfs(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
    7678
    7779static void vfs_out_mounted(ipc_callid_t rid, ipc_call_t *req)
     
    219221}
    220222
     223static void vfs_out_statfs(ipc_callid_t rid, ipc_call_t *req)
     224{
     225        libfs_statfs(libfs_ops, reg.fs_handle, rid, req);
     226}
    221227static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    222228{
     
    276282                case VFS_OUT_SYNC:
    277283                        vfs_out_sync(callid, &call);
     284                        break;
     285                case VFS_OUT_STATFS:
     286                        vfs_out_statfs(callid, &call);
    278287                        break;
    279288                default:
     
    825834       
    826835        ops->node_put(fn);
    827        
     836
     837
    828838        async_data_read_finalize(callid, &stat, sizeof(struct stat));
    829839        async_answer_0(rid, EOK);
    830840}
     841
     842void libfs_statfs(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
     843    ipc_call_t *request)
     844{
     845        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
     846        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     847       
     848        fs_node_t *fn;
     849        int rc = ops->node_get(&fn, service_id, index);
     850        on_error(rc, answer_and_return(rid, rc));
     851       
     852        ipc_callid_t callid;
     853        size_t size;
     854        if ((!async_data_read_receive(&callid, &size)) ||
     855            (size != sizeof(struct statfs))) {
     856                ops->node_put(fn);
     857                async_answer_0(callid, EINVAL);
     858                async_answer_0(rid, EINVAL);
     859                return;
     860        }
     861       
     862        struct statfs statfs;
     863        memset(&statfs, 0, sizeof(struct statfs));
     864
     865        if (NULL != ops->size_block) { 
     866                rc = ops->size_block(service_id, &statfs.f_bsize);
     867                if (rc != EOK) goto error;
     868        }
     869
     870        if (NULL != ops->total_block_count) {
     871                rc = ops->total_block_count(service_id, &statfs.f_blocks);
     872                if (rc != EOK) goto error;
     873        }
     874
     875        if (NULL != ops->free_block_count) {
     876                rc = ops->free_block_count(service_id, &statfs.f_bfree);
     877                if (rc != EOK) goto error;
     878        }
     879
     880        ops->node_put(fn);
     881        async_data_read_finalize(callid, &statfs, sizeof(struct statfs));
     882        async_answer_0(rid, EOK);
     883        return;
     884
     885error:
     886        ops->node_put(fn);
     887        async_answer_0(callid, EINVAL);
     888        async_answer_0(rid, EINVAL);
     889}
     890
    831891
    832892/** Open VFS triplet.
     
    882942
    883943        fibril_mutex_lock(&instances_mutex);
    884         list_foreach(instances_list, link) {
    885                 fs_instance_t *cur = list_get_instance(link, fs_instance_t,
    886                     link);
    887 
     944        list_foreach(instances_list, link, fs_instance_t, cur) {
    888945                if (cur->service_id == service_id) {
    889946                        fibril_mutex_unlock(&instances_mutex);
     
    908965{
    909966        fibril_mutex_lock(&instances_mutex);
    910         list_foreach(instances_list, link) {
    911                 fs_instance_t *inst = list_get_instance(link, fs_instance_t,
    912                     link);
    913 
     967        list_foreach(instances_list, link, fs_instance_t, inst) {
    914968                if (inst->service_id == service_id) {
    915969                        *idp = inst->data;
     
    925979{
    926980        fibril_mutex_lock(&instances_mutex);
    927         list_foreach(instances_list, link) {
    928                 fs_instance_t *inst = list_get_instance(link, fs_instance_t,
    929                     link);
    930 
     981        list_foreach(instances_list, link, fs_instance_t, inst) {
    931982                if (inst->service_id == service_id) {
    932983                        list_remove(&inst->link);
  • uspace/lib/fs/libfs.h

    r7f84430 r99c2c69e  
    9393        bool (* is_file)(fs_node_t *);
    9494        service_id_t (* service_get)(fs_node_t *);
     95        int (* size_block)(service_id_t, uint32_t *);
     96        int (* total_block_count)(service_id_t, uint64_t *);
     97        int (* free_block_count)(service_id_t, uint64_t *);
    9598} libfs_ops_t;
    9699
  • uspace/lib/graph/graph.c

    r7f84430 r99c2c69e  
    165165
    166166        fibril_mutex_lock(&visualizer_list_mtx);
    167         list_foreach(visualizer_list, link) {
    168                 visualizer_t *cur = list_get_instance(link, visualizer_t, link);
    169                 if (cur->reg_svc_handle == handle) {
    170                         vs = cur;
     167        list_foreach(visualizer_list, link, visualizer_t, vcur) {
     168                if (vcur->reg_svc_handle == handle) {
     169                        vs = vcur;
    171170                        break;
    172171                }
     
    182181
    183182        fibril_mutex_lock(&renderer_list_mtx);
    184         list_foreach(renderer_list, link) {
    185                 renderer_t *cur = list_get_instance(link, renderer_t, link);
    186                 if (cur->reg_svc_handle == handle) {
    187                         rnd = cur;
     183        list_foreach(renderer_list, link, renderer_t, rcur) {
     184                if (rcur->reg_svc_handle == handle) {
     185                        rnd = rcur;
    188186                        break;
    189187                }
     
    322320        fibril_mutex_lock(&vs->mode_mtx);
    323321        vslmode_list_element_t *mode_elem = NULL;
    324         list_foreach(vs->modes, link) {
    325                 vslmode_list_element_t *cur = list_get_instance(link, vslmode_list_element_t, link);
     322        list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
    326323                if (cur->mode.index == vs->def_mode_idx) {
    327324                        mode_elem = cur;
     
    382379        fibril_mutex_lock(&vs->mode_mtx);
    383380        vslmode_list_element_t *mode_elem = NULL;
    384         list_foreach(vs->modes, link) {
    385                 vslmode_list_element_t *cur = list_get_instance(link, vslmode_list_element_t, link);
     381        list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
    386382                if (cur->mode.index == mode_idx) {
    387383                        mode_elem = cur;
     
    425421        fibril_mutex_lock(&vs->mode_mtx);
    426422        vslmode_list_element_t *mode_elem = NULL;
    427         list_foreach(vs->modes, link) {
    428                 vslmode_list_element_t *cur = list_get_instance(link, vslmode_list_element_t, link);
     423        list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
    429424                if (cur->mode.index == mode_idx) {
    430425                        mode_elem = cur;
  • uspace/lib/gui/connection.c

    r7f84430 r99c2c69e  
    6565
    6666        signal_node_t *sig_node = NULL;
    67         list_foreach(connection_list, link) {
    68                 signal_node_t *cur = list_get_instance(link, signal_node_t, link);
     67        list_foreach(connection_list, link, signal_node_t, cur) {
    6968                if (cur->signal == signal) {
    7069                        sig_node = cur;
     
    8887
    8988        slot_node_t *slt_node = NULL;
    90         list_foreach(sig_node->slots, link) {
    91                 slot_node_t *cur = list_get_instance(link, slot_node_t, link);
     89        list_foreach(sig_node->slots, link, slot_node_t, cur) {
    9290                if (cur->widget == widget && cur->slot == slot) {
    9391                        slt_node = cur;
     
    121119
    122120        signal_node_t *sig_node = NULL;
    123         list_foreach(connection_list, link) {
    124                 signal_node_t *cur = list_get_instance(link, signal_node_t, link);
     121        list_foreach(connection_list, link, signal_node_t, cur) {
    125122                if (cur->signal == signal) {
    126123                        sig_node = cur;
     
    135132
    136133        slot_node_t *slt_node = NULL;
    137         list_foreach(sig_node->slots, link) {
    138                 slot_node_t *cur = list_get_instance(link, slot_node_t, link);
     134        list_foreach(sig_node->slots, link, slot_node_t, cur) {
    139135                if (cur->widget == widget && cur->slot == slot) {
    140136                        slt_node = cur;
     
    164160
    165161        signal_node_t *sig_node = NULL;
    166         list_foreach(connection_list, link) {
    167                 signal_node_t *cur = list_get_instance(link, signal_node_t, link);
     162        list_foreach(connection_list, link, signal_node_t, cur) {
    168163                if (cur->signal == signal) {
    169164                        sig_node = cur;
     
    177172        }
    178173
    179         list_foreach(sig_node->slots, link) {
    180                 slot_node_t *cur = list_get_instance(link, slot_node_t, link);
     174        list_foreach(sig_node->slots, link, slot_node_t, cur) {
    181175                cur->slot(cur->widget, data);
    182176        }
     
    190184
    191185        signal_node_t *sig_node = NULL;
    192         list_foreach(connection_list, link) {
    193                 signal_node_t *cur = list_get_instance(link, signal_node_t, link);
     186        list_foreach(connection_list, link, signal_node_t, cur) {
    194187                if (cur->signal == signal) {
    195188                        sig_node = cur;
     
    203196        }
    204197
    205         list_foreach(sig_node->slots, link) {
    206                 slot_node_t *cur = list_get_instance(link, slot_node_t, link);
    207 
     198        list_foreach(sig_node->slots, link, slot_node_t, cur) {
    208199                void *data_copy = NULL;
    209200                if (data != NULL) {
  • uspace/lib/gui/grid.c

    r7f84430 r99c2c69e  
    298298        paint_internal(widget);
    299299       
    300         list_foreach(widget->children, link) {
    301                 widget_t *child = list_get_instance(link, widget_t, link);
     300        list_foreach(widget->children, link, widget_t, child) {
    302301                child->repaint(child);
    303302        }
  • uspace/lib/gui/terminal.c

    r7f84430 r99c2c69e  
    685685        terminal_t *term = NULL;
    686686       
    687         list_foreach(terms, link) {
    688                 terminal_t *cur = list_get_instance(link, terminal_t, link);
    689                
     687        list_foreach(terms, link, terminal_t, cur) {
    690688                if (cur->dsid == (service_id_t) IPC_GET_ARG1(*icall)) {
    691689                        term = cur;
  • uspace/lib/gui/window.c

    r7f84430 r99c2c69e  
    137137{
    138138        if (widget->window->is_decorated) {
    139                 list_foreach(widget->children, link) {
    140                         widget_t *child = list_get_instance(link, widget_t, link);
     139                list_foreach(widget->children, link, widget_t, child) {
    141140                        child->rearrange(child,
    142141                            widget->hpos + border_thickness,
     
    146145                }
    147146        } else {
    148                 list_foreach(widget->children, link) {
    149                         widget_t *child = list_get_instance(link, widget_t, link);
     147                list_foreach(widget->children, link, widget_t, child) {
    150148                        child->rearrange(child, widget->hpos, widget->vpos,
    151149                            widget->width, widget->height);
     
    160158        if (widget->window->is_decorated) {
    161159                paint_internal(widget);
    162                 list_foreach(widget->children, link) {
    163                         widget_t *child = list_get_instance(link, widget_t, link);
     160                list_foreach(widget->children, link, widget_t, child) {
    164161                        child->rearrange(child,
    165162                            hpos + border_thickness,
     
    169166                }
    170167        } else {
    171                 list_foreach(widget->children, link) {
    172                         widget_t *child = list_get_instance(link, widget_t, link);
     168                list_foreach(widget->children, link, widget_t, child) {
    173169                        child->rearrange(child, hpos, vpos, width, height);
    174170                }
     
    181177                paint_internal(widget);
    182178        }
    183         list_foreach(widget->children, link) {
    184                 widget_t *child = list_get_instance(link, widget_t, link);
     179        list_foreach(widget->children, link, widget_t, child) {
    185180                child->repaint(child);
    186181        }
     
    268263                        win_grab(widget->window->osess, event.pos_id, flags);
    269264                } else {
    270                         list_foreach(widget->children, link) {
    271                                 widget_t *child = list_get_instance(link, widget_t, link);
     265                        list_foreach(widget->children, link, widget_t, child) {
    272266                                child->handle_position_event(child, event);
    273267                        }
    274268                }
    275269        } else {
    276                 list_foreach(widget->children, link) {
    277                         widget_t *child = list_get_instance(link, widget_t, link);
     270                list_foreach(widget->children, link, widget_t, child) {
    278271                        child->handle_position_event(child, event);
    279272                }
  • uspace/lib/usbdev/src/recognise.c

    r7f84430 r99c2c69e  
    383383                goto failure;
    384384       
    385         list_foreach(match_ids.ids, id_link) {
    386                 match_id_t *match_id = list_get_instance(id_link, match_id_t, link);
     385        list_foreach(match_ids.ids, link, match_id_t, match_id) {
    387386                rc = ddf_fun_add_match_id(child, match_id->id, match_id->score);
    388387                if (rc != EOK) {
  • uspace/lib/usbhid/src/hiddescriptor.c

    r7f84430 r99c2c69e  
    333333        }
    334334
    335         usb_hid_report_description_t *report_des = NULL;
    336        
    337         list_foreach(report->reports, report_it) {
    338                 report_des = list_get_instance(report_it,
    339                                 usb_hid_report_description_t, reports_link);
    340 
     335        list_foreach(report->reports, reports_link,
     336            usb_hid_report_description_t, report_des) {
    341337                // if report id not set, return the first of the type
    342338                if(((report_des->report_id == report_id) || (report_id == 0)) &&
     
    902898void usb_hid_descriptor_print_list(list_t *list)
    903899{
    904         usb_hid_report_field_t *report_item;
    905 
    906900        if(list == NULL || list_empty(list)) {
    907901            usb_log_debug("\tempty\n");
     
    909903        }
    910904
    911         list_foreach(*list, item) {
    912                 report_item = list_get_instance(item, usb_hid_report_field_t,
    913                                 ritems_link);
    914 
     905        list_foreach(*list, ritems_link, usb_hid_report_field_t,
     906            report_item) {
    915907                usb_log_debug("\t\tOFFSET: %X\n", report_item->offset);
    916908                usb_log_debug("\t\tSIZE: %zu\n", report_item->size);
     
    937929
    938930                usb_log_debug("\n");
    939 
    940         }
    941 
     931        }
    942932}
    943933
     
    951941void usb_hid_descriptor_print(usb_hid_report_t *report)
    952942{
    953         if(report == NULL) {
     943        if (report == NULL)
    954944                return;
    955         }
    956 
    957         usb_hid_report_description_t *report_des;
    958 
    959         list_foreach(report->reports, report_it) {
    960                 report_des = list_get_instance(report_it,
    961                         usb_hid_report_description_t, reports_link);
     945
     946        list_foreach(report->reports, reports_link,
     947            usb_hid_report_description_t, report_des) {
    962948                usb_log_debug("Report ID: %d\n", report_des->report_id);
    963949                usb_log_debug("\tType: %d\n", report_des->type);
  • uspace/lib/usbhid/src/hidparser.c

    r7f84430 r99c2c69e  
    130130    size_t size, uint8_t *report_id)
    131131{
    132         usb_hid_report_field_t *item;
    133 
    134132        usb_hid_report_description_t *report_des;
    135133        usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT;
     
    153151
    154152        /* read data */
    155         list_foreach(report_des->report_items, list_item) {
    156                 item = list_get_instance(list_item, usb_hid_report_field_t,
    157                     ritems_link);
     153        list_foreach(report_des->report_items, ritems_link,
     154            usb_hid_report_field_t, item) {
    158155
    159156                if (USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) {
     
    163160                                item->value =
    164161                                        usb_hid_translate_data(item, data);
    165                
     162                               
    166163                                item->usage = USB_HID_EXTENDED_USAGE(
    167164                                    item->usages[item->value -
     
    184181                                /* variable item */
    185182                                item->value = usb_hid_translate_data(item,
    186                                     data);                             
    187                         }                       
     183                                    data);
     184                        }
    188185                }
    189186        }
     
    295292        usb_hid_report_description_t *report_des = NULL;
    296293
    297         list_foreach(report->reports, report_it) {
    298                 report_des = list_get_instance(report_it,
    299                     usb_hid_report_description_t, reports_link);
    300                
    301                 if ((report_des->report_id == report_id) &&
    302                     (report_des->type == USB_HID_REPORT_TYPE_OUTPUT)) {
     294        list_foreach(report->reports, reports_link,
     295            usb_hid_report_description_t, rdes) {
     296                if ((rdes->report_id == report_id) &&
     297                    (rdes->type == USB_HID_REPORT_TYPE_OUTPUT)) {
     298                        report_des = rdes;
    303299                        break;
    304300                }
     
    351347
    352348        if (report->use_report_ids != 0) {
    353                 buffer[0] = report_id;         
     349                buffer[0] = report_id;
    354350        }
    355351
     
    362358        }
    363359
    364         usb_hid_report_field_t *report_item;
    365 
    366         list_foreach(report_des->report_items, item) {
    367                 report_item = list_get_instance(item, usb_hid_report_field_t,
    368                     ritems_link);
    369 
     360        list_foreach(report_des->report_items, ritems_link,
     361            usb_hid_report_field_t, report_item) {
    370362                value = usb_hid_translate_data_reverse(report_item,
    371363                    report_item->value);
     
    382374                        }
    383375                        size_t shift = 8 - offset % 8 - length;
    384                         value = value << shift;                                                 
     376                        value = value << shift;
    385377                        value = value & (((1 << length) - 1) << shift);
    386                                
     378                       
    387379                        uint8_t mask = 0;
    388380                        mask = 0xff - (((1 << length) - 1) << shift);
     
    400392
    401393                                        tmp_value = tmp_value << (offset % 8);
    402        
     394                                       
    403395                                        mask = ~(((1 << (8 - (offset % 8))) - 1)
    404396                                            << (offset % 8));
     
    413405                                        value = value & ((1 << (length -
    414406                                            ((offset + length) % 8))) - 1);
    415                                
     407                                       
    416408                                        mask = (1 << (length -
    417409                                            ((offset + length) % 8))) - 1;
  • uspace/lib/usbhid/src/hidpath.c

    r7f84430 r99c2c69e  
    176176        usb_log_debug("\tLENGTH: %d\n", path->depth);
    177177
    178         usb_hid_report_usage_path_t *path_item;
    179 
    180         list_foreach(path->items, item) {
    181                 path_item = list_get_instance(item, usb_hid_report_usage_path_t,
    182                         rpath_items_link);
     178        list_foreach(path->items, rpath_items_link,
     179            usb_hid_report_usage_path_t, path_item) {
    183180
    184181                usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page);
     
    237234                        usb_hid_report_usage_path_t, rpath_items_link);
    238235
    239                 list_foreach(report_path->items, report_link) {
    240                         report_item = list_get_instance(report_link,
    241                                 usb_hid_report_usage_path_t, rpath_items_link);
     236                list_foreach(report_path->items, rpath_items_link,
     237                    usb_hid_report_usage_path_t, report_item) {
     238
     239                        if (USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
     240                                path_item->usage_page)) {
    242241                               
    243                         if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    244                                 path_item->usage_page)){
    245                                        
    246                                 if(only_page == 0){
    247                                         if(USB_HID_SAME_USAGE(
    248                                                 report_item->usage,
    249                                                 path_item->usage)) {
    250                                                        
     242                                if (only_page == 0) {
     243                                        if (USB_HID_SAME_USAGE(report_item->usage,
     244                                            path_item->usage))
    251245                                                return EOK;
    252                                         }
    253246                                }
    254247                                else {
     
    266259                        return 1;
    267260                }
    268                
     261
    269262        /* path is prefix of the report_path */
    270263        case USB_HID_PATH_COMPARE_BEGIN:
    271        
     264
    272265                report_link = report_path->items.head.next;
    273266                path_link = path->items.head.next;
     267               
     268                while ((report_link != &report_path->items.head) &&
     269                    (path_link != &path->items.head)) {
    274270                       
    275                 while((report_link != &report_path->items.head) &&
    276                       (path_link != &path->items.head)) {
    277                                          
    278271                        report_item = list_get_instance(report_link,
    279                                 usb_hid_report_usage_path_t, rpath_items_link);
    280                                          
     272                            usb_hid_report_usage_path_t, rpath_items_link);
     273                       
    281274                        path_item = list_get_instance(path_link,
    282275                                usb_hid_report_usage_path_t, rpath_items_link);
    283276
    284                         if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    285                                 path_item->usage_page) || ((only_page == 0) &&
     277                        if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
     278                            path_item->usage_page) || ((only_page == 0) &&
    286279                            !USB_HID_SAME_USAGE(report_item->usage,
    287                                 path_item->usage))) {
    288                        
     280                            path_item->usage))) {
    289281                                return 1;
    290                         }
    291                         else {
     282                        } else {
    292283                                report_link = report_link->next;
    293                                 path_link = path_link->next;                   
     284                                path_link = path_link->next;
    294285                        }
    295                        
    296                 }
    297 
    298                 if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
    299                         (path_link == &path->items.head)) ||
    300                    ((report_link == &report_path->items.head) &&
    301                         (path_link == &path->items.head))) {
    302                                
     286                }
     287
     288                if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
     289                    (path_link == &path->items.head)) ||
     290                    ((report_link == &report_path->items.head) &&
     291                    (path_link == &path->items.head))) {
    303292                        return EOK;
    304                 }
    305                 else {
     293                } else {
    306294                        return 1;
    307                 }                                               
     295                }
    308296                break;
    309297
     
    405393        usb_hid_report_path_t *usage_path)
    406394{
    407         usb_hid_report_usage_path_t *path_item;
    408395        usb_hid_report_usage_path_t *new_path_item;
    409396        usb_hid_report_path_t *new_usage_path = usb_hid_report_path ();
     
    419406        }
    420407
    421         list_foreach(usage_path->items, path_link) {
    422                 path_item = list_get_instance(path_link,
    423                         usb_hid_report_usage_path_t, rpath_items_link);
     408        list_foreach(usage_path->items, rpath_items_link,
     409            usb_hid_report_usage_path_t, path_item) {
    424410
    425411                new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
  • uspace/lib/usbhost/src/usb_endpoint_manager.c

    r7f84430 r99c2c69e  
    9090        if (address < 0)
    9191                return NULL;
    92         list_foreach(*get_list(instance, address), iterator) {
    93                 endpoint_t *ep = endpoint_get_instance(iterator);
     92        list_foreach(*get_list(instance, address), link, endpoint_t, ep) {
    9493                if (ep_match(ep, address, endpoint, direction))
    9594                        return ep;
     
    196195                        fibril_mutex_lock(&instance->guard);
    197196                        /* endpoint number is < 16, thus first byte is enough */
    198                         list_foreach(*get_list(instance, target.address), it) {
    199                                 endpoint_t *ep = endpoint_get_instance(it);
     197                        list_foreach(*get_list(instance, target.address),
     198                            link, endpoint_t, ep) {
    200199                                if ((ep->address == target.address)
    201200                                    && (ep->endpoint = data[4])) {
     
    216215                if ((data[0] & 0xf) == 0) {
    217216                        fibril_mutex_lock(&instance->guard);
    218                         list_foreach(*get_list(instance, target.address), it) {
    219                                 endpoint_t *ep = endpoint_get_instance(it);
     217                        list_foreach(*get_list(instance, target.address),
     218                            link, endpoint_t, ep) {
    220219                                if (ep->address == target.address) {
    221220                                        endpoint_toggle_set(ep,0);
     
    408407    usb_address_t address, void (*callback)(endpoint_t *, void *), void *arg)
    409408{
     409        list_t *list;
     410        link_t *link;
     411        link_t *next;
     412
    410413        assert(address >= 0);
    411414        assert(instance);
    412415        fibril_mutex_lock(&instance->guard);
    413         list_foreach(*get_list(instance, address), iterator) {
    414                 endpoint_t *ep = endpoint_get_instance(iterator);
     416
     417        list = get_list(instance, address);
     418        link = list_first(list);
     419        while (link != NULL) {
     420                endpoint_t *ep = list_get_instance(link, endpoint_t, link);
     421                next = list_next(link, list);
     422
    415423                if (ep->address == address) {
    416                         iterator = iterator->next;
    417424                        list_remove(&ep->link);
    418425                        if (callback)
     
    420427                        endpoint_destroy(ep);
    421428                }
     429                link = next;
    422430        }
    423431        fibril_mutex_unlock(&instance->guard);
Note: See TracChangeset for help on using the changeset viewer.