Changeset fbfe59d in mainline for uspace/lib/c


Ignore:
Timestamp:
2018-06-25T21:45:05Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8119363
Parents:
2498b95 (diff), e3107e2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'virtio-net'

This commit merges basic support for the virtio-net NIC. As of now, the
driver does not support any advanced features that might be supported by
the device. Also device removal is not yet supported.

Location:
uspace/lib/c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/ddi.c

    r2498b95 rfbfe59d  
    220220/** Enable PIO for specified HW resource wrt. to the PIO window.
    221221 *
    222  * @param win      PIO window. May be NULL if the resources are known to be
    223  *                 absolute.
    224  * @param res      Resources specifying the I/O range wrt. to the PIO window.
    225  * @param virt     Virtual address for application's PIO operations.
     222 * @param win        PIO window. May be NULL if the resources are known to be
     223 *                   absolute.
     224 * @param res        Resources specifying the I/O range wrt. to the PIO window.
     225 * @param[out] virt  Virtual address for application's PIO operations.
     226 * @param[out] phys  If non-NULL, physical address of the resource
     227 * @param[out] size  If non-NULL, size of the enabled resource.
    226228 *
    227229 * @return EOK on success.
     
    229231 *
    230232 */
    231 errno_t pio_enable_resource(pio_window_t *win, hw_resource_t *res, void **virt)
     233errno_t pio_enable_resource(pio_window_t *win, hw_resource_t *res, void **virt,
     234    uintptr_t *phys, size_t *size)
    232235{
    233236        uintptr_t addr;
    234         size_t size;
     237        size_t sz;
    235238
    236239        switch (res->type) {
     
    242245                        addr += win->io.base;
    243246                }
    244                 size = res->res.io_range.size;
     247                sz = res->res.io_range.size;
    245248                break;
    246249        case MEM_RANGE:
     
    251254                        addr += win->mem.base;
    252255                }
    253                 size = res->res.mem_range.size;
     256                sz = res->res.mem_range.size;
    254257                break;
    255258        default:
     
    257260        }
    258261
    259         return pio_enable((void *) addr, size, virt);
     262        if (phys)
     263                *phys = addr;
     264        if (size)
     265                *size = sz;
     266
     267        return pio_enable((void *) addr, sz, virt);
    260268}
    261269
  • uspace/lib/c/include/ddi.h

    r2498b95 rfbfe59d  
    4040#include <stdint.h>
    4141#include <sys/time.h>
     42#include <byteorder.h>
    4243#include <abi/ddi/irq.h>
    4344#include <device/hw_res.h>
     
    6465
    6566extern errno_t pio_enable_range(addr_range_t *, void **);
    66 extern errno_t pio_enable_resource(pio_window_t *, hw_resource_t *, void **);
     67extern errno_t pio_enable_resource(pio_window_t *, hw_resource_t *, void **,
     68    uintptr_t *, size_t *);
    6769extern errno_t pio_enable(void *, size_t, void **);
    6870extern errno_t pio_disable(void *, size_t);
     
    8587extern uint64_t pio_read_64(const ioport64_t *);
    8688
     89static inline void pio_write_le16(ioport16_t *reg, uint16_t val)
     90{
     91        pio_write_16(reg, host2uint16_t_le(val));
     92}
     93static inline void pio_write_be16(ioport16_t *reg, uint16_t val)
     94{
     95        pio_write_16(reg, host2uint16_t_be(val));
     96}
     97static inline void pio_write_le32(ioport32_t *reg, uint32_t val)
     98{
     99        pio_write_32(reg, host2uint32_t_le(val));
     100}
     101static inline void pio_write_be32(ioport32_t *reg, uint32_t val)
     102{
     103        pio_write_32(reg, host2uint32_t_be(val));
     104}
     105static inline void pio_write_le64(ioport64_t *reg, uint64_t val)
     106{
     107        pio_write_64(reg, host2uint64_t_le(val));
     108}
     109static inline void pio_write_be64(ioport64_t *reg, uint64_t val)
     110{
     111        pio_write_64(reg, host2uint64_t_be(val));
     112}
     113
     114static inline uint16_t pio_read_le16(const ioport16_t *reg)
     115{
     116        return uint16_t_le2host(pio_read_16(reg));
     117}
     118static inline uint16_t pio_read_be16(const ioport16_t *reg)
     119{
     120        return uint16_t_be2host(pio_read_16(reg));
     121}
     122static inline uint32_t pio_read_le32(const ioport32_t *reg)
     123{
     124        return uint32_t_le2host(pio_read_32(reg));
     125}
     126static inline uint32_t pio_read_be32(const ioport32_t *reg)
     127{
     128        return uint32_t_be2host(pio_read_32(reg));
     129}
     130static inline uint64_t pio_read_le64(const ioport64_t *reg)
     131{
     132        return uint64_t_le2host(pio_read_64(reg));
     133}
     134static inline uint64_t pio_read_be64(const ioport64_t *reg)
     135{
     136        return uint64_t_be2host(pio_read_64(reg));
     137}
     138
    87139static inline uint8_t pio_change_8(ioport8_t *reg, uint8_t val, uint8_t mask,
    88140    useconds_t delay)
Note: See TracChangeset for help on using the changeset viewer.