Changeset 70253688 in mainline for uspace/lib
- Timestamp:
- 2012-09-07T08:12:05Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e0c836e8
- Parents:
- 131d9a4 (diff), 8cf4823 (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/lib
- Files:
-
- 7 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r131d9a4 r70253688 95 95 generic/inetping.c \ 96 96 generic/io/asprintf.c \ 97 generic/io/input.c \ 97 98 generic/io/io.c \ 98 99 generic/io/chargrid.c \ … … 106 107 generic/io/vsnprintf.c \ 107 108 generic/io/printf_core.c \ 109 generic/io/con_srv.c \ 108 110 generic/io/console.c \ 109 111 generic/io/visualizer.c \ -
uspace/lib/c/arch/abs32le/_link.ld.in
r131d9a4 r70253688 15 15 #ifdef LOADER 16 16 . = 0x70001000 + SIZEOF_HEADERS; 17 18 .interp : {19 *(.interp);20 } :interp :text21 17 #else 22 18 . = 0x1000 + SIZEOF_HEADERS; 23 19 #endif 24 25 /* Make sure the code is aligned reasonably */26 . = ALIGN(., 16);27 20 28 21 .text : { … … 30 23 *(.rodata .rodata.*); 31 24 } :text 25 26 #ifdef LOADER 27 .interp : { 28 *(.interp); 29 } :interp :text 30 #endif 32 31 33 32 . = . + 0x1000; -
uspace/lib/c/arch/abs32le/include/types.h
r131d9a4 r70253688 47 47 48 48 typedef uint32_t sysarg_t; 49 typedef int32_t native_t; 49 50 50 51 typedef int32_t ssize_t; -
uspace/lib/c/arch/amd64/_link.ld.in
r131d9a4 r70253688 16 16 #ifdef LOADER 17 17 . = 0x70001000 + SIZEOF_HEADERS; 18 19 .interp : {20 *(.interp);21 } :interp :text22 18 #else 23 19 . = 0x1000 + SIZEOF_HEADERS; 24 20 #endif 25 26 /* Make sure the code is aligned reasonably */27 . = ALIGN(., 16);28 21 29 22 .init : { … … 35 28 *(.rodata .rodata.*); 36 29 } :text 30 31 #ifdef LOADER 32 .interp : { 33 *(.interp); 34 } :interp :text 35 #endif 37 36 38 37 . = . + 0x1000; -
uspace/lib/c/arch/amd64/include/types.h
r131d9a4 r70253688 47 47 48 48 typedef uint64_t sysarg_t; 49 typedef int64_t native_t; 49 50 50 51 typedef int64_t ssize_t; -
uspace/lib/c/arch/arm32/_link.ld.in
r131d9a4 r70253688 15 15 #ifdef LOADER 16 16 . = 0x70001000 + SIZEOF_HEADERS; 17 18 .interp : {19 *(.interp);20 } :interp :text21 17 #else 22 18 . = 0x1000 + SIZEOF_HEADERS; 23 19 #endif 24 25 /* Make sure the code is aligned reasonably */26 . = ALIGN(., 8);27 20 28 21 .init : { … … 34 27 *(.rodata .rodata.*); 35 28 } :text 29 30 #ifdef LOADER 31 .interp : { 32 *(.interp); 33 } :interp :text 34 #endif 36 35 37 36 . = . + 0x1000; -
uspace/lib/c/arch/arm32/include/types.h
r131d9a4 r70253688 48 48 49 49 typedef uint32_t sysarg_t; 50 typedef int32_t native_t; 50 51 51 52 typedef int32_t ssize_t; -
uspace/lib/c/arch/ia32/_link.ld.in
r131d9a4 r70253688 24 24 . = 0x1000 + SIZEOF_HEADERS; 25 25 #endif 26 27 #if defined(LOADER) || defined(DLEXE)28 .interp : {29 *(.interp);30 } :interp :text31 #endif32 33 /* Make sure the code is aligned reasonably */34 . = ALIGN(., 16);35 26 36 27 .init : { … … 71 62 } :text 72 63 #endif 64 65 #if defined(LOADER) || defined(DLEXE) 66 .interp : { 67 *(.interp); 68 } :interp :text 69 #endif 70 73 71 . = . + 0x1000; 74 72 -
uspace/lib/c/arch/ia32/include/types.h
r131d9a4 r70253688 47 47 48 48 typedef uint32_t sysarg_t; 49 typedef int32_t native_t; 49 50 50 51 typedef int32_t ssize_t; -
uspace/lib/c/arch/ia64/_link.ld.in
r131d9a4 r70253688 15 15 #ifdef LOADER 16 16 . = 0x800000000 + SIZEOF_HEADERS; 17 18 .interp : {19 *(.interp);20 } :interp :text21 17 #else 22 18 . = 0x4000 + SIZEOF_HEADERS; 23 19 #endif 24 20 25 /* Make sure the code is aligned reasonably*/21 /* Workaround proper alignment of the .init section */ 26 22 . = ALIGN(., 16); 27 23 … … 34 30 *(.rodata .rodata.*); 35 31 } :text 32 33 #ifdef LOADER 34 .interp : { 35 *(.interp); 36 } :interp :text 37 #endif 36 38 37 39 . = . + 0x4000; -
uspace/lib/c/arch/ia64/include/types.h
r131d9a4 r70253688 57 57 58 58 typedef uint64_t sysarg_t; 59 typedef int64_t native_t; 59 60 60 61 typedef int64_t ssize_t; -
uspace/lib/c/arch/mips32/_link.ld.in
r131d9a4 r70253688 15 15 #ifdef LOADER 16 16 . = 0x70004000 + SIZEOF_HEADERS; 17 18 .interp : {19 *(.interp);20 } :interp :text21 17 #else 22 18 . = 0x4000 + SIZEOF_HEADERS; 23 19 #endif 24 25 /* Make sure the code is aligned reasonably */26 . = ALIGN(., 16);27 20 28 21 .init : { … … 34 27 *(.rodata .rodata.*); 35 28 } :text 29 30 #ifdef LOADER 31 .interp : { 32 *(.interp); 33 } :interp :text 34 #endif 36 35 37 36 . = . + 0x4000; -
uspace/lib/c/arch/mips32/include/types.h
r131d9a4 r70253688 48 48 49 49 typedef uint32_t sysarg_t; 50 typedef int32_t native_t; 50 51 51 52 typedef int32_t ssize_t; -
uspace/lib/c/arch/mips64/_link.ld.in
r131d9a4 r70253688 16 16 #ifdef LOADER 17 17 . = 0x70004000 + SIZEOF_HEADERS; 18 19 .interp : {20 *(.interp);21 } :interp :text22 18 #else 23 19 . = 0x4000 + SIZEOF_HEADERS; 24 20 #endif 25 26 /* Make sure the code is aligned reasonably */27 . = ALIGN(., 16);28 21 29 22 .init : { … … 35 28 *(.rodata .rodata.*); 36 29 } :text 30 31 #ifdef LOADER 32 .interp : { 33 *(.interp); 34 } :interp :text 35 #endif 37 36 38 37 . = . + 0x4000; -
uspace/lib/c/arch/mips64/include/types.h
r131d9a4 r70253688 48 48 49 49 typedef uint64_t sysarg_t; 50 typedef int64_t native_t; 50 51 51 52 typedef int64_t ssize_t; -
uspace/lib/c/arch/ppc32/_link.ld.in
r131d9a4 r70253688 16 16 #ifdef LOADER 17 17 . = 0x70001000 + SIZEOF_HEADERS; 18 19 .interp : {20 *(.interp);21 } :interp :text22 18 #else 23 19 . = 0x1000 + SIZEOF_HEADERS; 24 20 #endif 25 26 /* Make sure the code is aligned reasonably */27 . = ALIGN(., 4);28 21 29 22 .init : { … … 35 28 *(.rodata .rodata.*); 36 29 } :text 30 31 #ifdef LOADER 32 .interp : { 33 *(.interp); 34 } :interp :text 35 #endif 37 36 38 37 . = . + 0x1000; -
uspace/lib/c/arch/ppc32/include/types.h
r131d9a4 r70253688 47 47 48 48 typedef uint32_t sysarg_t; 49 typedef int32_t native_t; 49 50 50 51 typedef int32_t ssize_t; -
uspace/lib/c/arch/sparc64/_link.ld.in
r131d9a4 r70253688 15 15 #ifdef LOADER 16 16 . = 0x70004000 + SIZEOF_HEADERS; 17 18 .interp : {19 *(.interp);20 } :interp :text21 17 #else 22 18 . = 0x4000 + SIZEOF_HEADERS; 23 19 #endif 24 25 /* Make sure the code is aligned reasonably */26 . = ALIGN(., 16);27 20 28 21 .init : { … … 34 27 *(.rodata .rodata.*); 35 28 } :text 29 30 #ifdef LOADER 31 .interp : { 32 *(.interp); 33 } :interp :text 34 #endif 36 35 37 36 . = . + 0x4000; -
uspace/lib/c/arch/sparc64/include/types.h
r131d9a4 r70253688 47 47 48 48 typedef uint64_t sysarg_t; 49 typedef int64_t native_t; 49 50 50 51 typedef int64_t ssize_t; -
uspace/lib/c/generic/io/console.c
r131d9a4 r70253688 38 38 #include <async.h> 39 39 #include <errno.h> 40 #include <stdio.h>41 40 #include <malloc.h> 42 41 #include <vfs/vfs_sess.h> … … 126 125 { 127 126 async_exch_t *exch = async_exchange_begin(ctrl->output_sess); 128 async_req_1_0(exch, CONSOLE_ CURSOR_VISIBILITY, (show != false));127 async_req_1_0(exch, CONSOLE_SET_CURSOR_VISIBILITY, (show != false)); 129 128 async_exchange_end(exch); 130 129 } … … 151 150 { 152 151 async_exch_t *exch = async_exchange_begin(ctrl->output_sess); 153 async_req_2_0(exch, CONSOLE_ GOTO, col, row);152 async_req_2_0(exch, CONSOLE_SET_POS, col, row); 154 153 async_exchange_end(exch); 155 154 } -
uspace/lib/c/generic/io/output.c
r131d9a4 r70253688 37 37 #include <as.h> 38 38 #include <ipc/output.h> 39 #include <io/concaps.h> 39 40 #include <io/output.h> 40 41 -
uspace/lib/c/generic/tls.c
r131d9a4 r70253688 42 42 #include <str.h> 43 43 #include <align.h> 44 #include <unistd.h> 44 45 45 46 /** Create TLS (Thread Local Storage) data structures. … … 57 58 58 59 tcb = __alloc_tls(&data, tls_size); 60 if (!tcb) 61 return NULL; 59 62 60 63 /* … … 89 92 90 93 result = malloc(sizeof(tcb_t) + size); 94 if (!result) 95 return NULL; 91 96 *data = ((void *)result) + sizeof(tcb_t); 97 92 98 return result; 93 99 } … … 118 124 size = ALIGN_UP(size, &_tls_alignment); 119 125 *data = memalign((uintptr_t) &_tls_alignment, sizeof(tcb_t) + size); 120 126 if (!*data) 127 return NULL; 121 128 tcb = (tcb_t *) (*data + size); 122 129 tcb->self = tcb; -
uspace/lib/c/include/io/console.h
r131d9a4 r70253688 37 37 38 38 #include <sys/time.h> 39 #include <io/concaps.h> 40 #include <io/kbd_event.h> 39 41 #include <io/keycode.h> 40 42 #include <async.h> 41 43 #include <bool.h> 42 44 #include <stdio.h> 43 44 typedef enum {45 CONSOLE_CAP_NONE = 0,46 CONSOLE_CAP_STYLE = 1,47 CONSOLE_CAP_INDEXED = 2,48 CONSOLE_CAP_RGB = 449 } console_caps_t;50 45 51 46 /** Console control structure. */ … … 69 64 aid_t input_aid; 70 65 } console_ctrl_t; 71 72 typedef enum {73 KEY_PRESS,74 KEY_RELEASE75 } kbd_event_type_t;76 77 /** Console event structure. */78 typedef struct {79 /** List handle */80 link_t link;81 82 /** Press or release event. */83 kbd_event_type_t type;84 85 /** Keycode of the key that was pressed or released. */86 keycode_t key;87 88 /** Bitmask of modifiers held. */89 keymod_t mods;90 91 /** The character that was generated or '\0' for none. */92 wchar_t c;93 } kbd_event_t;94 66 95 67 extern console_ctrl_t *console_init(FILE *, FILE *); -
uspace/lib/c/include/io/klog.h
r131d9a4 r70253688 38 38 #include <sys/types.h> 39 39 #include <stdarg.h> 40 #include <io/verify.h> 40 41 41 42 extern size_t klog_write(const void *, size_t); 42 43 extern void klog_update(void); 43 extern int klog_printf(const char *, ...); 44 extern int klog_printf(const char *, ...) 45 PRINTF_ATTRIBUTE(1, 2); 44 46 extern int klog_vprintf(const char *, va_list); 45 47 -
uspace/lib/c/include/io/log.h
r131d9a4 r70253688 37 37 #include <stdarg.h> 38 38 #include <inttypes.h> 39 #include < bool.h>39 #include <io/verify.h> 40 40 41 41 typedef enum { … … 46 46 LVL_DEBUG, 47 47 LVL_DEBUG2, 48 48 49 49 /** For checking range of values */ 50 50 LVL_LIMIT … … 62 62 extern log_t log_create(const char *, log_t); 63 63 64 extern void log_msg(log_t, log_level_t, const char *, ...); 64 extern void log_msg(log_t, log_level_t, const char *, ...) 65 PRINTF_ATTRIBUTE(3, 4); 65 66 extern void log_msgv(log_t, log_level_t, const char *, va_list); 66 67 -
uspace/lib/c/include/ipc/console.h
r131d9a4 r70253688 43 43 CONSOLE_GET_EVENT, 44 44 CONSOLE_GET_POS, 45 CONSOLE_ GOTO,45 CONSOLE_SET_POS, 46 46 CONSOLE_CLEAR, 47 47 CONSOLE_SET_STYLE, 48 48 CONSOLE_SET_COLOR, 49 49 CONSOLE_SET_RGB_COLOR, 50 CONSOLE_ CURSOR_VISIBILITY50 CONSOLE_SET_CURSOR_VISIBILITY 51 51 } console_request_t; 52 52 -
uspace/lib/c/include/stdio.h
r131d9a4 r70253688 39 39 #include <stdarg.h> 40 40 #include <str.h> 41 42 #ifndef NVERIFY_PRINTF 43 44 #define PRINTF_ATTRIBUTE(start, end) \ 45 __attribute__((format(gnu_printf, start, end))) 46 47 #else /* NVERIFY_PRINTF */ 48 49 #define PRINTF_ATTRIBUTE(start, end) 50 51 #endif /* NVERIFY_PRINTF */ 41 #include <io/verify.h> 52 42 53 43 #define EOF (-1) -
uspace/lib/draw/surface.c
r131d9a4 r70253688 44 44 surface_flags_t flags; 45 45 46 s ysarg_t dirty_x_lo;47 s ysarg_t dirty_x_hi;48 s ysarg_t dirty_y_lo;49 s ysarg_t dirty_y_hi;46 surface_coord_t dirty_x_lo; 47 surface_coord_t dirty_x_hi; 48 surface_coord_t dirty_y_lo; 49 surface_coord_t dirty_y_hi; 50 50 51 51 pixelmap_t pixmap; 52 52 }; 53 53 54 surface_t *surface_create( 55 sysarg_t width, sysarg_t height,pixel_t *pixbuf, surface_flags_t flags)54 surface_t *surface_create(surface_coord_t width, surface_coord_t height, 55 pixel_t *pixbuf, surface_flags_t flags) 56 56 { 57 57 surface_t *surface = (surface_t *) malloc(sizeof(surface_t)); … … 118 118 } 119 119 120 void surface_get_resolution(surface_t *surface, s ysarg_t *width, sysarg_t *height)120 void surface_get_resolution(surface_t *surface, surface_coord_t *width, surface_coord_t *height) 121 121 { 122 122 assert(width); … … 127 127 } 128 128 129 void surface_get_damaged_region(surface_t *surface, s ysarg_t *x, sysarg_t *y,130 s ysarg_t *width, sysarg_t *height)129 void surface_get_damaged_region(surface_t *surface, surface_coord_t *x, surface_coord_t *y, 130 surface_coord_t *width, surface_coord_t *height) 131 131 { 132 132 assert(x); … … 151 151 } 152 152 153 void surface_put_pixel(surface_t *surface, s ysarg_t x, sysarg_t y, pixel_t pixel)153 void surface_put_pixel(surface_t *surface, surface_coord_t x, surface_coord_t y, pixel_t pixel) 154 154 { 155 155 surface->dirty_x_lo = surface->dirty_x_lo > x ? x : surface->dirty_x_lo; … … 163 163 } 164 164 165 pixel_t surface_get_pixel(surface_t *surface, s ysarg_t x, sysarg_t y)165 pixel_t surface_get_pixel(surface_t *surface, surface_coord_t x, surface_coord_t y) 166 166 { 167 167 if (x < surface->pixmap.width && y < surface->pixmap.height) { -
uspace/lib/draw/surface.h
r131d9a4 r70253688 45 45 typedef struct surface surface_t; 46 46 47 typedef sysarg_t surface_coord_t; 48 47 49 typedef enum { 48 50 SURFACE_FLAG_NONE = 0, … … 50 52 } surface_flags_t; 51 53 52 extern surface_t *surface_create(s ysarg_t, sysarg_t, pixel_t *, surface_flags_t);54 extern surface_t *surface_create(surface_coord_t, surface_coord_t, pixel_t *, surface_flags_t); 53 55 extern void surface_destroy(surface_t *); 54 56 … … 56 58 extern pixel_t *surface_direct_access(surface_t *); 57 59 extern pixelmap_t *surface_pixmap_access(surface_t *); 58 extern void surface_get_resolution(surface_t *, s ysarg_t *, sysarg_t *);59 extern void surface_get_damaged_region(surface_t *, s ysarg_t *, sysarg_t *,60 s ysarg_t *, sysarg_t *);60 extern void surface_get_resolution(surface_t *, surface_coord_t *, surface_coord_t *); 61 extern void surface_get_damaged_region(surface_t *, surface_coord_t *, surface_coord_t *, 62 surface_coord_t *, surface_coord_t *); 61 63 extern void surface_reset_damaged_region(surface_t *); 62 64 63 extern void surface_put_pixel(surface_t *, s ysarg_t, sysarg_t, pixel_t);64 extern pixel_t surface_get_pixel(surface_t *, s ysarg_t, sysarg_t);65 extern void surface_put_pixel(surface_t *, surface_coord_t, surface_coord_t, pixel_t); 66 extern pixel_t surface_get_pixel(surface_t *, surface_coord_t, surface_coord_t); 65 67 66 68 #endif -
uspace/lib/drv/include/ddf/log.h
r131d9a4 r70253688 35 35 36 36 #include <io/log.h> 37 #include <io/verify.h> 37 38 38 39 extern int ddf_log_init(const char *); 39 extern void ddf_msg(log_level_t, const char *, ...); 40 extern void ddf_msg(log_level_t, const char *, ...) 41 PRINTF_ATTRIBUTE(2, 3); 40 42 41 43 extern void ddf_dump_buffer(char *, size_t, const void *, size_t, size_t, -
uspace/lib/ext4/libext4_filesystem.c
r131d9a4 r70253688 1284 1284 block_t *block; 1285 1285 while (level > 0) { 1286 1287 /* Sparse check */ 1288 if (current_block == 0) 1289 return EOK; 1290 1286 1291 int rc = block_get(&block, fs->device, current_block, 0); 1287 1292 if (rc != EOK) -
uspace/lib/gui/terminal.c
r131d9a4 r70253688 39 39 #include <surface.h> 40 40 #include <gfx/font-8x16.h> 41 #include <io/con_srv.h> 42 #include <io/concaps.h> 41 43 #include <io/console.h> 42 #include <ipc/console.h>43 44 #include <task.h> 44 45 #include <adt/list.h> … … 60 61 61 62 static LIST_INITIALIZE(terms); 63 64 static int term_open(con_srvs_t *, con_srv_t *); 65 static int term_close(con_srv_t *); 66 static int term_read(con_srv_t *, void *, size_t); 67 static int term_write(con_srv_t *, void *, size_t); 68 static void term_sync(con_srv_t *); 69 static void term_clear(con_srv_t *); 70 static void term_set_pos(con_srv_t *, sysarg_t col, sysarg_t row); 71 static int term_get_pos(con_srv_t *, sysarg_t *, sysarg_t *); 72 static int term_get_size(con_srv_t *, sysarg_t *, sysarg_t *); 73 static int term_get_color_cap(con_srv_t *, console_caps_t *); 74 static void term_set_style(con_srv_t *, console_style_t); 75 static void term_set_color(con_srv_t *, console_color_t, console_color_t, 76 console_color_attr_t); 77 static void term_set_rgb_color(con_srv_t *, pixel_t, pixel_t); 78 static void term_set_cursor_visibility(con_srv_t *, bool); 79 static int term_get_event(con_srv_t *, kbd_event_t *); 80 81 static con_ops_t con_ops = { 82 .open = term_open, 83 .close = term_close, 84 .read = term_read, 85 .write = term_write, 86 .sync = term_sync, 87 .clear = term_clear, 88 .set_pos = term_set_pos, 89 .get_pos = term_get_pos, 90 .get_size = term_get_size, 91 .get_color_cap = term_get_color_cap, 92 .set_style = term_set_style, 93 .set_color = term_set_color, 94 .set_rgb_color = term_set_rgb_color, 95 .set_cursor_visibility = term_set_cursor_visibility, 96 .get_event = term_get_event 97 }; 98 99 static terminal_t *srv_to_terminal(con_srv_t *srv) 100 { 101 return srv->srvs->sarg; 102 } 62 103 63 104 static void getterm(const char *svc, const char *app) … … 341 382 } 342 383 343 static void term_set_cursor(terminal_t *term, sysarg_t col, sysarg_t row) 344 { 345 fibril_mutex_lock(&term->mtx); 346 chargrid_set_cursor(term->frontbuf, col, row); 347 fibril_mutex_unlock(&term->mtx); 348 349 term_update(term); 350 } 351 352 static void term_set_cursor_visibility(terminal_t *term, bool visible) 353 { 354 fibril_mutex_lock(&term->mtx); 355 chargrid_set_cursor_visibility(term->frontbuf, visible); 356 fibril_mutex_unlock(&term->mtx); 357 358 term_update(term); 359 } 360 361 static void term_read(terminal_t *term, ipc_callid_t iid, ipc_call_t *icall) 362 { 363 ipc_callid_t callid; 364 size_t size; 365 if (!async_data_read_receive(&callid, &size)) { 366 async_answer_0(callid, EINVAL); 367 async_answer_0(iid, EINVAL); 368 return; 369 } 370 371 char *buf = (char *) malloc(size); 372 if (buf == NULL) { 373 async_answer_0(callid, ENOMEM); 374 async_answer_0(iid, ENOMEM); 375 return; 376 } 377 384 static int term_open(con_srvs_t *srvs, con_srv_t *srv) 385 { 386 return EOK; 387 } 388 389 static int term_close(con_srv_t *srv) 390 { 391 return EOK; 392 } 393 394 static int term_read(con_srv_t *srv, void *buf, size_t size) 395 { 396 terminal_t *term = srv_to_terminal(srv); 397 uint8_t *bbuf = buf; 378 398 size_t pos = 0; 379 399 … … 386 406 /* Copy to the buffer remaining characters. */ 387 407 while ((pos < size) && (term->char_remains_len > 0)) { 388 b uf[pos] = term->char_remains[0];408 bbuf[pos] = term->char_remains[0]; 389 409 pos++; 390 410 … … 416 436 } 417 437 418 (void) async_data_read_finalize(callid, buf, size); 419 async_answer_1(iid, EOK, size); 420 free(buf); 438 return size; 421 439 } 422 440 … … 449 467 } 450 468 451 static void term_write(terminal_t *term, ipc_callid_t iid, ipc_call_t *icall) 452 { 453 void *buf; 454 size_t size; 455 int rc = async_data_write_accept(&buf, false, 0, 0, 0, &size); 456 457 if (rc != EOK) { 458 async_answer_0(iid, rc); 459 return; 460 } 469 static int term_write(con_srv_t *srv, void *data, size_t size) 470 { 471 terminal_t *term = srv_to_terminal(srv); 461 472 462 473 size_t off = 0; 463 474 while (off < size) 464 term_write_char(term, str_decode(buf, &off, size)); 465 466 async_answer_1(iid, EOK, size); 467 free(buf); 468 } 469 470 static void term_clear(terminal_t *term) 471 { 475 term_write_char(term, str_decode(data, &off, size)); 476 477 return size; 478 } 479 480 static void term_sync(con_srv_t *srv) 481 { 482 terminal_t *term = srv_to_terminal(srv); 483 484 term_update(term); 485 } 486 487 static void term_clear(con_srv_t *srv) 488 { 489 terminal_t *term = srv_to_terminal(srv); 490 472 491 fibril_mutex_lock(&term->mtx); 473 492 chargrid_clear(term->frontbuf); … … 477 496 } 478 497 479 static void term_get_cursor(terminal_t *term, ipc_callid_t iid, ipc_call_t *icall) 480 { 481 sysarg_t col; 482 sysarg_t row; 483 484 fibril_mutex_lock(&term->mtx); 485 chargrid_get_cursor(term->frontbuf, &col, &row); 486 fibril_mutex_unlock(&term->mtx); 487 488 async_answer_2(iid, EOK, col, row); 489 } 490 491 static void term_set_style(terminal_t *term, console_style_t style) 492 { 498 static void term_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row) 499 { 500 terminal_t *term = srv_to_terminal(srv); 501 502 fibril_mutex_lock(&term->mtx); 503 chargrid_set_cursor(term->frontbuf, col, row); 504 fibril_mutex_unlock(&term->mtx); 505 506 term_update(term); 507 } 508 509 static int term_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row) 510 { 511 terminal_t *term = srv_to_terminal(srv); 512 513 fibril_mutex_lock(&term->mtx); 514 chargrid_get_cursor(term->frontbuf, col, row); 515 fibril_mutex_unlock(&term->mtx); 516 517 return EOK; 518 } 519 520 static int term_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows) 521 { 522 terminal_t *term = srv_to_terminal(srv); 523 524 fibril_mutex_lock(&term->mtx); 525 *cols = term->cols; 526 *rows = term->rows; 527 fibril_mutex_unlock(&term->mtx); 528 529 return EOK; 530 } 531 532 static int term_get_color_cap(con_srv_t *srv, console_caps_t *caps) 533 { 534 (void) srv; 535 *caps = TERM_CAPS; 536 537 return EOK; 538 } 539 540 static void term_set_style(con_srv_t *srv, console_style_t style) 541 { 542 terminal_t *term = srv_to_terminal(srv); 543 493 544 fibril_mutex_lock(&term->mtx); 494 545 chargrid_set_style(term->frontbuf, style); … … 496 547 } 497 548 498 static void term_set_color( terminal_t *term, console_color_t bgcolor,549 static void term_set_color(con_srv_t *srv, console_color_t bgcolor, 499 550 console_color_t fgcolor, console_color_attr_t attr) 500 551 { 552 terminal_t *term = srv_to_terminal(srv); 553 501 554 fibril_mutex_lock(&term->mtx); 502 555 chargrid_set_color(term->frontbuf, bgcolor, fgcolor, attr); … … 504 557 } 505 558 506 static void term_set_rgb_color( terminal_t *term, pixel_t bgcolor,559 static void term_set_rgb_color(con_srv_t *srv, pixel_t bgcolor, 507 560 pixel_t fgcolor) 508 561 { 562 terminal_t *term = srv_to_terminal(srv); 563 509 564 fibril_mutex_lock(&term->mtx); 510 565 chargrid_set_rgb_color(term->frontbuf, bgcolor, fgcolor); … … 512 567 } 513 568 514 static void term_get_event(terminal_t *term, ipc_callid_t iid, ipc_call_t *icall) 515 { 569 static void term_set_cursor_visibility(con_srv_t *srv, bool visible) 570 { 571 terminal_t *term = srv_to_terminal(srv); 572 573 fibril_mutex_lock(&term->mtx); 574 chargrid_set_cursor_visibility(term->frontbuf, visible); 575 fibril_mutex_unlock(&term->mtx); 576 577 term_update(term); 578 } 579 580 static int term_get_event(con_srv_t *srv, kbd_event_t *event) 581 { 582 terminal_t *term = srv_to_terminal(srv); 516 583 link_t *link = prodcons_consume(&term->input_pc); 517 kbd_event_t *event = list_get_instance(link, kbd_event_t, link); 518 519 async_answer_4(iid, EOK, event->type, event->key, event->mods, event->c); 520 free(event); 584 kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link); 585 586 *event = *kevent; 587 free(kevent); 588 return EOK; 521 589 } 522 590 … … 612 680 613 681 if (atomic_postinc(&term->refcnt) == 0) 614 term_set_cursor_visibility(term, true); 615 616 /* Accept the connection */ 617 async_answer_0(iid, EOK); 618 619 while (true) { 620 ipc_call_t call; 621 ipc_callid_t callid = async_get_call(&call); 622 623 if (!IPC_GET_IMETHOD(call)) 624 return; 625 626 switch (IPC_GET_IMETHOD(call)) { 627 case VFS_OUT_READ: 628 term_read(term, callid, &call); 629 break; 630 case VFS_OUT_WRITE: 631 term_write(term, callid, &call); 632 break; 633 case VFS_OUT_SYNC: 634 term_update(term); 635 async_answer_0(callid, EOK); 636 break; 637 case CONSOLE_CLEAR: 638 term_clear(term); 639 async_answer_0(callid, EOK); 640 break; 641 case CONSOLE_GOTO: 642 term_set_cursor(term, IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 643 async_answer_0(callid, EOK); 644 break; 645 case CONSOLE_GET_POS: 646 term_get_cursor(term, callid, &call); 647 break; 648 case CONSOLE_GET_SIZE: 649 async_answer_2(callid, EOK, term->cols, term->rows); 650 break; 651 case CONSOLE_GET_COLOR_CAP: 652 async_answer_1(callid, EOK, TERM_CAPS); 653 break; 654 case CONSOLE_SET_STYLE: 655 term_set_style(term, IPC_GET_ARG1(call)); 656 async_answer_0(callid, EOK); 657 break; 658 case CONSOLE_SET_COLOR: 659 term_set_color(term, IPC_GET_ARG1(call), IPC_GET_ARG2(call), 660 IPC_GET_ARG3(call)); 661 async_answer_0(callid, EOK); 662 break; 663 case CONSOLE_SET_RGB_COLOR: 664 term_set_rgb_color(term, IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 665 async_answer_0(callid, EOK); 666 break; 667 case CONSOLE_CURSOR_VISIBILITY: 668 term_set_cursor_visibility(term, IPC_GET_ARG1(call)); 669 async_answer_0(callid, EOK); 670 break; 671 case CONSOLE_GET_EVENT: 672 term_get_event(term, callid, &call); 673 break; 674 default: 675 async_answer_0(callid, EINVAL); 676 } 677 } 682 chargrid_set_cursor_visibility(term->frontbuf, true); 683 684 con_conn(iid, icall, &term->srvs); 678 685 } 679 686 … … 727 734 728 735 async_set_client_connection(term_connection); 736 con_srvs_init(&term->srvs); 737 term->srvs.ops = &con_ops; 738 term->srvs.sarg = term; 739 729 740 int rc = loc_server_register(NAME); 730 741 if (rc != EOK) { -
uspace/lib/gui/terminal.h
r131d9a4 r70253688 41 41 #include <font.h> 42 42 #include <io/chargrid.h> 43 #include <io/con_srv.h> 43 44 #include <adt/list.h> 44 45 #include <adt/prodcons.h> … … 66 67 67 68 service_id_t dsid; 69 con_srvs_t srvs; 68 70 } terminal_t; 69 71
Note:
See TracChangeset
for help on using the changeset viewer.