Changeset 907bb49 in mainline
- Timestamp:
- 2009-03-18T22:22:31Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 266daf5a
- Parents:
- eada065e
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
reada065e r907bb49 45 45 #include <malloc.h> 46 46 #include <macros.h> 47 #include <console.h> 47 48 #include "init.h" 48 49 #include "version.h" -
uspace/app/klog/klog.c
reada065e r907bb49 42 42 #include <sysinfo.h> 43 43 #include <io/stream.h> 44 #include <console.h> 44 45 #include <errno.h> 45 46 -
uspace/app/tetris/input.c
reada065e r907bb49 59 59 #include <async.h> 60 60 #include <ipc/console.h> 61 #include <console.h> 61 62 #include <kbd/kbd.h> 62 63 … … 115 116 again: 116 117 if (!getchar_inprog) { 117 cons_phone = get_console_phone();118 cons_phone = console_phone_get(); 118 119 getchar_inprog = async_send_2(cons_phone, 119 120 CONSOLE_GETKEY, 0, 0, &charcall); -
uspace/lib/libc/generic/console.c
reada065e r907bb49 1 1 /* 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2006 Jakub Vana 2 4 * Copyright (c) 2008 Jiri Svoboda 3 5 * All rights reserved. … … 36 38 #include <io/stream.h> 37 39 #include <ipc/console.h> 40 #include <ipc/services.h> 38 41 #include <console.h> 42 43 static int console_phone = -1; 44 45 void console_open(void) 46 { 47 if (console_phone < 0) { 48 int phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, 0); 49 if (phone >= 0) 50 console_phone = phone; 51 } 52 } 53 54 void console_close(void) 55 { 56 if (console_phone >= 0) { 57 if (ipc_hangup(console_phone) == 0) { 58 console_phone = -1; 59 } 60 } 61 } 62 63 int console_phone_get(void) 64 { 65 if (console_phone < 0) 66 console_open(); 67 68 return console_phone; 69 } 70 71 void console_wait(void) 72 { 73 while (console_phone < 0) 74 console_open(); 75 } 39 76 40 77 void console_clear(void) 41 78 { 42 int cons_phone = get_console_phone();79 int cons_phone = console_phone_get(); 43 80 async_msg_0(cons_phone, CONSOLE_CLEAR); 44 81 } … … 46 83 void console_goto(int row, int col) 47 84 { 48 int cons_phone = get_console_phone();85 int cons_phone = console_phone_get(); 49 86 async_msg_2(cons_phone, CONSOLE_GOTO, row, col); 87 } 88 89 void console_putchar(int c) 90 { 91 int cons_phone = console_phone_get(); 92 async_msg_1(cons_phone, CONSOLE_PUTCHAR, c); 50 93 } 51 94 52 95 void console_flush(void) 53 96 { 54 int cons_phone = get_console_phone();97 int cons_phone = console_phone_get(); 55 98 async_msg_0(cons_phone, CONSOLE_FLUSH); 56 99 } … … 58 101 int console_get_size(int *rows, int *cols) 59 102 { 60 int cons_phone = get_console_phone();103 int cons_phone = console_phone_get(); 61 104 ipcarg_t r, c; 62 105 int rc; … … 72 115 void console_set_style(int style) 73 116 { 74 int cons_phone = get_console_phone();117 int cons_phone = console_phone_get(); 75 118 async_msg_1(cons_phone, CONSOLE_SET_STYLE, style); 76 119 } … … 78 121 void console_set_color(int fg_color, int bg_color, int flags) 79 122 { 80 int cons_phone = get_console_phone();123 int cons_phone = console_phone_get(); 81 124 async_msg_3(cons_phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags); 82 125 } … … 84 127 void console_set_rgb_color(int fg_color, int bg_color) 85 128 { 86 int cons_phone = get_console_phone();129 int cons_phone = console_phone_get(); 87 130 async_msg_2(cons_phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color); 88 131 } … … 90 133 void console_cursor_visibility(int show) 91 134 { 92 int cons_phone = get_console_phone();135 int cons_phone = console_phone_get(); 93 136 async_msg_1(cons_phone, CONSOLE_CURSOR_VISIBILITY, show != 0); 94 137 } -
uspace/lib/libc/generic/io/stream.c
reada065e r907bb49 44 44 #include <ipc/services.h> 45 45 #include <ipc/console.h> 46 #include <console.h> 46 47 #include <kbd/kbd.h> 47 48 #include <unistd.h> 48 49 #include <async.h> 49 50 #include <sys/types.h> 50 51 static int console_phone = -1;52 51 53 52 ssize_t write_stderr(const void *buf, size_t count) … … 58 57 ssize_t read_stdin(void *buf, size_t count) 59 58 { 60 open_console(); 61 if (console_phone >= 0) { 59 int cons_phone = console_phone_get(); 60 61 if (cons_phone >= 0) { 62 62 kbd_event_t ev; 63 63 int rc; … … 80 80 ssize_t write_stdout(const void *buf, size_t count) 81 81 { 82 open_console(); 83 if (console_phone >= 0) { 82 int cons_phone = console_phone_get(); 83 84 if (cons_phone >= 0) { 84 85 int i; 85 86 86 87 for (i = 0; i < count; i++) 87 async_msg_1(console_phone, CONSOLE_PUTCHAR, 88 ((const char *) buf)[i]); 89 88 console_putchar(((const char *) buf)[i]); 89 90 90 return count; 91 91 } else 92 92 return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, count); 93 }94 95 void open_console(void)96 {97 if (console_phone < 0) {98 int phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, 0);99 if (phone >= 0)100 console_phone = phone;101 }102 }103 104 void close_console(void)105 {106 if (console_phone >= 0) {107 if (ipc_hangup(console_phone) == 0) {108 console_phone = -1;109 }110 }111 93 } 112 94 … … 116 98 } 117 99 118 int get_console_phone(void)119 {120 if (console_phone < 0)121 console_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_CONSOLE, 0, 0);122 123 return console_phone;124 }125 126 void console_wait(void)127 {128 while (console_phone < 0)129 get_console_phone();130 }131 132 100 /** @} 133 101 */ -
uspace/lib/libc/generic/kbd.c
reada065e r907bb49 38 38 #include <ipc/ipc.h> 39 39 #include <ipc/console.h> 40 #include <console.h> 40 41 #include <async.h> 41 42 42 43 int kbd_get_event(kbd_event_t *ev) 43 44 { 44 int cons ole_phone = get_console_phone();45 int cons_phone = console_phone_get(); 45 46 ipcarg_t r0, r1, r2, r3; 46 47 int rc; 47 48 48 rc = async_req_0_4(console_phone, CONSOLE_GETKEY, &r0, &r1, &r2, &r3); 49 if (cons_phone < 0) 50 return -1; 51 52 rc = async_req_0_4(cons_phone, CONSOLE_GETKEY, &r0, &r1, &r2, &r3); 49 53 if (rc < 0) 50 54 return -1; -
uspace/lib/libc/include/console.h
reada065e r907bb49 39 39 #include <console/color.h> 40 40 41 extern void console_open(void); 42 extern void console_close(void); 43 44 extern int console_phone_get(void); 45 extern void console_wait(void); 46 41 47 extern void console_clear(void); 42 48 extern void console_goto(int, int); 49 extern void console_putchar(int); 43 50 extern void console_flush(void); 51 44 52 extern int console_get_size(int *, int *); 45 53 extern void console_set_style(int); -
uspace/lib/libc/include/io/stream.h
reada065e r907bb49 40 40 #define EMFILE -17 41 41 42 extern void open_console(void);43 extern void close_console(void);44 42 extern void klog_update(void); 45 43 … … 48 46 extern ssize_t write_stderr(const void *, size_t); 49 47 50 extern int get_console_phone(void);51 extern void console_wait(void);52 53 48 #endif 54 49 -
uspace/srv/loader/main.c
reada065e r907bb49 54 54 #include <ipc/loader.h> 55 55 #include <loader/pcb.h> 56 #include <console.h> 56 57 #include <errno.h> 57 58 #include <async.h> … … 283 284 DPRINTF("Run ELF interpreter.\n"); 284 285 DPRINTF("Entry point: 0x%lx\n", interp_info.entry); 285 c lose_console();286 console_close(); 286 287 287 288 ipc_answer_0(rid, EOK); … … 289 290 } else { 290 291 /* Statically linked program */ 291 c lose_console();292 console_close(); 292 293 ipc_answer_0(rid, EOK); 293 294 elf_run(&prog_info, &pcb);
Note:
See TracChangeset
for help on using the changeset viewer.