- Timestamp:
- 2009-12-12T10:11:35Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 99de22b
- Parents:
- 58d5803d (diff), 1e4cada (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 9 added
- 52 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile
r58d5803d r387416b 48 48 srv/devmap \ 49 49 srv/part/mbr_part \ 50 srv/clip \ 50 51 app/edit \ 51 52 app/tetris \ -
uspace/app/bdsh/input.c
r58d5803d r387416b 36 36 #include <io/keycode.h> 37 37 #include <io/style.h> 38 #include <io/color.h> 38 39 #include <vfs/vfs.h> 40 #include <clipboard.h> 41 #include <macros.h> 39 42 #include <errno.h> 43 #include <assert.h> 40 44 #include <bool.h> 41 45 … … 47 51 #include "exec.h" 48 52 49 static void read_line(char *, int); 53 #define HISTORY_LEN 10 54 55 /** Text input field. */ 56 typedef struct { 57 /** Buffer holding text currently being edited */ 58 wchar_t buffer[INPUT_MAX + 1]; 59 /** Screen coordinates of the top-left corner of the text field */ 60 int col0, row0; 61 /** Screen dimensions */ 62 int con_cols, con_rows; 63 /** Number of characters in @c buffer */ 64 int nc; 65 /** Caret position within buffer */ 66 int pos; 67 /** Selection mark position within buffer */ 68 int sel_start; 69 70 /** History (dynamically allocated strings) */ 71 char *history[1 + HISTORY_LEN]; 72 /** Number of entries in @c history, not counting [0] */ 73 int hnum; 74 /** Current position in history */ 75 int hpos; 76 /** Exit flag */ 77 bool done; 78 } tinput_t; 79 80 /** Seek direction */ 81 typedef enum { 82 seek_backward = -1, 83 seek_forward = 1 84 } seek_dir_t; 85 86 static tinput_t tinput; 87 88 static char *tinput_read(tinput_t *ti); 89 static void tinput_insert_string(tinput_t *ti, const char *str); 90 static void tinput_sel_get_bounds(tinput_t *ti, int *sa, int *sb); 91 static bool tinput_sel_active(tinput_t *ti); 92 static void tinput_sel_all(tinput_t *ti); 93 static void tinput_sel_delete(tinput_t *ti); 94 static void tinput_key_ctrl(tinput_t *ti, console_event_t *ev); 95 static void tinput_key_shift(tinput_t *ti, console_event_t *ev); 96 static void tinput_key_ctrl_shift(tinput_t *ti, console_event_t *ev); 97 static void tinput_key_unmod(tinput_t *ti, console_event_t *ev); 98 static void tinput_pre_seek(tinput_t *ti, bool shift_held); 99 static void tinput_post_seek(tinput_t *ti, bool shift_held); 50 100 51 101 /* Tokenizes input from console, sees if the first word is a built-in, if so … … 99 149 } 100 150 101 static void read_line(char *buffer, int n) 151 static void tinput_display_tail(tinput_t *ti, int start, int pad) 152 { 153 static wchar_t dbuf[INPUT_MAX + 1]; 154 int sa, sb; 155 int i, p; 156 157 tinput_sel_get_bounds(ti, &sa, &sb); 158 159 console_goto(fphone(stdout), (ti->col0 + start) % ti->con_cols, 160 ti->row0 + (ti->col0 + start) / ti->con_cols); 161 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 162 163 p = start; 164 if (p < sa) { 165 memcpy(dbuf, ti->buffer + p, (sa - p) * sizeof(wchar_t)); 166 dbuf[sa - p] = '\0'; 167 printf("%ls", dbuf); 168 p = sa; 169 } 170 171 if (p < sb) { 172 fflush(stdout); 173 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_RED, 0); 174 memcpy(dbuf, ti->buffer + p, 175 (sb - p) * sizeof(wchar_t)); 176 dbuf[sb - p] = '\0'; 177 printf("%ls", dbuf); 178 p = sb; 179 } 180 181 fflush(stdout); 182 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 183 184 if (p < ti->nc) { 185 memcpy(dbuf, ti->buffer + p, 186 (ti->nc - p) * sizeof(wchar_t)); 187 dbuf[ti->nc - p] = '\0'; 188 printf("%ls", dbuf); 189 } 190 191 for (i = 0; i < pad; ++i) 192 putchar(' '); 193 fflush(stdout); 194 } 195 196 static char *tinput_get_str(tinput_t *ti) 197 { 198 return wstr_to_astr(ti->buffer); 199 } 200 201 static void tinput_position_caret(tinput_t *ti) 202 { 203 console_goto(fphone(stdout), (ti->col0 + ti->pos) % ti->con_cols, 204 ti->row0 + (ti->col0 + ti->pos) / ti->con_cols); 205 } 206 207 /** Update row0 in case the screen could have scrolled. */ 208 static void tinput_update_origin(tinput_t *ti) 209 { 210 int width, rows; 211 212 width = ti->col0 + ti->nc; 213 rows = (width / ti->con_cols) + 1; 214 215 /* Update row0 if the screen scrolled. */ 216 if (ti->row0 + rows > ti->con_rows) 217 ti->row0 = ti->con_rows - rows; 218 } 219 220 static void tinput_insert_char(tinput_t *ti, wchar_t c) 221 { 222 int i; 223 int new_width, new_height; 224 225 if (ti->nc == INPUT_MAX) 226 return; 227 228 new_width = ti->col0 + ti->nc + 1; 229 if (new_width % ti->con_cols == 0) { 230 /* Advancing to new line. */ 231 new_height = (new_width / ti->con_cols) + 1; 232 if (new_height >= ti->con_rows) 233 return; /* Disallow text longer than 1 page for now. */ 234 } 235 236 for (i = ti->nc; i > ti->pos; --i) 237 ti->buffer[i] = ti->buffer[i - 1]; 238 239 ti->buffer[ti->pos] = c; 240 ti->pos += 1; 241 ti->nc += 1; 242 ti->buffer[ti->nc] = '\0'; 243 ti->sel_start = ti->pos; 244 245 tinput_display_tail(ti, ti->pos - 1, 0); 246 tinput_update_origin(ti); 247 tinput_position_caret(ti); 248 } 249 250 static void tinput_insert_string(tinput_t *ti, const char *str) 251 { 252 int i; 253 int new_width, new_height; 254 int ilen; 255 wchar_t c; 256 size_t off; 257 258 ilen = min((ssize_t) str_length(str), INPUT_MAX - ti->nc); 259 if (ilen == 0) 260 return; 261 262 new_width = ti->col0 + ti->nc + ilen; 263 new_height = (new_width / ti->con_cols) + 1; 264 if (new_height >= ti->con_rows) 265 return; /* Disallow text longer than 1 page for now. */ 266 267 for (i = ti->nc - 1; i >= ti->pos; --i) 268 ti->buffer[i + ilen] = ti->buffer[i]; 269 270 off = 0; i = 0; 271 while (i < ilen) { 272 c = str_decode(str, &off, STR_NO_LIMIT); 273 if (c == '\0') 274 break; 275 276 /* Filter out non-printable chars. */ 277 if (c < 32) 278 c = 32; 279 280 ti->buffer[ti->pos + i] = c; 281 ++i; 282 } 283 284 ti->pos += ilen; 285 ti->nc += ilen; 286 ti->buffer[ti->nc] = '\0'; 287 ti->sel_start = ti->pos; 288 289 tinput_display_tail(ti, ti->pos - ilen, 0); 290 tinput_update_origin(ti); 291 tinput_position_caret(ti); 292 } 293 294 static void tinput_backspace(tinput_t *ti) 295 { 296 int i; 297 298 if (tinput_sel_active(ti)) { 299 tinput_sel_delete(ti); 300 return; 301 } 302 303 if (ti->pos == 0) 304 return; 305 306 for (i = ti->pos; i < ti->nc; ++i) 307 ti->buffer[i - 1] = ti->buffer[i]; 308 ti->pos -= 1; 309 ti->nc -= 1; 310 ti->buffer[ti->nc] = '\0'; 311 ti->sel_start = ti->pos; 312 313 tinput_display_tail(ti, ti->pos, 1); 314 tinput_position_caret(ti); 315 } 316 317 static void tinput_delete(tinput_t *ti) 318 { 319 if (tinput_sel_active(ti)) { 320 tinput_sel_delete(ti); 321 return; 322 } 323 324 if (ti->pos == ti->nc) 325 return; 326 327 ti->pos += 1; 328 ti->sel_start = ti->pos; 329 330 tinput_backspace(ti); 331 } 332 333 static void tinput_seek_cell(tinput_t *ti, seek_dir_t dir, bool shift_held) 334 { 335 tinput_pre_seek(ti, shift_held); 336 337 if (dir == seek_forward) { 338 if (ti->pos < ti->nc) 339 ti->pos += 1; 340 } else { 341 if (ti->pos > 0) 342 ti->pos -= 1; 343 } 344 345 tinput_post_seek(ti, shift_held); 346 } 347 348 static void tinput_seek_word(tinput_t *ti, seek_dir_t dir, bool shift_held) 349 { 350 tinput_pre_seek(ti, shift_held); 351 352 if (dir == seek_forward) { 353 if (ti->pos == ti->nc) 354 return; 355 356 while (1) { 357 ti->pos += 1; 358 359 if (ti->pos == ti->nc) 360 break; 361 362 if (ti->buffer[ti->pos - 1] == ' ' && 363 ti->buffer[ti->pos] != ' ') 364 break; 365 } 366 } else { 367 if (ti->pos == 0) 368 return; 369 370 while (1) { 371 ti->pos -= 1; 372 373 if (ti->pos == 0) 374 break; 375 376 if (ti->buffer[ti->pos - 1] == ' ' && 377 ti->buffer[ti->pos] != ' ') 378 break; 379 } 380 381 } 382 383 tinput_post_seek(ti, shift_held); 384 } 385 386 static void tinput_seek_vertical(tinput_t *ti, seek_dir_t dir, bool shift_held) 387 { 388 tinput_pre_seek(ti, shift_held); 389 390 if (dir == seek_forward) { 391 if (ti->pos + ti->con_cols <= ti->nc) 392 ti->pos = ti->pos + ti->con_cols; 393 } else { 394 if (ti->pos - ti->con_cols >= 0) 395 ti->pos = ti->pos - ti->con_cols; 396 } 397 398 tinput_post_seek(ti, shift_held); 399 } 400 401 static void tinput_seek_max(tinput_t *ti, seek_dir_t dir, bool shift_held) 402 { 403 tinput_pre_seek(ti, shift_held); 404 405 if (dir == seek_backward) 406 ti->pos = 0; 407 else 408 ti->pos = ti->nc; 409 410 tinput_post_seek(ti, shift_held); 411 } 412 413 static void tinput_pre_seek(tinput_t *ti, bool shift_held) 414 { 415 if (tinput_sel_active(ti) && !shift_held) { 416 /* Unselect and redraw. */ 417 ti->sel_start = ti->pos; 418 tinput_display_tail(ti, 0, 0); 419 tinput_position_caret(ti); 420 } 421 } 422 423 static void tinput_post_seek(tinput_t *ti, bool shift_held) 424 { 425 if (shift_held) { 426 /* Selecting text. Need redraw. */ 427 tinput_display_tail(ti, 0, 0); 428 } else { 429 /* Shift not held. Keep selection empty. */ 430 ti->sel_start = ti->pos; 431 } 432 tinput_position_caret(ti); 433 } 434 435 static void tinput_history_insert(tinput_t *ti, char *str) 436 { 437 int i; 438 439 if (ti->hnum < HISTORY_LEN) { 440 ti->hnum += 1; 441 } else { 442 if (ti->history[HISTORY_LEN] != NULL) 443 free(ti->history[HISTORY_LEN]); 444 } 445 446 for (i = ti->hnum; i > 1; --i) 447 ti->history[i] = ti->history[i - 1]; 448 449 ti->history[1] = str_dup(str); 450 451 if (ti->history[0] != NULL) { 452 free(ti->history[0]); 453 ti->history[0] = NULL; 454 } 455 } 456 457 static void tinput_set_str(tinput_t *ti, char *str) 458 { 459 str_to_wstr(ti->buffer, INPUT_MAX, str); 460 ti->nc = wstr_length(ti->buffer); 461 ti->pos = ti->nc; 462 ti->sel_start = ti->pos; 463 } 464 465 static void tinput_sel_get_bounds(tinput_t *ti, int *sa, int *sb) 466 { 467 if (ti->sel_start < ti->pos) { 468 *sa = ti->sel_start; 469 *sb = ti->pos; 470 } else { 471 *sa = ti->pos; 472 *sb = ti->sel_start; 473 } 474 } 475 476 static bool tinput_sel_active(tinput_t *ti) 477 { 478 return ti->sel_start != ti->pos; 479 } 480 481 static void tinput_sel_all(tinput_t *ti) 482 { 483 ti->sel_start = 0; 484 ti->pos = ti->nc; 485 tinput_display_tail(ti, 0, 0); 486 tinput_position_caret(ti); 487 } 488 489 static void tinput_sel_delete(tinput_t *ti) 490 { 491 int sa, sb; 492 493 tinput_sel_get_bounds(ti, &sa, &sb); 494 if (sa == sb) 495 return; 496 497 memmove(ti->buffer + sa, ti->buffer + sb, 498 (ti->nc - sb) * sizeof(wchar_t)); 499 ti->pos = ti->sel_start = sa; 500 ti->nc -= (sb - sa); 501 ti->buffer[ti->nc] = '\0'; 502 503 tinput_display_tail(ti, sa, sb - sa); 504 tinput_position_caret(ti); 505 } 506 507 static void tinput_sel_copy_to_cb(tinput_t *ti) 508 { 509 int sa, sb; 510 wchar_t tmp_c; 511 char *str; 512 513 tinput_sel_get_bounds(ti, &sa, &sb); 514 515 if (sb < ti->nc) { 516 tmp_c = ti->buffer[sb]; 517 ti->buffer[sb] = '\0'; 518 } 519 520 str = wstr_to_astr(ti->buffer + sa); 521 522 if (sb < ti->nc) 523 ti->buffer[sb] = tmp_c; 524 525 if (str == NULL) 526 goto error; 527 528 if (clipboard_put_str(str) != EOK) 529 goto error; 530 531 free(str); 532 return; 533 error: 534 return; 535 /* TODO: Give the user some warning. */ 536 } 537 538 static void tinput_paste_from_cb(tinput_t *ti) 539 { 540 char *str; 541 int rc; 542 543 rc = clipboard_get_str(&str); 544 if (rc != EOK || str == NULL) 545 return; /* TODO: Give the user some warning. */ 546 547 tinput_insert_string(ti, str); 548 free(str); 549 } 550 551 static void tinput_history_seek(tinput_t *ti, int offs) 552 { 553 int pad; 554 555 if (ti->hpos + offs < 0 || ti->hpos + offs > ti->hnum) 556 return; 557 558 if (ti->history[ti->hpos] != NULL) { 559 free(ti->history[ti->hpos]); 560 ti->history[ti->hpos] = NULL; 561 } 562 563 ti->history[ti->hpos] = tinput_get_str(ti); 564 ti->hpos += offs; 565 566 pad = ti->nc - str_length(ti->history[ti->hpos]); 567 if (pad < 0) pad = 0; 568 569 tinput_set_str(ti, ti->history[ti->hpos]); 570 tinput_display_tail(ti, 0, pad); 571 tinput_update_origin(ti); 572 tinput_position_caret(ti); 573 } 574 575 /** Initialize text input field. 576 * 577 * Must be called before using the field. It clears the history. 578 */ 579 static void tinput_init(tinput_t *ti) 580 { 581 ti->hnum = 0; 582 ti->hpos = 0; 583 ti->history[0] = NULL; 584 } 585 586 /** Read in one line of input. */ 587 static char *tinput_read(tinput_t *ti) 102 588 { 103 589 console_event_t ev; 104 size_t offs, otmp; 105 wchar_t dec; 106 107 offs = 0; 108 while (true) { 590 char *str; 591 592 fflush(stdout); 593 594 if (console_get_size(fphone(stdin), &ti->con_cols, &ti->con_rows) != EOK) 595 return NULL; 596 if (console_get_pos(fphone(stdin), &ti->col0, &ti->row0) != EOK) 597 return NULL; 598 599 ti->pos = ti->sel_start = 0; 600 ti->nc = 0; 601 ti->buffer[0] = '\0'; 602 ti->done = false; 603 604 while (!ti->done) { 109 605 fflush(stdout); 110 606 if (!console_get_event(fphone(stdin), &ev)) 111 return ;112 607 return NULL; 608 113 609 if (ev.type != KEY_PRESS) 114 610 continue; 115 116 if (ev.key == KC_ENTER || ev.key == KC_NENTER) 117 break; 118 if (ev.key == KC_BACKSPACE) { 119 if (offs > 0) { 120 /* 121 * Back up until we reach valid start of 122 * character. 123 */ 124 while (offs > 0) { 125 --offs; otmp = offs; 126 dec = str_decode(buffer, &otmp, n); 127 if (dec != U_SPECIAL) 128 break; 129 } 130 putchar('\b'); 131 } 132 continue; 611 612 if ((ev.mods & KM_CTRL) != 0 && 613 (ev.mods & (KM_ALT | KM_SHIFT)) == 0) { 614 tinput_key_ctrl(ti, &ev); 133 615 } 616 617 if ((ev.mods & KM_SHIFT) != 0 && 618 (ev.mods & (KM_CTRL | KM_ALT)) == 0) { 619 tinput_key_shift(ti, &ev); 620 } 621 622 if ((ev.mods & KM_CTRL) != 0 && 623 (ev.mods & KM_SHIFT) != 0 && 624 (ev.mods & KM_ALT) == 0) { 625 tinput_key_ctrl_shift(ti, &ev); 626 } 627 628 if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) { 629 tinput_key_unmod(ti, &ev); 630 } 631 134 632 if (ev.c >= ' ') { 135 if (chr_encode(ev.c, buffer, &offs, n - 1) == EOK)136 putchar(ev.c);633 tinput_sel_delete(ti); 634 tinput_insert_char(ti, ev.c); 137 635 } 138 636 } 637 638 ti->pos = ti->nc; 639 tinput_position_caret(ti); 139 640 putchar('\n'); 140 buffer[offs] = '\0'; 141 } 142 143 /* TODO: 144 * Implement something like editline() / readline(), if even 145 * just for command history and making arrows work. */ 641 642 str = tinput_get_str(ti); 643 if (str_cmp(str, "") != 0) 644 tinput_history_insert(ti, str); 645 646 ti->hpos = 0; 647 648 return str; 649 } 650 651 static void tinput_key_ctrl(tinput_t *ti, console_event_t *ev) 652 { 653 switch (ev->key) { 654 case KC_LEFT: 655 tinput_seek_word(ti, seek_backward, false); 656 break; 657 case KC_RIGHT: 658 tinput_seek_word(ti, seek_forward, false); 659 break; 660 case KC_UP: 661 tinput_seek_vertical(ti, seek_backward, false); 662 break; 663 case KC_DOWN: 664 tinput_seek_vertical(ti, seek_forward, false); 665 break; 666 case KC_X: 667 tinput_sel_copy_to_cb(ti); 668 tinput_sel_delete(ti); 669 break; 670 case KC_C: 671 tinput_sel_copy_to_cb(ti); 672 break; 673 case KC_V: 674 tinput_sel_delete(ti); 675 tinput_paste_from_cb(ti); 676 break; 677 case KC_A: 678 tinput_sel_all(ti); 679 break; 680 default: 681 break; 682 } 683 } 684 685 static void tinput_key_ctrl_shift(tinput_t *ti, console_event_t *ev) 686 { 687 switch (ev->key) { 688 case KC_LEFT: 689 tinput_seek_word(ti, seek_backward, true); 690 break; 691 case KC_RIGHT: 692 tinput_seek_word(ti, seek_forward, true); 693 break; 694 case KC_UP: 695 tinput_seek_vertical(ti, seek_backward, true); 696 break; 697 case KC_DOWN: 698 tinput_seek_vertical(ti, seek_forward, true); 699 break; 700 default: 701 break; 702 } 703 } 704 705 static void tinput_key_shift(tinput_t *ti, console_event_t *ev) 706 { 707 switch (ev->key) { 708 case KC_LEFT: 709 tinput_seek_cell(ti, seek_backward, true); 710 break; 711 case KC_RIGHT: 712 tinput_seek_cell(ti, seek_forward, true); 713 break; 714 case KC_UP: 715 tinput_seek_vertical(ti, seek_backward, true); 716 break; 717 case KC_DOWN: 718 tinput_seek_vertical(ti, seek_forward, true); 719 break; 720 case KC_HOME: 721 tinput_seek_max(ti, seek_backward, true); 722 break; 723 case KC_END: 724 tinput_seek_max(ti, seek_forward, true); 725 break; 726 default: 727 break; 728 } 729 } 730 731 static void tinput_key_unmod(tinput_t *ti, console_event_t *ev) 732 { 733 switch (ev->key) { 734 case KC_ENTER: 735 case KC_NENTER: 736 ti->done = true; 737 break; 738 case KC_BACKSPACE: 739 tinput_backspace(ti); 740 break; 741 case KC_DELETE: 742 tinput_delete(ti); 743 break; 744 case KC_LEFT: 745 tinput_seek_cell(ti, seek_backward, false); 746 break; 747 case KC_RIGHT: 748 tinput_seek_cell(ti, seek_forward, false); 749 break; 750 case KC_HOME: 751 tinput_seek_max(ti, seek_backward, false); 752 break; 753 case KC_END: 754 tinput_seek_max(ti, seek_forward, false); 755 break; 756 case KC_UP: 757 tinput_history_seek(ti, +1); 758 break; 759 case KC_DOWN: 760 tinput_history_seek(ti, -1); 761 break; 762 default: 763 break; 764 } 765 } 766 146 767 void get_input(cliuser_t *usr) 147 768 { 148 char line[INPUT_MAX];769 char *str; 149 770 150 771 fflush(stdout); … … 154 775 console_set_style(fphone(stdout), STYLE_NORMAL); 155 776 156 read_line(line, INPUT_MAX); 157 /* Make sure we don't have rubbish or a C/R happy user */ 158 if (str_cmp(line, "") == 0 || str_cmp(line, "\n") == 0) 159 return; 160 usr->line = str_dup(line); 161 777 str = tinput_read(&tinput); 778 779 /* Check for empty input. */ 780 if (str_cmp(str, "") == 0) { 781 free(str); 782 return; 783 } 784 785 usr->line = str; 162 786 return; 163 787 } 164 788 789 void input_init(void) 790 { 791 tinput_init(&tinput); 792 } -
uspace/app/bdsh/input.h
r58d5803d r387416b 8 8 extern void get_input(cliuser_t *); 9 9 extern int tok_input(cliuser_t *); 10 extern void input_init(void); 10 11 11 12 #endif -
uspace/app/bdsh/scli.c
r58d5803d r387416b 64 64 usr->prompt = (char *) NULL; 65 65 usr->lasterr = 0; 66 67 input_init(); 68 66 69 return (int) cli_set_prompt(usr); 67 70 } -
uspace/app/edit/edit.c
r58d5803d r387416b 36 36 37 37 #include <stdio.h> 38 #include <stdlib.h> 38 39 #include <sys/types.h> 39 40 #include <vfs/vfs.h> … … 44 45 #include <align.h> 45 46 #include <macros.h> 47 #include <clipboard.h> 46 48 #include <bool.h> 47 49 … … 73 75 tag_t caret_pos; 74 76 77 /** Start of selection */ 78 tag_t sel_start; 79 75 80 /** 76 81 * Ideal column where the caret should try to get. This is used … … 101 106 #define ED_INFTY 65536 102 107 108 /** Maximum filename length that can be entered. */ 109 #define INFNAME_MAX_LEN 128 110 103 111 static void key_handle_unmod(console_event_t const *ev); 104 112 static void key_handle_ctrl(console_event_t const *ev); 113 static void key_handle_shift(console_event_t const *ev); 114 static void key_handle_movement(unsigned int key, bool shift); 115 105 116 static int file_save(char const *fname); 117 static void file_save_as(void); 106 118 static int file_insert(char *fname); 107 119 static int file_save_range(char const *fname, spt_t const *spos, 108 120 spt_t const *epos); 121 static char *filename_prompt(char const *prompt, char const *init_value); 122 static char *range_get_str(spt_t const *spos, spt_t const *epos); 123 109 124 static void pane_text_display(void); 110 125 static void pane_row_display(void); … … 112 127 static void pane_status_display(void); 113 128 static void pane_caret_display(void); 129 114 130 static void insert_char(wchar_t c); 115 131 static void delete_char_before(void); … … 117 133 static void caret_update(void); 118 134 static void caret_move(int drow, int dcolumn, enum dir_spec align_dir); 135 136 static bool selection_active(void); 137 static void selection_sel_all(void); 138 static void selection_get_points(spt_t *pa, spt_t *pb); 139 static void selection_delete(void); 140 static void selection_copy(void); 141 static void insert_clipboard_data(void); 142 119 143 static void pt_get_sof(spt_t *pt); 120 144 static void pt_get_eof(spt_t *pt); 145 static int tag_cmp(tag_t const *a, tag_t const *b); 146 static int spt_cmp(spt_t const *a, spt_t const *b); 147 static int coord_cmp(coord_t const *a, coord_t const *b); 148 121 149 static void status_display(char const *str); 122 150 … … 150 178 151 179 if (argc == 2) { 152 doc.file_name = argv[1];180 doc.file_name = str_dup(argv[1]); 153 181 } else if (argc > 1) { 154 182 printf("Invalid arguments.\n"); 155 183 return -2; 156 184 } else { 157 doc.file_name = "/edit.txt";185 doc.file_name = NULL; 158 186 } 159 187 160 188 new_file = false; 161 189 162 if ( file_insert(doc.file_name) != EOK)190 if (doc.file_name == NULL || file_insert(doc.file_name) != EOK) 163 191 new_file = true; 164 192 165 193 /* Move to beginning of file. */ 166 194 caret_move(-ED_INFTY, -ED_INFTY, dir_before); 195 196 /* Place selection start tag. */ 197 tag_get_pt(&pane.caret_pos, &pt); 198 sheet_place_tag(&doc.sh, &pt, &pane.sel_start); 167 199 168 200 /* Initial display */ … … 170 202 pane_text_display(); 171 203 pane_status_display(); 172 if (new_file )173 status_display("File not found. Createdempty file.");204 if (new_file && doc.file_name != NULL) 205 status_display("File not found. Starting empty file."); 174 206 pane_caret_display(); 175 207 … … 184 216 /* Handle key press. */ 185 217 if (((ev.mods & KM_ALT) == 0) && 218 ((ev.mods & KM_SHIFT) == 0) && 186 219 (ev.mods & KM_CTRL) != 0) { 187 220 key_handle_ctrl(&ev); 188 } else if ((ev.mods & (KM_CTRL | KM_ALT)) == 0) { 221 } else if (((ev.mods & KM_ALT) == 0) && 222 ((ev.mods & KM_CTRL) == 0) && 223 (ev.mods & KM_SHIFT) != 0) { 224 key_handle_shift(&ev); 225 } else if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) { 189 226 key_handle_unmod(&ev); 190 227 } … … 201 238 if (pane.rflags & REDRAW_CARET) 202 239 pane_caret_display(); 203 204 240 } 205 241 … … 214 250 switch (ev->key) { 215 251 case KC_ENTER: 252 selection_delete(); 216 253 insert_char('\n'); 217 254 caret_update(); 218 255 break; 219 256 case KC_LEFT: 220 caret_move(0, -1, dir_before);221 break;222 257 case KC_RIGHT: 223 caret_move(0, 0, dir_after);224 break;225 258 case KC_UP: 226 caret_move(-1, 0, dir_before);227 break;228 259 case KC_DOWN: 229 caret_move(+1, 0, dir_before);230 break;231 260 case KC_HOME: 232 caret_move(0, -ED_INFTY, dir_before);233 break;234 261 case KC_END: 235 caret_move(0, +ED_INFTY, dir_before);236 break;237 262 case KC_PAGE_UP: 238 caret_move(-pane.rows, 0, dir_before);239 break;240 263 case KC_PAGE_DOWN: 241 caret_move(+pane.rows, 0, dir_before);264 key_handle_movement(ev->key, false); 242 265 break; 243 266 case KC_BACKSPACE: 244 delete_char_before(); 267 if (selection_active()) 268 selection_delete(); 269 else 270 delete_char_before(); 245 271 caret_update(); 246 272 break; 247 273 case KC_DELETE: 248 delete_char_after(); 274 if (selection_active()) 275 selection_delete(); 276 else 277 delete_char_after(); 249 278 caret_update(); 250 279 break; 251 280 default: 252 281 if (ev->c >= 32 || ev->c == '\t') { 282 selection_delete(); 253 283 insert_char(ev->c); 254 284 caret_update(); … … 258 288 } 259 289 290 /** Handle Shift-key combination. */ 291 static void key_handle_shift(console_event_t const *ev) 292 { 293 switch (ev->key) { 294 case KC_LEFT: 295 case KC_RIGHT: 296 case KC_UP: 297 case KC_DOWN: 298 case KC_HOME: 299 case KC_END: 300 case KC_PAGE_UP: 301 case KC_PAGE_DOWN: 302 key_handle_movement(ev->key, true); 303 break; 304 default: 305 if (ev->c >= 32 || ev->c == '\t') { 306 selection_delete(); 307 insert_char(ev->c); 308 caret_update(); 309 } 310 break; 311 } 312 } 313 260 314 /** Handle Ctrl-key combination. */ 261 315 static void key_handle_ctrl(console_event_t const *ev) … … 266 320 break; 267 321 case KC_S: 268 (void) file_save(doc.file_name); 322 if (doc.file_name != NULL) 323 file_save(doc.file_name); 324 else 325 file_save_as(); 326 break; 327 case KC_E: 328 file_save_as(); 329 break; 330 case KC_C: 331 selection_copy(); 332 break; 333 case KC_V: 334 selection_delete(); 335 insert_clipboard_data(); 336 pane.rflags |= REDRAW_TEXT; 337 caret_update(); 338 break; 339 case KC_X: 340 selection_copy(); 341 selection_delete(); 342 pane.rflags |= REDRAW_TEXT; 343 caret_update(); 344 break; 345 case KC_A: 346 selection_sel_all(); 269 347 break; 270 348 default: … … 273 351 } 274 352 353 static void key_handle_movement(unsigned int key, bool select) 354 { 355 spt_t pt; 356 spt_t caret_pt; 357 coord_t c_old, c_new; 358 bool had_sel; 359 360 /* Check if we had selection before. */ 361 tag_get_pt(&pane.caret_pos, &caret_pt); 362 tag_get_pt(&pane.sel_start, &pt); 363 had_sel = !spt_equal(&caret_pt, &pt); 364 365 switch (key) { 366 case KC_LEFT: 367 caret_move(0, -1, dir_before); 368 break; 369 case KC_RIGHT: 370 caret_move(0, 0, dir_after); 371 break; 372 case KC_UP: 373 caret_move(-1, 0, dir_before); 374 break; 375 case KC_DOWN: 376 caret_move(+1, 0, dir_before); 377 break; 378 case KC_HOME: 379 caret_move(0, -ED_INFTY, dir_before); 380 break; 381 case KC_END: 382 caret_move(0, +ED_INFTY, dir_before); 383 break; 384 case KC_PAGE_UP: 385 caret_move(-pane.rows, 0, dir_before); 386 break; 387 case KC_PAGE_DOWN: 388 caret_move(+pane.rows, 0, dir_before); 389 break; 390 default: 391 break; 392 } 393 394 if (select == false) { 395 /* Move sel_start to the same point as caret. */ 396 sheet_remove_tag(&doc.sh, &pane.sel_start); 397 tag_get_pt(&pane.caret_pos, &pt); 398 sheet_place_tag(&doc.sh, &pt, &pane.sel_start); 399 } 400 401 if (select) { 402 tag_get_pt(&pane.caret_pos, &pt); 403 spt_get_coord(&caret_pt, &c_old); 404 spt_get_coord(&pt, &c_new); 405 406 if (c_old.row == c_new.row) 407 pane.rflags |= REDRAW_ROW; 408 else 409 pane.rflags |= REDRAW_TEXT; 410 411 } else if (had_sel == true) { 412 /* Redraw because text was unselected. */ 413 pane.rflags |= REDRAW_TEXT; 414 } 415 } 275 416 276 417 /** Save the document. */ … … 285 426 286 427 rc = file_save_range(fname, &sp, &ep); 287 status_display("File saved."); 428 429 switch (rc) { 430 case EINVAL: 431 status_display("Error opening file!"); 432 break; 433 case EIO: 434 status_display("Error writing data!"); 435 break; 436 default: 437 status_display("File saved."); 438 break; 439 } 288 440 289 441 return rc; 442 } 443 444 /** Change document name and save. */ 445 static void file_save_as(void) 446 { 447 char *old_fname, *fname; 448 int rc; 449 450 old_fname = (doc.file_name != NULL) ? doc.file_name : ""; 451 fname = filename_prompt("Save As", old_fname); 452 if (fname == NULL) { 453 status_display("Save cancelled."); 454 return; 455 } 456 457 rc = file_save(fname); 458 if (rc != EOK) 459 return; 460 461 if (doc.file_name != NULL) 462 free(doc.file_name); 463 doc.file_name = fname; 464 } 465 466 /** Ask for a file name. */ 467 static char *filename_prompt(char const *prompt, char const *init_value) 468 { 469 console_event_t ev; 470 char *str; 471 wchar_t buffer[INFNAME_MAX_LEN + 1]; 472 int max_len; 473 int nc; 474 bool done; 475 476 asprintf(&str, "%s: %s", prompt, init_value); 477 status_display(str); 478 console_goto(con, 1 + str_length(str), scr_rows - 1); 479 free(str); 480 481 console_set_color(con, COLOR_WHITE, COLOR_BLACK, 0); 482 483 max_len = min(INFNAME_MAX_LEN, scr_columns - 4 - str_length(prompt)); 484 str_to_wstr(buffer, max_len + 1, init_value); 485 nc = wstr_length(buffer); 486 done = false; 487 488 while (!done) { 489 console_get_event(con, &ev); 490 491 if (ev.type == KEY_PRESS) { 492 /* Handle key press. */ 493 if (((ev.mods & KM_ALT) == 0) && 494 (ev.mods & KM_CTRL) != 0) { 495 ; 496 } else if ((ev.mods & (KM_CTRL | KM_ALT)) == 0) { 497 switch (ev.key) { 498 case KC_ESCAPE: 499 return NULL; 500 case KC_BACKSPACE: 501 if (nc > 0) { 502 putchar('\b'); 503 fflush(stdout); 504 --nc; 505 } 506 break; 507 case KC_ENTER: 508 done = true; 509 break; 510 default: 511 if (ev.c >= 32 && nc < max_len) { 512 putchar(ev.c); 513 fflush(stdout); 514 buffer[nc++] = ev.c; 515 } 516 break; 517 } 518 } 519 } 520 } 521 522 buffer[nc] = '\0'; 523 str = wstr_to_astr(buffer); 524 525 console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0); 526 527 return str; 290 528 } 291 529 … … 359 597 } while (!spt_equal(&bep, epos)); 360 598 361 fclose(f); 599 if (fclose(f) != EOK) 600 return EIO; 362 601 363 602 return EOK; 603 } 604 605 /** Return contents of range as a new string. */ 606 static char *range_get_str(spt_t const *spos, spt_t const *epos) 607 { 608 char *buf; 609 spt_t sp, bep; 610 size_t bytes; 611 size_t buf_size, bpos; 612 613 buf_size = 1; 614 615 buf = malloc(buf_size); 616 if (buf == NULL) 617 return NULL; 618 619 bpos = 0; 620 sp = *spos; 621 622 while (true) { 623 sheet_copy_out(&doc.sh, &sp, epos, &buf[bpos], buf_size - bpos, 624 &bep); 625 bytes = str_size(&buf[bpos]); 626 bpos += bytes; 627 sp = bep; 628 629 if (spt_equal(&bep, epos)) 630 break; 631 632 buf_size *= 2; 633 buf = realloc(buf, buf_size); 634 if (buf == NULL) 635 return NULL; 636 } 637 638 return buf; 364 639 } 365 640 … … 408 683 { 409 684 int i, j, fill; 410 spt_t rb, re, dep ;685 spt_t rb, re, dep, pt; 411 686 coord_t rbc, rec; 412 687 char row_buf[ROW_BUF_SIZE]; … … 414 689 size_t pos, size; 415 690 unsigned s_column; 691 coord_t csel_start, csel_end, ctmp; 692 693 /* Determine selection start and end. */ 694 695 tag_get_pt(&pane.sel_start, &pt); 696 spt_get_coord(&pt, &csel_start); 697 698 tag_get_pt(&pane.caret_pos, &pt); 699 spt_get_coord(&pt, &csel_end); 700 701 if (coord_cmp(&csel_start, &csel_end) > 0) { 702 ctmp = csel_start; 703 csel_start = csel_end; 704 csel_end = ctmp; 705 } 416 706 417 707 /* Draw rows from the sheet. */ … … 434 724 /* Display text from the buffer. */ 435 725 726 if (coord_cmp(&csel_start, &rbc) <= 0 && 727 coord_cmp(&rbc, &csel_end) < 0) { 728 fflush(stdout); 729 console_set_color(con, COLOR_BLACK, COLOR_RED, 0); 730 fflush(stdout); 731 } 732 436 733 console_goto(con, 0, i); 437 734 size = str_size(row_buf); 438 735 pos = 0; 439 s_column = 1;736 s_column = pane.sh_column; 440 737 while (pos < size) { 738 if (csel_start.row == rbc.row && csel_start.column == s_column) { 739 fflush(stdout); 740 console_set_color(con, COLOR_BLACK, COLOR_RED, 0); 741 fflush(stdout); 742 } 743 744 if (csel_end.row == rbc.row && csel_end.column == s_column) { 745 fflush(stdout); 746 console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0); 747 fflush(stdout); 748 } 749 441 750 c = str_decode(row_buf, &pos, size); 442 751 if (c != '\t') { … … 453 762 } 454 763 764 if (csel_end.row == rbc.row && csel_end.column == s_column) { 765 fflush(stdout); 766 console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0); 767 fflush(stdout); 768 } 769 455 770 /* Fill until the end of display area. */ 456 771 … … 463 778 putchar(' '); 464 779 fflush(stdout); 780 console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0); 465 781 } 466 782 … … 473 789 spt_t caret_pt; 474 790 coord_t coord; 791 char *fname; 475 792 int n; 476 793 … … 478 795 spt_get_coord(&caret_pt, &coord); 479 796 797 fname = (doc.file_name != NULL) ? doc.file_name : "<unnamed>"; 798 480 799 console_goto(con, 0, scr_rows - 1); 481 800 console_set_color(con, COLOR_WHITE, COLOR_BLACK, 0); 482 n = printf(" %d, %d: File '%s'. Ctrl- S Save Ctrl-Q Quit",483 coord.row, coord.column, doc.file_name);801 n = printf(" %d, %d: File '%s'. Ctrl-Q Quit Ctrl-S Save " 802 "Ctrl-E Save As", coord.row, coord.column, fname); 484 803 printf("%*s", scr_columns - 1 - n, ""); 485 804 fflush(stdout); … … 648 967 } 649 968 969 /** Check for non-empty selection. */ 970 static bool selection_active(void) 971 { 972 return (tag_cmp(&pane.caret_pos, &pane.sel_start) != 0); 973 } 974 975 static void selection_get_points(spt_t *pa, spt_t *pb) 976 { 977 spt_t pt; 978 979 tag_get_pt(&pane.sel_start, pa); 980 tag_get_pt(&pane.caret_pos, pb); 981 982 if (spt_cmp(pa, pb) > 0) { 983 pt = *pa; 984 *pa = *pb; 985 *pb = pt; 986 } 987 } 988 989 /** Delete selected text. */ 990 static void selection_delete(void) 991 { 992 spt_t pa, pb; 993 coord_t ca, cb; 994 int rel; 995 996 tag_get_pt(&pane.sel_start, &pa); 997 tag_get_pt(&pane.caret_pos, &pb); 998 spt_get_coord(&pa, &ca); 999 spt_get_coord(&pb, &cb); 1000 rel = coord_cmp(&ca, &cb); 1001 1002 if (rel == 0) 1003 return; 1004 1005 if (rel < 0) 1006 sheet_delete(&doc.sh, &pa, &pb); 1007 else 1008 sheet_delete(&doc.sh, &pb, &pa); 1009 1010 if (ca.row == cb.row) 1011 pane.rflags |= REDRAW_ROW; 1012 else 1013 pane.rflags |= REDRAW_TEXT; 1014 } 1015 1016 static void selection_sel_all(void) 1017 { 1018 spt_t spt, ept; 1019 1020 pt_get_sof(&spt); 1021 pt_get_eof(&ept); 1022 sheet_remove_tag(&doc.sh, &pane.sel_start); 1023 sheet_place_tag(&doc.sh, &spt, &pane.sel_start); 1024 sheet_remove_tag(&doc.sh, &pane.caret_pos); 1025 sheet_place_tag(&doc.sh, &ept, &pane.caret_pos); 1026 1027 pane.rflags |= REDRAW_TEXT; 1028 caret_update(); 1029 } 1030 1031 static void selection_copy(void) 1032 { 1033 spt_t pa, pb; 1034 char *str; 1035 1036 selection_get_points(&pa, &pb); 1037 str = range_get_str(&pa, &pb); 1038 if (str == NULL || clipboard_put_str(str) != EOK) { 1039 status_display("Copying to clipboard failed!"); 1040 } 1041 free(str); 1042 } 1043 1044 static void insert_clipboard_data(void) 1045 { 1046 char *str; 1047 size_t off; 1048 wchar_t c; 1049 int rc; 1050 1051 rc = clipboard_get_str(&str); 1052 if (rc != EOK || str == NULL) 1053 return; 1054 1055 off = 0; 1056 1057 while (true) { 1058 c = str_decode(str, &off, STR_NO_LIMIT); 1059 if (c == '\0') 1060 break; 1061 1062 insert_char(c); 1063 } 1064 1065 free(str); 1066 } 650 1067 651 1068 /** Get start-of-file s-point. */ … … 669 1086 670 1087 sheet_get_cell_pt(&doc.sh, &coord, dir_after, pt); 1088 } 1089 1090 /** Compare tags. */ 1091 static int tag_cmp(tag_t const *a, tag_t const *b) 1092 { 1093 spt_t pa, pb; 1094 1095 tag_get_pt(a, &pa); 1096 tag_get_pt(b, &pb); 1097 1098 return spt_cmp(&pa, &pb); 1099 } 1100 1101 /** Compare s-points. */ 1102 static int spt_cmp(spt_t const *a, spt_t const *b) 1103 { 1104 coord_t ca, cb; 1105 1106 spt_get_coord(a, &ca); 1107 spt_get_coord(b, &cb); 1108 1109 return coord_cmp(&ca, &cb); 1110 } 1111 1112 /** Compare coordinats. */ 1113 static int coord_cmp(coord_t const *a, coord_t const *b) 1114 { 1115 if (a->row - b->row != 0) 1116 return a->row - b->row; 1117 1118 return a->column - b->column; 671 1119 } 672 1120 -
uspace/app/init/init.c
r58d5803d r387416b 235 235 spawn("/srv/kbd"); 236 236 spawn("/srv/console"); 237 spawn("/srv/clip"); 237 238 spawn("/srv/fhc"); 238 239 spawn("/srv/obio"); -
uspace/app/trace/trace.c
r58d5803d r387416b 48 48 #include <io/console.h> 49 49 #include <io/keycode.h> 50 #include <fibril_sync .h>50 #include <fibril_synch.h> 51 51 52 52 #include <libc.h> -
uspace/lib/libblock/libblock.c
r58d5803d r387416b 47 47 #include <as.h> 48 48 #include <assert.h> 49 #include <fibril_sync .h>49 #include <fibril_synch.h> 50 50 #include <adt/list.h> 51 51 #include <adt/hash_table.h> -
uspace/lib/libblock/libblock.h
r58d5803d r387416b 36 36 37 37 #ifndef LIBBLOCK_LIBBLOCK_H_ 38 #define LIBBLOCK_LIBBLOCK_H_38 #define LIBBLOCK_LIBBLOCK_H_ 39 39 40 40 #include <stdint.h> 41 41 #include "../../srv/vfs/vfs.h" 42 #include <fibril_sync .h>42 #include <fibril_synch.h> 43 43 #include <adt/hash_table.h> 44 44 #include <adt/list.h> -
uspace/lib/libc/Makefile.build
r58d5803d r387416b 50 50 generic/as.c \ 51 51 generic/cap.c \ 52 generic/clipboard.c \ 52 53 generic/devmap.c \ 53 54 generic/event.c \ … … 56 57 generic/string.c \ 57 58 generic/fibril.c \ 58 generic/fibril_sync .c \59 generic/fibril_synch.c \ 59 60 generic/pcb.c \ 60 61 generic/smc.c \ -
uspace/lib/libc/arch/amd64/include/atomic.h
r58d5803d r387416b 37 37 #ifndef LIBC_amd64_ATOMIC_H_ 38 38 #define LIBC_amd64_ATOMIC_H_ 39 40 #define LIBC_ARCH_ATOMIC_H_ 41 42 #include <atomicdflt.h> 39 43 40 44 static inline void atomic_inc(atomic_t *val) { -
uspace/lib/libc/arch/arm32/include/atomic.h
r58d5803d r387416b 37 37 #define LIBC_arm32_ATOMIC_H_ 38 38 39 #define LIBC_ARCH_ATOMIC_H_ 40 #define CAS 41 42 #include <atomicdflt.h> 43 #include <bool.h> 44 #include <sys/types.h> 45 46 extern uintptr_t *ras_page; 47 48 static inline bool cas(atomic_t *val, long ov, long nv) 49 { 50 long ret = 0; 51 52 /* 53 * The following instructions between labels 1 and 2 constitute a 54 * Restartable Atomic Seqeunce. Should the sequence be non-atomic, 55 * the kernel will restart it. 56 */ 57 asm volatile ( 58 "1:\n" 59 " adr %[ret], 1b\n" 60 " str %[ret], %[rp0]\n" 61 " adr %[ret], 2f\n" 62 " str %[ret], %[rp1]\n" 63 " ldr %[ret], %[addr]\n" 64 " cmp %[ret], %[ov]\n" 65 " streq %[nv], %[addr]\n" 66 "2:\n" 67 " moveq %[ret], #1\n" 68 " movne %[ret], #0\n" 69 : [ret] "+&r" (ret), 70 [rp0] "=m" (ras_page[0]), 71 [rp1] "=m" (ras_page[1]), 72 [addr] "+m" (val->count) 73 : [ov] "r" (ov), 74 [nv] "r" (nv) 75 : "memory" 76 ); 77 78 ras_page[0] = 0; 79 asm volatile ("" ::: "memory"); 80 ras_page[1] = 0xffffffff; 81 82 return (bool) ret; 83 } 84 39 85 /** Atomic addition. 40 86 * … … 46 92 static inline long atomic_add(atomic_t *val, int i) 47 93 { 48 int ret; 49 volatile long * mem = &(val->count); 94 long ret = 0; 50 95 96 /* 97 * The following instructions between labels 1 and 2 constitute a 98 * Restartable Atomic Seqeunce. Should the sequence be non-atomic, 99 * the kernel will restart it. 100 */ 51 101 asm volatile ( 52 "1:\n" 53 "ldr r2, [%1]\n" 54 "add r3, r2, %2\n" 55 "str r3, %0\n" 56 "swp r3, r3, [%1]\n" 57 "cmp r3, r2\n" 58 "bne 1b\n" 102 "1:\n" 103 " adr %[ret], 1b\n" 104 " str %[ret], %[rp0]\n" 105 " adr %[ret], 2f\n" 106 " str %[ret], %[rp1]\n" 107 " ldr %[ret], %[addr]\n" 108 " add %[ret], %[ret], %[imm]\n" 109 " str %[ret], %[addr]\n" 110 "2:\n" 111 : [ret] "+&r" (ret), 112 [rp0] "=m" (ras_page[0]), 113 [rp1] "=m" (ras_page[1]), 114 [addr] "+m" (val->count) 115 : [imm] "r" (i) 116 ); 59 117 60 : "=m" (ret) 61 : "r" (mem), "r" (i) 62 : "r3", "r2" 63 ); 118 ras_page[0] = 0; 119 asm volatile ("" ::: "memory"); 120 ras_page[1] = 0xffffffff; 64 121 65 122 return ret; -
uspace/lib/libc/arch/arm32/src/entry.s
r58d5803d r387416b 36 36 # 37 37 # r1 contains the PCB pointer 38 # r2 contains the RAS page address 38 39 # 39 40 __entry: 41 # Store the RAS page address into the ras_page variable 42 ldr r0, =ras_page 43 str r2, [r0] 44 40 45 # Pass pcb_ptr to __main as the first argument (in r0) 41 46 mov r0, r1 … … 43 48 44 49 bl __exit 50 51 .data 52 53 .global ras_page 54 ras_page: 55 .long 0 56 -
uspace/lib/libc/arch/arm32/src/syscall.c
r58d5803d r387416b 60 60 register sysarg_t __arm_reg_r5 asm("r5") = p6; 61 61 register sysarg_t __arm_reg_r6 asm("r6") = id; 62 63 asm volatile ( "swi" 62 63 asm volatile ( 64 "swi 0" 64 65 : "=r" (__arm_reg_r0) 65 66 : "r" (__arm_reg_r0), … … 71 72 "r" (__arm_reg_r6) 72 73 ); 73 74 74 75 return __arm_reg_r0; 75 76 } -
uspace/lib/libc/arch/ia32/Makefile.inc
r58d5803d r387416b 39 39 arch/$(UARCH)/src/setjmp.S 40 40 41 GCC_CFLAGS += -march=pentium 41 42 LFLAGS += -N 42 43 -
uspace/lib/libc/arch/ia32/include/atomic.h
r58d5803d r387416b 35 35 #ifndef LIBC_ia32_ATOMIC_H_ 36 36 #define LIBC_ia32_ATOMIC_H_ 37 38 #define LIBC_ARCH_ATOMIC_H_ 39 40 #include <atomicdflt.h> 37 41 38 42 static inline void atomic_inc(atomic_t *val) { -
uspace/lib/libc/arch/ia64/include/atomic.h
r58d5803d r387416b 35 35 #ifndef LIBC_ia64_ATOMIC_H_ 36 36 #define LIBC_ia64_ATOMIC_H_ 37 38 #define LIBC_ARCH_ATOMIC_H_ 39 40 #include <atomicdflt.h> 37 41 38 42 static inline void atomic_inc(atomic_t *val) -
uspace/lib/libc/arch/mips32/include/atomic.h
r58d5803d r387416b 36 36 #ifndef LIBC_mips32_ATOMIC_H_ 37 37 #define LIBC_mips32_ATOMIC_H_ 38 39 #define LIBC_ARCH_ATOMIC_H_ 40 41 #include <atomicdflt.h> 38 42 39 43 #define atomic_inc(x) ((void) atomic_add(x, 1)) -
uspace/lib/libc/arch/ppc32/include/atomic.h
r58d5803d r387416b 35 35 #ifndef LIBC_ppc32_ATOMIC_H_ 36 36 #define LIBC_ppc32_ATOMIC_H_ 37 38 #define LIBC_ARCH_ATOMIC_H_ 39 40 #include <atomicdflt.h> 37 41 38 42 static inline void atomic_inc(atomic_t *val) -
uspace/lib/libc/arch/sparc64/include/atomic.h
r58d5803d r387416b 36 36 #define LIBC_sparc64_ATOMIC_H_ 37 37 38 #define LIBC_ARCH_ATOMIC_H_ 39 40 #include <atomicdflt.h> 38 41 #include <sys/types.h> 39 42 -
uspace/lib/libc/generic/fibril_synch.c
r58d5803d r387416b 33 33 */ 34 34 35 #include <fibril_sync .h>35 #include <fibril_synch.h> 36 36 #include <fibril.h> 37 37 #include <async.h> -
uspace/lib/libc/generic/futex.c
r58d5803d r387416b 36 36 #include <atomic.h> 37 37 #include <libc.h> 38 #include <stdio.h>39 38 #include <sys/types.h> 40 #include <kernel/synch/synch.h>41 42 /*43 * Note about race conditions.44 * Because of non-atomic nature of operations performed sequentially on the45 * futex counter and the futex wait queue, there is a race condition:46 *47 * (wq->missed_wakeups == 1) && (futex->count = 1)48 *49 * Scenario 1 (wait queue timeout vs. futex_up()):50 * 1. assume wq->missed_wakeups == 0 && futex->count == -151 * (ie. thread A sleeping, thread B in the critical section)52 * 2. A receives timeout and gets removed from the wait queue53 * 3. B wants to leave the critical section and calls futex_up()54 * 4. B thus changes futex->count from -1 to 055 * 5. B has to call SYS_FUTEX_WAKEUP syscall to wake up the sleeping thread56 * 6. B finds the wait queue empty and changes wq->missed_wakeups from 0 to 157 * 7. A fixes futex->count (i.e. the number of waiting threads) by changing it58 * from 0 to 159 *60 * Scenario 2 (conditional down operation vs. futex_up)61 * 1. assume wq->missed_wakeups == 0 && futex->count == 062 * (i.e. thread A is in the critical section)63 * 2. thread B performs futex_trydown() operation and changes futex->count from64 * 0 to -165 * B is now obliged to call SYS_FUTEX_SLEEP syscall66 * 3. A wants to leave the critical section and does futex_up()67 * 4. A thus changes futex->count from -1 to 0 and must call SYS_FUTEX_WAKEUP68 * syscall69 * 5. B finds the wait queue empty and immediatelly aborts the conditional sleep70 * 6. No thread is queueing in the wait queue so wq->missed_wakeups changes from71 * 0 to 172 * 6. B fixes futex->count (i.e. the number of waiting threads) by changing it73 * from 0 to 174 *75 * Both scenarios allow two threads to be in the critical section76 * simultaneously. One without kernel intervention and the other through77 * wq->missed_wakeups being 1.78 *79 * To mitigate this problem, futex_down_timeout() detects that the syscall80 * didn't sleep in the wait queue, fixes the futex counter and RETRIES the81 * whole operation again.82 */83 39 84 40 /** Initialize futex counter. … … 92 48 } 93 49 94 int futex_down(futex_t *futex)95 {96 return futex_down_timeout(futex, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE);97 }98 99 int futex_trydown(futex_t *futex)100 {101 return futex_down_timeout(futex, SYNCH_NO_TIMEOUT,102 SYNCH_FLAGS_NON_BLOCKING);103 }104 105 50 /** Try to down the futex. 106 51 * 107 52 * @param futex Futex. 108 * @param usec Microseconds to wait. Zero value means sleep without 109 * timeout. 110 * @param flags Select mode of operation. See comment for 111 * waitq_sleep_timeout(). 53 * @return Non-zero if the futex was acquired. 54 * @return Zero if the futex was not acquired. 55 */ 56 int futex_trydown(futex_t *futex) 57 { 58 return cas(futex, 1, 0); 59 } 60 61 /** Down the futex. 112 62 * 113 * @return ENOENT if there is no such virtual address. One of 114 * ESYNCH_OK_ATOMIC and ESYNCH_OK_BLOCKED on success or 115 * ESYNCH_TIMEOUT if the lock was not acquired because of 116 * a timeout or ESYNCH_WOULD_BLOCK if the operation could 117 * not be carried out atomically (if requested so). 63 * @param futex Futex. 64 * @return ENOENT if there is no such virtual address. 65 * @return Zero in the uncontended case. 66 * @return Otherwise one of ESYNCH_OK_ATOMIC or ESYNCH_OK_BLOCKED. 118 67 */ 119 int futex_down _timeout(futex_t *futex, uint32_t usec, int flags)68 int futex_down(futex_t *futex) 120 69 { 121 int rc; 122 123 while (atomic_predec(futex) < 0) { 124 rc = __SYSCALL3(SYS_FUTEX_SLEEP, (sysarg_t) &futex->count, 125 (sysarg_t) usec, (sysarg_t) flags); 126 127 switch (rc) { 128 case ESYNCH_OK_ATOMIC: 129 /* 130 * Because of a race condition between timeout and 131 * futex_up() and between conditional 132 * futex_down_timeout() and futex_up(), we have to give 133 * up and try again in this special case. 134 */ 135 atomic_inc(futex); 136 break; 70 if (atomic_predec(futex) < 0) 71 return __SYSCALL1(SYS_FUTEX_SLEEP, (sysarg_t) &futex->count); 137 72 138 case ESYNCH_TIMEOUT: 139 atomic_inc(futex); 140 return ESYNCH_TIMEOUT; 141 break; 142 143 case ESYNCH_WOULD_BLOCK: 144 /* 145 * The conditional down operation should be implemented 146 * this way. The userspace-only variant tends to 147 * accumulate missed wakeups in the kernel futex wait 148 * queue. 149 */ 150 atomic_inc(futex); 151 return ESYNCH_WOULD_BLOCK; 152 break; 153 154 case ESYNCH_OK_BLOCKED: 155 /* 156 * Enter the critical section. 157 * The futex counter has already been incremented for 158 * us. 159 */ 160 return ESYNCH_OK_BLOCKED; 161 break; 162 default: 163 return rc; 164 } 165 } 166 167 /* 168 * Enter the critical section. 169 */ 170 return ESYNCH_OK_ATOMIC; 73 return 0; 171 74 } 172 75 … … 174 77 * 175 78 * @param futex Futex. 176 * 177 * @return ENOENT if there is no such virtual address. Otherwise 178 * zero. 79 * @return ENOENT if there is no such virtual address. 80 * @return Zero in the uncontended case. 179 81 */ 180 82 int futex_up(futex_t *futex) 181 83 { 182 long val; 183 184 val = atomic_postinc(futex); 185 if (val < 0) 84 if (atomic_postinc(futex) < 0) 186 85 return __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &futex->count); 187 86 -
uspace/lib/libc/generic/io/console.c
r58d5803d r387416b 94 94 } 95 95 96 int console_get_pos(int phone, int *col, int *row) 97 { 98 ipcarg_t col_v; 99 ipcarg_t row_v; 100 int rc; 101 102 rc = async_req_0_2(phone, CONSOLE_GET_POS, &col_v, &row_v); 103 104 *col = (int) col_v; 105 *row = (int) row_v; 106 return rc; 107 } 108 96 109 void console_goto(int phone, int col, int row) 97 110 { -
uspace/lib/libc/generic/io/io.c
r58d5803d r387416b 341 341 size_t fread(void *buf, size_t size, size_t nmemb, FILE *stream) 342 342 { 343 size_t left = size * nmemb; 344 size_t done = 0; 345 343 size_t left, done; 344 345 if (size == 0 || nmemb == 0) 346 return 0; 347 346 348 /* Make sure no data is pending write. */ 347 349 _fflushbuf(stream); 350 351 left = size * nmemb; 352 done = 0; 348 353 349 354 while ((left > 0) && (!stream->error) && (!stream->eof)) { … … 365 370 static size_t _fwrite(const void *buf, size_t size, size_t nmemb, FILE *stream) 366 371 { 367 size_t left = size * nmemb; 368 size_t done = 0; 369 372 size_t left; 373 size_t done; 374 375 if (size == 0 || nmemb == 0) 376 return 0; 377 378 left = size * nmemb; 379 done = 0; 380 370 381 while ((left > 0) && (!stream->error)) { 371 382 ssize_t wr; … … 421 432 uint8_t b; 422 433 bool need_flush; 423 434 435 if (size == 0 || nmemb == 0) 436 return 0; 437 424 438 /* If not buffered stream, write out directly. */ 425 439 if (stream->btype == _IONBF) { … … 480 494 481 495 if (chr_encode(c, buf, &sz, STR_BOUNDS(1)) == EOK) { 482 size_t wr = fwrite(buf, sz, 1, stream);496 size_t wr = fwrite(buf, 1, sz, stream); 483 497 484 498 if (wr < sz) -
uspace/lib/libc/generic/string.c
r58d5803d r387416b 471 471 * null-terminated and containing only complete characters. 472 472 * 473 * @param d st Destination buffer.473 * @param dest Destination buffer. 474 474 * @param count Size of the destination buffer (must be > 0). 475 475 * @param src Source string. … … 505 505 * have to be null-terminated. 506 506 * 507 * @param d st Destination buffer.507 * @param dest Destination buffer. 508 508 * @param count Size of the destination buffer (must be > 0). 509 509 * @param src Source string. … … 537 537 * null-terminated and containing only complete characters. 538 538 * 539 * @param d st Destination buffer.539 * @param dest Destination buffer. 540 540 * @param count Size of the destination buffer. 541 541 * @param src Source string. … … 549 549 } 550 550 551 /** Copy NULL-terminated wide string to string 552 * 553 * Copy source wide string @a src to destination buffer @a dst. 554 * No more than @a size bytes are written. NULL-terminator is always 555 * written after the last succesfully copied character (i.e. if the 556 * destination buffer is has at least 1 byte, it will be always 557 * NULL-terminated). 558 * 559 * @param src Source wide string. 560 * @param dst Destination buffer. 561 * @param count Size of the destination buffer. 562 * 563 */ 564 void wstr_nstr(char *dst, const wchar_t *src, size_t size) 565 { 566 /* No space for the NULL-terminator in the buffer */ 567 if (size == 0) 568 return; 569 551 /** Convert wide string to string. 552 * 553 * Convert wide string @a src to string. The output is written to the buffer 554 * specified by @a dest and @a size. @a size must be non-zero and the string 555 * written will always be well-formed. 556 * 557 * @param dest Destination buffer. 558 * @param size Size of the destination buffer. 559 * @param src Source wide string. 560 */ 561 void wstr_to_str(char *dest, size_t size, const wchar_t *src) 562 { 570 563 wchar_t ch; 571 size_t src_idx = 0; 572 size_t dst_off = 0; 573 564 size_t src_idx; 565 size_t dest_off; 566 567 /* There must be space for a null terminator in the buffer. */ 568 assert(size > 0); 569 570 src_idx = 0; 571 dest_off = 0; 572 574 573 while ((ch = src[src_idx++]) != 0) { 575 if (chr_encode(ch, d st, &dst_off, size) != EOK)574 if (chr_encode(ch, dest, &dest_off, size - 1) != EOK) 576 575 break; 577 576 } 578 579 if (dst_off >= size) 580 dst[size - 1] = 0; 581 else 582 dst[dst_off] = 0; 577 578 dest[dest_off] = '\0'; 579 } 580 581 /** Convert wide string to new string. 582 * 583 * Convert wide string @a src to string. Space for the new string is allocated 584 * on the heap. 585 * 586 * @param src Source wide string. 587 * @return New string. 588 */ 589 char *wstr_to_astr(const wchar_t *src) 590 { 591 char dbuf[STR_BOUNDS(1)]; 592 char *str; 593 wchar_t ch; 594 595 size_t src_idx; 596 size_t dest_off; 597 size_t dest_size; 598 599 /* Compute size of encoded string. */ 600 601 src_idx = 0; 602 dest_size = 0; 603 604 while ((ch = src[src_idx++]) != 0) { 605 dest_off = 0; 606 if (chr_encode(ch, dbuf, &dest_off, STR_BOUNDS(1)) != EOK) 607 break; 608 dest_size += dest_off; 609 } 610 611 str = malloc(dest_size + 1); 612 if (str == NULL) 613 return NULL; 614 615 /* Encode string. */ 616 617 src_idx = 0; 618 dest_off = 0; 619 620 while ((ch = src[src_idx++]) != 0) { 621 if (chr_encode(ch, str, &dest_off, dest_size) != EOK) 622 break; 623 } 624 625 str[dest_size] = '\0'; 626 return str; 627 } 628 629 630 /** Convert string to wide string. 631 * 632 * Convert string @a src to wide string. The output is written to the 633 * buffer specified by @a dest and @a dlen. @a dlen must be non-zero 634 * and the wide string written will always be null-terminated. 635 * 636 * @param dest Destination buffer. 637 * @param dlen Length of destination buffer (number of wchars). 638 * @param src Source string. 639 */ 640 void str_to_wstr(wchar_t *dest, size_t dlen, const char *src) 641 { 642 size_t offset; 643 size_t di; 644 wchar_t c; 645 646 assert(dlen > 0); 647 648 offset = 0; 649 di = 0; 650 651 do { 652 if (di >= dlen - 1) 653 break; 654 655 c = str_decode(src, &offset, STR_NO_LIMIT); 656 dest[di++] = c; 657 } while (c != '\0'); 658 659 dest[dlen - 1] = '\0'; 583 660 } 584 661 -
uspace/lib/libc/generic/time.c
r58d5803d r387416b 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 35 #include <sys/time.h> … … 40 40 #include <unistd.h> 41 41 #include <atomic.h> 42 #include <futex.h>43 42 #include <sysinfo.h> 44 43 #include <ipc/services.h> 44 #include <libc.h> 45 45 46 46 #include <sysinfo.h> … … 189 189 190 190 /** Wait unconditionally for specified number of microseconds */ 191 int usleep(unsigned long usec) 192 { 193 atomic_t futex = FUTEX_INITIALIZER; 194 195 futex_initialize(&futex, 0); 196 futex_down_timeout(&futex, usec, 0); 191 int usleep(useconds_t usec) 192 { 193 (void) __SYSCALL1(SYS_THREAD_USLEEP, usec); 197 194 return 0; 198 195 } 199 196 200 197 /** Wait unconditionally for specified number of seconds */ 201 unsigned int sleep(unsigned int seconds) 202 { 203 atomic_t futex = FUTEX_INITIALIZER; 204 205 futex_initialize(&futex, 0); 206 198 unsigned int sleep(unsigned int sec) 199 { 207 200 /* Sleep in 1000 second steps to support 208 201 full argument range */ 209 while (sec onds> 0) {210 unsigned int period = (sec onds > 1000) ? 1000 : seconds;202 while (sec > 0) { 203 unsigned int period = (sec > 1000) ? 1000 : sec; 211 204 212 futex_down_timeout(&futex, period * 1000000,0);213 sec onds-= period;205 usleep(period * 1000000); 206 sec -= period; 214 207 } 215 208 return 0; -
uspace/lib/libc/include/atomic.h
r58d5803d r387416b 1 1 /* 2 * Copyright (c) 200 6Jakub Jermar2 * Copyright (c) 2009 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 36 36 #define LIBC_ATOMIC_H_ 37 37 38 typedef struct atomic {39 volatile long count;40 } atomic_t;41 42 38 #include <libarch/atomic.h> 43 44 static inline void atomic_set(atomic_t *val, long i)45 {46 val->count = i;47 }48 49 static inline long atomic_get(atomic_t *val)50 {51 return val->count;52 }53 39 54 40 #endif -
uspace/lib/libc/include/fibril_synch.h
r58d5803d r387416b 33 33 */ 34 34 35 #ifndef LIBC_FIBRIL_SYNC _H_36 #define LIBC_FIBRIL_SYNC _H_35 #ifndef LIBC_FIBRIL_SYNCH_H_ 36 #define LIBC_FIBRIL_SYNCH_H_ 37 37 38 38 #include <async.h> -
uspace/lib/libc/include/futex.h
r58d5803d r387416b 46 46 extern int futex_down(futex_t *futex); 47 47 extern int futex_trydown(futex_t *futex); 48 extern int futex_down_timeout(futex_t *futex, uint32_t usec, int flags);49 48 extern int futex_up(futex_t *futex); 50 49 -
uspace/lib/libc/include/io/console.h
r58d5803d r387416b 69 69 70 70 extern int console_get_size(int phone, int *cols, int *rows); 71 extern int console_get_pos(int phone, int *col, int *row); 71 72 extern void console_goto(int phone, int col, int row); 72 73 -
uspace/lib/libc/include/ipc/console.h
r58d5803d r387416b 43 43 CONSOLE_GET_COLOR_CAP, 44 44 CONSOLE_GET_EVENT, 45 CONSOLE_GET_POS, 45 46 CONSOLE_GOTO, 46 47 CONSOLE_CLEAR, -
uspace/lib/libc/include/ipc/services.h
r58d5803d r387416b 47 47 SERVICE_DEVMAP, 48 48 SERVICE_FHC, 49 SERVICE_OBIO 49 SERVICE_OBIO, 50 SERVICE_CLIPBOARD 50 51 } services_t; 51 52 -
uspace/lib/libc/include/string.h
r58d5803d r387416b 73 73 extern void str_append(char *dest, size_t size, const char *src); 74 74 75 extern void wstr_nstr(char *dst, const wchar_t *src, size_t size); 75 extern void wstr_to_str(char *dest, size_t size, const wchar_t *src); 76 extern char *wstr_to_astr(const wchar_t *src); 77 extern void str_to_wstr(wchar_t *dest, size_t dlen, const char *src); 76 78 77 79 extern char *str_chr(const char *str, wchar_t ch); -
uspace/lib/libc/include/unistd.h
r58d5803d r387416b 51 51 #endif 52 52 53 typedef uint32_t useconds_t; 54 53 55 extern int dup2(int oldfd, int newfd); 54 56 … … 68 70 69 71 extern void _exit(int status) __attribute__ ((noreturn)); 70 extern int usleep(u nsigned long usec);71 extern unsigned int sleep(unsigned int se conds);72 extern int usleep(useconds_t uses); 73 extern unsigned int sleep(unsigned int se); 72 74 73 75 #endif -
uspace/srv/bd/ata_bd/ata_bd.c
r58d5803d r387416b 55 55 #include <async.h> 56 56 #include <as.h> 57 #include <fibril_sync .h>57 #include <fibril_synch.h> 58 58 #include <string.h> 59 59 #include <devmap.h> -
uspace/srv/bd/ata_bd/ata_bd.h
r58d5803d r387416b 37 37 38 38 #include <sys/types.h> 39 #include <fibril_sync .h>39 #include <fibril_synch.h> 40 40 #include <string.h> 41 41 42 42 enum { 43 CTL_READ_START 43 CTL_READ_START = 0, 44 44 CTL_WRITE_START = 1, 45 45 }; 46 46 47 47 enum { 48 STATUS_FAILURE 48 STATUS_FAILURE = 0 49 49 }; 50 50 -
uspace/srv/bd/file_bd/file_bd.c
r58d5803d r387416b 45 45 #include <async.h> 46 46 #include <as.h> 47 #include <fibril_sync .h>47 #include <fibril_synch.h> 48 48 #include <devmap.h> 49 49 #include <sys/types.h> -
uspace/srv/bd/gxe_bd/gxe_bd.c
r58d5803d r387416b 43 43 #include <async.h> 44 44 #include <as.h> 45 #include <fibril_sync .h>45 #include <fibril_synch.h> 46 46 #include <devmap.h> 47 47 #include <sys/types.h> -
uspace/srv/bd/rd/rd.c
r58d5803d r387416b 51 51 #include <align.h> 52 52 #include <async.h> 53 #include <fibril_sync .h>53 #include <fibril_synch.h> 54 54 #include <stdio.h> 55 55 #include <devmap.h> -
uspace/srv/console/console.c
r58d5803d r387416b 50 50 #include <event.h> 51 51 #include <devmap.h> 52 #include <fibril_sync .h>52 #include <fibril_synch.h> 53 53 54 54 #include "console.h" … … 601 601 IPC_GET_ARG2(call)); 602 602 break; 603 case CONSOLE_GET_POS: 604 arg1 = cons->scr.position_x; 605 arg2 = cons->scr.position_y; 606 break; 603 607 case CONSOLE_GET_SIZE: 604 608 arg1 = fb_info.cols; -
uspace/srv/devmap/devmap.c
r58d5803d r387416b 42 42 #include <errno.h> 43 43 #include <bool.h> 44 #include <fibril_sync .h>44 #include <fibril_synch.h> 45 45 #include <stdlib.h> 46 46 #include <string.h> … … 867 867 } 868 868 869 /** 869 /** 870 870 * @} 871 871 */ -
uspace/srv/fs/devfs/devfs_ops.c
r58d5803d r387416b 42 42 #include <string.h> 43 43 #include <libfs.h> 44 #include <fibril_sync .h>44 #include <fibril_synch.h> 45 45 #include <adt/hash_table.h> 46 46 #include <sys/stat.h> -
uspace/srv/fs/fat/fat.h
r58d5803d r387416b 36 36 #include "fat_fat.h" 37 37 #include <ipc/ipc.h> 38 #include <fibril_sync .h>38 #include <fibril_synch.h> 39 39 #include <libfs.h> 40 40 #include <atomic.h> -
uspace/srv/fs/fat/fat_fat.c
r58d5803d r387416b 46 46 #include <align.h> 47 47 #include <assert.h> 48 #include <fibril_sync .h>48 #include <fibril_synch.h> 49 49 #include <mem.h> 50 50 -
uspace/srv/fs/fat/fat_idx.c
r58d5803d r387416b 43 43 #include <adt/list.h> 44 44 #include <assert.h> 45 #include <fibril_sync .h>45 #include <fibril_synch.h> 46 46 47 47 /** Each instance of this type describes one interval of freed VFS indices. */ -
uspace/srv/fs/fat/fat_ops.c
r58d5803d r387416b 52 52 #include <adt/list.h> 53 53 #include <assert.h> 54 #include <fibril_sync .h>54 #include <fibril_synch.h> 55 55 #include <sys/mman.h> 56 56 #include <align.h> -
uspace/srv/loader/arch/arm32/arm32.s
r58d5803d r387416b 36 36 # Jump to a program entry point 37 37 program_run: 38 # load ras_page address to r2 39 ldr r2, =ras_page 40 ldr r2, [r2] 38 41 # pcb is passed to the entry point in r1 (where it already is) 39 42 mov r15, r0 -
uspace/srv/part/mbr_part/mbr_part.c
r58d5803d r387416b 61 61 #include <async.h> 62 62 #include <as.h> 63 #include <fibril_sync .h>63 #include <fibril_synch.h> 64 64 #include <devmap.h> 65 65 #include <sys/types.h> -
uspace/srv/vfs/vfs.h
r58d5803d r387416b 36 36 #include <ipc/ipc.h> 37 37 #include <adt/list.h> 38 #include <fibril_sync .h>38 #include <fibril_synch.h> 39 39 #include <sys/types.h> 40 40 #include <devmap.h> -
uspace/srv/vfs/vfs_file.c
r58d5803d r387416b 42 42 #include <bool.h> 43 43 #include <fibril.h> 44 #include <fibril_sync .h>44 #include <fibril_synch.h> 45 45 #include "vfs.h" 46 46 -
uspace/srv/vfs/vfs_lookup.c
r58d5803d r387416b 43 43 #include <stdarg.h> 44 44 #include <bool.h> 45 #include <fibril_sync .h>45 #include <fibril_synch.h> 46 46 #include <adt/list.h> 47 47 #include <vfs/canonify.h> -
uspace/srv/vfs/vfs_node.c
r58d5803d r387416b 39 39 #include <stdlib.h> 40 40 #include <string.h> 41 #include <fibril_sync .h>41 #include <fibril_synch.h> 42 42 #include <adt/hash_table.h> 43 43 #include <assert.h> -
uspace/srv/vfs/vfs_ops.c
r58d5803d r387416b 44 44 #include <string.h> 45 45 #include <bool.h> 46 #include <fibril_sync .h>46 #include <fibril_synch.h> 47 47 #include <adt/list.h> 48 48 #include <unistd.h> -
uspace/srv/vfs/vfs_register.c
r58d5803d r387416b 46 46 #include <ctype.h> 47 47 #include <bool.h> 48 #include <fibril_sync .h>48 #include <fibril_synch.h> 49 49 #include <adt/list.h> 50 50 #include <as.h>
Note:
See TracChangeset
for help on using the changeset viewer.