Changeset 2595dab in mainline for uspace/lib/libc/generic/io/console.c
- Timestamp:
- 2009-06-03T19:26:28Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d00ae4c
- Parents:
- ca3ba3a
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/io/console.c
rca3ba3a r2595dab 2 2 * Copyright (c) 2006 Josef Cejka 3 3 * Copyright (c) 2006 Jakub Vana 4 * Copyright (c) 2008 Jiri Svoboda 4 5 * All rights reserved. 5 6 * … … 34 35 */ 35 36 36 #include <io/io.h>37 #include <io/stream.h>38 #include <string.h>39 #include <malloc.h>40 37 #include <libc.h> 41 #include <ipc/ipc.h> 42 #include <ipc/ns.h> 43 #include <ipc/fb.h> 44 #include <ipc/services.h> 38 #include <async.h> 39 #include <io/console.h> 45 40 #include <ipc/console.h> 46 #include <console.h>47 #include <kbd/kbd.h>48 #include <unistd.h>49 #include <async.h>50 #include <sys/types.h>51 41 52 ssize_t read_stdin(void *buf, size_t count)42 void console_clear(int phone) 53 43 { 54 int cons_phone = console_open(false); 55 56 if (cons_phone >= 0) { 57 kbd_event_t ev; 58 int rc; 59 size_t i = 0; 60 61 while (i < count) { 62 do { 63 rc = kbd_get_event(&ev); 64 if (rc < 0) return -1; 65 } while (ev.c == 0 || ev.type == KE_RELEASE); 66 67 ((char *) buf)[i++] = ev.c; 68 } 69 return i; 70 } else 71 return -1; 44 async_msg_0(phone, CONSOLE_CLEAR); 72 45 } 73 46 74 /** Write a string to klog. */ 75 int klog_puts(const char *str) 47 int console_get_size(int phone, ipcarg_t *rows, ipcarg_t *cols) 76 48 { 77 return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) str, str_size(str));49 return async_req_0_2(phone, CONSOLE_GET_SIZE, rows, cols); 78 50 } 79 51 80 void klog_update(void)52 void console_set_style(int phone, int style) 81 53 { 82 (void) __SYSCALL3(SYS_KLOG, 1, NULL, 0); 54 async_msg_1(phone, CONSOLE_SET_STYLE, style); 55 } 56 57 void console_set_color(int phone, int fg_color, int bg_color, int flags) 58 { 59 async_msg_3(phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags); 60 } 61 62 void console_set_rgb_color(int phone, int fg_color, int bg_color) 63 { 64 async_msg_2(phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color); 65 } 66 67 void console_cursor_visibility(int phone, bool show) 68 { 69 async_msg_1(phone, CONSOLE_CURSOR_VISIBILITY, show != false); 70 } 71 72 void console_kcon_enable(int phone) 73 { 74 async_msg_0(phone, CONSOLE_KCON_ENABLE); 75 } 76 77 void console_goto(int phone, ipcarg_t row, ipcarg_t col) 78 { 79 async_msg_2(phone, CONSOLE_GOTO, row, col); 80 } 81 82 bool console_get_event(int phone, console_event_t *event) 83 { 84 ipcarg_t type; 85 ipcarg_t key; 86 ipcarg_t mods; 87 ipcarg_t c; 88 89 int rc = async_req_0_4(phone, CONSOLE_GET_EVENT, &type, &key, &mods, &c); 90 if (rc < 0) 91 return false; 92 93 event->type = type; 94 event->key = key; 95 event->mods = mods; 96 event->c = c; 97 98 return true; 83 99 } 84 100
Note:
See TracChangeset
for help on using the changeset viewer.