Changeset 3b3fcf36 in mainline
- Timestamp:
- 2018-11-20T10:53:13Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a615be0
- Parents:
- 8be3230
- git-author:
- Jiri Svoboda <jiri@…> (2018-11-19 18:49:18)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-11-20 10:53:13)
- Files:
-
- 4 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/abi/syscall.h
r8be3230 r3b3fcf36 60 60 SYS_AS_AREA_RESIZE, 61 61 SYS_AS_AREA_CHANGE_FLAGS, 62 SYS_AS_AREA_GET_INFO, 62 63 SYS_AS_AREA_DESTROY, 63 64 -
kernel/generic/include/mm/as.h
r8be3230 r3b3fcf36 322 322 extern sys_errno_t sys_as_area_resize(uintptr_t, size_t, unsigned int); 323 323 extern sys_errno_t sys_as_area_change_flags(uintptr_t, unsigned int); 324 extern sys_errno_t sys_as_area_get_info(uintptr_t, as_area_info_t *); 324 325 extern sys_errno_t sys_as_area_destroy(uintptr_t); 325 326 -
kernel/generic/src/mm/as.c
r8be3230 r3b3fcf36 2229 2229 } 2230 2230 2231 sys_errno_t sys_as_area_get_info(uintptr_t address, as_area_info_t *dest) 2232 { 2233 as_area_t *area; 2234 2235 mutex_lock(&AS->lock); 2236 area = find_area_and_lock(AS, address); 2237 if (area == NULL) { 2238 mutex_unlock(&AS->lock); 2239 return ENOENT; 2240 } 2241 2242 dest->start_addr = area->base; 2243 dest->size = P2SZ(area->pages); 2244 dest->flags = area->flags; 2245 2246 mutex_unlock(&area->lock); 2247 mutex_unlock(&AS->lock); 2248 return EOK; 2249 } 2250 2231 2251 sys_errno_t sys_as_area_destroy(uintptr_t address) 2232 2252 { -
kernel/generic/src/syscall/syscall.c
r8be3230 r3b3fcf36 146 146 [SYS_AS_AREA_RESIZE] = (syshandler_t) sys_as_area_resize, 147 147 [SYS_AS_AREA_CHANGE_FLAGS] = (syshandler_t) sys_as_area_change_flags, 148 [SYS_AS_AREA_GET_INFO] = (syshandler_t) sys_as_area_get_info, 148 149 [SYS_AS_AREA_DESTROY] = (syshandler_t) sys_as_area_destroy, 149 150 -
uspace/app/tester/Makefile
r8be3230 r3b3fcf36 56 56 float/float2.c \ 57 57 vfs/vfs1.c \ 58 ipc/sharein.c \ 58 59 ipc/starve.c \ 59 60 loop/loop1.c \ -
uspace/app/tester/tester.c
r8be3230 r3b3fcf36 66 66 #include "float/float2.def" 67 67 #include "vfs/vfs1.def" 68 #include "ipc/sharein.def" 68 69 #include "ipc/starve.def" 69 70 #include "loop/loop1.def" -
uspace/app/tester/tester.h
r8be3230 r3b3fcf36 99 99 extern const char *test_vfs1(void); 100 100 extern const char *test_ping_pong(void); 101 extern const char *test_sharein(void); 101 102 extern const char *test_starve_ipc(void); 102 103 extern const char *test_loop1(void); -
uspace/lib/c/generic/as.c
r8be3230 r3b3fcf36 108 108 } 109 109 110 /** Get address-space area information. 111 * 112 * @param address Virtual address pointing into the address space area being 113 * modified. 114 * @param info Pointer to information structure to fill in. 115 * 116 * @return zero on success or a code from @ref errno.h on failure. 117 * 118 */ 119 errno_t as_area_get_info(void *address, as_area_info_t *info) 120 { 121 return (errno_t) __SYSCALL2(SYS_AS_AREA_GET_INFO, (sysarg_t) address, 122 (sysarg_t) info); 123 } 124 110 125 /** Find mapping to physical address. 111 126 * -
uspace/lib/c/generic/ipc_test.c
r8be3230 r3b3fcf36 34 34 35 35 #include <abi/ipc/interfaces.h> 36 #include <as.h> 36 37 #include <errno.h> 37 38 #include <ipc/services.h> … … 111 112 } 112 113 114 /** Get size of shared read-only memory area. 115 * 116 * @param test IPC test service 117 * @param rsize Place to store size of the shared area 118 * @return EOK on success or an error code 119 */ 120 errno_t ipc_test_get_ro_area_size(ipc_test_t *test, size_t *rsize) 121 { 122 async_exch_t *exch; 123 errno_t retval; 124 sysarg_t size; 125 126 exch = async_exchange_begin(test->sess); 127 retval = async_req_0_1(exch, IPC_TEST_GET_RO_AREA_SIZE, &size); 128 async_exchange_end(exch); 129 130 if (retval != EOK) 131 return retval; 132 133 *rsize = size; 134 return EOK; 135 } 136 137 /** Get size of shared read-write memory area. 138 * 139 * @param test IPC test service 140 * @param rsize Place to store size of the shared area 141 * @return EOK on success or an error code 142 */ 143 errno_t ipc_test_get_rw_area_size(ipc_test_t *test, size_t *rsize) 144 { 145 async_exch_t *exch; 146 errno_t retval; 147 sysarg_t size; 148 149 exch = async_exchange_begin(test->sess); 150 retval = async_req_0_1(exch, IPC_TEST_GET_RW_AREA_SIZE, &size); 151 async_exchange_end(exch); 152 153 if (retval != EOK) 154 return retval; 155 156 *rsize = size; 157 return EOK; 158 } 159 160 /** Test share-in of read-only area. 161 * 162 * @param test IPC test service 163 * @param size Size of the shared area 164 * @param rptr Place to store pointer to the shared-in area 165 * @return EOK on success or an error code 166 */ 167 errno_t ipc_test_share_in_ro(ipc_test_t *test, size_t size, const void **rptr) 168 { 169 async_exch_t *exch; 170 ipc_call_t answer; 171 aid_t req; 172 void *dst; 173 errno_t rc; 174 175 exch = async_exchange_begin(test->sess); 176 req = async_send_0(exch, IPC_TEST_SHARE_IN_RO, &answer); 177 178 dst = NULL; 179 rc = async_share_in_start_0_0(exch, size, &dst); 180 if (rc != EOK || dst == AS_MAP_FAILED) { 181 async_exchange_end(exch); 182 async_forget(req); 183 return ENOMEM; 184 } 185 186 async_exchange_end(exch); 187 async_wait_for(req, NULL); 188 *rptr = dst; 189 return EOK; 190 } 191 192 /** Test share-in of read-write area. 193 * 194 * @param test IPC test service 195 * @param size Size of the shared area 196 * @param rptr Place to store pointer to the shared-in area 197 * @return EOK on success or an error code 198 */ 199 errno_t ipc_test_share_in_rw(ipc_test_t *test, size_t size, void **rptr) 200 { 201 async_exch_t *exch; 202 ipc_call_t answer; 203 aid_t req; 204 void *dst; 205 errno_t rc; 206 207 exch = async_exchange_begin(test->sess); 208 req = async_send_0(exch, IPC_TEST_SHARE_IN_RW, &answer); 209 210 rc = async_share_in_start_0_0(exch, size, &dst); 211 if (rc != EOK || dst == AS_MAP_FAILED) { 212 async_exchange_end(exch); 213 async_forget(req); 214 return ENOMEM; 215 } 216 217 async_exchange_end(exch); 218 async_wait_for(req, NULL); 219 *rptr = dst; 220 return EOK; 221 } 222 113 223 /** @} 114 224 */ -
uspace/lib/c/include/as.h
r8be3230 r3b3fcf36 59 59 extern errno_t as_area_resize(void *, size_t, unsigned int); 60 60 extern errno_t as_area_change_flags(void *, unsigned int); 61 extern errno_t as_area_get_info(void *, as_area_info_t *); 61 62 extern errno_t as_area_destroy(void *); 62 63 extern void *set_maxheapsize(size_t); -
uspace/lib/c/include/ipc/ipc_test.h
r8be3230 r3b3fcf36 39 39 40 40 typedef enum { 41 IPC_TEST_PING = IPC_FIRST_USER_METHOD 41 IPC_TEST_PING = IPC_FIRST_USER_METHOD, 42 IPC_TEST_GET_RO_AREA_SIZE, 43 IPC_TEST_GET_RW_AREA_SIZE, 44 IPC_TEST_SHARE_IN_RO, 45 IPC_TEST_SHARE_IN_RW 42 46 } ipc_test_request_t; 43 47 -
uspace/lib/c/include/ipc_test.h
r8be3230 r3b3fcf36 46 46 extern void ipc_test_destroy(ipc_test_t *); 47 47 extern errno_t ipc_test_ping(ipc_test_t *); 48 extern errno_t ipc_test_get_ro_area_size(ipc_test_t *, size_t *); 49 extern errno_t ipc_test_get_rw_area_size(ipc_test_t *, size_t *); 50 extern errno_t ipc_test_share_in_ro(ipc_test_t *, size_t, const void **); 51 extern errno_t ipc_test_share_in_rw(ipc_test_t *, size_t, void **); 48 52 49 53 #endif -
uspace/srv/test/chardev-test/main.c
r8be3230 r3b3fcf36 27 27 */ 28 28 29 /** @addtogroup chardev-test 30 * @{ 31 */ 32 /** 33 * @file 34 * @brief Character device interface test service 35 */ 36 29 37 #include <async.h> 30 38 #include <errno.h> … … 259 267 return EIO; 260 268 } 269 270 /** 271 * @} 272 */ -
uspace/srv/test/ipc-test/main.c
r8be3230 r3b3fcf36 27 27 */ 28 28 29 /** @addtogroup ipc-test 30 * @{ 31 */ 32 /** 33 * @file 34 * @brief IPC test service 35 * 36 * If run as an initial task, this can be used to test sharing areas 37 * backed by the ELF backend. 38 */ 39 40 #include <as.h> 29 41 #include <async.h> 30 42 #include <errno.h> 31 43 #include <str_error.h> 44 #include <io/log.h> 32 45 #include <ipc/ipc_test.h> 33 46 #include <ipc/services.h> … … 41 54 static service_id_t svc_id; 42 55 56 /** Object in read-only memory area that will be shared. 57 * 58 * If the server is run as an initial task, the area should be backed 59 * by ELF backend. 60 */ 61 static const char *ro_data = "Hello, world!"; 62 63 /** Object in read-write memory area that will be shared. 64 * 65 * If the server is run as an initial task, the area should be backed 66 * by ELF backend. 67 */ 68 static char rw_data[] = "Hello, world!"; 69 70 static void ipc_test_get_ro_area_size_srv(ipc_call_t *icall) 71 { 72 errno_t rc; 73 as_area_info_t info; 74 75 log_msg(LOG_DEFAULT, LVL_DEBUG, "ipc_test_get_ro_area_size_srv"); 76 77 rc = as_area_get_info((void *)ro_data, &info); 78 if (rc != EOK) { 79 async_answer_0(icall, EIO); 80 log_msg(LOG_DEFAULT, LVL_ERROR, "as_area_get_info failed"); 81 return; 82 } 83 84 async_answer_1(icall, EOK, info.size); 85 } 86 87 static void ipc_test_get_rw_area_size_srv(ipc_call_t *icall) 88 { 89 errno_t rc; 90 as_area_info_t info; 91 92 log_msg(LOG_DEFAULT, LVL_DEBUG, "ipc_test_get_rw_area_size_srv"); 93 94 rc = as_area_get_info(rw_data, &info); 95 if (rc != EOK) { 96 async_answer_0(icall, EIO); 97 log_msg(LOG_DEFAULT, LVL_ERROR, "as_area_get_info failed"); 98 return; 99 } 100 101 async_answer_1(icall, EOK, info.size); 102 } 103 104 static void ipc_test_share_in_ro_srv(ipc_call_t *icall) 105 { 106 ipc_call_t call; 107 errno_t rc; 108 size_t size; 109 as_area_info_t info; 110 111 log_msg(LOG_DEFAULT, LVL_DEBUG, "ipc_test_share_in_ro_srv"); 112 if (!async_share_in_receive(&call, &size)) { 113 async_answer_0(icall, EINVAL); 114 log_msg(LOG_DEFAULT, LVL_ERROR, "share_in_receive failed"); 115 return; 116 } 117 118 rc = as_area_get_info((void *)ro_data, &info); 119 if (rc != EOK) { 120 async_answer_0(icall, EINVAL); 121 log_msg(LOG_DEFAULT, LVL_ERROR, "as_area_get_info failed"); 122 return; 123 } 124 125 if (size != info.size) { 126 log_msg(LOG_DEFAULT, LVL_ERROR, "size(%zu) != %zu", 127 size, info.size); 128 async_answer_0(icall, EINVAL); 129 return; 130 } 131 132 rc = async_share_in_finalize(&call, (void *) info.start_addr, 133 AS_AREA_READ); 134 if (rc != EOK) { 135 log_msg(LOG_DEFAULT, LVL_ERROR, 136 " - async_share_in_finalize failed"); 137 async_answer_0(icall, EINVAL); 138 return; 139 } 140 141 async_answer_0(icall, EOK); 142 } 143 144 static void ipc_test_share_in_rw_srv(ipc_call_t *icall) 145 { 146 ipc_call_t call; 147 errno_t rc; 148 size_t size; 149 as_area_info_t info; 150 151 log_msg(LOG_DEFAULT, LVL_DEBUG, "ipc_test_share_in_ro_srv"); 152 if (!async_share_in_receive(&call, &size)) { 153 async_answer_0(icall, EINVAL); 154 log_msg(LOG_DEFAULT, LVL_ERROR, "share_in_receive failed"); 155 return; 156 } 157 158 rc = as_area_get_info(rw_data, &info); 159 if (rc != EOK) { 160 async_answer_0(icall, EINVAL); 161 log_msg(LOG_DEFAULT, LVL_ERROR, "as_area_get_info failed"); 162 return; 163 } 164 165 if (size != info.size) { 166 log_msg(LOG_DEFAULT, LVL_ERROR, " size(%zu) != %zu", 167 size, info.size); 168 async_answer_0(icall, EINVAL); 169 return; 170 } 171 172 rc = async_share_in_finalize(&call, (void *) info.start_addr, 173 AS_AREA_READ | AS_AREA_WRITE); 174 if (rc != EOK) { 175 log_msg(LOG_DEFAULT, LVL_ERROR, 176 "async_share_in_finalize failed"); 177 async_answer_0(icall, EINVAL); 178 return; 179 } 180 181 async_answer_0(icall, EOK); 182 } 183 43 184 static void ipc_test_connection(ipc_call_t *icall, void *arg) 44 185 { … … 59 200 async_answer_0(&call, EOK); 60 201 break; 202 case IPC_TEST_GET_RO_AREA_SIZE: 203 ipc_test_get_ro_area_size_srv(&call); 204 break; 205 case IPC_TEST_GET_RW_AREA_SIZE: 206 ipc_test_get_rw_area_size_srv(&call); 207 break; 208 case IPC_TEST_SHARE_IN_RO: 209 ipc_test_share_in_ro_srv(&call); 210 break; 211 case IPC_TEST_SHARE_IN_RW: 212 ipc_test_share_in_rw_srv(&call); 213 break; 61 214 default: 62 215 async_answer_0(&call, ENOTSUP); … … 73 226 async_set_fallback_port_handler(ipc_test_connection, NULL); 74 227 228 rc = log_init(NAME); 229 if (rc != EOK) { 230 printf(NAME ": Failed to initialize log.\n"); 231 return rc; 232 } 233 75 234 rc = loc_server_register(NAME); 76 235 if (rc != EOK) { 77 printf("%s: Failed registering server. (%s)\n", NAME,236 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server. (%s)\n", 78 237 str_error(rc)); 79 238 return rc; … … 82 241 rc = loc_service_register(SERVICE_NAME_IPC_TEST, &svc_id); 83 242 if (rc != EOK) { 84 printf("%s: Failed registering service. (%s)\n", NAME,243 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service. (%s)\n", 85 244 str_error(rc)); 86 245 return rc; … … 94 253 return 0; 95 254 } 255 256 /** 257 * @} 258 */
Note:
See TracChangeset
for help on using the changeset viewer.