Changeset a0d1d9d in mainline
- Timestamp:
- 2011-11-14T10:12:53Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a066c1b9
- Parents:
- ec388d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/device/hw_res.c
rec388d7 ra0d1d9d 42 42 { 43 43 sysarg_t count = 0; 44 44 45 45 async_exch_t *exch = async_exchange_begin(sess); 46 if (exch == NULL) 47 return ENOMEM; 46 48 int rc = async_req_1_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 47 49 HW_RES_GET_RESOURCE_LIST, &count); 48 50 49 51 if (rc != EOK) { 50 52 async_exchange_end(exch); 51 53 return rc; 52 54 } 53 55 54 56 size_t size = count * sizeof(hw_resource_t); 55 57 hw_resource_t *resources = (hw_resource_t *) malloc(size); … … 59 61 return ENOMEM; 60 62 } 61 63 62 64 rc = async_data_read_start(exch, resources, size); 63 65 async_exchange_end(exch); 64 66 65 67 if (rc != EOK) { 66 68 free(resources); 67 69 return rc; 68 70 } 69 71 70 72 hw_resources->resources = resources; 71 73 hw_resources->count = count; 72 74 73 75 return EOK; 74 76 } … … 77 79 { 78 80 async_exch_t *exch = async_exchange_begin(sess); 81 if (exch == NULL) 82 return false; 79 83 int rc = async_req_1_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 80 84 HW_RES_ENABLE_INTERRUPT); 81 85 async_exchange_end(exch); 82 86 83 87 return (rc == EOK); 84 88 } 85 89 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 101 * @return Error code. 102 */ 86 103 int hw_res_dma_channel_setup(async_sess_t *sess, 87 104 unsigned channel, uint32_t pa, uint16_t size, uint8_t mode) … … 90 107 if (exch == NULL) 91 108 return ENOMEM; 92 uint32_t packed = size | (mode << 16);93 int ret = async_req_4_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),109 const uint32_t packed = size | (mode << 16); 110 const int ret = async_req_4_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 94 111 HW_RES_DMA_CHANNEL_SETUP, channel, pa, packed); 95 112 async_exchange_end(exch); 96 113 97 114 return ret; 98 115 }
Note:
See TracChangeset
for help on using the changeset viewer.