Changeset d6b1359 in mainline for uspace/lib/c/generic
- Timestamp:
- 2011-01-09T18:00:14Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 80bffdb0
- Parents:
- 0c70f7e (diff), 8871dba (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. - Location:
- uspace/lib/c/generic/device
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/device/char_dev.c
r0c70f7e rd6b1359 34 34 35 35 #include <ipc/dev_iface.h> 36 #include <device/char .h>36 #include <device/char_dev.h> 37 37 #include <errno.h> 38 38 #include <async.h> … … 45 45 * using its character interface. 46 46 * 47 * @param dev_phone Phone to the device. 48 * @param buf Buffer for the data read 49 * from or written to the device. 50 * @param len Maximum length of the data to be 51 * read or written. 52 * @param read Read from the device if true, 53 * write to it otherwise. 47 * @param dev_phone Phone to the device. 48 * @param buf Buffer for the data read from or written to the device. 49 * @param size Maximum size of data (in bytes) to be read or written. 50 * @param read Read from the device if true, write to it otherwise. 54 51 * 55 * @return Non-negative number of bytes actually read 56 * from or written to the device on success, 57 * negative error number otherwise. 58 * 52 * @return Non-negative number of bytes actually read from or 53 * written to the device on success, negative error number 54 * otherwise. 59 55 */ 60 static ssize_t rw_dev(int dev_phone, void *buf, size_t len, bool read)56 static ssize_t char_dev_rw(int dev_phone, void *buf, size_t size, bool read) 61 57 { 62 58 async_serialize_start(); … … 68 64 if (read) { 69 65 req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), 70 CHAR_ READ_DEV, &answer);71 ret = async_data_read_start(dev_phone, buf, len);66 CHAR_DEV_READ, &answer); 67 ret = async_data_read_start(dev_phone, buf, size); 72 68 } else { 73 69 req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), 74 CHAR_ WRITE_DEV, &answer);75 ret = async_data_write_start(dev_phone, buf, len);70 CHAR_DEV_WRITE, &answer); 71 ret = async_data_write_start(dev_phone, buf, size); 76 72 } 77 73 … … 82 78 if (rc == EOK) 83 79 return (ssize_t) ret; 84 80 85 81 return (ssize_t) rc; 86 82 } … … 96 92 } 97 93 98 /** Read from device using its character interface.94 /** Read from character device. 99 95 * 100 * @param dev_phone Phone to the device. 101 * @param buf Output buffer for the data 102 * read from the device. 103 * @param len Maximum length of the data to be read. 96 * @param dev_phone Phone to the device. 97 * @param buf Output buffer for the data read from the device. 98 * @param size Maximum size (in bytes) of the data to be read. 104 99 * 105 * @return Non-negative number of bytes actually read 106 * from the device on success, negative error 107 * number otherwise. 108 * 100 * @return Non-negative number of bytes actually read from the 101 * device on success, negative error number otherwise. 109 102 */ 110 ssize_t read_dev(int dev_phone, void *buf, size_t len)103 ssize_t char_dev_read(int dev_phone, void *buf, size_t size) 111 104 { 112 return rw_dev(dev_phone, buf, len, true);105 return char_dev_rw(dev_phone, buf, size, true); 113 106 } 114 107 115 /** Write to device using its character interface.108 /** Write to character device. 116 109 * 117 * @param dev_phone 118 * @param buf Input buffer containg the data119 * to be written to thedevice.120 * @param len Maximum lengthof the data to be written.110 * @param dev_phone Phone to the device. 111 * @param buf Input buffer containg the data to be written to the 112 * device. 113 * @param size Maximum size (in bytes) of the data to be written. 121 114 * 122 * @return Non-negative number of bytes actually written 123 * to the device on success, negative error number 124 * otherwise. 125 * 115 * @return Non-negative number of bytes actually written to the 116 * device on success, negative error number otherwise. 126 117 */ 127 ssize_t write_dev(int dev_phone, void *buf, size_t len)118 ssize_t char_dev_write(int dev_phone, void *buf, size_t size) 128 119 { 129 return rw_dev(dev_phone, buf, len, false);120 return char_dev_rw(dev_phone, buf, size, false); 130 121 } 131 122 -
uspace/lib/c/generic/device/hw_res.c
r0c70f7e rd6b1359 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 29 /** @addtogroup libc 30 30 * @{ … … 32 32 /** @file 33 33 */ 34 34 35 35 #include <device/hw_res.h> 36 36 #include <errno.h> … … 38 38 #include <malloc.h> 39 39 40 int get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)40 int hw_res_get_resource_list(int dev_phone, hw_resource_list_t *hw_resources) 41 41 { 42 42 sysarg_t count = 0; 43 int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count); 43 44 int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), 45 HW_RES_GET_RESOURCE_LIST, &count); 46 44 47 hw_resources->count = count; 45 48 if (rc != EOK) … … 57 60 return rc; 58 61 } 59 62 60 63 return EOK; 61 64 } 62 65 63 bool enable_interrupt(int dev_phone)66 bool hw_res_enable_interrupt(int dev_phone) 64 67 { 65 int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), ENABLE_INTERRUPT); 68 int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), 69 HW_RES_ENABLE_INTERRUPT); 70 66 71 return rc == EOK; 67 72 } 68 69 70 71 /** @} 73 74 /** @} 72 75 */
Note:
See TracChangeset
for help on using the changeset viewer.