Changeset 19b28b0 in mainline
- Timestamp:
- 2009-03-02T17:31:05Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8026731
- Parents:
- 97c9da8
- Location:
- uspace/lib/libc
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/console.c
r97c9da8 r19b28b0 40 40 void console_clear(void) 41 41 { 42 int cons_phone = get_cons _phone();42 int cons_phone = get_console_phone(); 43 43 async_msg_0(cons_phone, CONSOLE_CLEAR); 44 44 } … … 46 46 void console_goto(int row, int col) 47 47 { 48 int cons_phone = get_cons _phone();48 int cons_phone = get_console_phone(); 49 49 async_msg_2(cons_phone, CONSOLE_GOTO, row, col); 50 50 } … … 52 52 void console_flush(void) 53 53 { 54 int cons_phone = get_cons _phone();54 int cons_phone = get_console_phone(); 55 55 async_msg_0(cons_phone, CONSOLE_FLUSH); 56 56 } … … 58 58 int console_get_size(int *rows, int *cols) 59 59 { 60 int cons_phone = get_cons _phone();60 int cons_phone = get_console_phone(); 61 61 ipcarg_t r, c; 62 62 int rc; … … 72 72 void console_set_style(int style) 73 73 { 74 int cons_phone = get_cons _phone();74 int cons_phone = get_console_phone(); 75 75 async_msg_1(cons_phone, CONSOLE_SET_STYLE, style); 76 76 } … … 78 78 void console_set_color(int fg_color, int bg_color, int flags) 79 79 { 80 int cons_phone = get_cons _phone();80 int cons_phone = get_console_phone(); 81 81 async_msg_3(cons_phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags); 82 82 } … … 84 84 void console_set_rgb_color(int fg_color, int bg_color) 85 85 { 86 int cons_phone = get_cons _phone();86 int cons_phone = get_console_phone(); 87 87 async_msg_2(cons_phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color); 88 88 } … … 90 90 void console_cursor_visibility(int show) 91 91 { 92 int cons_phone = get_cons _phone();92 int cons_phone = get_console_phone(); 93 93 async_msg_1(cons_phone, CONSOLE_CURSOR_VISIBILITY, show != 0); 94 94 } -
uspace/lib/libc/generic/io/stream.c
r97c9da8 r19b28b0 116 116 } 117 117 118 int get_cons _phone(void)118 int get_console_phone(void) 119 119 { 120 open_console(); 120 if (console_phone < 0) 121 console_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_CONSOLE, 0, 0); 122 121 123 return console_phone; 124 } 125 126 void console_wait(void) 127 { 128 while (console_phone < 0) 129 get_console_phone(); 122 130 } 123 131 -
uspace/lib/libc/generic/ipc.c
r97c9da8 r19b28b0 599 599 int res; 600 600 601 res = ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 601 res = ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 602 602 NULL, NULL, NULL, NULL, &newphid); 603 if (res) 604 return res; 605 return newphid; 606 } 607 608 /** Ask through phone for a new connection to some service. 609 * 610 * If the connection is not available at the moment, the 611 * call will block. 612 * 613 * @param phoneid Phone handle used for contacting the other side. 614 * @param arg1 User defined argument. 615 * @param arg2 User defined argument. 616 * @param arg3 User defined argument. 617 * 618 * @return New phone handle on success or a negative error code. 619 */ 620 int ipc_connect_me_to_blocking(int phoneid, int arg1, int arg2, int arg3) 621 { 622 ipcarg_t newphid; 623 int res; 624 625 res = ipc_call_sync_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 626 IPC_FLAG_BLOCKING, NULL, NULL, NULL, NULL, &newphid); 603 627 if (res) 604 628 return res; -
uspace/lib/libc/generic/kbd.c
r97c9da8 r19b28b0 42 42 int kbd_get_event(kbd_event_t *ev) 43 43 { 44 int console_phone = get_cons _phone();44 int console_phone = get_console_phone(); 45 45 ipcarg_t r0, r1, r2, r3; 46 46 int rc; -
uspace/lib/libc/generic/vfs/vfs.c
r97c9da8 r19b28b0 32 32 /** @file 33 33 */ 34 34 35 35 #include <vfs/vfs.h> 36 36 #include <vfs/canonify.h> … … 58 58 DIR *cwd_dir = NULL; 59 59 char *cwd_path = NULL; 60 size_t cwd_len = 0; 60 size_t cwd_len = 0; 61 61 62 62 char *absolutize(const char *path, size_t *retlen) … … 110 110 } 111 111 112 static int vfs_connect(void) 113 { 114 if (vfs_phone < 0) 115 vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0, 0); 116 return vfs_phone; 117 } 118 119 static int device_get_handle(const char *name, dev_handle_t *handle) 120 { 121 int phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, 122 0); 112 static void vfs_connect(void) 113 { 114 while (vfs_phone < 0) 115 vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0); 116 } 117 118 static int device_get_handle(const char *name, dev_handle_t *handle, 119 const unsigned int flags) 120 { 121 int phone; 122 123 if (flags & IPC_FLAG_BLOCKING) 124 phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, 0); 125 else 126 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, 0); 127 123 128 if (phone < 0) 124 129 return phone; 125 130 126 131 ipc_call_t answer; 127 aid_t req = async_send_2(phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0,132 aid_t req = async_send_2(phone, DEVMAP_DEVICE_GET_HANDLE, flags, 0, 128 133 &answer); 129 134 130 135 ipcarg_t retval = ipc_data_write_start(phone, name, strlen(name) + 1); 131 136 132 137 if (retval != EOK) { 133 138 async_wait_for(req, NULL); … … 135 140 return retval; 136 141 } 137 142 138 143 async_wait_for(req, &retval); 139 144 140 145 if (handle != NULL) 141 146 *handle = -1; … … 150 155 } 151 156 152 int mount(const char *fs_name, const char *mp, const char *dev) 157 int mount(const char *fs_name, const char *mp, const char *dev, 158 const unsigned int flags) 153 159 { 154 160 int res; … … 157 163 dev_handle_t dev_handle; 158 164 159 res = device_get_handle(dev, &dev_handle );165 res = device_get_handle(dev, &dev_handle, flags); 160 166 if (res != EOK) 161 167 return res; … … 165 171 if (!mpa) 166 172 return ENOMEM; 167 168 futex_down(&vfs_phone_futex); 169 async_serialize_start(); 170 if (vfs_phone < 0) { 171 res = vfs_connect(); 172 if (res < 0) { 173 async_serialize_end(); 174 futex_up(&vfs_phone_futex); 175 free(mpa); 176 return res; 177 } 178 } 179 req = async_send_1(vfs_phone, VFS_MOUNT, dev_handle, NULL); 180 rc = ipc_data_write_start(vfs_phone, (void *)fs_name, strlen(fs_name)); 173 174 futex_down(&vfs_phone_futex); 175 async_serialize_start(); 176 vfs_connect(); 177 178 req = async_send_2(vfs_phone, VFS_MOUNT, dev_handle, flags, NULL); 179 rc = ipc_data_write_start(vfs_phone, (void *) mpa, mpa_len); 181 180 if (rc != EOK) { 182 181 async_wait_for(req, NULL); … … 186 185 return (int) rc; 187 186 } 188 /* Ask VFS whether it likes fs_name. */189 rc = async_req_0_0(vfs_phone, IPC_M_PING);187 188 rc = ipc_data_write_start(vfs_phone, (void *) fs_name, strlen(fs_name)); 190 189 if (rc != EOK) { 191 190 async_wait_for(req, NULL); … … 195 194 return (int) rc; 196 195 } 197 rc = ipc_data_write_start(vfs_phone, (void *)mpa, mpa_len); 198 if (rc != EOK) { 199 async_wait_for(req, NULL); 200 async_serialize_end(); 201 futex_up(&vfs_phone_futex); 202 free(mpa); 203 return (int) rc; 204 } 196 205 197 async_wait_for(req, &rc); 206 198 async_serialize_end(); 207 199 futex_up(&vfs_phone_futex); 208 200 free(mpa); 201 209 202 return (int) rc; 210 203 } … … 212 205 static int _open(const char *path, int lflag, int oflag, ...) 213 206 { 214 int res;215 207 ipcarg_t rc; 216 208 ipc_call_t answer; … … 224 216 futex_down(&vfs_phone_futex); 225 217 async_serialize_start(); 226 if (vfs_phone < 0) { 227 res = vfs_connect(); 228 if (res < 0) { 229 async_serialize_end(); 230 futex_up(&vfs_phone_futex); 231 free(pa); 232 return res; 233 } 234 } 218 vfs_connect(); 219 235 220 req = async_send_3(vfs_phone, VFS_OPEN, lflag, oflag, 0, &answer); 236 221 rc = ipc_data_write_start(vfs_phone, pa, pa_len); … … 259 244 int close(int fildes) 260 245 { 261 int res; 262 ipcarg_t rc; 263 264 futex_down(&vfs_phone_futex); 265 async_serialize_start(); 266 if (vfs_phone < 0) { 267 res = vfs_connect(); 268 if (res < 0) { 269 async_serialize_end(); 270 futex_up(&vfs_phone_futex); 271 return res; 272 } 273 } 274 246 ipcarg_t rc; 247 248 futex_down(&vfs_phone_futex); 249 async_serialize_start(); 250 vfs_connect(); 251 275 252 rc = async_req_1_0(vfs_phone, VFS_CLOSE, fildes); 276 253 277 254 async_serialize_end(); 278 255 futex_up(&vfs_phone_futex); … … 283 260 ssize_t read(int fildes, void *buf, size_t nbyte) 284 261 { 285 int res;286 262 ipcarg_t rc; 287 263 ipc_call_t answer; … … 290 266 futex_down(&vfs_phone_futex); 291 267 async_serialize_start(); 292 if (vfs_phone < 0) { 293 res = vfs_connect(); 294 if (res < 0) { 295 async_serialize_end(); 296 futex_up(&vfs_phone_futex); 297 return res; 298 } 299 } 268 vfs_connect(); 269 300 270 req = async_send_1(vfs_phone, VFS_READ, fildes, &answer); 301 271 rc = ipc_data_read_start(vfs_phone, (void *)buf, nbyte); … … 317 287 ssize_t write(int fildes, const void *buf, size_t nbyte) 318 288 { 319 int res;320 289 ipcarg_t rc; 321 290 ipc_call_t answer; … … 324 293 futex_down(&vfs_phone_futex); 325 294 async_serialize_start(); 326 if (vfs_phone < 0) { 327 res = vfs_connect(); 328 if (res < 0) { 329 async_serialize_end(); 330 futex_up(&vfs_phone_futex); 331 return res; 332 } 333 } 295 vfs_connect(); 296 334 297 req = async_send_1(vfs_phone, VFS_WRITE, fildes, &answer); 335 298 rc = ipc_data_write_start(vfs_phone, (void *)buf, nbyte); … … 351 314 off_t lseek(int fildes, off_t offset, int whence) 352 315 { 353 int res; 354 ipcarg_t rc; 355 356 futex_down(&vfs_phone_futex); 357 async_serialize_start(); 358 if (vfs_phone < 0) { 359 res = vfs_connect(); 360 if (res < 0) { 361 async_serialize_end(); 362 futex_up(&vfs_phone_futex); 363 return res; 364 } 365 } 366 316 ipcarg_t rc; 317 318 futex_down(&vfs_phone_futex); 319 async_serialize_start(); 320 vfs_connect(); 321 367 322 ipcarg_t newoffs; 368 323 rc = async_req_3_1(vfs_phone, VFS_SEEK, fildes, offset, whence, … … 380 335 int ftruncate(int fildes, off_t length) 381 336 { 382 int res; 383 ipcarg_t rc; 384 385 futex_down(&vfs_phone_futex); 386 async_serialize_start(); 387 if (vfs_phone < 0) { 388 res = vfs_connect(); 389 if (res < 0) { 390 async_serialize_end(); 391 futex_up(&vfs_phone_futex); 392 return res; 393 } 394 } 337 ipcarg_t rc; 338 339 futex_down(&vfs_phone_futex); 340 async_serialize_start(); 341 vfs_connect(); 342 395 343 rc = async_req_2_0(vfs_phone, VFS_TRUNCATE, fildes, length); 396 344 async_serialize_end(); … … 434 382 int mkdir(const char *path, mode_t mode) 435 383 { 436 int res;437 384 ipcarg_t rc; 438 385 aid_t req; … … 442 389 if (!pa) 443 390 return ENOMEM; 444 445 futex_down(&vfs_phone_futex); 446 async_serialize_start(); 447 if (vfs_phone < 0) { 448 res = vfs_connect(); 449 if (res < 0) { 450 async_serialize_end(); 451 futex_up(&vfs_phone_futex); 452 free(pa); 453 return res; 454 } 455 } 391 392 futex_down(&vfs_phone_futex); 393 async_serialize_start(); 394 vfs_connect(); 395 456 396 req = async_send_1(vfs_phone, VFS_MKDIR, mode, NULL); 457 397 rc = ipc_data_write_start(vfs_phone, pa, pa_len); … … 472 412 static int _unlink(const char *path, int lflag) 473 413 { 474 int res;475 414 ipcarg_t rc; 476 415 aid_t req; … … 483 422 futex_down(&vfs_phone_futex); 484 423 async_serialize_start(); 485 if (vfs_phone < 0) { 486 res = vfs_connect(); 487 if (res < 0) { 488 async_serialize_end(); 489 futex_up(&vfs_phone_futex); 490 free(pa); 491 return res; 492 } 493 } 424 vfs_connect(); 425 494 426 req = async_send_0(vfs_phone, VFS_UNLINK, NULL); 495 427 rc = ipc_data_write_start(vfs_phone, pa, pa_len); … … 520 452 int rename(const char *old, const char *new) 521 453 { 522 int res;523 454 ipcarg_t rc; 524 455 aid_t req; … … 538 469 futex_down(&vfs_phone_futex); 539 470 async_serialize_start(); 540 if (vfs_phone < 0) { 541 res = vfs_connect(); 542 if (res < 0) { 543 async_serialize_end(); 544 futex_up(&vfs_phone_futex); 545 free(olda); 546 free(newa); 547 return res; 548 } 549 } 471 vfs_connect(); 472 550 473 req = async_send_0(vfs_phone, VFS_RENAME, NULL); 551 474 rc = ipc_data_write_start(vfs_phone, olda, olda_len); -
uspace/lib/libc/include/async.h
r97c9da8 r19b28b0 77 77 async_send_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \ 78 78 (arg5), (dataptr)) 79 79 80 80 extern aid_t async_send_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, 81 81 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr); … … 87 87 suseconds_t timeout); 88 88 89 fid_t async_new_connection(ipcarg_t in_phone_hash, ipc_callid_t callid,90 ipc_call_t *call, void (*cthread)(ipc_callid_t, ipc_call_t *));89 fid_t async_new_connection(ipcarg_t in_phone_hash, ipc_callid_t callid, 90 ipc_call_t *call, void (*cthread)(ipc_callid_t, ipc_call_t *)); 91 91 void async_usleep(suseconds_t timeout); 92 92 void async_create_manager(void); -
uspace/lib/libc/include/io/stream.h
r97c9da8 r19b28b0 48 48 extern ssize_t write_stderr(const void *, size_t); 49 49 50 extern int get_cons_phone(void); 50 extern int get_console_phone(void); 51 extern void console_wait(void); 51 52 52 53 #endif -
uspace/lib/libc/include/ipc/ipc.h
r97c9da8 r19b28b0 247 247 ipcarg_t, ipcarg_t, void *, ipc_async_callback_t, int); 248 248 249 #define IPC_FLAG_BLOCKING 0x01 250 249 251 extern int ipc_connect_to_me(int, int, int, int, ipcarg_t *); 250 252 extern int ipc_connect_me_to(int, int, int, int); 253 extern int ipc_connect_me_to_blocking(int, int, int, int); 251 254 extern int ipc_hangup(int); 252 255 extern int ipc_register_irq(int, int, int, irq_code_t *); -
uspace/lib/libc/include/ipc/services.h
r97c9da8 r19b28b0 31 31 */ 32 32 /** 33 * @file 34 * @brief 33 * @file services.h 34 * @brief List of all known services and their codes. 35 35 */ 36 36 -
uspace/lib/libc/include/vfs/vfs.h
r97c9da8 r19b28b0 40 40 extern char *absolutize(const char *, size_t *); 41 41 42 extern int mount(const char *, const char *, const char *); 42 extern int mount(const char *, const char *, const char *, 43 const unsigned int flags); 43 44 44 45 #endif
Note:
See TracChangeset
for help on using the changeset viewer.