Changeset 241f1985 in mainline for uspace/lib/sysman/src/ctl.c
- Timestamp:
- 2019-08-31T10:45:17Z (5 years ago)
- Children:
- 102f641
- Parents:
- f92b315
- git-author:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-23 22:04:34)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-31 10:45:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/sysman/src/ctl.c
rf92b315 r241f1985 34 34 #include <sysman/sysman.h> 35 35 36 int sysman_unit_handle(const char *unit_name, unit_handle_t *handle_ptr)36 errno_t sysman_unit_handle(const char *unit_name, unit_handle_t *handle_ptr) 37 37 { 38 38 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); … … 40 40 ipc_call_t call; 41 41 aid_t req = async_send_0(exch, SYSMAN_CTL_UNIT_HANDLE, &call); 42 sysarg_t rc = async_data_write_start(exch, unit_name, str_size(unit_name));42 errno_t rc = async_data_write_start(exch, unit_name, str_size(unit_name)); 43 43 sysman_exchange_end(exch); 44 44 … … 50 50 async_wait_for(req, &rc); 51 51 if (rc == EOK) { 52 *handle_ptr = IPC_GET_ARG1(call);52 *handle_ptr = ipc_get_arg1(&call); 53 53 } 54 54 return rc; … … 64 64 * TODO convert to name->handle API 65 65 */ 66 int sysman_unit_start_by_name(const char *unit_name, int flags)66 errno_t sysman_unit_start_by_name(const char *unit_name, int flags) 67 67 { 68 68 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); 69 69 70 70 aid_t req = async_send_1(exch, SYSMAN_CTL_UNIT_START_BY_NAME, flags, NULL); 71 sysarg_t rc = async_data_write_start(exch, unit_name, str_size(unit_name));71 errno_t rc = async_data_write_start(exch, unit_name, str_size(unit_name)); 72 72 sysman_exchange_end(exch); 73 73 … … 81 81 } 82 82 83 int sysman_unit_start(unit_handle_t handle, int flags)84 { 85 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); 86 87 int rc = async_req_2_0(exch, SYSMAN_CTL_UNIT_START, handle, flags);83 errno_t sysman_unit_start(unit_handle_t handle, int flags) 84 { 85 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); 86 87 errno_t rc = async_req_2_0(exch, SYSMAN_CTL_UNIT_START, handle, flags); 88 88 sysman_exchange_end(exch); 89 89 … … 91 91 } 92 92 93 int sysman_unit_stop(unit_handle_t handle, int flags)94 { 95 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); 96 97 int rc = async_req_2_0(exch, SYSMAN_CTL_UNIT_STOP, handle, flags);93 errno_t sysman_unit_stop(unit_handle_t handle, int flags) 94 { 95 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); 96 97 errno_t rc = async_req_2_0(exch, SYSMAN_CTL_UNIT_STOP, handle, flags); 98 98 sysman_exchange_end(exch); 99 99 … … 101 101 } 102 102 103 static int sysman_get_units_once(sysarg_t *buf, size_t buf_size,103 static errno_t sysman_get_units_once(sysarg_t *buf, size_t buf_size, 104 104 size_t *act_size) 105 105 { … … 108 108 ipc_call_t answer; 109 109 aid_t req = async_send_0(exch, SYSMAN_CTL_GET_UNITS, &answer); 110 int rc = async_data_read_start(exch, buf, buf_size);111 112 sysman_exchange_end(exch); 113 114 if (rc != EOK) { 115 async_forget(req); 116 return rc; 117 } 118 119 sysarg_t retval;110 errno_t rc = async_data_read_start(exch, buf, buf_size); 111 112 sysman_exchange_end(exch); 113 114 if (rc != EOK) { 115 async_forget(req); 116 return rc; 117 } 118 119 errno_t retval; 120 120 async_wait_for(req, &retval); 121 121 … … 124 124 } 125 125 126 *act_size = IPC_GET_ARG1(answer);126 *act_size = ipc_get_arg1(&answer); 127 127 return EOK; 128 128 } 129 129 130 int sysman_get_units(unit_handle_t **units_ptr, size_t *cnt_ptr)130 errno_t sysman_get_units(unit_handle_t **units_ptr, size_t *cnt_ptr) 131 131 { 132 132 *units_ptr = NULL; … … 138 138 139 139 while (true) { 140 int rc = sysman_get_units_once(units, alloc_size, &act_size);140 errno_t rc = sysman_get_units_once(units, alloc_size, &act_size); 141 141 if (rc != EOK) { 142 142 return rc; … … 159 159 } 160 160 161 int sysman_unit_get_name(unit_handle_t handle, char *buf, size_t buf_size)161 errno_t sysman_unit_get_name(unit_handle_t handle, char *buf, size_t buf_size) 162 162 { 163 163 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); … … 165 165 ipc_call_t answer; 166 166 aid_t req = async_send_1(exch, SYSMAN_CTL_UNIT_GET_NAME, handle, &answer); 167 int rc = async_data_read_start(exch, buf, buf_size);168 169 sysman_exchange_end(exch); 170 171 if (rc != EOK) { 172 async_forget(req); 173 return rc; 174 } 175 176 sysarg_t retval;167 errno_t rc = async_data_read_start(exch, buf, buf_size); 168 169 sysman_exchange_end(exch); 170 171 if (rc != EOK) { 172 async_forget(req); 173 return rc; 174 } 175 176 errno_t retval; 177 177 async_wait_for(req, &retval); 178 178 … … 184 184 } 185 185 186 int sysman_unit_get_state(unit_handle_t handle, unit_state_t *state)187 { 188 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); 189 int rc = async_req_1_1(exch, SYSMAN_CTL_UNIT_GET_STATE, handle,state);190 sysman_exchange_end(exch); 191 192 return rc; 193 } 194 195 int sysman_shutdown(void)196 { 197 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); 198 int rc = async_req_0_0(exch, SYSMAN_CTL_SHUTDOWN);199 sysman_exchange_end(exch); 200 201 return rc; 202 } 186 errno_t sysman_unit_get_state(unit_handle_t handle, unit_state_t *state) 187 { 188 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); 189 errno_t rc = async_req_1_1(exch, SYSMAN_CTL_UNIT_GET_STATE, handle, (sysarg_t *)state); 190 sysman_exchange_end(exch); 191 192 return rc; 193 } 194 195 errno_t sysman_shutdown(void) 196 { 197 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); 198 errno_t rc = async_req_0_0(exch, SYSMAN_CTL_SHUTDOWN); 199 sysman_exchange_end(exch); 200 201 return rc; 202 }
Note:
See TracChangeset
for help on using the changeset viewer.