| 1 | /*
|
|---|
| 2 | * Copyright (c) 2006 Ondrej Palkovsky
|
|---|
| 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 | */
|
|---|
| 28 |
|
|---|
| 29 | /** @defgroup egafb EGA framebuffer
|
|---|
| 30 | * @brief HelenOS EGA framebuffer.
|
|---|
| 31 | * @ingroup fbs
|
|---|
| 32 | * @{
|
|---|
| 33 | */
|
|---|
| 34 | /** @file
|
|---|
| 35 | */
|
|---|
| 36 |
|
|---|
| 37 | #include <stdlib.h>
|
|---|
| 38 | #include <unistd.h>
|
|---|
| 39 | #include <align.h>
|
|---|
| 40 | #include <async.h>
|
|---|
| 41 | #include <errno.h>
|
|---|
| 42 | #include <stdio.h>
|
|---|
| 43 | #include <ddi.h>
|
|---|
| 44 | #include <sysinfo.h>
|
|---|
| 45 | #include <as.h>
|
|---|
| 46 | #include <ipc/fb.h>
|
|---|
| 47 | #include <ipc/ns.h>
|
|---|
| 48 | #include <ipc/services.h>
|
|---|
| 49 | #include <libarch/ddi.h>
|
|---|
| 50 | #include <io/style.h>
|
|---|
| 51 | #include <io/color.h>
|
|---|
| 52 | #include <io/screenbuffer.h>
|
|---|
| 53 | #include <sys/types.h>
|
|---|
| 54 | #include "ega.h"
|
|---|
| 55 | #include "main.h"
|
|---|
| 56 |
|
|---|
| 57 | // FIXME: remove this header
|
|---|
| 58 | #include <kernel/ipc/ipc_methods.h>
|
|---|
| 59 |
|
|---|
| 60 | #define MAX_SAVED_SCREENS 256
|
|---|
| 61 |
|
|---|
| 62 | typedef struct saved_screen {
|
|---|
| 63 | short *data;
|
|---|
| 64 | } saved_screen;
|
|---|
| 65 |
|
|---|
| 66 | saved_screen saved_screens[MAX_SAVED_SCREENS];
|
|---|
| 67 |
|
|---|
| 68 | #define EGA_IO_BASE ((ioport8_t *) 0x3d4)
|
|---|
| 69 | #define EGA_IO_SIZE 2
|
|---|
| 70 |
|
|---|
| 71 | /* Allow only 1 connection */
|
|---|
| 72 | static int client_connected = 0;
|
|---|
| 73 |
|
|---|
| 74 | static sysarg_t scr_width;
|
|---|
| 75 | static sysarg_t scr_height;
|
|---|
| 76 | static uint8_t *scr_addr;
|
|---|
| 77 |
|
|---|
| 78 | static uint8_t style_normal = 0xf0;
|
|---|
| 79 | static uint8_t style_inverted = 0x0f;
|
|---|
| 80 | static uint8_t style;
|
|---|
| 81 |
|
|---|
| 82 | static uint8_t style_to_ega_style(uint8_t style)
|
|---|
| 83 | {
|
|---|
| 84 | switch (style) {
|
|---|
| 85 | case STYLE_EMPHASIS:
|
|---|
| 86 | return (style_normal | 0x04);
|
|---|
| 87 | case STYLE_SELECTED:
|
|---|
| 88 | return (style_inverted | 0x40);
|
|---|
| 89 | case STYLE_INVERTED:
|
|---|
| 90 | return style_inverted;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | return style_normal;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | static uint8_t color_to_ega_style(uint8_t fg_color, uint8_t bg_color,
|
|---|
| 97 | uint8_t attr)
|
|---|
| 98 | {
|
|---|
| 99 | uint8_t style = (fg_color & 7) | ((bg_color & 7) << 4);
|
|---|
| 100 |
|
|---|
| 101 | if (attr & CATTR_BRIGHT)
|
|---|
| 102 | style |= 0x08;
|
|---|
| 103 |
|
|---|
| 104 | return style;
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | static uint8_t rgb_to_ega_style(uint32_t fg, uint32_t bg)
|
|---|
| 108 | {
|
|---|
| 109 | return (fg > bg) ? style_inverted : style_normal;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | static uint8_t attr_to_ega_style(const attrs_t *attr)
|
|---|
| 113 | {
|
|---|
| 114 | switch (attr->t) {
|
|---|
| 115 | case at_style:
|
|---|
| 116 | return style_to_ega_style(attr->a.s.style);
|
|---|
| 117 | case at_idx:
|
|---|
| 118 | return color_to_ega_style(attr->a.i.fg_color,
|
|---|
| 119 | attr->a.i.bg_color, attr->a.i.flags);
|
|---|
| 120 | case at_rgb:
|
|---|
| 121 | return rgb_to_ega_style(attr->a.r.fg_color, attr->a.r.bg_color);
|
|---|
| 122 | default:
|
|---|
| 123 | return style_normal;
|
|---|
| 124 | }
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | static uint8_t ega_glyph(wchar_t ch)
|
|---|
| 128 | {
|
|---|
| 129 | if (ch >= 0 && ch < 128)
|
|---|
| 130 | return ch;
|
|---|
| 131 |
|
|---|
| 132 | return '?';
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | static void clrscr(void)
|
|---|
| 136 | {
|
|---|
| 137 | unsigned i;
|
|---|
| 138 |
|
|---|
| 139 | for (i = 0; i < scr_width * scr_height; i++) {
|
|---|
| 140 | scr_addr[i * 2] = ' ';
|
|---|
| 141 | scr_addr[i * 2 + 1] = style;
|
|---|
| 142 | }
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | static void cursor_goto(sysarg_t col, sysarg_t row)
|
|---|
| 146 | {
|
|---|
| 147 | sysarg_t cursor = col + scr_width * row;
|
|---|
| 148 |
|
|---|
| 149 | pio_write_8(EGA_IO_BASE, 0xe);
|
|---|
| 150 | pio_write_8(EGA_IO_BASE + 1, (cursor >> 8) & 0xff);
|
|---|
| 151 | pio_write_8(EGA_IO_BASE, 0xf);
|
|---|
| 152 | pio_write_8(EGA_IO_BASE + 1, cursor & 0xff);
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | static void cursor_disable(void)
|
|---|
| 156 | {
|
|---|
| 157 | pio_write_8(EGA_IO_BASE, 0xa);
|
|---|
| 158 |
|
|---|
| 159 | uint8_t stat = pio_read_8(EGA_IO_BASE + 1);
|
|---|
| 160 |
|
|---|
| 161 | pio_write_8(EGA_IO_BASE, 0xa);
|
|---|
| 162 | pio_write_8(EGA_IO_BASE + 1, stat | (1 << 5));
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | static void cursor_enable(void)
|
|---|
| 166 | {
|
|---|
| 167 | pio_write_8(EGA_IO_BASE, 0xa);
|
|---|
| 168 |
|
|---|
| 169 | uint8_t stat = pio_read_8(EGA_IO_BASE + 1);
|
|---|
| 170 |
|
|---|
| 171 | pio_write_8(EGA_IO_BASE, 0xa);
|
|---|
| 172 | pio_write_8(EGA_IO_BASE + 1, stat & (~(1 << 5)));
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | static void scroll(ssize_t rows)
|
|---|
| 176 | {
|
|---|
| 177 | size_t i;
|
|---|
| 178 |
|
|---|
| 179 | if (rows > 0) {
|
|---|
| 180 | memmove(scr_addr, ((char *) scr_addr) + rows * scr_width * 2,
|
|---|
| 181 | scr_width * scr_height * 2 - rows * scr_width * 2);
|
|---|
| 182 | for (i = 0; i < rows * scr_width; i++)
|
|---|
| 183 | (((short *) scr_addr) + scr_width * scr_height - rows *
|
|---|
| 184 | scr_width)[i] = ((style << 8) + ' ');
|
|---|
| 185 | } else if (rows < 0) {
|
|---|
| 186 | memmove(((char *)scr_addr) - rows * scr_width * 2, scr_addr,
|
|---|
| 187 | scr_width * scr_height * 2 + rows * scr_width * 2);
|
|---|
| 188 | for (i = 0; i < -rows * scr_width; i++)
|
|---|
| 189 | ((short *) scr_addr)[i] = ((style << 8 ) + ' ');
|
|---|
| 190 | }
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 | static void printchar(wchar_t c, sysarg_t col, sysarg_t row)
|
|---|
| 194 | {
|
|---|
| 195 | scr_addr[(row * scr_width + col) * 2] = ega_glyph(c);
|
|---|
| 196 | scr_addr[(row * scr_width + col) * 2 + 1] = style;
|
|---|
| 197 |
|
|---|
| 198 | cursor_goto(col + 1, row);
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | /** Draw text data to viewport.
|
|---|
| 202 | *
|
|---|
| 203 | * @param vport Viewport id
|
|---|
| 204 | * @param data Text data.
|
|---|
| 205 | * @param x Leftmost column of the area.
|
|---|
| 206 | * @param y Topmost row of the area.
|
|---|
| 207 | * @param w Number of rows.
|
|---|
| 208 | * @param h Number of columns.
|
|---|
| 209 | *
|
|---|
| 210 | */
|
|---|
| 211 | static void draw_text_data(keyfield_t *data, sysarg_t x, sysarg_t y,
|
|---|
| 212 | sysarg_t w, sysarg_t h)
|
|---|
| 213 | {
|
|---|
| 214 | sysarg_t i;
|
|---|
| 215 | sysarg_t j;
|
|---|
| 216 | keyfield_t *field;
|
|---|
| 217 | uint8_t *dp;
|
|---|
| 218 |
|
|---|
| 219 | for (j = 0; j < h; j++) {
|
|---|
| 220 | for (i = 0; i < w; i++) {
|
|---|
| 221 | field = &data[j * w + i];
|
|---|
| 222 | dp = &scr_addr[2 * ((y + j) * scr_width + (x + i))];
|
|---|
| 223 |
|
|---|
| 224 | dp[0] = ega_glyph(field->character);
|
|---|
| 225 | dp[1] = attr_to_ega_style(&field->attrs);
|
|---|
| 226 | }
|
|---|
| 227 | }
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | static int save_screen(void)
|
|---|
| 231 | {
|
|---|
| 232 | sysarg_t i;
|
|---|
| 233 |
|
|---|
| 234 | /* Find empty screen */
|
|---|
| 235 | for (i = 0; (i < MAX_SAVED_SCREENS) && (saved_screens[i].data); i++);
|
|---|
| 236 |
|
|---|
| 237 | if (i == MAX_SAVED_SCREENS)
|
|---|
| 238 | return EINVAL;
|
|---|
| 239 |
|
|---|
| 240 | if (!(saved_screens[i].data = malloc(2 * scr_width * scr_height)))
|
|---|
| 241 | return ENOMEM;
|
|---|
| 242 |
|
|---|
| 243 | memcpy(saved_screens[i].data, scr_addr, 2 * scr_width * scr_height);
|
|---|
| 244 | return (int) i;
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | static int print_screen(sysarg_t i)
|
|---|
| 248 | {
|
|---|
| 249 | if ((i >= MAX_SAVED_SCREENS) || (saved_screens[i].data))
|
|---|
| 250 | memcpy(scr_addr, saved_screens[i].data, 2 * scr_width *
|
|---|
| 251 | scr_height);
|
|---|
| 252 | else
|
|---|
| 253 | return EINVAL;
|
|---|
| 254 |
|
|---|
| 255 | return (int) i;
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall)
|
|---|
| 259 | {
|
|---|
| 260 | size_t intersize = 0;
|
|---|
| 261 | keyfield_t *interbuf = NULL;
|
|---|
| 262 |
|
|---|
| 263 | if (client_connected) {
|
|---|
| 264 | async_answer_0(iid, ELIMIT);
|
|---|
| 265 | return;
|
|---|
| 266 | }
|
|---|
| 267 |
|
|---|
| 268 | /* Accept connection */
|
|---|
| 269 | client_connected = 1;
|
|---|
| 270 | async_answer_0(iid, EOK);
|
|---|
| 271 |
|
|---|
| 272 | while (true) {
|
|---|
| 273 | ipc_call_t call;
|
|---|
| 274 | ipc_callid_t callid = async_get_call(&call);
|
|---|
| 275 |
|
|---|
| 276 | wchar_t c;
|
|---|
| 277 |
|
|---|
| 278 | sysarg_t col;
|
|---|
| 279 | sysarg_t row;
|
|---|
| 280 | sysarg_t w;
|
|---|
| 281 | sysarg_t h;
|
|---|
| 282 |
|
|---|
| 283 | ssize_t rows;
|
|---|
| 284 |
|
|---|
| 285 | uint8_t bg_color;
|
|---|
| 286 | uint8_t fg_color;
|
|---|
| 287 | uint8_t attr;
|
|---|
| 288 |
|
|---|
| 289 | uint32_t fg_rgb;
|
|---|
| 290 | uint32_t bg_rgb;
|
|---|
| 291 |
|
|---|
| 292 | sysarg_t scr;
|
|---|
| 293 | int retval;
|
|---|
| 294 |
|
|---|
| 295 | if (!IPC_GET_IMETHOD(call)) {
|
|---|
| 296 | client_connected = 0;
|
|---|
| 297 | async_answer_0(callid, EOK);
|
|---|
| 298 |
|
|---|
| 299 | /* Exit thread */
|
|---|
| 300 | return;
|
|---|
| 301 | }
|
|---|
| 302 |
|
|---|
| 303 | switch (IPC_GET_IMETHOD(call)) {
|
|---|
| 304 | case IPC_M_SHARE_OUT:
|
|---|
| 305 | /* We accept one area for data interchange */
|
|---|
| 306 | intersize = IPC_GET_ARG2(call);
|
|---|
| 307 | if (intersize >= scr_width * scr_height *
|
|---|
| 308 | sizeof(*interbuf)) {
|
|---|
| 309 | receive_comm_area(callid, &call,
|
|---|
| 310 | (void *) &interbuf);
|
|---|
| 311 | continue;
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | retval = EINVAL;
|
|---|
| 315 | break;
|
|---|
| 316 | case FB_DRAW_TEXT_DATA:
|
|---|
| 317 | if (!interbuf) {
|
|---|
| 318 | retval = EINVAL;
|
|---|
| 319 | break;
|
|---|
| 320 | }
|
|---|
| 321 |
|
|---|
| 322 | col = IPC_GET_ARG1(call);
|
|---|
| 323 | row = IPC_GET_ARG2(call);
|
|---|
| 324 | w = IPC_GET_ARG3(call);
|
|---|
| 325 | h = IPC_GET_ARG4(call);
|
|---|
| 326 |
|
|---|
| 327 | if ((col + w > scr_width) || (row + h > scr_height)) {
|
|---|
| 328 | retval = EINVAL;
|
|---|
| 329 | break;
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | draw_text_data(interbuf, col, row, w, h);
|
|---|
| 333 | retval = 0;
|
|---|
| 334 | break;
|
|---|
| 335 | case FB_GET_CSIZE:
|
|---|
| 336 | async_answer_2(callid, EOK, scr_width, scr_height);
|
|---|
| 337 | continue;
|
|---|
| 338 | case FB_GET_COLOR_CAP:
|
|---|
| 339 | async_answer_1(callid, EOK, FB_CCAP_INDEXED);
|
|---|
| 340 | continue;
|
|---|
| 341 | case FB_CLEAR:
|
|---|
| 342 | clrscr();
|
|---|
| 343 | retval = 0;
|
|---|
| 344 | break;
|
|---|
| 345 | case FB_PUTCHAR:
|
|---|
| 346 | c = IPC_GET_ARG1(call);
|
|---|
| 347 | col = IPC_GET_ARG2(call);
|
|---|
| 348 | row = IPC_GET_ARG3(call);
|
|---|
| 349 |
|
|---|
| 350 | if ((col >= scr_width) || (row >= scr_height)) {
|
|---|
| 351 | retval = EINVAL;
|
|---|
| 352 | break;
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 | printchar(c, col, row);
|
|---|
| 356 | retval = 0;
|
|---|
| 357 | break;
|
|---|
| 358 | case FB_CURSOR_GOTO:
|
|---|
| 359 | col = IPC_GET_ARG1(call);
|
|---|
| 360 | row = IPC_GET_ARG2(call);
|
|---|
| 361 |
|
|---|
| 362 | if ((row >= scr_height) || (col >= scr_width)) {
|
|---|
| 363 | retval = EINVAL;
|
|---|
| 364 | break;
|
|---|
| 365 | }
|
|---|
| 366 |
|
|---|
| 367 | cursor_goto(col, row);
|
|---|
| 368 | retval = 0;
|
|---|
| 369 | break;
|
|---|
| 370 | case FB_SCROLL:
|
|---|
| 371 | rows = IPC_GET_ARG1(call);
|
|---|
| 372 |
|
|---|
| 373 | if (rows >= 0) {
|
|---|
| 374 | if ((sysarg_t) rows > scr_height) {
|
|---|
| 375 | retval = EINVAL;
|
|---|
| 376 | break;
|
|---|
| 377 | }
|
|---|
| 378 | } else {
|
|---|
| 379 | if ((sysarg_t) (-rows) > scr_height) {
|
|---|
| 380 | retval = EINVAL;
|
|---|
| 381 | break;
|
|---|
| 382 | }
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | scroll(rows);
|
|---|
| 386 | retval = 0;
|
|---|
| 387 | break;
|
|---|
| 388 | case FB_CURSOR_VISIBILITY:
|
|---|
| 389 | if (IPC_GET_ARG1(call))
|
|---|
| 390 | cursor_enable();
|
|---|
| 391 | else
|
|---|
| 392 | cursor_disable();
|
|---|
| 393 |
|
|---|
| 394 | retval = 0;
|
|---|
| 395 | break;
|
|---|
| 396 | case FB_SET_STYLE:
|
|---|
| 397 | style = style_to_ega_style(IPC_GET_ARG1(call));
|
|---|
| 398 | retval = 0;
|
|---|
| 399 | break;
|
|---|
| 400 | case FB_SET_COLOR:
|
|---|
| 401 | fg_color = IPC_GET_ARG1(call);
|
|---|
| 402 | bg_color = IPC_GET_ARG2(call);
|
|---|
| 403 | attr = IPC_GET_ARG3(call);
|
|---|
| 404 |
|
|---|
| 405 | style = color_to_ega_style(fg_color, bg_color, attr);
|
|---|
| 406 | retval = 0;
|
|---|
| 407 | break;
|
|---|
| 408 | case FB_SET_RGB_COLOR:
|
|---|
| 409 | fg_rgb = IPC_GET_ARG1(call);
|
|---|
| 410 | bg_rgb = IPC_GET_ARG2(call);
|
|---|
| 411 |
|
|---|
| 412 | style = rgb_to_ega_style(fg_rgb, bg_rgb);
|
|---|
| 413 | retval = 0;
|
|---|
| 414 | break;
|
|---|
| 415 | case FB_VP_DRAW_PIXMAP:
|
|---|
| 416 | scr = IPC_GET_ARG2(call);
|
|---|
| 417 | retval = print_screen(scr);
|
|---|
| 418 | break;
|
|---|
| 419 | case FB_VP2PIXMAP:
|
|---|
| 420 | retval = save_screen();
|
|---|
| 421 | break;
|
|---|
| 422 | case FB_DROP_PIXMAP:
|
|---|
| 423 | scr = IPC_GET_ARG1(call);
|
|---|
| 424 |
|
|---|
| 425 | if (scr >= MAX_SAVED_SCREENS) {
|
|---|
| 426 | retval = EINVAL;
|
|---|
| 427 | break;
|
|---|
| 428 | }
|
|---|
| 429 |
|
|---|
| 430 | if (saved_screens[scr].data) {
|
|---|
| 431 | free(saved_screens[scr].data);
|
|---|
| 432 | saved_screens[scr].data = NULL;
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 | retval = 0;
|
|---|
| 436 | break;
|
|---|
| 437 | case FB_SCREEN_YIELD:
|
|---|
| 438 | case FB_SCREEN_RECLAIM:
|
|---|
| 439 | retval = EOK;
|
|---|
| 440 | break;
|
|---|
| 441 | default:
|
|---|
| 442 | retval = EINVAL;
|
|---|
| 443 | }
|
|---|
| 444 | async_answer_0(callid, retval);
|
|---|
| 445 | }
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | int ega_init(void)
|
|---|
| 449 | {
|
|---|
| 450 | sysarg_t paddr;
|
|---|
| 451 | if (sysinfo_get_value("fb.address.physical", &paddr) != EOK)
|
|---|
| 452 | return -1;
|
|---|
| 453 |
|
|---|
| 454 | if (sysinfo_get_value("fb.width", &scr_width) != EOK)
|
|---|
| 455 | return -1;
|
|---|
| 456 |
|
|---|
| 457 | if (sysinfo_get_value("fb.height", &scr_height) != EOK)
|
|---|
| 458 | return -1;
|
|---|
| 459 |
|
|---|
| 460 | sysarg_t blinking;
|
|---|
| 461 | if (sysinfo_get_value("fb.blinking", &blinking) != EOK)
|
|---|
| 462 | blinking = false;
|
|---|
| 463 |
|
|---|
| 464 | void *ega_ph_addr = (void *) paddr;
|
|---|
| 465 | if (blinking) {
|
|---|
| 466 | style_normal &= 0x77;
|
|---|
| 467 | style_inverted &= 0x77;
|
|---|
| 468 | }
|
|---|
| 469 |
|
|---|
| 470 | style = style_normal;
|
|---|
| 471 |
|
|---|
| 472 | iospace_enable(task_get_id(), (void *) EGA_IO_BASE, 2);
|
|---|
| 473 |
|
|---|
| 474 | size_t sz = scr_width * scr_height * 2;
|
|---|
| 475 | scr_addr = as_get_mappable_page(sz);
|
|---|
| 476 |
|
|---|
| 477 | if (physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >>
|
|---|
| 478 | PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0)
|
|---|
| 479 | return -1;
|
|---|
| 480 |
|
|---|
| 481 | async_set_client_connection(ega_client_connection);
|
|---|
| 482 |
|
|---|
| 483 | return 0;
|
|---|
| 484 | }
|
|---|
| 485 |
|
|---|
| 486 | /**
|
|---|
| 487 | * @}
|
|---|
| 488 | */
|
|---|