Changeset b252e87 in mainline
- Timestamp:
- 2020-02-11T11:17:22Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e1f2079
- Parents:
- b43edabe
- git-author:
- Jiri Svoboda <jiri@…> (2020-02-10 20:17:06)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-02-11 11:17:22)
- Location:
- uspace/lib/ddev
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ddev/include/ddev.h
rb43edabe rb252e87 36 36 #define _LIBDDEV_DDEV_H_ 37 37 38 #include <ddev/info.h> 38 39 #include <errno.h> 39 40 #include <gfx/context.h> 40 41 #include <stdbool.h> 41 42 #include "types/ddev.h" 43 #include "types/ddev/info.h" 42 44 43 45 extern errno_t ddev_open(const char *, ddev_t **); 44 46 extern void ddev_close(ddev_t *); 45 47 extern errno_t ddev_get_gc(ddev_t *, gfx_context_t **); 48 extern errno_t ddev_get_info(ddev_t *, ddev_info_t *); 46 49 47 50 #endif -
uspace/lib/ddev/include/ddev_srv.h
rb43edabe rb252e87 39 39 #include <errno.h> 40 40 #include <gfx/context.h> 41 #include "types/ddev/info.h" 41 42 42 43 typedef struct ddev_ops ddev_ops_t; … … 51 52 struct ddev_ops { 52 53 errno_t (*get_gc)(void *, sysarg_t *, sysarg_t *); 54 errno_t (*get_info)(void *, ddev_info_t *); 53 55 }; 54 56 -
uspace/lib/ddev/include/ipc/ddev.h
rb43edabe rb252e87 39 39 40 40 typedef enum { 41 DDEV_GET_GC = IPC_FIRST_USER_METHOD 41 DDEV_GET_GC = IPC_FIRST_USER_METHOD, 42 DDEV_GET_INFO 42 43 } ddev_request_t; 43 44 -
uspace/lib/ddev/meson.build
rb43edabe rb252e87 31 31 'src/ddev.c', 32 32 'src/ddev_srv.c', 33 'src/info.c', 33 34 ) 34 35 -
uspace/lib/ddev/src/ddev.c
rb43edabe rb252e87 111 111 } 112 112 113 /** Get display device information. 114 * 115 * @param ddev Display device 116 * @param info Place to store information 117 */ 118 errno_t ddev_get_info(ddev_t *ddev, ddev_info_t *info) 119 { 120 async_exch_t *exch; 121 errno_t retval; 122 ipc_call_t answer; 123 124 exch = async_exchange_begin(ddev->sess); 125 aid_t req = async_send_0(exch, DDEV_GET_INFO, &answer); 126 127 errno_t rc = async_data_read_start(exch, info, sizeof(ddev_info_t)); 128 async_exchange_end(exch); 129 if (rc != EOK) { 130 async_forget(req); 131 return rc; 132 } 133 134 async_wait_for(req, &retval); 135 if (retval != EOK) 136 return rc; 137 138 return EOK; 139 } 140 113 141 /** @} 114 142 */ -
uspace/lib/ddev/src/ddev_srv.c
rb43edabe rb252e87 70 70 } 71 71 72 /** Get display device information */ 73 static void ddev_get_info_srv(ddev_srv_t *srv, ipc_call_t *icall) 74 { 75 ddev_info_t info; 76 errno_t rc; 77 78 printf("ddev_get_info_srv\n"); 79 80 ipc_call_t call; 81 size_t size; 82 if (!async_data_read_receive(&call, &size)) { 83 async_answer_0(&call, EREFUSED); 84 async_answer_0(icall, EREFUSED); 85 return; 86 } 87 88 if (size != sizeof(ddev_info_t)) { 89 async_answer_0(&call, EINVAL); 90 async_answer_0(icall, EINVAL); 91 return; 92 } 93 94 if (srv->ops->get_info == NULL) { 95 printf("get_info is NULL -> ENOTSUP\n"); 96 async_answer_0(&call, ENOTSUP); 97 async_answer_0(icall, ENOTSUP); 98 return; 99 } 100 101 rc = srv->ops->get_info(srv->arg, &info); 102 if (rc != EOK) { 103 async_answer_0(&call, rc); 104 async_answer_0(icall, rc); 105 return; 106 } 107 108 rc = async_data_read_finalize(&call, &info, sizeof(ddev_info_t)); 109 if (rc != EOK) { 110 async_answer_0(icall, rc); 111 return; 112 } 113 114 async_answer_0(icall, EOK); 115 } 116 72 117 void ddev_conn(ipc_call_t *icall, ddev_srv_t *srv) 73 118 { … … 92 137 case DDEV_GET_GC: 93 138 ddev_get_gc_srv(srv, &call); 139 break; 140 case DDEV_GET_INFO: 141 ddev_get_info_srv(srv, &call); 94 142 break; 95 143 default: -
uspace/lib/ddev/test/ddev.c
rb43edabe rb252e87 49 49 50 50 static errno_t test_get_gc(void *, sysarg_t *, sysarg_t *); 51 static errno_t test_get_info(void *, ddev_info_t *); 51 52 static errno_t test_gc_set_color(void *, gfx_color_t *); 52 53 53 54 static ddev_ops_t test_ddev_ops = { 54 .get_gc = test_get_gc 55 .get_gc = test_get_gc, 56 .get_info = test_get_info 55 57 }; 56 58 … … 66 68 bool set_color_called; 67 69 ddev_srv_t *srv; 70 ddev_info_t info; 68 71 } test_response_t; 69 72 … … 172 175 } 173 176 177 /** ddev_get_info with server returning failure */ 178 PCUT_TEST(dev_get_info_failure) 179 { 180 errno_t rc; 181 service_id_t sid; 182 ddev_t *ddev = NULL; 183 test_response_t resp; 184 ddev_info_t info; 185 186 async_set_fallback_port_handler(test_ddev_conn, &resp); 187 188 // FIXME This causes this test to be non-reentrant! 189 rc = loc_server_register(test_ddev_server); 190 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 191 192 rc = loc_service_register(test_ddev_svc, &sid); 193 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 194 195 rc = ddev_open(test_ddev_svc, &ddev); 196 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 197 PCUT_ASSERT_NOT_NULL(ddev); 198 199 resp.rc = ENOMEM; 200 rc = ddev_get_info(ddev, &info); 201 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 202 203 ddev_close(ddev); 204 rc = loc_service_unregister(sid); 205 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 206 } 207 208 /** ddev_get_info with server returning success */ 209 PCUT_TEST(dev_get_info_success) 210 { 211 errno_t rc; 212 service_id_t sid; 213 ddev_t *ddev = NULL; 214 test_response_t resp; 215 ddev_info_t info; 216 217 async_set_fallback_port_handler(test_ddev_conn, &resp); 218 219 // FIXME This causes this test to be non-reentrant! 220 rc = loc_server_register(test_ddev_server); 221 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 222 223 rc = loc_service_register(test_ddev_svc, &sid); 224 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 225 226 rc = ddev_open(test_ddev_svc, &ddev); 227 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 228 PCUT_ASSERT_NOT_NULL(ddev); 229 230 resp.rc = EOK; 231 232 ddev_info_init(&resp.info); 233 resp.info.rect.p0.x = 1; 234 resp.info.rect.p0.y = 2; 235 resp.info.rect.p1.x = 3; 236 resp.info.rect.p1.y = 4; 237 238 rc = ddev_get_info(ddev, &info); 239 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 240 241 PCUT_ASSERT_INT_EQUALS(resp.info.rect.p0.x, info.rect.p0.x); 242 PCUT_ASSERT_INT_EQUALS(resp.info.rect.p0.y, info.rect.p0.y); 243 PCUT_ASSERT_INT_EQUALS(resp.info.rect.p1.x, info.rect.p1.x); 244 PCUT_ASSERT_INT_EQUALS(resp.info.rect.p1.y, info.rect.p1.y); 245 246 ddev_close(ddev); 247 rc = loc_service_unregister(sid); 248 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 249 } 250 174 251 /** Test display device connection. 175 252 * … … 222 299 } 223 300 301 static errno_t test_get_info(void *arg, ddev_info_t *info) 302 { 303 test_response_t *resp = (test_response_t *) arg; 304 305 if (resp->rc != EOK) 306 return resp->rc; 307 308 *info = resp->info; 309 return EOK; 310 } 311 224 312 static errno_t test_gc_set_color(void *arg, gfx_color_t *color) 225 313 {
Note:
See TracChangeset
for help on using the changeset viewer.