| [51c1b003] | 1 | /*
|
|---|
| [df4ed85] | 2 | * Copyright (c) 2006 Josef Cejka
|
|---|
| [51c1b003] | 3 | * All rights reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | * modification, are permitted provided that the following conditions
|
|---|
| 7 | * are met:
|
|---|
| 8 | *
|
|---|
| 9 | * - Redistributions of source code must retain the above copyright
|
|---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | * documentation and/or other materials provided with the distribution.
|
|---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 15 | * derived from this software without specific prior written permission.
|
|---|
| 16 | *
|
|---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | */
|
|---|
| [ce5bcb4] | 28 |
|
|---|
| [231a60a] | 29 | /** @addtogroup console
|
|---|
| [1601f3c] | 30 | * @{
|
|---|
| [ce5bcb4] | 31 | */
|
|---|
| 32 | /** @file
|
|---|
| 33 | */
|
|---|
| 34 |
|
|---|
| [3209923] | 35 | #include <libc.h>
|
|---|
| [51c1b003] | 36 | #include <ipc/ipc.h>
|
|---|
| [e795203] | 37 | #include <ipc/kbd.h>
|
|---|
| [424cd43] | 38 | #include <io/keycode.h>
|
|---|
| [79460ae] | 39 | #include <ipc/fb.h>
|
|---|
| [51c1b003] | 40 | #include <ipc/services.h>
|
|---|
| 41 | #include <errno.h>
|
|---|
| [424cd43] | 42 | #include <keybuffer.h>
|
|---|
| [d3e6935] | 43 | #include <ipc/console.h>
|
|---|
| [eaf34f7] | 44 | #include <unistd.h>
|
|---|
| 45 | #include <async.h>
|
|---|
| [d9c8c81] | 46 | #include <adt/fifo.h>
|
|---|
| [2def788] | 47 | #include <sys/mman.h>
|
|---|
| [271b540] | 48 | #include <stdio.h>
|
|---|
| [171f9a1] | 49 | #include <string.h>
|
|---|
| [3ad953c] | 50 | #include <sysinfo.h>
|
|---|
| [05641a9e] | 51 | #include <event.h>
|
|---|
| [424cd43] | 52 | #include <devmap.h>
|
|---|
| [953769f] | 53 | #include <fibril_sync.h>
|
|---|
| [79460ae] | 54 |
|
|---|
| [9805cde] | 55 | #include "console.h"
|
|---|
| [e1c4849] | 56 | #include "gcons.h"
|
|---|
| [424cd43] | 57 | #include "screenbuffer.h"
|
|---|
| [e1c4849] | 58 |
|
|---|
| [1601f3c] | 59 | #define NAME "console"
|
|---|
| [51c1b003] | 60 |
|
|---|
| [424cd43] | 61 | #define MAX_DEVICE_NAME 32
|
|---|
| [eaf34f7] | 62 |
|
|---|
| [ccd1a14] | 63 | /** Phone to the keyboard driver. */
|
|---|
| 64 | static int kbd_phone;
|
|---|
| 65 |
|
|---|
| [dc033a1] | 66 | /** Information about framebuffer */
|
|---|
| [3993b3d] | 67 | struct {
|
|---|
| [1601f3c] | 68 | int phone; /**< Framebuffer phone */
|
|---|
| 69 | ipcarg_t cols; /**< Framebuffer columns */
|
|---|
| [424cd43] | 70 | ipcarg_t rows; /**< Framebuffer rows */
|
|---|
| [50cfa6c] | 71 | int color_cap; /**< Color capabilities (FB_CCAP_xxx) */
|
|---|
| [3993b3d] | 72 | } fb_info;
|
|---|
| 73 |
|
|---|
| [79460ae] | 74 | typedef struct {
|
|---|
| [424cd43] | 75 | size_t index; /**< Console index */
|
|---|
| 76 | size_t refcount; /**< Connection reference count */
|
|---|
| 77 | dev_handle_t dev_handle; /**< Device handle */
|
|---|
| 78 | keybuffer_t keybuffer; /**< Buffer for incoming keys. */
|
|---|
| 79 | screenbuffer_t scr; /**< Screenbuffer for saving screen
|
|---|
| 80 | contents and related settings. */
|
|---|
| 81 | } console_t;
|
|---|
| [79460ae] | 82 |
|
|---|
| [1601f3c] | 83 | /** Array of data for virtual consoles */
|
|---|
| [424cd43] | 84 | static console_t consoles[CONSOLE_COUNT];
|
|---|
| 85 |
|
|---|
| 86 | static console_t *active_console = &consoles[0];
|
|---|
| 87 | static console_t *prev_console = &consoles[0];
|
|---|
| 88 | static console_t *kernel_console = &consoles[KERNEL_CONSOLE];
|
|---|
| [1601f3c] | 89 |
|
|---|
| 90 | /** Pointer to memory shared with framebufer used for
|
|---|
| 91 | faster virtual console switching */
|
|---|
| 92 | static keyfield_t *interbuffer = NULL;
|
|---|
| [d2cc7e1] | 93 |
|
|---|
| [dc033a1] | 94 | /** Information on row-span yet unsent to FB driver. */
|
|---|
| 95 | struct {
|
|---|
| [424cd43] | 96 | size_t col; /**< Leftmost column of the span. */
|
|---|
| 97 | size_t row; /**< Row where the span lies. */
|
|---|
| 98 | size_t cnt; /**< Width of the span. */
|
|---|
| [dc033a1] | 99 | } fb_pending;
|
|---|
| [d2cc7e1] | 100 |
|
|---|
| [953769f] | 101 | static FIBRIL_MUTEX_INITIALIZE(input_mutex);
|
|---|
| 102 | static FIBRIL_CONDVAR_INITIALIZE(input_cv);
|
|---|
| [429acb9] | 103 |
|
|---|
| [8c6337d] | 104 | static void curs_visibility(bool visible)
|
|---|
| [429acb9] | 105 | {
|
|---|
| [8c6337d] | 106 | async_msg_1(fb_info.phone, FB_CURSOR_VISIBILITY, visible);
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | static void curs_hide_sync(void)
|
|---|
| 110 | {
|
|---|
| 111 | ipc_call_sync_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false);
|
|---|
| [429acb9] | 112 | }
|
|---|
| 113 |
|
|---|
| [424cd43] | 114 | static void curs_goto(size_t x, size_t y)
|
|---|
| [429acb9] | 115 | {
|
|---|
| [424cd43] | 116 | async_msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y);
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | static void screen_clear(void)
|
|---|
| 120 | {
|
|---|
| 121 | async_msg_0(fb_info.phone, FB_CLEAR);
|
|---|
| [429acb9] | 122 | }
|
|---|
| 123 |
|
|---|
| [ebfabf6] | 124 | static void screen_yield(void)
|
|---|
| [10270a8] | 125 | {
|
|---|
| [ebfabf6] | 126 | ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_YIELD);
|
|---|
| [10270a8] | 127 | }
|
|---|
| 128 |
|
|---|
| [ebfabf6] | 129 | static void screen_reclaim(void)
|
|---|
| [10270a8] | 130 | {
|
|---|
| [ebfabf6] | 131 | ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_RECLAIM);
|
|---|
| [10270a8] | 132 | }
|
|---|
| 133 |
|
|---|
| [ccd1a14] | 134 | static void kbd_yield(void)
|
|---|
| 135 | {
|
|---|
| 136 | ipc_call_sync_0_0(kbd_phone, KBD_YIELD);
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | static void kbd_reclaim(void)
|
|---|
| 140 | {
|
|---|
| 141 | ipc_call_sync_0_0(kbd_phone, KBD_RECLAIM);
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| [9805cde] | 144 | static void set_style(int style)
|
|---|
| [429acb9] | 145 | {
|
|---|
| [424cd43] | 146 | async_msg_1(fb_info.phone, FB_SET_STYLE, style);
|
|---|
| [429acb9] | 147 | }
|
|---|
| 148 |
|
|---|
| [9805cde] | 149 | static void set_color(int fgcolor, int bgcolor, int flags)
|
|---|
| [429acb9] | 150 | {
|
|---|
| [9805cde] | 151 | async_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags);
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | static void set_rgb_color(int fgcolor, int bgcolor)
|
|---|
| 155 | {
|
|---|
| 156 | async_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | static void set_attrs(attrs_t *attrs)
|
|---|
| 160 | {
|
|---|
| 161 | switch (attrs->t) {
|
|---|
| 162 | case at_style:
|
|---|
| 163 | set_style(attrs->a.s.style);
|
|---|
| 164 | break;
|
|---|
| 165 | case at_idx:
|
|---|
| 166 | set_color(attrs->a.i.fg_color, attrs->a.i.bg_color,
|
|---|
| 167 | attrs->a.i.flags);
|
|---|
| 168 | break;
|
|---|
| 169 | case at_rgb:
|
|---|
| 170 | set_rgb_color(attrs->a.r.fg_color, attrs->a.r.bg_color);
|
|---|
| 171 | break;
|
|---|
| 172 | }
|
|---|
| [429acb9] | 173 | }
|
|---|
| 174 |
|
|---|
| [a405563] | 175 | static int ccap_fb_to_con(int ccap_fb, int *ccap_con)
|
|---|
| [50cfa6c] | 176 | {
|
|---|
| 177 | switch (ccap_fb) {
|
|---|
| 178 | case FB_CCAP_NONE: *ccap_con = CONSOLE_CCAP_NONE; break;
|
|---|
| 179 | case FB_CCAP_STYLE: *ccap_con = CONSOLE_CCAP_STYLE; break;
|
|---|
| 180 | case FB_CCAP_INDEXED: *ccap_con = CONSOLE_CCAP_INDEXED; break;
|
|---|
| 181 | case FB_CCAP_RGB: *ccap_con = CONSOLE_CCAP_RGB; break;
|
|---|
| 182 | default: return EINVAL;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | return EOK;
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| [dc033a1] | 188 | /** Send an area of screenbuffer to the FB driver. */
|
|---|
| [424cd43] | 189 | static void fb_update_area(console_t *cons, ipcarg_t x0, ipcarg_t y0, ipcarg_t width, ipcarg_t height)
|
|---|
| [d2cc7e1] | 190 | {
|
|---|
| [dc033a1] | 191 | if (interbuffer) {
|
|---|
| [424cd43] | 192 | ipcarg_t x;
|
|---|
| 193 | ipcarg_t y;
|
|---|
| 194 |
|
|---|
| 195 | for (y = 0; y < height; y++) {
|
|---|
| 196 | for (x = 0; x < width; x++) {
|
|---|
| 197 | interbuffer[y * width + x] =
|
|---|
| 198 | *get_field_at(&cons->scr, x0 + x, y0 + y);
|
|---|
| [dc033a1] | 199 | }
|
|---|
| 200 | }
|
|---|
| [1601f3c] | 201 |
|
|---|
| 202 | async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
|
|---|
| [424cd43] | 203 | x0, y0, width, height);
|
|---|
| [dc033a1] | 204 | }
|
|---|
| [d2cc7e1] | 205 | }
|
|---|
| 206 |
|
|---|
| [dc033a1] | 207 | /** Flush pending cells to FB. */
|
|---|
| 208 | static void fb_pending_flush(void)
|
|---|
| [d2cc7e1] | 209 | {
|
|---|
| [1601f3c] | 210 | if (fb_pending.cnt > 0) {
|
|---|
| [424cd43] | 211 | fb_update_area(active_console, fb_pending.col,
|
|---|
| [1601f3c] | 212 | fb_pending.row, fb_pending.cnt, 1);
|
|---|
| 213 | fb_pending.cnt = 0;
|
|---|
| [d2cc7e1] | 214 | }
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| [dc033a1] | 217 | /** Mark a character cell as changed.
|
|---|
| 218 | *
|
|---|
| 219 | * This adds the cell to the pending rowspan if possible. Otherwise
|
|---|
| 220 | * the old span is flushed first.
|
|---|
| [1601f3c] | 221 | *
|
|---|
| [dc033a1] | 222 | */
|
|---|
| [424cd43] | 223 | static void cell_mark_changed(size_t col, size_t row)
|
|---|
| [429acb9] | 224 | {
|
|---|
| [1601f3c] | 225 | if (fb_pending.cnt != 0) {
|
|---|
| [424cd43] | 226 | if ((col != fb_pending.col + fb_pending.cnt)
|
|---|
| 227 | || (row != fb_pending.row)) {
|
|---|
| [dc033a1] | 228 | fb_pending_flush();
|
|---|
| 229 | }
|
|---|
| 230 | }
|
|---|
| [1601f3c] | 231 |
|
|---|
| 232 | if (fb_pending.cnt == 0) {
|
|---|
| [dc033a1] | 233 | fb_pending.col = col;
|
|---|
| [424cd43] | 234 | fb_pending.row = row;
|
|---|
| [d2cc7e1] | 235 | }
|
|---|
| [1601f3c] | 236 |
|
|---|
| 237 | fb_pending.cnt++;
|
|---|
| [429acb9] | 238 | }
|
|---|
| 239 |
|
|---|
| [dc033a1] | 240 | /** Print a character to the active VC with buffering. */
|
|---|
| [424cd43] | 241 | static void fb_putchar(wchar_t c, ipcarg_t col, ipcarg_t row)
|
|---|
| [dc033a1] | 242 | {
|
|---|
| [424cd43] | 243 | async_msg_3(fb_info.phone, FB_PUTCHAR, c, col, row);
|
|---|
| [dc033a1] | 244 | }
|
|---|
| 245 |
|
|---|
| 246 | /** Process a character from the client (TTY emulation). */
|
|---|
| [424cd43] | 247 | static void write_char(console_t *cons, wchar_t ch)
|
|---|
| [10569b1] | 248 | {
|
|---|
| [0ed2e0e] | 249 | bool flush_cursor = false;
|
|---|
| 250 |
|
|---|
| [7ce3cb2] | 251 | switch (ch) {
|
|---|
| [00bb6965] | 252 | case '\n':
|
|---|
| [dc033a1] | 253 | fb_pending_flush();
|
|---|
| [0ed2e0e] | 254 | flush_cursor = true;
|
|---|
| [424cd43] | 255 | cons->scr.position_y++;
|
|---|
| 256 | cons->scr.position_x = 0;
|
|---|
| [00bb6965] | 257 | break;
|
|---|
| 258 | case '\r':
|
|---|
| 259 | break;
|
|---|
| 260 | case '\t':
|
|---|
| [424cd43] | 261 | cons->scr.position_x += 8;
|
|---|
| 262 | cons->scr.position_x -= cons->scr.position_x % 8;
|
|---|
| [00bb6965] | 263 | break;
|
|---|
| 264 | case '\b':
|
|---|
| [424cd43] | 265 | if (cons->scr.position_x == 0)
|
|---|
| [10569b1] | 266 | break;
|
|---|
| [424cd43] | 267 | cons->scr.position_x--;
|
|---|
| 268 | if (cons == active_console)
|
|---|
| 269 | cell_mark_changed(cons->scr.position_x, cons->scr.position_y);
|
|---|
| 270 | screenbuffer_putchar(&cons->scr, ' ');
|
|---|
| [00bb6965] | 271 | break;
|
|---|
| [1601f3c] | 272 | default:
|
|---|
| [424cd43] | 273 | if (cons == active_console)
|
|---|
| 274 | cell_mark_changed(cons->scr.position_x, cons->scr.position_y);
|
|---|
| [1601f3c] | 275 |
|
|---|
| [424cd43] | 276 | screenbuffer_putchar(&cons->scr, ch);
|
|---|
| 277 | cons->scr.position_x++;
|
|---|
| [10569b1] | 278 | }
|
|---|
| [1601f3c] | 279 |
|
|---|
| [0ed2e0e] | 280 | if (cons->scr.position_x >= cons->scr.size_x) {
|
|---|
| 281 | flush_cursor = true;
|
|---|
| [424cd43] | 282 | cons->scr.position_y++;
|
|---|
| [0ed2e0e] | 283 | }
|
|---|
| [10569b1] | 284 |
|
|---|
| [424cd43] | 285 | if (cons->scr.position_y >= cons->scr.size_y) {
|
|---|
| [dc033a1] | 286 | fb_pending_flush();
|
|---|
| [424cd43] | 287 | cons->scr.position_y = cons->scr.size_y - 1;
|
|---|
| 288 | screenbuffer_clear_line(&cons->scr, cons->scr.top_line);
|
|---|
| 289 | cons->scr.top_line = (cons->scr.top_line + 1) % cons->scr.size_y;
|
|---|
| 290 |
|
|---|
| 291 | if (cons == active_console)
|
|---|
| [0cc4313] | 292 | async_msg_1(fb_info.phone, FB_SCROLL, 1);
|
|---|
| [10569b1] | 293 | }
|
|---|
| [0ed2e0e] | 294 |
|
|---|
| 295 | if (cons == active_console && flush_cursor)
|
|---|
| 296 | curs_goto(cons->scr.position_x, cons->scr.position_y);
|
|---|
| [424cd43] | 297 | cons->scr.position_x = cons->scr.position_x % cons->scr.size_x;
|
|---|
| [10569b1] | 298 | }
|
|---|
| 299 |
|
|---|
| [429acb9] | 300 | /** Switch to new console */
|
|---|
| [424cd43] | 301 | static void change_console(console_t *cons)
|
|---|
| [429acb9] | 302 | {
|
|---|
| [424cd43] | 303 | if (cons == active_console)
|
|---|
| [429acb9] | 304 | return;
|
|---|
| [1601f3c] | 305 |
|
|---|
| [dc033a1] | 306 | fb_pending_flush();
|
|---|
| [1601f3c] | 307 |
|
|---|
| [424cd43] | 308 | if (cons == kernel_console) {
|
|---|
| [1f83244] | 309 | async_serialize_start();
|
|---|
| [8c6337d] | 310 | curs_hide_sync();
|
|---|
| [76fca31] | 311 | gcons_in_kernel();
|
|---|
| [ebfabf6] | 312 | screen_yield();
|
|---|
| [ccd1a14] | 313 | kbd_yield();
|
|---|
| [1f83244] | 314 | async_serialize_end();
|
|---|
| [1601f3c] | 315 |
|
|---|
| [3ad953c] | 316 | if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {
|
|---|
| 317 | prev_console = active_console;
|
|---|
| [424cd43] | 318 | active_console = kernel_console;
|
|---|
| [3ad953c] | 319 | } else
|
|---|
| [424cd43] | 320 | cons = active_console;
|
|---|
| [01f5e17] | 321 | }
|
|---|
| [6d5005c] | 322 |
|
|---|
| [424cd43] | 323 | if (cons != kernel_console) {
|
|---|
| 324 | size_t x;
|
|---|
| 325 | size_t y;
|
|---|
| 326 | int rc = 0;
|
|---|
| 327 |
|
|---|
| [76fca31] | 328 | async_serialize_start();
|
|---|
| 329 |
|
|---|
| [424cd43] | 330 | if (active_console == kernel_console) {
|
|---|
| [ebfabf6] | 331 | screen_reclaim();
|
|---|
| [ccd1a14] | 332 | kbd_reclaim();
|
|---|
| [76fca31] | 333 | gcons_redraw_console();
|
|---|
| [10270a8] | 334 | }
|
|---|
| [76fca31] | 335 |
|
|---|
| [424cd43] | 336 | active_console = cons;
|
|---|
| 337 | gcons_change_console(cons->index);
|
|---|
| [76fca31] | 338 |
|
|---|
| [424cd43] | 339 | set_attrs(&cons->scr.attrs);
|
|---|
| [8c6337d] | 340 | curs_visibility(false);
|
|---|
| [76fca31] | 341 | if (interbuffer) {
|
|---|
| [424cd43] | 342 | for (y = 0; y < cons->scr.size_y; y++) {
|
|---|
| 343 | for (x = 0; x < cons->scr.size_x; x++) {
|
|---|
| 344 | interbuffer[y * cons->scr.size_x + x] =
|
|---|
| 345 | *get_field_at(&cons->scr, x, y);
|
|---|
| [76fca31] | 346 | }
|
|---|
| [dc033a1] | 347 | }
|
|---|
| [424cd43] | 348 |
|
|---|
| [76fca31] | 349 | /* This call can preempt, but we are already at the end */
|
|---|
| [dc033a1] | 350 | rc = async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
|
|---|
| [424cd43] | 351 | 0, 0, cons->scr.size_x,
|
|---|
| 352 | cons->scr.size_y);
|
|---|
| [76fca31] | 353 | }
|
|---|
| 354 |
|
|---|
| 355 | if ((!interbuffer) || (rc != 0)) {
|
|---|
| [424cd43] | 356 | set_attrs(&cons->scr.attrs);
|
|---|
| 357 | screen_clear();
|
|---|
| [76fca31] | 358 |
|
|---|
| [424cd43] | 359 | for (y = 0; y < cons->scr.size_y; y++)
|
|---|
| 360 | for (x = 0; x < cons->scr.size_x; x++) {
|
|---|
| 361 | keyfield_t *field = get_field_at(&cons->scr, x, y);
|
|---|
| 362 |
|
|---|
| 363 | if (!attrs_same(cons->scr.attrs, field->attrs))
|
|---|
| [9805cde] | 364 | set_attrs(&field->attrs);
|
|---|
| [424cd43] | 365 |
|
|---|
| 366 | cons->scr.attrs = field->attrs;
|
|---|
| [76fca31] | 367 | if ((field->character == ' ') &&
|
|---|
| [424cd43] | 368 | (attrs_same(field->attrs, cons->scr.attrs)))
|
|---|
| [76fca31] | 369 | continue;
|
|---|
| [1601f3c] | 370 |
|
|---|
| [424cd43] | 371 | fb_putchar(field->character, x, y);
|
|---|
| [76fca31] | 372 | }
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| [424cd43] | 375 | curs_goto(cons->scr.position_x, cons->scr.position_y);
|
|---|
| 376 | curs_visibility(cons->scr.is_cursor_visible);
|
|---|
| [76fca31] | 377 |
|
|---|
| 378 | async_serialize_end();
|
|---|
| [429acb9] | 379 | }
|
|---|
| 380 | }
|
|---|
| [10569b1] | 381 |
|
|---|
| [e87e18f] | 382 | /** Handler for keyboard */
|
|---|
| [eaf34f7] | 383 | static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
|
|---|
| [51c1b003] | 384 | {
|
|---|
| [424cd43] | 385 | /* Ignore parameters, the connection is already opened */
|
|---|
| [1601f3c] | 386 | while (true) {
|
|---|
| [424cd43] | 387 |
|
|---|
| 388 | ipc_call_t call;
|
|---|
| 389 | ipc_callid_t callid = async_get_call(&call);
|
|---|
| 390 |
|
|---|
| 391 | int retval;
|
|---|
| 392 | console_event_t ev;
|
|---|
| 393 |
|
|---|
| [eaf34f7] | 394 | switch (IPC_GET_METHOD(call)) {
|
|---|
| 395 | case IPC_M_PHONE_HUNGUP:
|
|---|
| 396 | /* TODO: Handle hangup */
|
|---|
| 397 | return;
|
|---|
| [fa09449] | 398 | case KBD_EVENT:
|
|---|
| 399 | /* Got event from keyboard driver. */
|
|---|
| [eaf34f7] | 400 | retval = 0;
|
|---|
| [fa09449] | 401 | ev.type = IPC_GET_ARG1(call);
|
|---|
| 402 | ev.key = IPC_GET_ARG2(call);
|
|---|
| 403 | ev.mods = IPC_GET_ARG3(call);
|
|---|
| 404 | ev.c = IPC_GET_ARG4(call);
|
|---|
| 405 |
|
|---|
| [f89979b] | 406 | if ((ev.key >= KC_F1) && (ev.key < KC_F1 +
|
|---|
| [0175246] | 407 | CONSOLE_COUNT) && ((ev.mods & KM_CTRL) == 0)) {
|
|---|
| [424cd43] | 408 | if (ev.key == KC_F1 + KERNEL_CONSOLE)
|
|---|
| 409 | change_console(kernel_console);
|
|---|
| [429acb9] | 410 | else
|
|---|
| [424cd43] | 411 | change_console(&consoles[ev.key - KC_F1]);
|
|---|
| [eaf34f7] | 412 | break;
|
|---|
| 413 | }
|
|---|
| [cf28036c] | 414 |
|
|---|
| [953769f] | 415 | fibril_mutex_lock(&input_mutex);
|
|---|
| [424cd43] | 416 | keybuffer_push(&active_console->keybuffer, &ev);
|
|---|
| [af65b72] | 417 | fibril_condvar_broadcast(&input_cv);
|
|---|
| [953769f] | 418 | fibril_mutex_unlock(&input_mutex);
|
|---|
| [eaf34f7] | 419 | break;
|
|---|
| 420 | default:
|
|---|
| [1029d3d3] | 421 | retval = ENOENT;
|
|---|
| [085bd54] | 422 | }
|
|---|
| [b74959bd] | 423 | ipc_answer_0(callid, retval);
|
|---|
| [eaf34f7] | 424 | }
|
|---|
| 425 | }
|
|---|
| 426 |
|
|---|
| [424cd43] | 427 | static void cons_write(console_t *cons, ipc_callid_t rid, ipc_call_t *request)
|
|---|
| [d2cc7e1] | 428 | {
|
|---|
| 429 | ipc_callid_t callid;
|
|---|
| [171f9a1] | 430 | size_t size;
|
|---|
| [0da4e41] | 431 | if (!async_data_write_receive(&callid, &size)) {
|
|---|
| [d2cc7e1] | 432 | ipc_answer_0(callid, EINVAL);
|
|---|
| 433 | ipc_answer_0(rid, EINVAL);
|
|---|
| [6568225] | 434 | return;
|
|---|
| [d2cc7e1] | 435 | }
|
|---|
| [1601f3c] | 436 |
|
|---|
| [424cd43] | 437 | char *buf = (char *) malloc(size);
|
|---|
| 438 | if (buf == NULL) {
|
|---|
| 439 | ipc_answer_0(callid, ENOMEM);
|
|---|
| 440 | ipc_answer_0(rid, ENOMEM);
|
|---|
| 441 | return;
|
|---|
| 442 | }
|
|---|
| [1601f3c] | 443 |
|
|---|
| [0da4e41] | 444 | (void) async_data_write_finalize(callid, buf, size);
|
|---|
| [1601f3c] | 445 |
|
|---|
| [6568225] | 446 | async_serialize_start();
|
|---|
| [1601f3c] | 447 |
|
|---|
| [424cd43] | 448 | size_t off = 0;
|
|---|
| [171f9a1] | 449 | while (off < size) {
|
|---|
| [424cd43] | 450 | wchar_t ch = str_decode(buf, &off, size);
|
|---|
| 451 | write_char(cons, ch);
|
|---|
| [d2cc7e1] | 452 | }
|
|---|
| [1601f3c] | 453 |
|
|---|
| [6568225] | 454 | async_serialize_end();
|
|---|
| [1601f3c] | 455 |
|
|---|
| [424cd43] | 456 | gcons_notify_char(cons->index);
|
|---|
| [171f9a1] | 457 | ipc_answer_1(rid, EOK, size);
|
|---|
| [424cd43] | 458 |
|
|---|
| 459 | free(buf);
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | static void cons_read(console_t *cons, ipc_callid_t rid, ipc_call_t *request)
|
|---|
| 463 | {
|
|---|
| 464 | ipc_callid_t callid;
|
|---|
| 465 | size_t size;
|
|---|
| [0da4e41] | 466 | if (!async_data_read_receive(&callid, &size)) {
|
|---|
| [424cd43] | 467 | ipc_answer_0(callid, EINVAL);
|
|---|
| 468 | ipc_answer_0(rid, EINVAL);
|
|---|
| 469 | return;
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | char *buf = (char *) malloc(size);
|
|---|
| 473 | if (buf == NULL) {
|
|---|
| 474 | ipc_answer_0(callid, ENOMEM);
|
|---|
| 475 | ipc_answer_0(rid, ENOMEM);
|
|---|
| 476 | return;
|
|---|
| 477 | }
|
|---|
| 478 |
|
|---|
| 479 | size_t pos = 0;
|
|---|
| 480 | console_event_t ev;
|
|---|
| [953769f] | 481 | fibril_mutex_lock(&input_mutex);
|
|---|
| [af65b72] | 482 | recheck:
|
|---|
| [424cd43] | 483 | while ((keybuffer_pop(&cons->keybuffer, &ev)) && (pos < size)) {
|
|---|
| 484 | if (ev.type == KEY_PRESS) {
|
|---|
| 485 | buf[pos] = ev.c;
|
|---|
| 486 | pos++;
|
|---|
| 487 | }
|
|---|
| 488 | }
|
|---|
| 489 |
|
|---|
| 490 | if (pos == size) {
|
|---|
| [0da4e41] | 491 | (void) async_data_read_finalize(callid, buf, size);
|
|---|
| [424cd43] | 492 | ipc_answer_1(rid, EOK, size);
|
|---|
| 493 | free(buf);
|
|---|
| 494 | } else {
|
|---|
| [af65b72] | 495 | fibril_condvar_wait(&input_cv, &input_mutex);
|
|---|
| 496 | goto recheck;
|
|---|
| [424cd43] | 497 | }
|
|---|
| [953769f] | 498 | fibril_mutex_unlock(&input_mutex);
|
|---|
| [424cd43] | 499 | }
|
|---|
| 500 |
|
|---|
| 501 | static void cons_get_event(console_t *cons, ipc_callid_t rid, ipc_call_t *request)
|
|---|
| 502 | {
|
|---|
| 503 | console_event_t ev;
|
|---|
| [953769f] | 504 |
|
|---|
| 505 | fibril_mutex_lock(&input_mutex);
|
|---|
| [af65b72] | 506 | recheck:
|
|---|
| [424cd43] | 507 | if (keybuffer_pop(&cons->keybuffer, &ev)) {
|
|---|
| 508 | ipc_answer_4(rid, EOK, ev.type, ev.key, ev.mods, ev.c);
|
|---|
| 509 | } else {
|
|---|
| [af65b72] | 510 | fibril_condvar_wait(&input_cv, &input_mutex);
|
|---|
| 511 | goto recheck;
|
|---|
| [424cd43] | 512 | }
|
|---|
| [953769f] | 513 | fibril_mutex_unlock(&input_mutex);
|
|---|
| [d2cc7e1] | 514 | }
|
|---|
| 515 |
|
|---|
| [eaf34f7] | 516 | /** Default thread for new connections */
|
|---|
| [b1f51f0] | 517 | static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
|
|---|
| [eaf34f7] | 518 | {
|
|---|
| [424cd43] | 519 | console_t *cons = NULL;
|
|---|
| [3ad953c] | 520 |
|
|---|
| [424cd43] | 521 | size_t i;
|
|---|
| 522 | for (i = 0; i < CONSOLE_COUNT; i++) {
|
|---|
| 523 | if (i == KERNEL_CONSOLE)
|
|---|
| 524 | continue;
|
|---|
| 525 |
|
|---|
| 526 | if (consoles[i].dev_handle == (dev_handle_t) IPC_GET_ARG1(*icall)) {
|
|---|
| 527 | cons = &consoles[i];
|
|---|
| 528 | break;
|
|---|
| 529 | }
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 | if (cons == NULL) {
|
|---|
| 533 | ipc_answer_0(iid, ENOENT);
|
|---|
| [eaf34f7] | 534 | return;
|
|---|
| 535 | }
|
|---|
| [424cd43] | 536 |
|
|---|
| 537 | ipc_callid_t callid;
|
|---|
| 538 | ipc_call_t call;
|
|---|
| 539 | ipcarg_t arg1;
|
|---|
| 540 | ipcarg_t arg2;
|
|---|
| 541 | ipcarg_t arg3;
|
|---|
| [50cfa6c] | 542 |
|
|---|
| 543 | int cons_ccap;
|
|---|
| 544 | int rc;
|
|---|
| [a7d2d78] | 545 |
|
|---|
| [085bd54] | 546 | async_serialize_start();
|
|---|
| [424cd43] | 547 | if (cons->refcount == 0)
|
|---|
| 548 | gcons_notify_connect(cons->index);
|
|---|
| 549 |
|
|---|
| 550 | cons->refcount++;
|
|---|
| [10569b1] | 551 |
|
|---|
| [eaf34f7] | 552 | /* Accept the connection */
|
|---|
| [b74959bd] | 553 | ipc_answer_0(iid, EOK);
|
|---|
| [3ad953c] | 554 |
|
|---|
| [1601f3c] | 555 | while (true) {
|
|---|
| [085bd54] | 556 | async_serialize_end();
|
|---|
| [eaf34f7] | 557 | callid = async_get_call(&call);
|
|---|
| [085bd54] | 558 | async_serialize_start();
|
|---|
| [3ad953c] | 559 |
|
|---|
| [96858e8] | 560 | arg1 = 0;
|
|---|
| 561 | arg2 = 0;
|
|---|
| [fa09449] | 562 | arg3 = 0;
|
|---|
| [1601f3c] | 563 |
|
|---|
| [eaf34f7] | 564 | switch (IPC_GET_METHOD(call)) {
|
|---|
| 565 | case IPC_M_PHONE_HUNGUP:
|
|---|
| [424cd43] | 566 | cons->refcount--;
|
|---|
| 567 | if (cons->refcount == 0)
|
|---|
| 568 | gcons_notify_disconnect(cons->index);
|
|---|
| [eaf34f7] | 569 | return;
|
|---|
| [4198f9c3] | 570 | case VFS_OUT_READ:
|
|---|
| [424cd43] | 571 | async_serialize_end();
|
|---|
| 572 | cons_read(cons, callid, &call);
|
|---|
| 573 | async_serialize_start();
|
|---|
| 574 | continue;
|
|---|
| [4198f9c3] | 575 | case VFS_OUT_WRITE:
|
|---|
| [6568225] | 576 | async_serialize_end();
|
|---|
| [424cd43] | 577 | cons_write(cons, callid, &call);
|
|---|
| [6568225] | 578 | async_serialize_start();
|
|---|
| [d2cc7e1] | 579 | continue;
|
|---|
| [4198f9c3] | 580 | case VFS_OUT_SYNC:
|
|---|
| [424cd43] | 581 | fb_pending_flush();
|
|---|
| 582 | if (cons == active_console) {
|
|---|
| 583 | async_req_0_0(fb_info.phone, FB_FLUSH);
|
|---|
| 584 |
|
|---|
| 585 | curs_goto(cons->scr.position_x, cons->scr.position_y);
|
|---|
| 586 | }
|
|---|
| 587 | break;
|
|---|
| [ad123964] | 588 | case CONSOLE_CLEAR:
|
|---|
| [3993b3d] | 589 | /* Send message to fb */
|
|---|
| [424cd43] | 590 | if (cons == active_console)
|
|---|
| 591 | async_msg_0(fb_info.phone, FB_CLEAR);
|
|---|
| [3993b3d] | 592 |
|
|---|
| [424cd43] | 593 | screenbuffer_clear(&cons->scr);
|
|---|
| [3993b3d] | 594 |
|
|---|
| [eaf34f7] | 595 | break;
|
|---|
| [ad123964] | 596 | case CONSOLE_GOTO:
|
|---|
| [424cd43] | 597 | screenbuffer_goto(&cons->scr,
|
|---|
| 598 | IPC_GET_ARG1(call), IPC_GET_ARG2(call));
|
|---|
| 599 | if (cons == active_console)
|
|---|
| [00bb6965] | 600 | curs_goto(IPC_GET_ARG1(call),
|
|---|
| [01f5e17] | 601 | IPC_GET_ARG2(call));
|
|---|
| [ad123964] | 602 | break;
|
|---|
| [424cd43] | 603 | case CONSOLE_GET_SIZE:
|
|---|
| 604 | arg1 = fb_info.cols;
|
|---|
| 605 | arg2 = fb_info.rows;
|
|---|
| [a9bd960c] | 606 | break;
|
|---|
| [50cfa6c] | 607 | case CONSOLE_GET_COLOR_CAP:
|
|---|
| 608 | rc = ccap_fb_to_con(fb_info.color_cap, &cons_ccap);
|
|---|
| 609 | if (rc != EOK) {
|
|---|
| 610 | ipc_answer_0(callid, rc);
|
|---|
| 611 | continue;
|
|---|
| 612 | }
|
|---|
| 613 | arg1 = cons_ccap;
|
|---|
| 614 | break;
|
|---|
| [a9bd960c] | 615 | case CONSOLE_SET_STYLE:
|
|---|
| [dc033a1] | 616 | fb_pending_flush();
|
|---|
| [9805cde] | 617 | arg1 = IPC_GET_ARG1(call);
|
|---|
| [424cd43] | 618 | screenbuffer_set_style(&cons->scr, arg1);
|
|---|
| 619 | if (cons == active_console)
|
|---|
| [9805cde] | 620 | set_style(arg1);
|
|---|
| 621 | break;
|
|---|
| 622 | case CONSOLE_SET_COLOR:
|
|---|
| [dc033a1] | 623 | fb_pending_flush();
|
|---|
| [9805cde] | 624 | arg1 = IPC_GET_ARG1(call);
|
|---|
| 625 | arg2 = IPC_GET_ARG2(call);
|
|---|
| 626 | arg3 = IPC_GET_ARG3(call);
|
|---|
| [424cd43] | 627 | screenbuffer_set_color(&cons->scr, arg1, arg2, arg3);
|
|---|
| 628 | if (cons == active_console)
|
|---|
| [9805cde] | 629 | set_color(arg1, arg2, arg3);
|
|---|
| 630 | break;
|
|---|
| 631 | case CONSOLE_SET_RGB_COLOR:
|
|---|
| [dc033a1] | 632 | fb_pending_flush();
|
|---|
| [a9bd960c] | 633 | arg1 = IPC_GET_ARG1(call);
|
|---|
| 634 | arg2 = IPC_GET_ARG2(call);
|
|---|
| [424cd43] | 635 | screenbuffer_set_rgb_color(&cons->scr, arg1, arg2);
|
|---|
| 636 | if (cons == active_console)
|
|---|
| [9805cde] | 637 | set_rgb_color(arg1, arg2);
|
|---|
| [0c6984e] | 638 | break;
|
|---|
| [a8b2b5b2] | 639 | case CONSOLE_CURSOR_VISIBILITY:
|
|---|
| [dc033a1] | 640 | fb_pending_flush();
|
|---|
| [a8b2b5b2] | 641 | arg1 = IPC_GET_ARG1(call);
|
|---|
| [424cd43] | 642 | cons->scr.is_cursor_visible = arg1;
|
|---|
| 643 | if (cons == active_console)
|
|---|
| [a8b2b5b2] | 644 | curs_visibility(arg1);
|
|---|
| 645 | break;
|
|---|
| [424cd43] | 646 | case CONSOLE_GET_EVENT:
|
|---|
| 647 | async_serialize_end();
|
|---|
| 648 | cons_get_event(cons, callid, &call);
|
|---|
| 649 | async_serialize_start();
|
|---|
| 650 | continue;
|
|---|
| [3fe00ee] | 651 | case CONSOLE_KCON_ENABLE:
|
|---|
| [424cd43] | 652 | change_console(kernel_console);
|
|---|
| [3fe00ee] | 653 | break;
|
|---|
| [eaf34f7] | 654 | }
|
|---|
| [424cd43] | 655 | ipc_answer_3(callid, EOK, arg1, arg2, arg3);
|
|---|
| [eaf34f7] | 656 | }
|
|---|
| 657 | }
|
|---|
| 658 |
|
|---|
| [3ad953c] | 659 | static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 660 | {
|
|---|
| 661 | change_console(prev_console);
|
|---|
| 662 | }
|
|---|
| 663 |
|
|---|
| [424cd43] | 664 | static bool console_init(void)
|
|---|
| [eaf34f7] | 665 | {
|
|---|
| [50cfa6c] | 666 | ipcarg_t color_cap;
|
|---|
| 667 |
|
|---|
| [4a68194] | 668 | /* Connect to keyboard driver */
|
|---|
| [4904de8] | 669 | kbd_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_KEYBOARD, 0, 0);
|
|---|
| 670 | if (kbd_phone < 0) {
|
|---|
| 671 | printf(NAME ": Failed to connect to keyboard service\n");
|
|---|
| [424cd43] | 672 | return false;
|
|---|
| [00bb6965] | 673 | }
|
|---|
| [51c1b003] | 674 |
|
|---|
| [424cd43] | 675 | ipcarg_t phonehash;
|
|---|
| [4904de8] | 676 | if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
|
|---|
| 677 | printf(NAME ": Failed to create callback from keyboard service\n");
|
|---|
| [424cd43] | 678 | return false;
|
|---|
| [4904de8] | 679 | }
|
|---|
| 680 |
|
|---|
| [290c0db] | 681 | async_new_connection(phonehash, 0, NULL, keyboard_events);
|
|---|
| [953769f] | 682 |
|
|---|
| [51c1b003] | 683 | /* Connect to framebuffer driver */
|
|---|
| [4904de8] | 684 | fb_info.phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VIDEO, 0, 0);
|
|---|
| 685 | if (fb_info.phone < 0) {
|
|---|
| 686 | printf(NAME ": Failed to connect to video service\n");
|
|---|
| 687 | return -1;
|
|---|
| [3993b3d] | 688 | }
|
|---|
| [429acb9] | 689 |
|
|---|
| [424cd43] | 690 | /* Register driver */
|
|---|
| 691 | int rc = devmap_driver_register(NAME, client_connection);
|
|---|
| 692 | if (rc < 0) {
|
|---|
| 693 | printf(NAME ": Unable to register driver (%d)\n", rc);
|
|---|
| 694 | return false;
|
|---|
| 695 | }
|
|---|
| [516ff92] | 696 |
|
|---|
| [e1c4849] | 697 | /* Initialize gcons */
|
|---|
| 698 | gcons_init(fb_info.phone);
|
|---|
| [3993b3d] | 699 |
|
|---|
| [424cd43] | 700 | /* Synchronize, the gcons could put something in queue */
|
|---|
| 701 | async_req_0_0(fb_info.phone, FB_FLUSH);
|
|---|
| 702 | async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows);
|
|---|
| [50cfa6c] | 703 | async_req_0_1(fb_info.phone, FB_GET_COLOR_CAP, &color_cap);
|
|---|
| 704 | fb_info.color_cap = color_cap;
|
|---|
| [1601f3c] | 705 |
|
|---|
| [7447572] | 706 | /* Set up shared memory buffer. */
|
|---|
| [424cd43] | 707 | size_t ib_size = sizeof(keyfield_t) * fb_info.cols * fb_info.rows;
|
|---|
| [7447572] | 708 | interbuffer = as_get_mappable_page(ib_size);
|
|---|
| [1601f3c] | 709 |
|
|---|
| [7447572] | 710 | if (as_area_create(interbuffer, ib_size, AS_AREA_READ |
|
|---|
| [424cd43] | 711 | AS_AREA_WRITE | AS_AREA_CACHEABLE) != interbuffer)
|
|---|
| [7447572] | 712 | interbuffer = NULL;
|
|---|
| [1601f3c] | 713 |
|
|---|
| [7447572] | 714 | if (interbuffer) {
|
|---|
| [0da4e41] | 715 | if (async_share_out_start(fb_info.phone, interbuffer,
|
|---|
| [27d293a] | 716 | AS_AREA_READ) != EOK) {
|
|---|
| [7447572] | 717 | as_area_destroy(interbuffer);
|
|---|
| [390a678] | 718 | interbuffer = NULL;
|
|---|
| 719 | }
|
|---|
| 720 | }
|
|---|
| [3ad953c] | 721 |
|
|---|
| [424cd43] | 722 | fb_pending.cnt = 0;
|
|---|
| [3ad953c] | 723 |
|
|---|
| [424cd43] | 724 | /* Inititalize consoles */
|
|---|
| 725 | size_t i;
|
|---|
| 726 | for (i = 0; i < CONSOLE_COUNT; i++) {
|
|---|
| 727 | if (i != KERNEL_CONSOLE) {
|
|---|
| 728 | if (screenbuffer_init(&consoles[i].scr,
|
|---|
| 729 | fb_info.cols, fb_info.rows) == NULL) {
|
|---|
| 730 | printf(NAME ": Unable to allocate screen buffer %u\n", i);
|
|---|
| 731 | return false;
|
|---|
| 732 | }
|
|---|
| 733 | screenbuffer_clear(&consoles[i].scr);
|
|---|
| 734 | keybuffer_init(&consoles[i].keybuffer);
|
|---|
| 735 | consoles[i].index = i;
|
|---|
| 736 | consoles[i].refcount = 0;
|
|---|
| 737 |
|
|---|
| 738 | char vc[MAX_DEVICE_NAME];
|
|---|
| 739 | snprintf(vc, MAX_DEVICE_NAME, "vc%u", i);
|
|---|
| 740 |
|
|---|
| 741 | if (devmap_device_register(vc, &consoles[i].dev_handle) != EOK) {
|
|---|
| 742 | devmap_hangup_phone(DEVMAP_DRIVER);
|
|---|
| 743 | printf(NAME ": Unable to register device %s\n", vc);
|
|---|
| 744 | return false;
|
|---|
| 745 | }
|
|---|
| 746 | }
|
|---|
| 747 | }
|
|---|
| 748 |
|
|---|
| [1035437] | 749 | /* Disable kernel output to the console */
|
|---|
| 750 | __SYSCALL0(SYS_DEBUG_DISABLE_CONSOLE);
|
|---|
| 751 |
|
|---|
| [424cd43] | 752 | /* Initialize the screen */
|
|---|
| [953769f] | 753 | async_serialize_start();
|
|---|
| [1035437] | 754 | gcons_redraw_console();
|
|---|
| [424cd43] | 755 | set_rgb_color(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
|
|---|
| 756 | screen_clear();
|
|---|
| 757 | curs_goto(0, 0);
|
|---|
| 758 | curs_visibility(active_console->scr.is_cursor_visible);
|
|---|
| [953769f] | 759 | async_serialize_end();
|
|---|
| [51c1b003] | 760 |
|
|---|
| [3ad953c] | 761 | /* Receive kernel notifications */
|
|---|
| [05641a9e] | 762 | if (event_subscribe(EVENT_KCONSOLE, 0) != EOK)
|
|---|
| 763 | printf(NAME ": Error registering kconsole notifications\n");
|
|---|
| [1601f3c] | 764 |
|
|---|
| [05641a9e] | 765 | async_set_interrupt_received(interrupt_received);
|
|---|
| [3ad953c] | 766 |
|
|---|
| [424cd43] | 767 | return true;
|
|---|
| 768 | }
|
|---|
| 769 |
|
|---|
| 770 | int main(int argc, char *argv[])
|
|---|
| 771 | {
|
|---|
| 772 | printf(NAME ": HelenOS Console service\n");
|
|---|
| 773 |
|
|---|
| [1035437] | 774 | if (!console_init())
|
|---|
| [424cd43] | 775 | return -1;
|
|---|
| 776 |
|
|---|
| 777 | printf(NAME ": Accepting connections\n");
|
|---|
| [eaf34f7] | 778 | async_manager();
|
|---|
| [3ad953c] | 779 |
|
|---|
| 780 | return 0;
|
|---|
| [51c1b003] | 781 | }
|
|---|
| [516ff92] | 782 |
|
|---|
| [ce5bcb4] | 783 | /** @}
|
|---|
| 784 | */
|
|---|