Changeset fd6bd6d in mainline


Ignore:
Timestamp:
2011-12-14T17:09:25Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9916841
Parents:
b402dadd
Message:

add stubs for DMA memory management functions (not working yet)

Location:
uspace/lib
Files:
9 edited

Legend:

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

    rb402dadd rfd6bd6d  
    7575}
    7676
     77int dmamem_map(dmamem_t *dmamem, size_t pages, unsigned int map_flags,
     78    unsigned int dma_flags)
     79{
     80        // FIXME TODO
     81        return -1;
     82}
     83
     84int dmamem_unmap(dmamem_t *dmamem)
     85{
     86        // FIXME TODO
     87        return -1;
     88}
     89
     90int dmamem_lock(void *virt, void **phys, size_t pages)
     91{
     92        // FIXME TODO
     93        return -1;
     94}
     95
     96int dmamem_unlock(void *virt, size_t pages)
     97{
     98        // FIXME TODO
     99        return -1;
     100}
     101
    77102/** Enable I/O space range to task.
    78103 *
    79104 * Caller of this function must have the IO_MEM_MANAGER capability.
    80105 *
    81  * @param id            Task ID.
    82  * @param ioaddr        Starting address of the I/O range.
    83  * @param size          Size of the range.
     106 * @param id     Task ID.
     107 * @param ioaddr Starting address of the I/O range.
     108 * @param size   Size of the range.
    84109 *
    85  * @return              0 on success, EPERM if the caller lacks the
    86  *                      CAP_IO_MANAGER capability, ENOENT if there is no task
    87  *                      with specified ID and ENOMEM if there was some problem
    88  *                      in allocating memory.
     110 * @return EOK on success
     111 * @return EPERM if the caller lacks the CAP_IO_MANAGER capability
     112 * @return ENOENT if there is no task with specified ID
     113 * @return ENOMEM if there was some problem in allocating memory.
     114 *
    89115 */
    90116int iospace_enable(task_id_t id, void *ioaddr, unsigned long size)
    91117{
    92118        ddi_ioarg_t arg;
    93 
     119       
    94120        arg.task_id = id;
    95121        arg.ioaddr = ioaddr;
    96122        arg.size = size;
    97 
     123       
    98124        return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg);
    99125}
     
    101127/** Enable PIO for specified I/O range.
    102128 *
    103  * @param pio_addr      I/O start address.
    104  * @param size          Size of the I/O region.
    105  * @param use_addr      Address where the final address for application's PIO
    106  *                      will be stored.
     129 * @param pio_addr I/O start address.
     130 * @param size     Size of the I/O region.
     131 * @param use_addr Address where the final address for
     132 *                 application's PIO will be stored.
    107133 *
    108  * @return              Zero on success or negative error code.
     134 * @return Zero on success or negative error code.
     135 *
    109136 */
    110137int pio_enable(void *pio_addr, size_t size, void **use_addr)
     
    114141        size_t offset;
    115142        unsigned int pages;
    116 
     143       
    117144#ifdef IO_SPACE_BOUNDARY
    118145        if (pio_addr < IO_SPACE_BOUNDARY) {
     
    121148        }
    122149#endif
    123 
     150       
    124151        phys = (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);
    125152        offset = pio_addr - phys;
  • uspace/lib/c/generic/device/nic.c

    rb402dadd rfd6bd6d  
    895895 *
    896896 */
    897 int nic_vlan_set_tag(async_sess_t *dev_sess, uint16_t tag, int add, int strip)
     897int nic_vlan_set_tag(async_sess_t *dev_sess, uint16_t tag, bool add, bool strip)
    898898{
    899899        async_exch_t *exch = async_exchange_begin(dev_sess);
  • uspace/lib/c/include/ddi.h

    rb402dadd rfd6bd6d  
    4040#include <task.h>
    4141
     42typedef struct {
     43        /** Physical memory */
     44        void *phys;
     45       
     46        /** Virtual memory */
     47        void *virt;
     48       
     49        /** Size in pages */
     50        size_t size;
     51       
     52        /** Mapping flags */
     53        unsigned int flags;
     54} dmamem_t;
     55
    4256extern int device_assign_devno(void);
    4357extern int physmem_map(void *, void *, size_t, unsigned int);
     58extern int dmamem_map(dmamem_t *, size_t, unsigned int, unsigned int);
     59extern int dmamem_unmap(dmamem_t *);
     60extern int dmamem_lock(void *, void **, size_t);
     61extern int dmamem_unlock(void *, size_t);
    4462extern int iospace_enable(task_id_t, void *, unsigned long);
    4563extern int pio_enable(void *, size_t, void **);
  • uspace/lib/c/include/device/nic.h

    rb402dadd rfd6bd6d  
    127127extern int nic_vlan_get_mask(async_sess_t *, nic_vlan_mask_t *);
    128128extern int nic_vlan_set_mask(async_sess_t *, const nic_vlan_mask_t *);
    129 extern int nic_vlan_set_tag(async_sess_t *, uint16_t, int, int);
     129extern int nic_vlan_set_tag(async_sess_t *, uint16_t, bool, bool);
    130130
    131131extern int nic_wol_virtue_add(async_sess_t *, nic_wv_type_t, const void *,
  • uspace/lib/c/include/net/device.h

    rb402dadd rfd6bd6d  
    7777#define NIC_PART_NUMBER_MAX_LENGTH    64
    7878#define NIC_SERIAL_NUMBER_MAX_LENGTH  64
     79
     80#define NIC_DEFECTIVE_LONG               0x0001
     81#define NIC_DEFECTIVE_SHORT              0x0002
     82#define NIC_DEFECTIVE_BAD_CRC            0x0010
     83#define NIC_DEFECTIVE_BAD_IPV4_CHECKSUM  0x0020
     84#define NIC_DEFECTIVE_BAD_IPV6_CHECKSUM  0x0040
     85#define NIC_DEFECTIVE_BAD_TCP_CHECKSUM   0x0080
     86#define NIC_DEFECTIVE_BAD_UDP_CHECKSUM   0x0100
    7987
    8088/**
  • uspace/lib/drv/generic/remote_nic.c

    rb402dadd rfd6bd6d  
    829829       
    830830        uint16_t tag = (uint16_t) IPC_GET_ARG2(*call);
    831         int add = (int) IPC_GET_ARG3(*call);
    832         int strip = (int) IPC_GET_ARG4(*call);
     831        bool add = (int) IPC_GET_ARG3(*call);
     832        bool strip = (int) IPC_GET_ARG4(*call);
    833833       
    834834        int rc = nic_iface->vlan_set_tag(dev, tag, add, strip);
  • uspace/lib/drv/include/ops/nic.h

    rb402dadd rfd6bd6d  
    8989        int (*vlan_get_mask)(ddf_fun_t *, nic_vlan_mask_t *);
    9090        int (*vlan_set_mask)(ddf_fun_t *, const nic_vlan_mask_t *);
    91         int (*vlan_set_tag)(ddf_fun_t *, uint16_t, int, int);
     91        int (*vlan_set_tag)(ddf_fun_t *, uint16_t, bool, bool);
    9292       
    9393        int (*wol_virtue_add)(ddf_fun_t *, nic_wv_type_t, const void *,
  • uspace/lib/nic/include/nic.h

    rb402dadd rfd6bd6d  
    275275
    276276/* Packet DMA lock */
    277 extern void * nic_dma_lock_packet(packet_t * packet);
    278 extern void nic_dma_unlock_packet(packet_t * packet);
     277extern void *nic_dma_lock_packet(packet_t *);
     278extern int nic_dma_unlock_packet(packet_t *);
    279279
    280280#endif // __NIC_H__
  • uspace/lib/nic/src/nic_driver.c

    rb402dadd rfd6bd6d  
    13291329}
    13301330
    1331 // FIXME: Later
    1332 #if 0
    1333 
    13341331/** Lock packet for DMA usage
    13351332 *
     
    13401337{
    13411338        void *phys_addr;
    1342         size_t locked;
    1343         int rc = dma_lock(packet, &phys_addr, 1, &locked);
     1339        int rc = dmamem_lock(packet, &phys_addr, 1);
    13441340        if (rc != EOK)
    13451341                return NULL;
    13461342       
    1347         assert(locked == 1);
    13481343        return phys_addr;
    13491344}
     
    13531348 * @param packet
    13541349 */
    1355 void nic_dma_unlock_packet(packet_t *packet)
    1356 {
    1357         size_t unlocked;
    1358         int rc = dma_unlock(packet, 1, &unlocked);
    1359         if (rc != EOK)
    1360                 return;
    1361        
    1362         assert(unlocked == 1);
    1363 }
    1364 
    1365 #endif
     1350int nic_dma_unlock_packet(packet_t *packet)
     1351{
     1352        return dmamem_unlock(packet, 1);
     1353}
    13661354
    13671355/** @}
Note: See TracChangeset for help on using the changeset viewer.