Changeset f4f866c in mainline for uspace/srv/hid
- Timestamp:
- 2010-04-23T21:42:26Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6c39a907
- Parents:
- 38aaacc2 (diff), 80badbe (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/srv/hid
- Files:
-
- 23 edited
-
console/Makefile (modified) (1 diff)
-
console/console.c (modified) (30 diffs)
-
console/gcons.c (modified) (19 diffs)
-
console/gcons.h (modified) (1 diff)
-
console/keybuffer.h (modified) (1 diff)
-
fb/Makefile (modified) (2 diffs)
-
fb/ega.c (modified) (15 diffs)
-
fb/fb.c (modified) (6 diffs)
-
fb/main.c (modified) (7 diffs)
-
fb/msim.c (modified) (4 diffs)
-
fb/niagara.c (modified) (1 diff)
-
fb/serial_console.c (modified) (19 diffs)
-
fb/serial_console.h (modified) (2 diffs)
-
fb/sgcn.c (modified) (1 diff)
-
kbd/generic/kbd.c (modified) (3 diffs)
-
kbd/port/gxemul.c (modified) (2 diffs)
-
kbd/port/msim.c (modified) (3 diffs)
-
kbd/port/niagara.c (modified) (3 diffs)
-
kbd/port/ns16550.c (modified) (4 diffs)
-
kbd/port/pl050.c (modified) (3 diffs)
-
kbd/port/sgcn.c (modified) (3 diffs)
-
kbd/port/sun.c (modified) (2 diffs)
-
kbd/port/z8530.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/Makefile
r38aaacc2 rf4f866c 33 33 GENERIC_SOURCES = \ 34 34 console.c \ 35 screenbuffer.c \36 35 keybuffer.c \ 37 36 gcons.c -
uspace/srv/hid/console/console.c
r38aaacc2 rf4f866c 54 54 #include <vfs/vfs.h> 55 55 #include <fibril_synch.h> 56 #include <io/style.h> 57 #include <io/screenbuffer.h> 56 58 57 59 #include "console.h" 58 60 #include "gcons.h" 59 61 #include "keybuffer.h" 60 #include "screenbuffer.h" 62 61 63 62 64 #define NAME "console" … … 71 73 /** Information about framebuffer */ 72 74 struct { 73 int phone; /**< Framebuffer phone */74 ipcarg_t cols; /**< Framebuffer columns */75 ipcarg_t rows; /**< Framebuffer rows */76 i nt color_cap; /**< Color capabilities (FB_CCAP_xxx) */75 int phone; /**< Framebuffer phone */ 76 ipcarg_t cols; /**< Framebuffer columns */ 77 ipcarg_t rows; /**< Framebuffer rows */ 78 ipcarg_t color_cap; /**< Color capabilities (FB_CCAP_xxx) */ 77 79 } fb_info; 78 80 … … 99 101 /** Information on row-span yet unsent to FB driver. */ 100 102 struct { 101 size_t col; /**< Leftmost column of the span. */102 size_t row; /**< Row where the span lies. */103 size_t cnt; /**< Width of the span. */103 ipcarg_t col; /**< Leftmost column of the span. */ 104 ipcarg_t row; /**< Row where the span lies. */ 105 ipcarg_t cnt; /**< Width of the span. */ 104 106 } fb_pending; 105 107 … … 117 119 } 118 120 119 static void curs_goto( size_t x, size_t y)121 static void curs_goto(ipcarg_t x, ipcarg_t y) 120 122 { 121 123 async_msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y); … … 147 149 } 148 150 149 static void set_style( int style)151 static void set_style(uint8_t style) 150 152 { 151 153 async_msg_1(fb_info.phone, FB_SET_STYLE, style); 152 154 } 153 155 154 static void set_color( int fgcolor, int bgcolor, int flags)156 static void set_color(uint8_t fgcolor, uint8_t bgcolor, uint8_t flags) 155 157 { 156 158 async_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags); 157 159 } 158 160 159 static void set_rgb_color( int fgcolor, int bgcolor)161 static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor) 160 162 { 161 163 async_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor); … … 178 180 } 179 181 180 static int ccap_fb_to_con(i nt ccap_fb, int *ccap_con)182 static int ccap_fb_to_con(ipcarg_t ccap_fb, ipcarg_t *ccap_con) 181 183 { 182 184 switch (ccap_fb) { 183 case FB_CCAP_NONE: *ccap_con = CONSOLE_CCAP_NONE; break; 184 case FB_CCAP_STYLE: *ccap_con = CONSOLE_CCAP_STYLE; break; 185 case FB_CCAP_INDEXED: *ccap_con = CONSOLE_CCAP_INDEXED; break; 186 case FB_CCAP_RGB: *ccap_con = CONSOLE_CCAP_RGB; break; 187 default: return EINVAL; 188 } 189 185 case FB_CCAP_NONE: 186 *ccap_con = CONSOLE_CCAP_NONE; 187 break; 188 case FB_CCAP_STYLE: 189 *ccap_con = CONSOLE_CCAP_STYLE; 190 break; 191 case FB_CCAP_INDEXED: 192 *ccap_con = CONSOLE_CCAP_INDEXED; 193 break; 194 case FB_CCAP_RGB: 195 *ccap_con = CONSOLE_CCAP_RGB; 196 break; 197 default: 198 return EINVAL; 199 } 200 190 201 return EOK; 191 202 } … … 226 237 * 227 238 */ 228 static void cell_mark_changed( size_t col, size_t row)239 static void cell_mark_changed(ipcarg_t col, ipcarg_t row) 229 240 { 230 241 if (fb_pending.cnt != 0) { … … 253 264 { 254 265 bool flush_cursor = false; 255 266 256 267 switch (ch) { 257 268 case '\n': … … 297 308 async_msg_1(fb_info.phone, FB_SCROLL, 1); 298 309 } 299 310 300 311 if (cons == active_console && flush_cursor) 301 312 curs_goto(cons->scr.position_x, cons->scr.position_y); … … 327 338 328 339 if (cons != kernel_console) { 329 size_t x;330 size_t y;331 int rc = 0;332 333 340 async_serialize_start(); 334 341 … … 344 351 set_attrs(&cons->scr.attrs); 345 352 curs_visibility(false); 353 354 ipcarg_t x; 355 ipcarg_t y; 356 int rc = 0; 357 346 358 if (interbuffer) { 347 359 for (y = 0; y < cons->scr.size_y; y++) { … … 390 402 /* Ignore parameters, the connection is already opened */ 391 403 while (true) { 392 393 404 ipc_call_t call; 394 405 ipc_callid_t callid = async_get_call(&call); … … 433 444 static void mouse_events(ipc_callid_t iid, ipc_call_t *icall) 434 445 { 435 int button, press;436 int dx, dy;437 int newcon;438 439 446 /* Ignore parameters, the connection is already opened */ 440 447 while (true) { 441 442 448 ipc_call_t call; 443 449 ipc_callid_t callid = async_get_call(&call); 444 450 445 451 int retval; 446 452 447 453 switch (IPC_GET_METHOD(call)) { 448 454 case IPC_M_PHONE_HUNGUP: … … 450 456 return; 451 457 case MEVENT_BUTTON: 452 button = IPC_GET_ARG1(call); 453 press = IPC_GET_ARG2(call); 454 if (button == 1) { 455 newcon = gcons_mouse_btn(press); 458 if (IPC_GET_ARG1(call) == 1) { 459 int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call)); 456 460 if (newcon != -1) 457 461 change_console(&consoles[newcon]); … … 460 464 break; 461 465 case MEVENT_MOVE: 462 dx = IPC_GET_ARG1(call); 463 dy = IPC_GET_ARG2(call); 464 gcons_mouse_move(dx, dy); 466 gcons_mouse_move((int) IPC_GET_ARG1(call), 467 (int) IPC_GET_ARG2(call)); 465 468 retval = 0; 466 469 break; … … 520 523 console_event_t ev; 521 524 fibril_mutex_lock(&input_mutex); 525 522 526 recheck: 523 527 while ((keybuffer_pop(&cons->keybuffer, &ev)) && (pos < size)) { … … 536 540 goto recheck; 537 541 } 542 538 543 fibril_mutex_unlock(&input_mutex); 539 544 } … … 542 547 { 543 548 console_event_t ev; 544 549 545 550 fibril_mutex_lock(&input_mutex); 551 546 552 recheck: 547 553 if (keybuffer_pop(&cons->keybuffer, &ev)) { … … 551 557 goto recheck; 552 558 } 559 553 560 fibril_mutex_unlock(&input_mutex); 554 561 } … … 580 587 ipcarg_t arg2; 581 588 ipcarg_t arg3; 582 583 int cons_ccap; 589 584 590 int rc; 585 591 … … 622 628 if (cons == active_console) { 623 629 async_req_0_0(fb_info.phone, FB_FLUSH); 624 625 630 curs_goto(cons->scr.position_x, cons->scr.position_y); 626 631 } … … 650 655 break; 651 656 case CONSOLE_GET_COLOR_CAP: 652 rc = ccap_fb_to_con(fb_info.color_cap, & cons_ccap);657 rc = ccap_fb_to_con(fb_info.color_cap, &arg1); 653 658 if (rc != EOK) { 654 659 ipc_answer_0(callid, rc); 655 660 continue; 656 661 } 657 arg1 = cons_ccap;658 662 break; 659 663 case CONSOLE_SET_STYLE: … … 714 718 return false; 715 719 } 716 720 717 721 kbd_phone = fd_phone(input_fd); 718 722 if (kbd_phone < 0) { … … 720 724 return false; 721 725 } 722 726 723 727 /* NB: The callback connection is slotted for removal */ 724 728 ipcarg_t phonehash; … … 727 731 return false; 728 732 } 729 733 730 734 async_new_connection(phonehash, 0, NULL, keyboard_events); 731 735 732 736 /* Connect to mouse device */ 733 737 mouse_phone = -1; 734 738 int mouse_fd = open("/dev/hid_in/mouse", O_RDONLY); 735 739 736 740 if (mouse_fd < 0) { 737 741 printf(NAME ": Notice - failed opening %s\n", "/dev/hid_in/mouse"); 738 742 goto skip_mouse; 739 743 } 740 744 741 745 mouse_phone = fd_phone(mouse_fd); 742 746 if (mouse_phone < 0) { … … 744 748 goto skip_mouse; 745 749 } 746 750 747 751 if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) { 748 752 printf(NAME ": Failed to create callback from mouse device\n"); … … 750 754 goto skip_mouse; 751 755 } 752 756 753 757 async_new_connection(phonehash, 0, NULL, mouse_events); 754 758 skip_mouse: 755 759 756 760 /* Connect to framebuffer driver */ 757 761 fb_info.phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VIDEO, 0, 0); … … 760 764 return -1; 761 765 } 762 766 763 767 /* Register driver */ 764 768 int rc = devmap_driver_register(NAME, client_connection); … … 772 776 773 777 /* Synchronize, the gcons could put something in queue */ 774 ipcarg_t color_cap;775 778 async_req_0_0(fb_info.phone, FB_FLUSH); 776 779 async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows); 777 async_req_0_1(fb_info.phone, FB_GET_COLOR_CAP, &color_cap); 778 fb_info.color_cap = color_cap; 780 async_req_0_1(fb_info.phone, FB_GET_COLOR_CAP, &fb_info.color_cap); 779 781 780 782 /* Set up shared memory buffer. */ … … 827 829 async_serialize_start(); 828 830 gcons_redraw_console(); 829 set_ rgb_color(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);831 set_style(STYLE_NORMAL); 830 832 screen_clear(); 831 833 curs_goto(0, 0); -
uspace/srv/hid/console/gcons.c
r38aaacc2 rf4f866c 54 54 #define STATUS_HEIGHT 48 55 55 56 #define MAIN_COLOR 0xffffff 56 #define COLOR_MAIN 0xffffff 57 #define COLOR_FOREGROUND 0x202020 58 #define COLOR_BACKGROUND 0xffffff 59 60 extern char _binary_gfx_helenos_ppm_start[0]; 61 extern int _binary_gfx_helenos_ppm_size; 62 extern char _binary_gfx_nameic_ppm_start[0]; 63 extern int _binary_gfx_nameic_ppm_size; 64 65 extern char _binary_gfx_anim_1_ppm_start[0]; 66 extern int _binary_gfx_anim_1_ppm_size; 67 extern char _binary_gfx_anim_2_ppm_start[0]; 68 extern int _binary_gfx_anim_2_ppm_size; 69 extern char _binary_gfx_anim_3_ppm_start[0]; 70 extern int _binary_gfx_anim_3_ppm_size; 71 extern char _binary_gfx_anim_4_ppm_start[0]; 72 extern int _binary_gfx_anim_4_ppm_size; 73 74 extern char _binary_gfx_cons_selected_ppm_start[0]; 75 extern int _binary_gfx_cons_selected_ppm_size; 76 extern char _binary_gfx_cons_idle_ppm_start[0]; 77 extern int _binary_gfx_cons_idle_ppm_size; 78 extern char _binary_gfx_cons_has_data_ppm_start[0]; 79 extern int _binary_gfx_cons_has_data_ppm_size; 80 extern char _binary_gfx_cons_kernel_ppm_start[0]; 81 extern int _binary_gfx_cons_kernel_ppm_size; 57 82 58 83 static bool use_gcons = false; … … 82 107 static size_t active_console = 0; 83 108 84 s ize_t mouse_x;85 s ize_t mouse_y;86 87 bool btn_pressed;88 s ize_t btn_x;89 s ize_t btn_y;109 static ipcarg_t mouse_x = 0; 110 static ipcarg_t mouse_y= 0; 111 112 static bool btn_pressed = false; 113 static ipcarg_t btn_x = 0; 114 static ipcarg_t btn_y = 0; 90 115 91 116 static void vp_switch(int vp) … … 95 120 96 121 /** Create view port */ 97 static int vp_create( size_t x, size_t y, size_t width, size_t height)122 static int vp_create(ipcarg_t x, ipcarg_t y, ipcarg_t width, ipcarg_t height) 98 123 { 99 124 return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y, … … 112 137 113 138 /** Transparent putchar */ 114 static void tran_putch(wchar_t ch, size_t col, size_t row)139 static void tran_putch(wchar_t ch, ipcarg_t col, ipcarg_t row) 115 140 { 116 141 async_msg_3(fbphone, FB_PUTCHAR, ch, col, row); … … 259 284 void gcons_mouse_move(ssize_t dx, ssize_t dy) 260 285 { 261 mouse_x = limit(mouse_x + dx, 0, xres); 262 mouse_y = limit(mouse_y + dy, 0, yres); 263 286 ssize_t nx = (ssize_t) mouse_x + dx; 287 ssize_t ny = (ssize_t) mouse_y + dy; 288 289 mouse_x = (size_t) limit(nx, 0, xres); 290 mouse_y = (size_t) limit(ny, 0, yres); 291 264 292 if (active_console != KERNEL_CONSOLE) 265 293 async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); 266 294 } 267 295 268 static int gcons_find_conbut(i nt x, int y)269 { 270 i nt status_start = STATUS_START + (xres - 800) / 2;296 static int gcons_find_conbut(ipcarg_t x, ipcarg_t y) 297 { 298 ipcarg_t status_start = STATUS_START + (xres - 800) / 2; 271 299 272 300 if ((y < STATUS_TOP) || (y >= STATUS_TOP + STATUS_HEIGHT)) … … 278 306 if (x >= status_start + (STATUS_WIDTH + STATUS_SPACE) * CONSOLE_COUNT) 279 307 return -1; 308 280 309 if (((x - status_start) % (STATUS_WIDTH + STATUS_SPACE)) < STATUS_SPACE) 281 310 return -1; 282 311 283 return (x - status_start) / (STATUS_WIDTH + STATUS_SPACE); 312 ipcarg_t btn = (x - status_start) / (STATUS_WIDTH + STATUS_SPACE); 313 314 if (btn < CONSOLE_COUNT) 315 return btn; 316 317 return -1; 284 318 } 285 319 … … 287 321 * 288 322 * @param state New state (true - pressed, false - depressed) 323 * 289 324 */ 290 325 int gcons_mouse_btn(bool state) 291 326 { 292 int conbut; 327 /* Ignore mouse clicks if no buttons 328 are drawn at all */ 329 if (xres < 800) 330 return -1; 293 331 294 332 if (state) { 295 conbut = gcons_find_conbut(mouse_x, mouse_y);333 int conbut = gcons_find_conbut(mouse_x, mouse_y); 296 334 if (conbut != -1) { 297 335 btn_pressed = true; … … 307 345 btn_pressed = false; 308 346 309 conbut = gcons_find_conbut(mouse_x, mouse_y);347 int conbut = gcons_find_conbut(mouse_x, mouse_y); 310 348 if (conbut == gcons_find_conbut(btn_x, btn_y)) 311 349 return conbut; … … 313 351 return -1; 314 352 } 315 316 353 317 354 /** Draw a PPM pixmap to framebuffer … … 321 358 * @param x Coordinate of upper left corner 322 359 * @param y Coordinate of upper left corner 323 */ 324 static void draw_pixmap(char *logo, size_t size, int x, int y) 325 { 326 char *shm; 327 int rc; 328 360 * 361 */ 362 static void draw_pixmap(char *logo, size_t size, ipcarg_t x, ipcarg_t y) 363 { 329 364 /* Create area */ 330 shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |365 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | 331 366 MAP_ANONYMOUS, 0, 0); 332 367 if (shm == MAP_FAILED) … … 336 371 337 372 /* Send area */ 338 rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);373 int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); 339 374 if (rc) 340 375 goto exit; … … 356 391 } 357 392 358 extern char _binary_gfx_helenos_ppm_start[0];359 extern int _binary_gfx_helenos_ppm_size;360 extern char _binary_gfx_nameic_ppm_start[0];361 extern int _binary_gfx_nameic_ppm_size;362 363 393 /** Redraws console graphics */ 364 394 void gcons_redraw_console(void) 365 395 { 366 int i;367 368 396 if (!use_gcons) 369 397 return; 370 398 371 399 vp_switch(0); 372 set_rgb_color( MAIN_COLOR, MAIN_COLOR);400 set_rgb_color(COLOR_MAIN, COLOR_MAIN); 373 401 clear(); 374 402 draw_pixmap(_binary_gfx_helenos_ppm_start, … … 377 405 (size_t) &_binary_gfx_nameic_ppm_size, 5, 17); 378 406 407 unsigned int i; 379 408 for (i = 0; i < CONSOLE_COUNT; i++) 380 409 redraw_state(i); … … 393 422 static int make_pixmap(char *data, size_t size) 394 423 { 395 char *shm;396 int rc;397 int pxid = -1;398 399 424 /* Create area */ 400 shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |425 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | 401 426 MAP_ANONYMOUS, 0, 0); 402 427 if (shm == MAP_FAILED) … … 405 430 memcpy(shm, data, size); 406 431 432 int pxid = -1; 433 407 434 /* Send area */ 408 rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);435 int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); 409 436 if (rc) 410 437 goto exit; … … 432 459 } 433 460 434 extern char _binary_gfx_anim_1_ppm_start[0];435 extern int _binary_gfx_anim_1_ppm_size;436 extern char _binary_gfx_anim_2_ppm_start[0];437 extern int _binary_gfx_anim_2_ppm_size;438 extern char _binary_gfx_anim_3_ppm_start[0];439 extern int _binary_gfx_anim_3_ppm_size;440 extern char _binary_gfx_anim_4_ppm_start[0];441 extern int _binary_gfx_anim_4_ppm_size;442 443 461 static void make_anim(void) 444 462 { 445 int an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); 463 int an = async_req_1_0(fbphone, FB_ANIM_CREATE, 464 cstatus_vp[KERNEL_CONSOLE]); 446 465 if (an < 0) 447 466 return; … … 467 486 animation = an; 468 487 } 469 470 extern char _binary_gfx_cons_selected_ppm_start[0];471 extern int _binary_gfx_cons_selected_ppm_size;472 extern char _binary_gfx_cons_idle_ppm_start[0];473 extern int _binary_gfx_cons_idle_ppm_size;474 extern char _binary_gfx_cons_has_data_ppm_start[0];475 extern int _binary_gfx_cons_has_data_ppm_size;476 extern char _binary_gfx_cons_kernel_ppm_start[0];477 extern int _binary_gfx_cons_kernel_ppm_size;478 488 479 489 /** Initialize nice graphical console environment */ … … 500 510 501 511 /* Create status buttons */ 502 size_t status_start = STATUS_START + (xres - 800) / 2;512 ipcarg_t status_start = STATUS_START + (xres - 800) / 2; 503 513 size_t i; 504 514 for (i = 0; i < CONSOLE_COUNT; i++) { … … 511 521 512 522 vp_switch(cstatus_vp[i]); 513 set_rgb_color( 0x202020, 0xffffff);523 set_rgb_color(COLOR_FOREGROUND, COLOR_BACKGROUND); 514 524 } 515 525 -
uspace/srv/hid/console/gcons.h
r38aaacc2 rf4f866c 38 38 #include <sys/types.h> 39 39 40 void gcons_init(int phone);40 void gcons_init(int); 41 41 42 42 void gcons_redraw_console(void); 43 void gcons_change_console(size_t index);44 void gcons_notify_char(size_t index);43 void gcons_change_console(size_t); 44 void gcons_notify_char(size_t); 45 45 void gcons_in_kernel(void); 46 46 47 void gcons_notify_connect(size_t index);48 void gcons_notify_disconnect(size_t index);47 void gcons_notify_connect(size_t); 48 void gcons_notify_disconnect(size_t); 49 49 50 void gcons_mouse_move(ssize_t dx, ssize_t dy);50 void gcons_mouse_move(ssize_t, ssize_t); 51 51 int gcons_mouse_btn(bool state); 52 52 -
uspace/srv/hid/console/keybuffer.h
r38aaacc2 rf4f866c 47 47 typedef struct { 48 48 console_event_t fifo[KEYBUFFER_SIZE]; 49 unsigned longhead;50 unsigned longtail;51 unsigned longitems;49 size_t head; 50 size_t tail; 51 size_t items; 52 52 } keybuffer_t; 53 53 -
uspace/srv/hid/fb/Makefile
r38aaacc2 rf4f866c 29 29 30 30 USPACE_PREFIX = ../../.. 31 ROOT_PATH = $(USPACE_PREFIX)/.. 32 33 COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common 34 CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config 35 31 36 BINARY = fb 37 38 -include $(COMMON_MAKEFILE) 39 -include $(CONFIG_MAKEFILE) 32 40 33 41 SOURCES = \ … … 36 44 37 45 ifneq ($(UARCH),ia64) 38 SOURCES += fb.c \ 46 SOURCES += \ 47 fb.c \ 39 48 font-8x16.c 40 EXTRA_CFLAGS = -DFB_ENABLED49 EXTRA_CFLAGS += -DFB_ENABLED 41 50 endif 42 51 43 52 ifeq ($(UARCH),ia32) 44 SOURCES += ega.c 45 EXTRA_CFLAGS = -DEGA_ENABLED 53 SOURCES += \ 54 ega.c 55 EXTRA_CFLAGS += -DEGA_ENABLED 46 56 endif 47 57 48 58 ifeq ($(UARCH),ia64) 49 SOURCES += ega.c \ 59 SOURCES += \ 60 ega.c \ 50 61 ski.c \ 51 62 serial_console.c 52 EXTRA_CFLAGS = -DSKI_ENABLED -DEGA_ENABLED63 EXTRA_CFLAGS += -DSKI_ENABLED -DEGA_ENABLED 53 64 endif 54 65 55 66 ifeq ($(UARCH),amd64) 56 SOURCES += ega.c 57 EXTRA_CFLAGS = -DEGA_ENABLED 67 SOURCES += \ 68 ega.c 69 EXTRA_CFLAGS += -DEGA_ENABLED 58 70 endif 59 71 60 72 ifeq ($(UARCH),mips32) 61 SOURCES += msim.c \ 73 SOURCES += \ 74 msim.c \ 62 75 serial_console.c 63 EXTRA_CFLAGS = -DMSIM_ENABLED76 EXTRA_CFLAGS += -DMSIM_ENABLED 64 77 endif 65 78 66 79 ifeq ($(UARCH),sparc64) 67 ifeq ($(PROCESSOR), sun4v) 68 SOURCES += niagara.c \ 80 ifeq ($(PROCESSOR),sun4v) 81 SOURCES += \ 82 niagara.c \ 69 83 serial_console.c 70 EXTRA_CFLAGS = -DNIAGARA_ENABLED84 EXTRA_CFLAGS += -DNIAGARA_ENABLED 71 85 endif 72 73 ifeq ($(MACHINE), serengeti) 74 SOURCES += sgcn.c \ 86 87 ifeq ($(MACHINE),serengeti) 88 SOURCES += \ 89 sgcn.c \ 75 90 serial_console.c 76 EXTRA_CFLAGS = -DSGCN_ENABLED91 EXTRA_CFLAGS += -DSGCN_ENABLED 77 92 endif 78 93 endif -
uspace/srv/hid/fb/ega.c
r38aaacc2 rf4f866c 28 28 29 29 /** @defgroup egafb EGA framebuffer 30 * @brief HelenOS EGA framebuffer.30 * @brief HelenOS EGA framebuffer. 31 31 * @ingroup fbs 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 35 */ … … 52 52 #include <io/style.h> 53 53 #include <io/color.h> 54 #include <io/screenbuffer.h> 54 55 #include <sys/types.h> 55 56 56 57 #include "ega.h" 57 #include "../console/screenbuffer.h"58 58 #include "main.h" 59 59 60 #define MAX_SAVED_SCREENS 256 60 #define MAX_SAVED_SCREENS 256 61 61 62 typedef struct saved_screen { 62 63 short *data; … … 65 66 saved_screen saved_screens[MAX_SAVED_SCREENS]; 66 67 67 #define EGA_IO_BASE ((ioport8_t *) 0x3d4) 68 #define EGA_IO_SIZE 2 69 70 int ega_normal_color = 0x0f; 71 int ega_inverted_color = 0xf0; 72 73 #define NORMAL_COLOR ega_normal_color 74 #define INVERTED_COLOR ega_inverted_color 68 #define EGA_IO_BASE ((ioport8_t *) 0x3d4) 69 #define EGA_IO_SIZE 2 75 70 76 71 /* Allow only 1 connection */ 77 72 static int client_connected = 0; 78 73 79 static unsigned int scr_width;80 static unsigned int scr_height;74 static sysarg_t scr_width; 75 static sysarg_t scr_height; 81 76 static uint8_t *scr_addr; 82 77 83 static unsigned int style; 84 85 static unsigned attr_to_ega_style(const attrs_t *a); 86 static uint8_t ega_glyph(wchar_t ch); 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 } 87 134 88 135 static void clrscr(void) … … 96 143 } 97 144 98 static void cursor_goto(unsigned int col, unsigned int row) 99 { 100 int ega_cursor; 101 102 ega_cursor = col + scr_width * row; 145 static void cursor_goto(sysarg_t col, sysarg_t row) 146 { 147 sysarg_t cursor = col + scr_width * row; 103 148 104 149 pio_write_8(EGA_IO_BASE, 0xe); 105 pio_write_8(EGA_IO_BASE + 1, ( ega_cursor >> 8) & 0xff);150 pio_write_8(EGA_IO_BASE + 1, (cursor >> 8) & 0xff); 106 151 pio_write_8(EGA_IO_BASE, 0xf); 107 pio_write_8(EGA_IO_BASE + 1, ega_cursor & 0xff);152 pio_write_8(EGA_IO_BASE + 1, cursor & 0xff); 108 153 } 109 154 110 155 static void cursor_disable(void) 111 156 { 112 uint8_t stat;113 114 157 pio_write_8(EGA_IO_BASE, 0xa); 115 stat = pio_read_8(EGA_IO_BASE + 1); 158 159 uint8_t stat = pio_read_8(EGA_IO_BASE + 1); 160 116 161 pio_write_8(EGA_IO_BASE, 0xa); 117 162 pio_write_8(EGA_IO_BASE + 1, stat | (1 << 5)); … … 120 165 static void cursor_enable(void) 121 166 { 122 uint8_t stat;123 124 167 pio_write_8(EGA_IO_BASE, 0xa); 125 stat = pio_read_8(EGA_IO_BASE + 1); 168 169 uint8_t stat = pio_read_8(EGA_IO_BASE + 1); 170 126 171 pio_write_8(EGA_IO_BASE, 0xa); 127 172 pio_write_8(EGA_IO_BASE + 1, stat & (~(1 << 5))); 128 173 } 129 174 130 static void scroll( int rows)131 { 132 unsignedi;133 175 static void scroll(ssize_t rows) 176 { 177 size_t i; 178 134 179 if (rows > 0) { 135 180 memmove(scr_addr, ((char *) scr_addr) + rows * scr_width * 2, … … 142 187 scr_width * scr_height * 2 + rows * scr_width * 2); 143 188 for (i = 0; i < -rows * scr_width; i++) 144 ((short *) scr_addr)[i] = ((style << 8 ) + ' ');145 } 146 } 147 148 static void printchar(wchar_t c, unsigned int col, unsigned int row)189 ((short *) scr_addr)[i] = ((style << 8 ) + ' '); 190 } 191 } 192 193 static void printchar(wchar_t c, sysarg_t col, sysarg_t row) 149 194 { 150 195 scr_addr[(row * scr_width + col) * 2] = ega_glyph(c); … … 158 203 * @param vport Viewport id 159 204 * @param data Text data. 160 * @param x Leftmost column of the area. 161 * @param y Topmost row of the area. 162 * @param w Number of rows. 163 * @param h Number of columns. 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 * 164 210 */ 165 static void draw_text_data(keyfield_t *data, unsigned int x, 166 unsigned int y, unsigned int w, unsigned int h) 167 { 168 unsigned int i, j; 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; 169 216 keyfield_t *field; 170 217 uint8_t *dp; 171 218 172 219 for (j = 0; j < h; j++) { 173 220 for (i = 0; i < w; i++) { 174 221 field = &data[j * w + i]; 175 222 dp = &scr_addr[2 * ((y + j) * scr_width + (x + i))]; 176 223 177 224 dp[0] = ega_glyph(field->character); 178 225 dp[1] = attr_to_ega_style(&field->attrs); … … 183 230 static int save_screen(void) 184 231 { 185 int i; 186 187 for (i = 0; (i < MAX_SAVED_SCREENS) && (saved_screens[i].data); i++) 188 ; 189 if (i == MAX_SAVED_SCREENS) 232 ipcarg_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) 190 238 return EINVAL; 191 if (!(saved_screens[i].data = malloc(2 * scr_width * scr_height))) 239 240 if (!(saved_screens[i].data = malloc(2 * scr_width * scr_height))) 192 241 return ENOMEM; 242 193 243 memcpy(saved_screens[i].data, scr_addr, 2 * scr_width * scr_height); 194 195 return i; 196 } 197 198 static int print_screen(int i) 199 { 200 if (saved_screens[i].data) 244 return (int) i; 245 } 246 247 static int print_screen(ipcarg_t i) 248 { 249 if ((i >= MAX_SAVED_SCREENS) || (saved_screens[i].data)) 201 250 memcpy(scr_addr, saved_screens[i].data, 2 * scr_width * 202 251 scr_height); 203 252 else 204 253 return EINVAL; 205 return i; 206 } 207 208 static int style_to_ega_style(int style) 209 { 210 unsigned int ega_style; 211 212 switch (style) { 213 case STYLE_NORMAL: 214 ega_style = INVERTED_COLOR; 215 break; 216 case STYLE_EMPHASIS: 217 ega_style = INVERTED_COLOR | 4; 218 break; 219 default: 220 return INVERTED_COLOR; 221 } 222 223 return ega_style; 224 } 225 226 static unsigned int color_to_ega_style(int fg_color, int bg_color, int attr) 227 { 228 unsigned int style; 229 230 style = (fg_color & 7) | ((bg_color & 7) << 4); 231 if (attr & CATTR_BRIGHT) 232 style = style | 0x08; 233 234 return style; 235 } 236 237 static unsigned int rgb_to_ega_style(uint32_t fg, uint32_t bg) 238 { 239 return (fg > bg) ? NORMAL_COLOR : INVERTED_COLOR; 240 } 241 242 static unsigned attr_to_ega_style(const attrs_t *a) 243 { 244 switch (a->t) { 245 case at_style: 246 return style_to_ega_style(a->a.s.style); 247 case at_rgb: 248 return rgb_to_ega_style(a->a.r.fg_color, a->a.r.bg_color); 249 case at_idx: 250 return color_to_ega_style(a->a.i.fg_color, 251 a->a.i.bg_color, a->a.i.flags); 252 default: 253 return INVERTED_COLOR; 254 } 255 } 256 257 static uint8_t ega_glyph(wchar_t ch) 258 { 259 if (ch >= 0 && ch < 128) 260 return ch; 261 262 return '?'; 254 255 return (int) i; 263 256 } 264 257 265 258 static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) 266 259 { 267 int retval; 268 ipc_callid_t callid; 269 ipc_call_t call; 270 wchar_t c; 271 unsigned int row, col, w, h; 272 int bg_color, fg_color, attr; 273 uint32_t bg_rgb, fg_rgb; 260 size_t intersize = 0; 274 261 keyfield_t *interbuf = NULL; 275 size_t intersize = 0; 276 int i; 277 262 278 263 if (client_connected) { 279 264 ipc_answer_0(iid, ELIMIT); 280 265 return; 281 266 } 267 268 /* Accept connection */ 282 269 client_connected = 1; 283 ipc_answer_0(iid, EOK); /* Accept connection */ 284 285 while (1) { 286 callid = async_get_call(&call); 287 switch (IPC_GET_METHOD(call)) { 270 ipc_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 ipcarg_t col; 279 ipcarg_t row; 280 ipcarg_t w; 281 ipcarg_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 ipcarg_t scr; 293 int retval; 294 295 switch (IPC_GET_METHOD(call)) { 288 296 case IPC_M_PHONE_HUNGUP: 289 297 client_connected = 0; 290 298 ipc_answer_0(callid, EOK); 291 return; /* Exit thread */ 299 300 /* Exit thread */ 301 return; 292 302 case IPC_M_SHARE_OUT: 293 303 /* We accept one area for data interchange */ … … 299 309 continue; 300 310 } 311 301 312 retval = EINVAL; 302 313 break; 303 314 case FB_DRAW_TEXT_DATA: 315 if (!interbuf) { 316 retval = EINVAL; 317 break; 318 } 319 304 320 col = IPC_GET_ARG1(call); 305 321 row = IPC_GET_ARG2(call); 306 322 w = IPC_GET_ARG3(call); 307 323 h = IPC_GET_ARG4(call); 308 if (!interbuf) { 324 325 if ((col + w > scr_width) || (row + h > scr_height)) { 309 326 retval = EINVAL; 310 327 break; 311 328 } 312 if (col + w > scr_width || row + h > scr_height) { 313 retval = EINVAL; 314 break; 315 } 329 316 330 draw_text_data(interbuf, col, row, w, h); 317 331 retval = 0; … … 331 345 col = IPC_GET_ARG2(call); 332 346 row = IPC_GET_ARG3(call); 333 if (col >= scr_width || row >= scr_height) { 347 348 if ((col >= scr_width) || (row >= scr_height)) { 334 349 retval = EINVAL; 335 350 break; 336 351 } 352 337 353 printchar(c, col, row); 338 354 retval = 0; 339 355 break; 340 case FB_CURSOR_GOTO:341 col = IPC_GET_ARG1(call);356 case FB_CURSOR_GOTO: 357 col = IPC_GET_ARG1(call); 342 358 row = IPC_GET_ARG2(call); 343 if (row >= scr_height || col >= scr_width) { 359 360 if ((row >= scr_height) || (col >= scr_width)) { 344 361 retval = EINVAL; 345 362 break; 346 363 } 364 347 365 cursor_goto(col, row); 348 retval = 0;349 break;366 retval = 0; 367 break; 350 368 case FB_SCROLL: 351 i = IPC_GET_ARG1(call); 352 if (i > (int) scr_height || i < -((int) scr_height)) { 353 retval = EINVAL; 354 break; 355 } 356 scroll(i); 369 rows = IPC_GET_ARG1(call); 370 371 if (rows >= 0) { 372 if ((ipcarg_t) rows > scr_height) { 373 retval = EINVAL; 374 break; 375 } 376 } else { 377 if ((ipcarg_t) (-rows) > scr_height) { 378 retval = EINVAL; 379 break; 380 } 381 } 382 383 scroll(rows); 357 384 retval = 0; 358 385 break; … … 362 389 else 363 390 cursor_disable(); 391 364 392 retval = 0; 365 393 break; … … 372 400 bg_color = IPC_GET_ARG2(call); 373 401 attr = IPC_GET_ARG3(call); 402 374 403 style = color_to_ega_style(fg_color, bg_color, attr); 375 404 retval = 0; … … 378 407 fg_rgb = IPC_GET_ARG1(call); 379 408 bg_rgb = IPC_GET_ARG2(call); 409 380 410 style = rgb_to_ega_style(fg_rgb, bg_rgb); 381 411 retval = 0; 382 412 break; 383 413 case FB_VP_DRAW_PIXMAP: 384 i= IPC_GET_ARG2(call);385 retval = print_screen( i);414 scr = IPC_GET_ARG2(call); 415 retval = print_screen(scr); 386 416 break; 387 417 case FB_VP2PIXMAP: … … 389 419 break; 390 420 case FB_DROP_PIXMAP: 391 i = IPC_GET_ARG1(call); 392 if (i >= MAX_SAVED_SCREENS) { 421 scr = IPC_GET_ARG1(call); 422 423 if (scr >= MAX_SAVED_SCREENS) { 393 424 retval = EINVAL; 394 425 break; 395 426 } 396 if (saved_screens[i].data) { 397 free(saved_screens[i].data); 398 saved_screens[i].data = NULL; 399 } 427 428 if (saved_screens[scr].data) { 429 free(saved_screens[scr].data); 430 saved_screens[scr].data = NULL; 431 } 432 400 433 retval = 0; 401 434 break; … … 413 446 int ega_init(void) 414 447 { 415 void *ega_ph_addr; 416 size_t sz; 417 418 ega_ph_addr = (void *) sysinfo_value("fb.address.physical"); 419 scr_width = sysinfo_value("fb.width"); 420 scr_height = sysinfo_value("fb.height"); 421 422 if (sysinfo_value("fb.blinking")) { 423 ega_normal_color &= 0x77; 424 ega_inverted_color &= 0x77; 425 } 426 427 style = NORMAL_COLOR; 428 448 sysarg_t paddr; 449 if (sysinfo_get_value("fb.address.physical", &paddr) != EOK) 450 return -1; 451 452 if (sysinfo_get_value("fb.width", &scr_width) != EOK) 453 return -1; 454 455 if (sysinfo_get_value("fb.height", &scr_height) != EOK) 456 return -1; 457 458 sysarg_t blinking; 459 if (sysinfo_get_value("fb.blinking", &blinking) != EOK) 460 blinking = false; 461 462 void *ega_ph_addr = (void *) paddr; 463 if (blinking) { 464 style_normal &= 0x77; 465 style_inverted &= 0x77; 466 } 467 468 style = style_normal; 469 429 470 iospace_enable(task_get_id(), (void *) EGA_IO_BASE, 2); 430 431 s z = scr_width * scr_height * 2;471 472 size_t sz = scr_width * scr_height * 2; 432 473 scr_addr = as_get_mappable_page(sz); 433 474 434 475 if (physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> 435 476 PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0) 436 477 return -1; 437 478 438 479 async_set_client_connection(ega_client_connection); 439 480 440 481 return 0; 441 482 } 442 443 483 444 484 /** -
uspace/srv/hid/fb/fb.c
r38aaacc2 rf4f866c 59 59 #include <stdio.h> 60 60 #include <byteorder.h> 61 #include <io/screenbuffer.h> 61 62 62 63 #include "font-8x16.h" 63 64 #include "fb.h" 64 65 #include "main.h" 65 #include "../console/screenbuffer.h"66 66 #include "ppm.h" 67 67 … … 72 72 #define DEFAULT_FGCOLOR 0x000000 73 73 74 #define GLYPH_UNAVAIL '?'75 76 #define MAX_ANIM_LEN 877 #define MAX_ANIMATIONS 478 #define MAX_PIXMAPS 256 /**< Maximum number of saved pixmaps */79 #define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */74 #define GLYPH_UNAVAIL '?' 75 76 #define MAX_ANIM_LEN 8 77 #define MAX_ANIMATIONS 4 78 #define MAX_PIXMAPS 256 /**< Maximum number of saved pixmaps */ 79 #define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */ 80 80 81 81 /** Function to render a pixel from a RGB value. */ … … 956 956 bb_cell_t *bbp; 957 957 attrs_t *a; 958 attr_rgb_t rgb;959 958 960 959 for (j = 0; j < h; j++) { … … 966 965 967 966 a = &data[j * w + i].attrs; 967 968 attr_rgb_t rgb; 969 rgb.fg_color = 0; 970 rgb.bg_color = 0; 968 971 rgb_from_attr(&rgb, a); 969 972 … … 1511 1514 rgb->bg_color = color_table[COLOR_WHITE]; 1512 1515 break; 1516 case STYLE_INVERTED: 1517 rgb->fg_color = color_table[COLOR_WHITE]; 1518 rgb->bg_color = color_table[COLOR_BLACK]; 1519 break; 1520 case STYLE_SELECTED: 1521 rgb->fg_color = color_table[COLOR_WHITE]; 1522 rgb->bg_color = color_table[COLOR_RED]; 1523 break; 1513 1524 default: 1514 1525 return EINVAL; 1515 1526 } 1516 1527 1517 1528 return EOK; 1518 1529 } … … 1756 1767 async_set_client_connection(fb_client_connection); 1757 1768 1758 void *fb_ph_addr = (void *) sysinfo_value("fb.address.physical"); 1759 unsigned int fb_offset = sysinfo_value("fb.offset"); 1760 unsigned int fb_width = sysinfo_value("fb.width"); 1761 unsigned int fb_height = sysinfo_value("fb.height"); 1762 unsigned int fb_scanline = sysinfo_value("fb.scanline"); 1763 unsigned int fb_visual = sysinfo_value("fb.visual"); 1764 1765 unsigned int fbsize = fb_scanline * fb_height; 1769 sysarg_t fb_ph_addr; 1770 if (sysinfo_get_value("fb.address.physical", &fb_ph_addr) != EOK) 1771 return -1; 1772 1773 sysarg_t fb_offset; 1774 if (sysinfo_get_value("fb.offset", &fb_offset) != EOK) 1775 fb_offset = 0; 1776 1777 sysarg_t fb_width; 1778 if (sysinfo_get_value("fb.width", &fb_width) != EOK) 1779 return -1; 1780 1781 sysarg_t fb_height; 1782 if (sysinfo_get_value("fb.height", &fb_height) != EOK) 1783 return -1; 1784 1785 sysarg_t fb_scanline; 1786 if (sysinfo_get_value("fb.scanline", &fb_scanline) != EOK) 1787 return -1; 1788 1789 sysarg_t fb_visual; 1790 if (sysinfo_get_value("fb.visual", &fb_visual) != EOK) 1791 return -1; 1792 1793 sysarg_t fbsize = fb_scanline * fb_height; 1766 1794 void *fb_addr = as_get_mappable_page(fbsize); 1767 1768 if (physmem_map( fb_ph_addr + fb_offset, fb_addr,1795 1796 if (physmem_map((void *) fb_ph_addr + fb_offset, fb_addr, 1769 1797 ALIGN_UP(fbsize, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0) 1770 1798 return -1; 1771 1799 1772 1800 if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual)) 1773 1801 return 0; 1774 1802 1775 1803 return -1; 1776 1804 } -
uspace/srv/hid/fb/main.c
r38aaacc2 rf4f866c 60 60 int main(int argc, char *argv[]) 61 61 { 62 printf( NAME ": HelenOS Framebuffer service\n");62 printf("%s: HelenOS Framebuffer service\n", NAME); 63 63 64 ipcarg_t phonead;65 64 bool initialized = false; 65 sysarg_t fb_present; 66 sysarg_t fb_kind; 67 68 if (sysinfo_get_value("fb", &fb_present) != EOK) 69 fb_present = false; 70 71 if (sysinfo_get_value("fb.kind", &fb_kind) != EOK) { 72 printf("%s: Unable to detect framebuffer configuration\n", NAME); 73 return -1; 74 } 66 75 67 76 #ifdef FB_ENABLED 68 if ( sysinfo_value("fb.kind") == 1) {77 if ((!initialized) && (fb_kind == 1)) { 69 78 if (fb_init() == 0) 70 79 initialized = true; … … 72 81 #endif 73 82 #ifdef EGA_ENABLED 74 if ((!initialized) && ( sysinfo_value("fb.kind")== 2)) {83 if ((!initialized) && (fb_kind == 2)) { 75 84 if (ega_init() == 0) 76 85 initialized = true; … … 78 87 #endif 79 88 #ifdef MSIM_ENABLED 80 if ((!initialized) && ( sysinfo_value("fb.kind")== 3)) {89 if ((!initialized) && (fb_kind == 3)) { 81 90 if (msim_init() == 0) 82 91 initialized = true; … … 84 93 #endif 85 94 #ifdef SGCN_ENABLED 86 if ((!initialized) && ( sysinfo_value("fb.kind")== 4)) {95 if ((!initialized) && (fb_kind == 4)) { 87 96 if (sgcn_init() == 0) 88 97 initialized = true; … … 90 99 #endif 91 100 #ifdef NIAGARA_ENABLED 92 if ((!initialized) && ( sysinfo_value("fb.kind")== 5)) {101 if ((!initialized) && (fb_kind == 5)) { 93 102 if (niagara_init() == 0) 94 103 initialized = true; … … 96 105 #endif 97 106 #ifdef SKI_ENABLED 98 if ((!initialized) && ( sysinfo_value("fb") != true)) {107 if ((!initialized) && (!fb_present)) { 99 108 if (ski_init() == 0) 100 109 initialized = true; … … 105 114 return -1; 106 115 116 ipcarg_t phonead; 107 117 if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, &phonead) != 0) 108 118 return -1; 109 119 110 printf( NAME ": Accepting connections\n");120 printf("%s: Accepting connections\n", NAME); 111 121 async_manager(); 112 122 -
uspace/srv/hid/fb/msim.c
r38aaacc2 rf4f866c 29 29 30 30 /** @defgroup msimfb MSIM text console 31 * @brief HelenOS MSIM text console.31 * @brief HelenOS MSIM text console. 32 32 * @ingroup fbs 33 33 * @{ 34 */ 34 */ 35 35 /** @file 36 36 */ … … 41 41 #include <as.h> 42 42 #include <ddi.h> 43 #include <errno.h> 43 44 44 45 #include "serial_console.h" … … 57 58 int msim_init(void) 58 59 { 59 void *phys_addr = (void *) sysinfo_value("fb.address.physical"); 60 sysarg_t phys_addr; 61 if (sysinfo_get_value("fb.address.physical", &phys_addr) != EOK) 62 return -1; 63 60 64 virt_addr = (char *) as_get_mappable_page(1); 61 65 62 if (physmem_map(phys_addr, virt_addr, 1, AS_AREA_READ | AS_AREA_WRITE) != 0) 66 if (physmem_map((void *) phys_addr, virt_addr, 1, 67 AS_AREA_READ | AS_AREA_WRITE) != 0) 63 68 return -1; 64 69 … … 69 74 } 70 75 71 /** 72 * @} 76 /** @} 73 77 */ -
uspace/srv/hid/fb/niagara.c
r38aaacc2 rf4f866c 91 91 int niagara_init(void) 92 92 { 93 sysarg_t paddr; 94 if (sysinfo_get_value("niagara.outbuf.address", &paddr) != EOK) 95 return -1; 96 93 97 output_buffer_addr = (uintptr_t) as_get_mappable_page(PAGE_SIZE); 94 int result = physmem_map( 95 (void *) sysinfo_value("niagara.outbuf.address"), 96 (void *) output_buffer_addr, 97 1, AS_AREA_READ | AS_AREA_WRITE); 98 int result = physmem_map((void *) paddr, 99 (void *) output_buffer_addr, 1, 100 AS_AREA_READ | AS_AREA_WRITE); 98 101 99 102 if (result != 0) { -
uspace/srv/hid/fb/serial_console.c
r38aaacc2 rf4f866c 31 31 /** 32 32 * @defgroup serial Serial console 33 * @brief Serial console services (putc, puts, clear screen, cursor goto,...)33 * @brief Serial console services (putc, puts, clear screen, cursor goto,...) 34 34 * @{ 35 */ 35 */ 36 36 37 37 /** @file … … 47 47 #include <io/style.h> 48 48 #include <str.h> 49 50 #include "../console/screenbuffer.h" 49 #include <io/screenbuffer.h> 50 51 51 #include "main.h" 52 52 #include "serial_console.h" … … 54 54 #define MAX_CONTROL 20 55 55 56 static void serial_sgr(const unsigned int mode); 57 void serial_putchar(wchar_t ch); 58 59 static unsigned int scr_width; 60 static unsigned int scr_height; 61 static bool color = true; /** True if producing color output. */ 62 static bool utf8 = false; /** True if producing UTF8 output. */ 56 static ipcarg_t scr_width; 57 static ipcarg_t scr_height; 58 static bool color = true; /**< True if producing color output. */ 59 static bool utf8 = false; /**< True if producing UTF8 output. */ 63 60 static putc_function_t putc_function; 61 62 static ipcarg_t lastcol = 0; 63 static ipcarg_t lastrow = 0; 64 static attrs_t cur_attr = { 65 .t = at_style, 66 .a.s.style = STYLE_NORMAL 67 }; 64 68 65 69 /* Allow only 1 connection */ … … 67 71 68 72 enum sgr_color_index { 69 CI_BLACK = 0,70 CI_RED = 1,71 CI_GREEN = 2,72 CI_BROWN = 3,73 CI_BLUE = 4,74 CI_MAGENTA = 5,75 CI_CYAN = 6,76 CI_WHITE = 7,73 CI_BLACK = 0, 74 CI_RED = 1, 75 CI_GREEN = 2, 76 CI_BROWN = 3, 77 CI_BLUE = 4, 78 CI_MAGENTA = 5, 79 CI_CYAN = 6, 80 CI_WHITE = 7 77 81 }; 78 82 79 83 enum sgr_command { 80 SGR_RESET = 0,81 SGR_BOLD = 1,82 SGR_BLINK = 5,83 SGR_REVERSE = 7,84 SGR_NORMAL_INT = 22,85 SGR_BLINK_OFF = 25,84 SGR_RESET = 0, 85 SGR_BOLD = 1, 86 SGR_BLINK = 5, 87 SGR_REVERSE = 7, 88 SGR_NORMAL_INT = 22, 89 SGR_BLINK_OFF = 25, 86 90 SGR_REVERSE_OFF = 27, 87 SGR_FGCOLOR = 30,88 SGR_BGCOLOR = 4091 SGR_FGCOLOR = 30, 92 SGR_BGCOLOR = 40 89 93 }; 90 94 91 95 static int color_map[] = { 92 [COLOR_BLACK] = CI_BLACK,93 [COLOR_BLUE] = CI_RED,94 [COLOR_GREEN] = CI_GREEN,95 [COLOR_CYAN] = CI_CYAN,96 [COLOR_RED] = CI_RED,96 [COLOR_BLACK] = CI_BLACK, 97 [COLOR_BLUE] = CI_RED, 98 [COLOR_GREEN] = CI_GREEN, 99 [COLOR_CYAN] = CI_CYAN, 100 [COLOR_RED] = CI_RED, 97 101 [COLOR_MAGENTA] = CI_MAGENTA, 98 [COLOR_YELLOW] = CI_BROWN,99 [COLOR_WHITE] = CI_WHITE102 [COLOR_YELLOW] = CI_BROWN, 103 [COLOR_WHITE] = CI_WHITE 100 104 }; 101 105 … … 106 110 } 107 111 108 void serial_putchar(wchar_t ch) 109 { 110 char buf[STR_BOUNDS(1)]; 111 size_t offs; 112 size_t i; 113 112 static void serial_putchar(wchar_t ch) 113 { 114 114 if (utf8 != true) { 115 115 if (ch >= 0 && ch < 128) 116 116 (*putc_function)((uint8_t) ch); 117 else 117 else 118 118 (*putc_function)('?'); 119 119 120 return; 120 121 } 121 122 offs = 0; 122 123 size_t offs = 0; 124 char buf[STR_BOUNDS(1)]; 123 125 if (chr_encode(ch, buf, &offs, STR_BOUNDS(1)) == EOK) { 126 size_t i; 124 127 for (i = 0; i < offs; i++) 125 128 (*putc_function)(buf[i]); 126 } else {129 } else 127 130 (*putc_function)('?'); 128 } 129 130 } 131 132 void serial_goto(const unsigned int col, const unsigned int row) 131 } 132 133 void serial_goto(const ipcarg_t col, const ipcarg_t row) 133 134 { 134 135 if ((col > scr_width) || (row > scr_height)) … … 138 139 snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1); 139 140 serial_puts(control); 141 } 142 143 /** ECMA-48 Set Graphics Rendition. */ 144 static void serial_sgr(const unsigned int mode) 145 { 146 char control[MAX_CONTROL]; 147 snprintf(control, MAX_CONTROL, "\033[%um", mode); 148 serial_puts(control); 149 } 150 151 static void serial_set_style(console_style_t style) 152 { 153 switch (style) { 154 case STYLE_EMPHASIS: 155 if (color) { 156 serial_sgr(SGR_RESET); 157 serial_sgr(SGR_FGCOLOR + CI_RED); 158 serial_sgr(SGR_BGCOLOR + CI_WHITE); 159 } 160 serial_sgr(SGR_BOLD); 161 break; 162 case STYLE_INVERTED: 163 if (color) { 164 serial_sgr(SGR_RESET); 165 serial_sgr(SGR_FGCOLOR + CI_WHITE); 166 serial_sgr(SGR_BGCOLOR + CI_BLACK); 167 serial_sgr(SGR_NORMAL_INT); 168 } else 169 serial_sgr(SGR_REVERSE); 170 break; 171 case STYLE_SELECTED: 172 if (color) { 173 serial_sgr(SGR_RESET); 174 serial_sgr(SGR_FGCOLOR + CI_WHITE); 175 serial_sgr(SGR_BGCOLOR + CI_RED); 176 serial_sgr(SGR_NORMAL_INT); 177 } else { 178 serial_sgr(SGR_BOLD); 179 serial_sgr(SGR_REVERSE); 180 } 181 break; 182 default: 183 if (color) { 184 serial_sgr(SGR_RESET); 185 serial_sgr(SGR_FGCOLOR + CI_BLACK); 186 serial_sgr(SGR_BGCOLOR + CI_WHITE); 187 } 188 serial_sgr(SGR_NORMAL_INT); 189 } 190 } 191 192 static void serial_set_idx(uint8_t fgcolor, uint8_t bgcolor, 193 uint8_t flags) 194 { 195 if (color) { 196 serial_sgr(SGR_RESET); 197 serial_sgr(SGR_FGCOLOR + color_map[fgcolor]); 198 serial_sgr(SGR_BGCOLOR + color_map[bgcolor]); 199 } else { 200 if (fgcolor < bgcolor) 201 serial_sgr(SGR_RESET); 202 else 203 serial_sgr(SGR_REVERSE); 204 } 205 } 206 207 static void serial_set_rgb(uint32_t fgcolor, uint32_t bgcolor) 208 { 209 serial_sgr(SGR_RESET); 210 211 if (fgcolor < bgcolor) 212 serial_sgr(SGR_REVERSE_OFF); 213 else 214 serial_sgr(SGR_REVERSE); 215 } 216 217 static void serial_set_attrs(attrs_t *a) 218 { 219 switch (a->t) { 220 case at_style: 221 serial_set_style(a->a.s.style); 222 break; 223 case at_rgb: 224 serial_set_rgb(a->a.r.fg_color, a->a.r.bg_color); 225 break; 226 case at_idx: 227 serial_set_idx(a->a.i.fg_color, a->a.i.bg_color, 228 a->a.i.flags); 229 break; 230 } 140 231 } 141 232 … … 148 239 serial_sgr(SGR_BGCOLOR + CI_WHITE); 149 240 } 150 241 151 242 serial_puts("\033[2J"); 152 } 153 154 void serial_scroll(int i) 243 244 serial_set_attrs(&cur_attr); 245 } 246 247 void serial_scroll(ssize_t i) 155 248 { 156 249 if (i > 0) { … … 165 258 } 166 259 167 /** ECMA-48 Set Graphics Rendition. */168 static void serial_sgr(const unsigned int mode)169 {170 char control[MAX_CONTROL];171 snprintf(control, MAX_CONTROL, "\033[%um", mode);172 serial_puts(control);173 }174 175 260 /** Set scrolling region. */ 176 void serial_set_scroll_region( unsignedlast_row)261 void serial_set_scroll_region(ipcarg_t last_row) 177 262 { 178 263 char control[MAX_CONTROL]; … … 191 276 } 192 277 193 void serial_console_init(putc_function_t putc_fn, uint32_t w, uint32_t h)278 void serial_console_init(putc_function_t putc_fn, ipcarg_t w, ipcarg_t h) 194 279 { 195 280 scr_width = w; … … 198 283 } 199 284 200 static void serial_set_style(int style) 201 { 202 if (style == STYLE_EMPHASIS) { 203 if (color) { 204 serial_sgr(SGR_RESET); 205 serial_sgr(SGR_FGCOLOR + CI_RED); 206 serial_sgr(SGR_BGCOLOR + CI_WHITE); 207 } 208 serial_sgr(SGR_BOLD); 209 } else { 210 if (color) { 211 serial_sgr(SGR_RESET); 212 serial_sgr(SGR_FGCOLOR + CI_BLACK); 213 serial_sgr(SGR_BGCOLOR + CI_WHITE); 214 } 215 serial_sgr(SGR_NORMAL_INT); 216 } 217 } 218 219 static void serial_set_idx(unsigned fgcolor, unsigned bgcolor, 220 unsigned flags) 221 { 222 if (color) { 223 serial_sgr(SGR_RESET); 224 serial_sgr(SGR_FGCOLOR + color_map[fgcolor]); 225 serial_sgr(SGR_BGCOLOR + color_map[bgcolor]); 226 } else { 227 if (fgcolor < bgcolor) 228 serial_sgr(SGR_RESET); 229 else 230 serial_sgr(SGR_REVERSE); 231 } 232 } 233 234 static void serial_set_rgb(uint32_t fgcolor, uint32_t bgcolor) 235 { 236 if (fgcolor < bgcolor) 237 serial_sgr(SGR_REVERSE_OFF); 238 else 239 serial_sgr(SGR_REVERSE); 240 } 241 242 static void serial_set_attrs(const attrs_t *a) 243 { 244 switch (a->t) { 245 case at_style: 246 serial_set_style(a->a.s.style); 247 break; 248 case at_rgb: 249 serial_set_rgb(a->a.r.fg_color, a->a.r.bg_color); 250 break; 251 case at_idx: 252 serial_set_idx(a->a.i.fg_color, 253 a->a.i.bg_color, a->a.i.flags); 254 break; 255 default: 256 break; 257 } 258 } 285 259 286 260 287 /** Draw text data to viewport. … … 262 289 * @param vport Viewport id 263 290 * @param data Text data. 264 * @param x Leftmost column of the area. 265 * @param y Topmost row of the area. 266 * @param w Number of rows. 267 * @param h Number of columns. 268 */ 269 static void draw_text_data(keyfield_t *data, unsigned int x, 270 unsigned int y, unsigned int w, unsigned int h) 271 { 272 unsigned int i, j; 273 keyfield_t *field; 274 attrs_t *a0, *a1; 275 291 * @param x Leftmost column of the area. 292 * @param y Topmost row of the area. 293 * @param w Number of rows. 294 * @param h Number of columns. 295 * 296 */ 297 static void draw_text_data(keyfield_t *data, ipcarg_t x, ipcarg_t y, 298 ipcarg_t w, ipcarg_t h) 299 { 276 300 serial_goto(x, y); 277 a0 = &data[0].attrs; 278 serial_set_attrs(a0); 279 301 ipcarg_t i; 302 ipcarg_t j; 303 304 attrs_t *a0 = &data[0].attrs; 305 280 306 for (j = 0; j < h; j++) { 281 if ( j > 0 && w != scr_width)307 if ((j > 0) && (w != scr_width)) 282 308 serial_goto(x, j); 283 309 284 310 for (i = 0; i < w; i++) { 285 field = &data[j * w + i]; 286 287 a1 = &field->attrs; 288 if (!attrs_same(*a0, *a1)) 311 attrs_t *a1 = &data[j * w + i].attrs; 312 313 if (!attrs_same(*a0, *a1)) { 289 314 serial_set_attrs(a1); 290 serial_putchar(field->character); 291 a0 = a1; 315 a0 = a1; 316 } 317 318 serial_putchar(data[j * w + i].character); 292 319 } 293 320 } 294 321 } 295 296 unsigned int lastcol = 0;297 unsigned int lastrow = 0;298 322 299 323 /** … … 302 326 void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall) 303 327 { 304 int retval;305 ipc_callid_t callid;306 ipc_call_t call;307 328 keyfield_t *interbuf = NULL; 308 329 size_t intersize = 0; 309 310 wchar_t c;311 unsigned int col;312 unsigned int row;313 unsigned int w;314 unsigned int h;315 int i;316 317 attrs_t cur_attr;318 330 319 331 if (client_connected) { … … 324 336 client_connected = 1; 325 337 ipc_answer_0(iid, EOK); 326 327 cur_attr.t = at_style;328 cur_attr.a.s.style = STYLE_NORMAL;329 338 330 339 /* Clear the terminal, set scrolling region … … 335 344 336 345 while (true) { 337 callid = async_get_call(&call); 346 ipc_call_t call; 347 ipc_callid_t callid = async_get_call(&call); 348 349 wchar_t c; 350 ipcarg_t col; 351 ipcarg_t row; 352 ipcarg_t w; 353 ipcarg_t h; 354 attrs_t attr; 355 ssize_t rows; 356 357 int retval; 358 338 359 switch (IPC_GET_METHOD(call)) { 339 360 case IPC_M_PHONE_HUNGUP: 340 361 client_connected = 0; 341 362 ipc_answer_0(callid, EOK); 363 364 /* Exit thread */ 342 365 return; 343 366 case IPC_M_SHARE_OUT: … … 350 373 continue; 351 374 } 375 352 376 retval = EINVAL; 353 377 break; … … 357 381 w = IPC_GET_ARG3(call); 358 382 h = IPC_GET_ARG4(call); 383 359 384 if (!interbuf) { 360 385 retval = EINVAL; 361 386 break; 362 387 } 388 363 389 if ((col + w > scr_width) || (row + h > scr_height)) { 364 390 retval = EINVAL; 365 391 break; 366 392 } 393 367 394 draw_text_data(interbuf, col, row, w, h); 368 395 lastcol = col + w; … … 374 401 col = IPC_GET_ARG2(call); 375 402 row = IPC_GET_ARG3(call); 403 376 404 if ((lastcol != col) || (lastrow != row)) 377 405 serial_goto(col, row); 406 378 407 lastcol = col + 1; 379 408 lastrow = row; … … 401 430 break; 402 431 case FB_SET_STYLE: 403 cur_attr.t = at_style; 404 cur_attr.a.s.style = IPC_GET_ARG1(call); 405 cur_attr.a.i.bg_color = IPC_GET_ARG2(call); 432 attr.t = at_style; 433 attr.a.s.style = IPC_GET_ARG1(call); 406 434 serial_set_attrs(&cur_attr); 407 408 435 retval = 0; 409 436 break; 410 437 case FB_SET_COLOR: 411 cur_attr.t = at_idx;412 cur_attr.a.i.fg_color = IPC_GET_ARG1(call);413 cur_attr.a.i.bg_color = IPC_GET_ARG2(call);414 cur_attr.a.i.flags = IPC_GET_ARG3(call);438 attr.t = at_idx; 439 attr.a.i.fg_color = IPC_GET_ARG1(call); 440 attr.a.i.bg_color = IPC_GET_ARG2(call); 441 attr.a.i.flags = IPC_GET_ARG3(call); 415 442 serial_set_attrs(&cur_attr); 416 417 443 retval = 0; 418 444 break; 419 445 case FB_SET_RGB_COLOR: 420 cur_attr.t = at_rgb;421 cur_attr.a.i.fg_color = IPC_GET_ARG1(call);422 cur_attr.a.i.bg_color = IPC_GET_ARG2(call);446 attr.t = at_rgb; 447 attr.a.r.fg_color = IPC_GET_ARG1(call); 448 attr.a.r.bg_color = IPC_GET_ARG2(call); 423 449 serial_set_attrs(&cur_attr); 424 425 450 retval = 0; 426 451 break; 427 452 case FB_SCROLL: 428 i = IPC_GET_ARG1(call); 429 if ((i > (int) scr_height) || (i < -((int) scr_height))) { 430 retval = EINVAL; 431 break; 453 rows = IPC_GET_ARG1(call); 454 455 if (rows >= 0) { 456 if ((ipcarg_t) rows > scr_height) { 457 retval = EINVAL; 458 break; 459 } 460 } else { 461 if ((ipcarg_t) (-rows) > scr_height) { 462 retval = EINVAL; 463 break; 464 } 432 465 } 433 serial_scroll(i); 466 467 serial_scroll(rows); 434 468 serial_goto(lastcol, lastrow); 435 469 retval = 0; … … 451 485 case FB_SCREEN_RECLAIM: 452 486 serial_clrscr(); 453 serial_set_attrs(&cur_attr);454 487 retval = 0; 455 488 break; -
uspace/srv/hid/fb/serial_console.h
r38aaacc2 rf4f866c 29 29 /** 30 30 * @defgroup serial Serial console 31 * @brief Serial console services (putc, puts, clear screen, cursor goto,...)31 * @brief Serial console services (putc, puts, clear screen, cursor goto,...) 32 32 * @{ 33 */ 33 */ 34 34 35 35 /** @file … … 43 43 typedef void (*putc_function_t)(char); 44 44 45 void serial_puts(const char *str); 46 void serial_goto(const unsigned int col, const unsigned int row); 47 void serial_clrscr(void); 48 void serial_scroll(int i); 49 void serial_cursor_disable(void); 50 void serial_cursor_enable(void); 51 void serial_set_scroll_region(unsigned height); 52 void serial_console_init(putc_function_t putc_fn, uint32_t w, uint32_t h); 53 void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall); 54 45 extern void serial_puts(const char *); 46 extern void serial_goto(const ipcarg_t, const ipcarg_t); 47 extern void serial_clrscr(void); 48 extern void serial_scroll(ssize_t); 49 extern void serial_cursor_disable(void); 50 extern void serial_cursor_enable(void); 51 extern void serial_set_scroll_region(ipcarg_t); 52 extern void serial_console_init(putc_function_t, ipcarg_t, ipcarg_t); 53 extern void serial_client_connection(ipc_callid_t, ipc_call_t *); 55 54 56 55 #endif -
uspace/srv/hid/fb/sgcn.c
r38aaacc2 rf4f866c 122 122 int sgcn_init(void) 123 123 { 124 sram_virt_addr = (uintptr_t) as_get_mappable_page(sysinfo_value("sram.area.size")); 124 sysarg_t sram_paddr; 125 if (sysinfo_get_value("sram.address.physical", &sram_paddr) != EOK) 126 return -1; 125 127 126 if (physmem_map((void *) sysinfo_value("sram.address.physical"), 127 (void *) sram_virt_addr, sysinfo_value("sram.area.size") / PAGE_SIZE, 128 AS_AREA_READ | AS_AREA_WRITE) != 0) 128 sysarg_t sram_size; 129 if (sysinfo_get_value("sram.area.size", &sram_size) != EOK) 130 return -1; 131 132 if (sysinfo_get_value("sram.buffer.offset", &sram_buffer_offset) != EOK) 133 sram_buffer_offset = 0; 134 135 sram_virt_addr = (uintptr_t) as_get_mappable_page(sram_size); 136 137 if (physmem_map((void *) sram_paddr, (void *) sram_virt_addr, 138 sram_size / PAGE_SIZE, AS_AREA_READ | AS_AREA_WRITE) != 0) 129 139 return -1; 130 140 131 141 serial_console_init(sgcn_putc, WIDTH, HEIGHT); 132 133 sram_buffer_offset = sysinfo_value("sram.buffer.offset");134 142 135 143 async_set_client_connection(serial_client_connection); -
uspace/srv/hid/kbd/generic/kbd.c
r38aaacc2 rf4f866c 212 212 int main(int argc, char **argv) 213 213 { 214 printf(NAME ": HelenOS Keyboard service\n"); 215 216 if (sysinfo_value("kbd.cir.fhc") == 1) 214 printf("%s: HelenOS Keyboard service\n", NAME); 215 216 sysarg_t fhc; 217 sysarg_t obio; 218 219 if ((sysinfo_get_value("kbd.cir.fhc", &fhc) == EOK) && (fhc)) 217 220 cir_service = SERVICE_FHC; 218 else if ( sysinfo_value("kbd.cir.obio") == 1)221 else if ((sysinfo_get_value("kbd.cir.obio", &obio) == EOK) && (obio)) 219 222 cir_service = SERVICE_OBIO; 220 223 … … 240 243 int rc = devmap_driver_register(NAME, client_connection); 241 244 if (rc < 0) { 242 printf( NAME ": Unable to register driver (%d)\n", rc);245 printf("%s: Unable to register driver (%d)\n", NAME, rc); 243 246 return -1; 244 247 } … … 249 252 dev_handle_t dev_handle; 250 253 if (devmap_device_register(kbd, &dev_handle) != EOK) { 251 printf( NAME ": Unable to register device %s\n", kbd);254 printf("%s: Unable to register device %s\n", NAME, kbd); 252 255 return -1; 253 256 } -
uspace/srv/hid/kbd/port/gxemul.c
r38aaacc2 rf4f866c 41 41 #include <kbd.h> 42 42 #include <ddi.h> 43 #include <errno.h> 43 44 44 45 static irq_cmd_t gxemul_cmds[] = { … … 63 64 int kbd_port_init(void) 64 65 { 66 sysarg_t addr; 67 if (sysinfo_get_value("kbd.address.virtual", &addr) != EOK) 68 return -1; 69 70 sysarg_t inr; 71 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 72 return -1; 73 65 74 async_set_interrupt_received(gxemul_irq_handler); 66 gxemul_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual"); 67 ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 68 0, &gxemul_kbd); 75 gxemul_cmds[0].addr = (void *) addr; 76 ipc_register_irq(inr, device_assign_devno(), 0, &gxemul_kbd); 69 77 return 0; 70 78 } -
uspace/srv/hid/kbd/port/msim.c
r38aaacc2 rf4f866c 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 * @brief Msim keyboard port driver.34 * @brief Msim keyboard port driver. 35 35 */ 36 36 … … 41 41 #include <kbd.h> 42 42 #include <ddi.h> 43 #include <errno.h> 43 44 44 45 irq_cmd_t msim_cmds[] = { … … 63 64 int kbd_port_init(void) 64 65 { 66 sysarg_t vaddr; 67 if (sysinfo_get_value("kbd.address.virtual", &vaddr) != EOK) 68 return -1; 69 70 sysarg_t inr; 71 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 72 return -1; 73 74 msim_cmds[0].addr = (void *) vaddr; 65 75 async_set_interrupt_received(msim_irq_handler); 66 msim_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual"); 67 ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 68 0, &msim_kbd); 76 ipc_register_irq(inr, device_assign_devno(), 0, &msim_kbd); 77 69 78 return 0; 70 79 } -
uspace/srv/hid/kbd/port/niagara.c
r38aaacc2 rf4f866c 44 44 #include <thread.h> 45 45 #include <bool.h> 46 #include <errno.h> 46 47 47 #define POLL_INTERVAL 1000048 #define POLL_INTERVAL 10000 48 49 49 50 /** … … 57 58 * kernel/arch/sparc64/src/drivers/niagara.c. 58 59 */ 59 #define INPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 60 #define INPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 61 60 62 typedef volatile struct { 61 63 uint64_t write_ptr; … … 79 81 int kbd_port_init(void) 80 82 { 83 sysarg_t paddr; 84 if (sysinfo_get_value("niagara.inbuf.address", &paddr) != EOK) 85 return -1; 86 81 87 input_buffer_addr = (uintptr_t) as_get_mappable_page(PAGE_SIZE); 82 int result = physmem_map( 83 (void *) sysinfo_value("niagara.inbuf.address"), 84 (void *) input_buffer_addr, 85 1, AS_AREA_READ | AS_AREA_WRITE); 86 87 if (result != 0) { 88 int rc = physmem_map((void *) paddr, (void *) input_buffer_addr, 89 1, AS_AREA_READ | AS_AREA_WRITE); 90 91 if (rc != 0) { 88 92 printf("Niagara: uspace driver couldn't map physical memory: %d\n", 89 result); 90 } 91 92 input_buffer = (input_buffer_t) input_buffer_addr; 93 94 thread_id_t tid; 95 int rc; 96 97 rc = thread_create(niagara_thread_impl, NULL, "kbd_poll", &tid); 98 if (rc != 0) { 93 rc); 99 94 return rc; 100 95 } 96 97 input_buffer = (input_buffer_t) input_buffer_addr; 98 99 thread_id_t tid; 100 rc = thread_create(niagara_thread_impl, NULL, "kbd_poll", &tid); 101 if (rc != 0) 102 return rc; 103 101 104 return 0; 102 105 } -
uspace/srv/hid/kbd/port/ns16550.c
r38aaacc2 rf4f866c 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 * @brief NS16550 port driver.34 * @brief NS16550 port driver. 35 35 */ 36 36 … … 43 43 #include <sun.h> 44 44 #include <ddi.h> 45 #include <errno.h> 45 46 46 47 /* NS16550 registers */ 47 #define RBR_REG 0/** Receiver Buffer Register. */48 #define IER_REG 1/** Interrupt Enable Register. */49 #define IIR_REG 2/** Interrupt Ident Register (read). */50 #define FCR_REG 2/** FIFO control register (write). */51 #define LCR_REG 3/** Line Control register. */52 #define MCR_REG 4/** Modem Control Register. */53 #define LSR_REG 5/** Line Status Register. */48 #define RBR_REG 0 /** Receiver Buffer Register. */ 49 #define IER_REG 1 /** Interrupt Enable Register. */ 50 #define IIR_REG 2 /** Interrupt Ident Register (read). */ 51 #define FCR_REG 2 /** FIFO control register (write). */ 52 #define LCR_REG 3 /** Line Control register. */ 53 #define MCR_REG 4 /** Modem Control Register. */ 54 #define LSR_REG 5 /** Line Status Register. */ 54 55 55 #define LSR_DATA_READY 0x0156 #define LSR_DATA_READY 0x01 56 57 57 58 static irq_cmd_t ns16550_cmds[] = { 58 59 { 59 60 .cmd = CMD_PIO_READ_8, 60 .addr = (void *) 0, /* will be patched in run-time */61 .addr = (void *) 0, /* Will be patched in run-time */ 61 62 .dstarg = 1 62 63 }, … … 74 75 { 75 76 .cmd = CMD_PIO_READ_8, 76 .addr = (void *) 0, /* will be patched in run-time */77 .addr = (void *) 0, /* Will be patched in run-time */ 77 78 .dstarg = 2 78 79 }, … … 96 97 void *vaddr; 97 98 98 async_set_interrupt_received(ns16550_irq_handler); 99 100 ns16550_physical = sysinfo_value("kbd.address.physical"); 101 ns16550_kernel = sysinfo_value("kbd.address.kernel"); 99 if (sysinfo_get_value("kbd.address.physical", &ns16550_physical) != EOK) 100 return -1; 101 102 if (sysinfo_get_value("kbd.address.kernel", &ns16550_kernel) != EOK) 103 return -1; 104 105 sysarg_t inr; 106 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 107 return -1; 108 102 109 ns16550_kbd.cmds[0].addr = (void *) (ns16550_kernel + LSR_REG); 103 110 ns16550_kbd.cmds[3].addr = (void *) (ns16550_kernel + RBR_REG); 104 ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 105 sysinfo_value("kbd.inr"), &ns16550_kbd); 111 112 async_set_interrupt_received(ns16550_irq_handler); 113 ipc_register_irq(inr, device_assign_devno(), inr, &ns16550_kbd); 114 106 115 return pio_enable((void *) ns16550_physical, 8, &vaddr); 107 116 } -
uspace/srv/hid/kbd/port/pl050.c
r38aaacc2 rf4f866c 45 45 #include <ddi.h> 46 46 #include <stdio.h> 47 #include <errno.h> 47 48 48 #define PL050_STAT_RXFULL (1 << 4) 49 #define PL050_STAT_RXFULL (1 << 4) 50 49 51 static irq_cmd_t pl050_cmds[] = { 50 52 { … … 66 68 { 67 69 .cmd = CMD_PIO_READ_8, 68 .addr = NULL, /* will be patched in run-time */70 .addr = NULL, /* Will be patched in run-time */ 69 71 .dstarg = 2 70 72 }, … … 83 85 int kbd_port_init(void) 84 86 { 85 86 pl050_kbd.cmds[0].addr = (void *) sysinfo_value("kbd.address.status"); 87 pl050_kbd.cmds[3].addr = (void *) sysinfo_value("kbd.address.data"); 88 87 sysarg_t addr; 88 if (sysinfo_get_value("kbd.address.status", &addr) != EOK) 89 return -1; 90 91 pl050_kbd.cmds[0].addr = (void *) addr; 92 93 if (sysinfo_get_value("kbd.address.data", &addr) != EOK) 94 return -1; 95 96 pl050_kbd.cmds[3].addr = (void *) addr; 97 98 sysarg_t inr; 99 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 100 return -1; 101 89 102 async_set_interrupt_received(pl050_irq_handler); 90 91 ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 0, &pl050_kbd); 92 103 ipc_register_irq(inr, device_assign_devno(), 0, &pl050_kbd); 104 93 105 return 0; 94 106 } -
uspace/srv/hid/kbd/port/sgcn.c
r38aaacc2 rf4f866c 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 * @brief SGCN (Serengeti Console) keyboard port driver.34 * @brief SGCN (Serengeti Console) keyboard port driver. 35 35 */ 36 36 … … 44 44 #include <thread.h> 45 45 #include <bool.h> 46 #include <errno.h> 46 47 47 #define POLL_INTERVAL 1000048 #define POLL_INTERVAL 10000 48 49 49 50 /** 50 51 * SGCN buffer header. It is placed at the very beginning of the SGCN 51 * buffer. 52 * buffer. 52 53 */ 53 54 typedef struct { … … 102 103 int kbd_port_init(void) 103 104 { 104 sram_virt_addr = (uintptr_t) as_get_mappable_page(sysinfo_value("sram.area.size")); 105 if (physmem_map((void *) sysinfo_value("sram.address.physical"), 106 (void *) sram_virt_addr, sysinfo_value("sram.area.size") / PAGE_SIZE, 107 AS_AREA_READ | AS_AREA_WRITE) != 0) { 105 sysarg_t sram_paddr; 106 if (sysinfo_get_value("sram.address.physical", &sram_paddr) != EOK) 107 return -1; 108 109 sysarg_t sram_size; 110 if (sysinfo_get_value("sram.area.size", &sram_size) != EOK) 111 return -1; 112 113 if (sysinfo_get_value("sram.buffer.offset", &sram_buffer_offset) != EOK) 114 sram_buffer_offset = 0; 115 116 sram_virt_addr = (uintptr_t) as_get_mappable_page(sram_size); 117 118 if (physmem_map((void *) sram_paddr, (void *) sram_virt_addr, 119 sram_size / PAGE_SIZE, AS_AREA_READ | AS_AREA_WRITE) != 0) { 108 120 printf("SGCN: uspace driver could not map physical memory."); 109 121 return -1; 110 122 } 111 123 112 sram_buffer_offset = sysinfo_value("sram.buffer.offset");113 114 124 thread_id_t tid; 115 int rc; 116 117 rc = thread_create(sgcn_thread_impl, NULL, "kbd_poll", &tid); 118 if (rc != 0) { 125 int rc = thread_create(sgcn_thread_impl, NULL, "kbd_poll", &tid); 126 if (rc != 0) 119 127 return rc; 120 } 121 128 122 129 return 0; 123 130 } -
uspace/srv/hid/kbd/port/sun.c
r38aaacc2 rf4f866c 39 39 #include <sun.h> 40 40 #include <sysinfo.h> 41 #include <errno.h> 42 #include <bool.h> 41 43 42 44 /** Sun keyboard virtual port driver. … … 50 52 int kbd_port_init(void) 51 53 { 52 if (sysinfo_value("kbd.type.z8530")) { 54 sysarg_t z8530; 55 if (sysinfo_get_value("kbd.type.z8530", &z8530) != EOK) 56 z8530 = false; 57 58 sysarg_t ns16550; 59 if (sysinfo_get_value("kbd.type.ns16550", &ns16550) != EOK) 60 ns16550 = false; 61 62 if (z8530) { 53 63 if (z8530_port_init() == 0) 54 64 return 0; 55 65 } 56 66 57 if ( sysinfo_value("kbd.type.ns16550")) {67 if (ns16550) { 58 68 if (ns16550_port_init() == 0) 59 69 return 0; -
uspace/srv/hid/kbd/port/z8530.c
r38aaacc2 rf4f866c 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 * @brief Z8530 keyboard port driver.34 * @brief Z8530 keyboard port driver. 35 35 */ 36 36 … … 44 44 #include <sys/types.h> 45 45 #include <ddi.h> 46 #include <errno.h> 46 47 47 #define CHAN_A_STATUS 448 #define CHAN_A_DATA 648 #define CHAN_A_STATUS 4 49 #define CHAN_A_DATA 6 49 50 50 #define RR0_RCA 151 #define RR0_RCA 1 51 52 52 53 static irq_cmd_t z8530_cmds[] = { 53 54 { 54 55 .cmd = CMD_PIO_READ_8, 55 .addr = (void *) 0, /* will be patched in run-time */56 .addr = (void *) 0, /* Will be patched in run-time */ 56 57 .dstarg = 1 57 58 }, … … 69 70 { 70 71 .cmd = CMD_PIO_READ_8, 71 .addr = (void *) 0, /* will be patched in run-time */72 .addr = (void *) 0, /* Will be patched in run-time */ 72 73 .dstarg = 2 73 74 }, … … 86 87 int z8530_port_init(void) 87 88 { 89 sysarg_t kaddr; 90 if (sysinfo_get_value("kbd.address.kernel", &kaddr) != EOK) 91 return -1; 92 93 sysarg_t inr; 94 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 95 return -1; 96 97 z8530_cmds[0].addr = (void *) kaddr + CHAN_A_STATUS; 98 z8530_cmds[3].addr = (void *) kaddr + CHAN_A_DATA; 99 88 100 async_set_interrupt_received(z8530_irq_handler); 89 z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.kernel") + 90 CHAN_A_STATUS; 91 z8530_cmds[3].addr = (void *) sysinfo_value("kbd.address.kernel") + 92 CHAN_A_DATA; 93 ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 94 sysinfo_value("kbd.inr"), &z8530_kbd); 101 ipc_register_irq(inr, device_assign_devno(), inr, &z8530_kbd); 102 95 103 return 0; 96 104 }
Note:
See TracChangeset
for help on using the changeset viewer.
