Changes in uspace/lib/drv/generic/remote_ahci.c [58563585:9904eb90] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_ahci.c
r58563585 r9904eb90 33 33 */ 34 34 35 #include <as.h>36 35 #include <async.h> 37 #include <devman.h>38 36 #include <errno.h> 39 37 #include <stdio.h> 40 #include <macros.h>41 38 #include "ahci_iface.h" 42 39 #include "ddf/driver.h" … … 50 47 } ahci_iface_funcs_t; 51 48 52 #define MAX_NAME_LENGTH 102453 54 49 #define LO(ptr) \ 55 50 ((uint32_t) (((uint64_t) ((uintptr_t) (ptr))) & 0xffffffff)) … … 58 53 ((uint32_t) (((uint64_t) ((uintptr_t) (ptr))) >> 32)) 59 54 60 async_sess_t* ahci_get_sess(devman_handle_t funh, char **name)61 {62 // FIXME: Use a better way than substring match63 64 *name = NULL;65 66 char devn[MAX_NAME_LENGTH];67 int rc = devman_fun_get_name(funh, devn, MAX_NAME_LENGTH);68 if (rc != EOK)69 return NULL;70 71 size_t devn_size = str_size(devn);72 73 if ((devn_size > 5) && (str_lcmp(devn, "ahci_", 5) == 0)) {74 async_sess_t *sess = devman_device_connect(funh, IPC_FLAG_BLOCKING);75 76 if (sess) {77 *name = str_dup(devn);78 return sess;79 }80 }81 82 return NULL;83 }84 85 int ahci_get_sata_device_name(async_sess_t *sess, size_t sata_dev_name_length,86 char *sata_dev_name)87 {88 async_exch_t *exch = async_exchange_begin(sess);89 if (!exch)90 return EINVAL;91 92 aid_t req = async_send_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),93 IPC_M_AHCI_GET_SATA_DEVICE_NAME, sata_dev_name_length, NULL);94 95 async_data_read_start(exch, sata_dev_name, sata_dev_name_length);96 97 sysarg_t rc;98 async_wait_for(req, &rc);99 100 return rc;101 }102 103 int ahci_get_num_blocks(async_sess_t *sess, uint64_t *blocks)104 {105 async_exch_t *exch = async_exchange_begin(sess);106 if (!exch)107 return EINVAL;108 109 sysarg_t blocks_hi;110 sysarg_t blocks_lo;111 int rc = async_req_1_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),112 IPC_M_AHCI_GET_NUM_BLOCKS, &blocks_hi, &blocks_lo);113 114 async_exchange_end(exch);115 116 if (rc == EOK) {117 *blocks = (((uint64_t) blocks_hi) << 32)118 | (((uint64_t) blocks_lo) & 0xffffffff);119 }120 121 return rc;122 }123 124 int ahci_get_block_size(async_sess_t *sess, size_t *blocks_size)125 {126 async_exch_t *exch = async_exchange_begin(sess);127 if (!exch)128 return EINVAL;129 130 sysarg_t bs;131 int rc = async_req_1_1(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),132 IPC_M_AHCI_GET_BLOCK_SIZE, &bs);133 134 async_exchange_end(exch);135 136 if (rc == EOK)137 *blocks_size = (size_t) bs;138 139 return rc;140 }141 142 int ahci_read_blocks(async_sess_t *sess, uint64_t blocknum, size_t count,143 void *buf)144 {145 async_exch_t *exch = async_exchange_begin(sess);146 if (!exch)147 return EINVAL;148 149 aid_t req;150 req = async_send_4(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),151 IPC_M_AHCI_READ_BLOCKS, HI(blocknum), LO(blocknum), count, NULL);152 153 async_share_out_start(exch, buf, AS_AREA_READ | AS_AREA_WRITE);154 155 async_exchange_end(exch);156 157 sysarg_t rc;158 async_wait_for(req, &rc);159 160 return rc;161 }162 163 int ahci_write_blocks(async_sess_t *sess, uint64_t blocknum, size_t count,164 void* buf)165 {166 async_exch_t *exch = async_exchange_begin(sess);167 if (!exch)168 return EINVAL;169 170 aid_t req = async_send_4(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),171 IPC_M_AHCI_WRITE_BLOCKS, HI(blocknum), LO(blocknum), count, NULL);172 173 async_share_out_start(exch, buf, AS_AREA_READ | AS_AREA_WRITE);174 175 async_exchange_end(exch);176 177 sysarg_t rc;178 async_wait_for(req, &rc);179 180 return rc;181 }182 183 55 static void remote_ahci_get_sata_device_name(ddf_fun_t *, void *, ipc_callid_t, 184 56 ipc_call_t *); … … 193 65 194 66 /** Remote AHCI interface operations. */ 195 static constremote_iface_func_ptr_t remote_ahci_iface_ops [] = {67 static remote_iface_func_ptr_t remote_ahci_iface_ops [] = { 196 68 [IPC_M_AHCI_GET_SATA_DEVICE_NAME] = remote_ahci_get_sata_device_name, 197 69 [IPC_M_AHCI_GET_NUM_BLOCKS] = remote_ahci_get_num_blocks, … … 203 75 /** Remote AHCI interface structure. 204 76 */ 205 const remote_iface_t remote_ahci_iface = { 206 .method_count = ARRAY_SIZE(remote_ahci_iface_ops), 77 remote_iface_t remote_ahci_iface = { 78 .method_count = sizeof(remote_ahci_iface_ops) / 79 sizeof(remote_ahci_iface_ops[0]), 207 80 .methods = remote_ahci_iface_ops 208 81 }; … … 222 95 223 96 char* sata_dev_name = malloc(sata_dev_name_length); 224 if (sata_dev_name == NULL) {225 async_answer_0(callid, ENOMEM);226 return;227 }228 97 229 98 const int ret = ahci_iface->get_sata_device_name(fun, … … 236 105 async_data_read_finalize(cid, sata_dev_name, sata_dev_name_length); 237 106 238 free(sata_dev_name);239 107 async_answer_0(callid, ret); 240 108 }
Note:
See TracChangeset
for help on using the changeset viewer.