Rev 3386 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3386 | Rev 4153 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | #include <libc.h> |
40 | #include <libc.h> |
41 | #include <ipc/ipc.h> |
41 | #include <ipc/ipc.h> |
42 | #include <ipc/ns.h> |
42 | #include <ipc/ns.h> |
43 | #include <ipc/fb.h> |
43 | #include <ipc/fb.h> |
44 | #include <ipc/services.h> |
44 | #include <ipc/services.h> |
45 | #include <console.h> |
45 | #include <ipc/console.h> |
- | 46 | #include <kbd/kbd.h> |
|
46 | #include <unistd.h> |
47 | #include <unistd.h> |
47 | #include <async.h> |
48 | #include <async.h> |
48 | #include <sys/types.h> |
49 | #include <sys/types.h> |
49 | 50 | ||
50 | static int console_phone = -1; |
51 | static int console_phone = -1; |
Line 56... | Line 57... | ||
56 | 57 | ||
57 | ssize_t read_stdin(void *buf, size_t count) |
58 | ssize_t read_stdin(void *buf, size_t count) |
58 | { |
59 | { |
59 | open_console(); |
60 | open_console(); |
60 | if (console_phone >= 0) { |
61 | if (console_phone >= 0) { |
- | 62 | kbd_event_t ev; |
|
61 | ipcarg_t r0, r1; |
63 | int rc; |
62 | size_t i = 0; |
64 | size_t i = 0; |
63 | 65 | ||
64 | while (i < count) { |
66 | while (i < count) { |
- | 67 | do { |
|
65 | if (async_req_0_2(console_phone, CONSOLE_GETCHAR, &r0, &r1) < 0) |
68 | rc = kbd_get_event(&ev); |
66 | return -1; |
69 | if (rc < 0) return -1; |
- | 70 | } while (ev.c == 0 || ev.type == KE_RELEASE); |
|
- | 71 | ||
67 | ((char *) buf)[i++] = r0; |
72 | ((char *) buf)[i++] = ev.c; |
68 | } |
73 | } |
69 | return i; |
74 | return i; |
70 | } else { |
75 | } else { |
71 | return -1; |
76 | return -1; |
72 | } |
77 | } |
Line 108... | Line 113... | ||
108 | void klog_update(void) |
113 | void klog_update(void) |
109 | { |
114 | { |
110 | (void) __SYSCALL3(SYS_KLOG, 1, NULL, 0); |
115 | (void) __SYSCALL3(SYS_KLOG, 1, NULL, 0); |
111 | } |
116 | } |
112 | 117 | ||
113 | int get_cons_phone(void) |
118 | int get_console_phone(void) |
114 | { |
119 | { |
115 | open_console(); |
120 | if (console_phone < 0) |
- | 121 | console_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_CONSOLE, 0, 0); |
|
- | 122 | ||
116 | return console_phone; |
123 | return console_phone; |
117 | } |
124 | } |
118 | 125 | ||
- | 126 | void console_wait(void) |
|
- | 127 | { |
|
- | 128 | while (console_phone < 0) |
|
- | 129 | get_console_phone(); |
|
- | 130 | } |
|
- | 131 | ||
119 | /** @} |
132 | /** @} |
120 | */ |
133 | */ |