Changeset c621f4aa in mainline for uspace/srv/hid


Ignore:
Timestamp:
2010-07-25T10:11:13Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
377cce8
Parents:
24a2517 (diff), a2da43c (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.
Message:

Merge with mainline.

Location:
uspace/srv/hid
Files:
3 added
5 deleted
30 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/adb_mouse/Makefile

    r24a2517 rc621f4aa  
    2828
    2929USPACE_PREFIX = ../../..
    30 LIBS = $(LIBC_PREFIX)/libc.a
    3130EXTRA_CFLAGS = -Iinclude
    32 
    33 OUTPUT = adb_ms
     31BINARY = adb_ms
    3432
    3533SOURCES = \
     
    3735        adb_dev.c
    3836
    39 include ../../Makefile.common
     37include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hid/adb_mouse/adb_dev.c

    r24a2517 rc621f4aa  
    5050int adb_dev_init(void)
    5151{
    52         char *input = "/dev/adb/mouse";
     52        const char *input = "/dev/adb/mouse";
    5353        int input_fd;
    5454
  • uspace/srv/hid/char_mouse/Makefile

    r24a2517 rc621f4aa  
    2929
    3030USPACE_PREFIX = ../../..
    31 LIBS = $(LIBC_PREFIX)/libc.a
    3231EXTRA_CFLAGS = -Iinclude
    33 
    34 OUTPUT = char_ms
     32BINARY = char_ms
    3533
    3634SOURCES = \
     
    3937        chardev.c
    4038
    41 include ../../Makefile.common
     39include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hid/char_mouse/chardev.c

    r24a2517 rc621f4aa  
    4848static int dev_phone;
    4949
    50 #define NAME "kbd"
     50#define NAME "char_mouse"
    5151
    5252int mouse_port_init(void)
    5353{
    54         char *input = "/dev/char/ps2b";
     54        const char *input = "/dev/char/ps2b";
    5555        int input_fd;
    5656
  • uspace/srv/hid/char_mouse/proto/ps2.c

    r24a2517 rc621f4aa  
    3636
    3737#include <stdio.h>
     38#include <mouse_port.h>
     39#include <char_mouse.h>
    3840#include <mouse_proto.h>
    39 #include <char_mouse.h>
    4041
    4142#define BUFSIZE 3
     43
     44#define PS2_MOUSE_OUT_INIT  0xf4
     45#define PS2_MOUSE_ACK       0xfa
    4246
    4347typedef struct {
     
    6771int mouse_proto_init(void)
    6872{
     73        mouse_port_write(PS2_MOUSE_OUT_INIT);
    6974        return 0;
    7075}
  • uspace/srv/hid/console/Makefile

    r24a2517 rc621f4aa  
    2828#
    2929
    30 include Makefile.common
     30USPACE_PREFIX = ../../..
     31BINARY = console
    3132
    32 .PHONY: all clean
     33GENERIC_SOURCES = \
     34        console.c \
     35        keybuffer.c \
     36        gcons.c
    3337
    34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
    35         -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
    36         $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
     38IMAGES = \
     39        gfx/helenos.ppm \
     40        gfx/nameic.ppm \
     41        gfx/cons_selected.ppm \
     42        gfx/cons_idle.ppm \
     43        gfx/cons_has_data.ppm \
     44        gfx/cons_kernel.ppm \
     45        gfx/anim_1.ppm \
     46        gfx/anim_2.ppm \
     47        gfx/anim_3.ppm \
     48        gfx/anim_4.ppm
    3749
    38 clean:
    39         rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
    40         find . -name '*.o' -follow -exec rm \{\} \;
     50SOURCES = \
     51        $(GENERIC_SOURCES) \
     52        $(IMAGES)
     53
     54include $(USPACE_PREFIX)/Makefile.common
     55
     56%.o: %.ppm
     57        $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) $< $@
  • uspace/srv/hid/console/console.c

    r24a2517 rc621f4aa  
    4747#include <sys/mman.h>
    4848#include <stdio.h>
    49 #include <string.h>
     49#include <str.h>
    5050#include <sysinfo.h>
    5151#include <event.h>
     
    5454#include <vfs/vfs.h>
    5555#include <fibril_synch.h>
     56#include <io/style.h>
     57#include <io/screenbuffer.h>
    5658
    5759#include "console.h"
    5860#include "gcons.h"
    5961#include "keybuffer.h"
    60 #include "screenbuffer.h"
     62
    6163
    6264#define NAME       "console"
     
    7173/** Information about framebuffer */
    7274struct {
    73         int phone;      /**< Framebuffer phone */
    74         ipcarg_t cols;  /**< Framebuffer columns */
    75         ipcarg_t rows;  /**< Framebuffer rows */
    76         int 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) */
    7779} fb_info;
    7880
     
    99101/** Information on row-span yet unsent to FB driver. */
    100102struct {
    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. */
    104106} fb_pending;
    105107
     
    117119}
    118120
    119 static void curs_goto(size_t x, size_t y)
     121static void curs_goto(ipcarg_t x, ipcarg_t y)
    120122{
    121123        async_msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y);
     
    147149}
    148150
    149 static void set_style(int style)
     151static void set_style(uint8_t style)
    150152{
    151153        async_msg_1(fb_info.phone, FB_SET_STYLE, style);
    152154}
    153155
    154 static void set_color(int fgcolor, int bgcolor, int flags)
     156static void set_color(uint8_t fgcolor, uint8_t bgcolor, uint8_t flags)
    155157{
    156158        async_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags);
    157159}
    158160
    159 static void set_rgb_color(int fgcolor, int bgcolor)
     161static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor)
    160162{
    161163        async_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
     
    178180}
    179181
    180 static int ccap_fb_to_con(int ccap_fb, int *ccap_con)
     182static int ccap_fb_to_con(ipcarg_t ccap_fb, ipcarg_t *ccap_con)
    181183{
    182184        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       
    190201        return EOK;
    191202}
     
    226237 *
    227238 */
    228 static void cell_mark_changed(size_t col, size_t row)
     239static void cell_mark_changed(ipcarg_t col, ipcarg_t row)
    229240{
    230241        if (fb_pending.cnt != 0) {
     
    253264{
    254265        bool flush_cursor = false;
    255 
     266       
    256267        switch (ch) {
    257268        case '\n':
     
    297308                        async_msg_1(fb_info.phone, FB_SCROLL, 1);
    298309        }
    299 
     310       
    300311        if (cons == active_console && flush_cursor)
    301312                curs_goto(cons->scr.position_x, cons->scr.position_y);
     
    327338       
    328339        if (cons != kernel_console) {
    329                 size_t x;
    330                 size_t y;
    331                 int rc = 0;
    332                
    333340                async_serialize_start();
    334341               
     
    344351                set_attrs(&cons->scr.attrs);
    345352                curs_visibility(false);
     353               
     354                ipcarg_t x;
     355                ipcarg_t y;
     356                int rc = 0;
     357               
    346358                if (interbuffer) {
    347359                        for (y = 0; y < cons->scr.size_y; y++) {
     
    390402        /* Ignore parameters, the connection is already opened */
    391403        while (true) {
    392                
    393404                ipc_call_t call;
    394405                ipc_callid_t callid = async_get_call(&call);
     
    433444static void mouse_events(ipc_callid_t iid, ipc_call_t *icall)
    434445{
    435         int button, press;
    436         int dx, dy;
    437         int newcon;
    438 
    439446        /* Ignore parameters, the connection is already opened */
    440447        while (true) {
    441 
    442448                ipc_call_t call;
    443449                ipc_callid_t callid = async_get_call(&call);
    444 
     450               
    445451                int retval;
    446 
     452               
    447453                switch (IPC_GET_METHOD(call)) {
    448454                case IPC_M_PHONE_HUNGUP:
     
    450456                        return;
    451457                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));
    456460                                if (newcon != -1)
    457461                                        change_console(&consoles[newcon]);
     
    460464                        break;
    461465                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));
    465468                        retval = 0;
    466469                        break;
     
    520523        console_event_t ev;
    521524        fibril_mutex_lock(&input_mutex);
     525       
    522526recheck:
    523527        while ((keybuffer_pop(&cons->keybuffer, &ev)) && (pos < size)) {
     
    536540                goto recheck;
    537541        }
     542       
    538543        fibril_mutex_unlock(&input_mutex);
    539544}
     
    542547{
    543548        console_event_t ev;
    544 
     549       
    545550        fibril_mutex_lock(&input_mutex);
     551       
    546552recheck:
    547553        if (keybuffer_pop(&cons->keybuffer, &ev)) {
     
    551557                goto recheck;
    552558        }
     559       
    553560        fibril_mutex_unlock(&input_mutex);
    554561}
     
    580587        ipcarg_t arg2;
    581588        ipcarg_t arg3;
    582 
    583         int cons_ccap;
     589       
    584590        int rc;
    585591       
     
    622628                        if (cons == active_console) {
    623629                                async_req_0_0(fb_info.phone, FB_FLUSH);
    624                                
    625630                                curs_goto(cons->scr.position_x, cons->scr.position_y);
    626631                        }
     
    650655                        break;
    651656                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);
    653658                        if (rc != EOK) {
    654659                                ipc_answer_0(callid, rc);
    655660                                continue;
    656661                        }
    657                         arg1 = cons_ccap;
    658662                        break;
    659663                case CONSOLE_SET_STYLE:
     
    714718                return false;
    715719        }
    716 
     720       
    717721        kbd_phone = fd_phone(input_fd);
    718722        if (kbd_phone < 0) {
     
    720724                return false;
    721725        }
    722 
     726       
    723727        /* NB: The callback connection is slotted for removal */
    724728        ipcarg_t phonehash;
     
    727731                return false;
    728732        }
    729 
     733       
    730734        async_new_connection(phonehash, 0, NULL, keyboard_events);
    731 
     735       
    732736        /* Connect to mouse device */
    733737        mouse_phone = -1;
    734738        int mouse_fd = open("/dev/hid_in/mouse", O_RDONLY);
    735 
     739       
    736740        if (mouse_fd < 0) {
    737741                printf(NAME ": Notice - failed opening %s\n", "/dev/hid_in/mouse");
    738742                goto skip_mouse;
    739743        }
    740 
     744       
    741745        mouse_phone = fd_phone(mouse_fd);
    742746        if (mouse_phone < 0) {
     
    744748                goto skip_mouse;
    745749        }
    746 
     750       
    747751        if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
    748752                printf(NAME ": Failed to create callback from mouse device\n");
     
    750754                goto skip_mouse;
    751755        }
    752 
     756       
    753757        async_new_connection(phonehash, 0, NULL, mouse_events);
    754758skip_mouse:
    755 
     759       
    756760        /* Connect to framebuffer driver */
    757761        fb_info.phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VIDEO, 0, 0);
     
    760764                return -1;
    761765        }
    762 
     766       
    763767        /* Register driver */
    764768        int rc = devmap_driver_register(NAME, client_connection);
     
    772776       
    773777        /* Synchronize, the gcons could put something in queue */
    774         ipcarg_t color_cap;
    775778        async_req_0_0(fb_info.phone, FB_FLUSH);
    776779        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);
    779781       
    780782        /* Set up shared memory buffer. */
     
    827829        async_serialize_start();
    828830        gcons_redraw_console();
    829         set_rgb_color(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
     831        set_style(STYLE_NORMAL);
    830832        screen_clear();
    831833        curs_goto(0, 0);
  • uspace/srv/hid/console/gcons.c

    r24a2517 rc621f4aa  
    3838#include <stdio.h>
    3939#include <sys/mman.h>
    40 #include <string.h>
     40#include <str.h>
    4141#include <align.h>
    4242#include <bool.h>
     
    5454#define STATUS_HEIGHT  48
    5555
    56 #define MAIN_COLOR  0xffffff
     56#define COLOR_MAIN        0xffffff
     57#define COLOR_FOREGROUND  0x202020
     58#define COLOR_BACKGROUND  0xffffff
     59
     60extern char _binary_gfx_helenos_ppm_start[0];
     61extern int _binary_gfx_helenos_ppm_size;
     62extern char _binary_gfx_nameic_ppm_start[0];
     63extern int _binary_gfx_nameic_ppm_size;
     64
     65extern char _binary_gfx_anim_1_ppm_start[0];
     66extern int _binary_gfx_anim_1_ppm_size;
     67extern char _binary_gfx_anim_2_ppm_start[0];
     68extern int _binary_gfx_anim_2_ppm_size;
     69extern char _binary_gfx_anim_3_ppm_start[0];
     70extern int _binary_gfx_anim_3_ppm_size;
     71extern char _binary_gfx_anim_4_ppm_start[0];
     72extern int _binary_gfx_anim_4_ppm_size;
     73
     74extern char _binary_gfx_cons_selected_ppm_start[0];
     75extern int _binary_gfx_cons_selected_ppm_size;
     76extern char _binary_gfx_cons_idle_ppm_start[0];
     77extern int _binary_gfx_cons_idle_ppm_size;
     78extern char _binary_gfx_cons_has_data_ppm_start[0];
     79extern int _binary_gfx_cons_has_data_ppm_size;
     80extern char _binary_gfx_cons_kernel_ppm_start[0];
     81extern int _binary_gfx_cons_kernel_ppm_size;
    5782
    5883static bool use_gcons = false;
     
    82107static size_t active_console = 0;
    83108
    84 size_t mouse_x;
    85 size_t mouse_y;
    86 
    87 bool btn_pressed;
    88 size_t btn_x;
    89 size_t btn_y;
     109static ipcarg_t mouse_x = 0;
     110static ipcarg_t mouse_y= 0;
     111
     112static bool btn_pressed = false;
     113static ipcarg_t btn_x = 0;
     114static ipcarg_t btn_y = 0;
    90115
    91116static void vp_switch(int vp)
     
    95120
    96121/** Create view port */
    97 static int vp_create(size_t x, size_t y, size_t width, size_t height)
     122static int vp_create(ipcarg_t x, ipcarg_t y, ipcarg_t width, ipcarg_t height)
    98123{
    99124        return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
     
    112137
    113138/** Transparent putchar */
    114 static void tran_putch(wchar_t ch, size_t col, size_t row)
     139static void tran_putch(wchar_t ch, ipcarg_t col, ipcarg_t row)
    115140{
    116141        async_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
     
    259284void gcons_mouse_move(ssize_t dx, ssize_t dy)
    260285{
    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       
    264292        if (active_console != KERNEL_CONSOLE)
    265293                async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
    266294}
    267295
    268 static int gcons_find_conbut(int x, int y)
    269 {
    270         int status_start = STATUS_START + (xres - 800) / 2;
     296static int gcons_find_conbut(ipcarg_t x, ipcarg_t y)
     297{
     298        ipcarg_t status_start = STATUS_START + (xres - 800) / 2;
    271299       
    272300        if ((y < STATUS_TOP) || (y >= STATUS_TOP + STATUS_HEIGHT))
     
    278306        if (x >= status_start + (STATUS_WIDTH + STATUS_SPACE) * CONSOLE_COUNT)
    279307                return -1;
     308       
    280309        if (((x - status_start) % (STATUS_WIDTH + STATUS_SPACE)) < STATUS_SPACE)
    281310                return -1;
    282311       
    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;
    284318}
    285319
     
    287321 *
    288322 * @param state New state (true - pressed, false - depressed)
     323 *
    289324 */
    290325int gcons_mouse_btn(bool state)
    291326{
    292         int conbut;
     327        /* Ignore mouse clicks if no buttons
     328           are drawn at all */
     329        if (xres < 800)
     330                return -1;
    293331       
    294332        if (state) {
    295                 conbut = gcons_find_conbut(mouse_x, mouse_y);
     333                int conbut = gcons_find_conbut(mouse_x, mouse_y);
    296334                if (conbut != -1) {
    297335                        btn_pressed = true;
     
    307345        btn_pressed = false;
    308346       
    309         conbut = gcons_find_conbut(mouse_x, mouse_y);
     347        int conbut = gcons_find_conbut(mouse_x, mouse_y);
    310348        if (conbut == gcons_find_conbut(btn_x, btn_y))
    311349                return conbut;
     
    313351        return -1;
    314352}
    315 
    316353
    317354/** Draw a PPM pixmap to framebuffer
     
    321358 * @param x Coordinate of upper left corner
    322359 * @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 */
     362static void draw_pixmap(char *logo, size_t size, ipcarg_t x, ipcarg_t y)
     363{
    329364        /* 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 |
    331366            MAP_ANONYMOUS, 0, 0);
    332367        if (shm == MAP_FAILED)
     
    336371       
    337372        /* 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);
    339374        if (rc)
    340375                goto exit;
     
    356391}
    357392
    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 
    363393/** Redraws console graphics */
    364394void gcons_redraw_console(void)
    365395{
    366         int i;
    367        
    368396        if (!use_gcons)
    369397                return;
    370398       
    371399        vp_switch(0);
    372         set_rgb_color(MAIN_COLOR, MAIN_COLOR);
     400        set_rgb_color(COLOR_MAIN, COLOR_MAIN);
    373401        clear();
    374402        draw_pixmap(_binary_gfx_helenos_ppm_start,
     
    377405            (size_t) &_binary_gfx_nameic_ppm_size, 5, 17);
    378406       
     407        unsigned int i;
    379408        for (i = 0; i < CONSOLE_COUNT; i++)
    380409                redraw_state(i);
     
    393422static int make_pixmap(char *data, size_t size)
    394423{
    395         char *shm;
    396         int rc;
    397         int pxid = -1;
    398        
    399424        /* 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 |
    401426            MAP_ANONYMOUS, 0, 0);
    402427        if (shm == MAP_FAILED)
     
    405430        memcpy(shm, data, size);
    406431       
     432        int pxid = -1;
     433       
    407434        /* 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);
    409436        if (rc)
    410437                goto exit;
     
    432459}
    433460
    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 
    443461static void make_anim(void)
    444462{
    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]);
    446465        if (an < 0)
    447466                return;
    448467       
    449468        int pm = make_pixmap(_binary_gfx_anim_1_ppm_start,
    450             (int) &_binary_gfx_anim_1_ppm_size);
     469            (size_t) &_binary_gfx_anim_1_ppm_size);
    451470        async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    452471       
    453472        pm = make_pixmap(_binary_gfx_anim_2_ppm_start,
    454             (int) &_binary_gfx_anim_2_ppm_size);
     473            (size_t) &_binary_gfx_anim_2_ppm_size);
    455474        async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    456475       
    457476        pm = make_pixmap(_binary_gfx_anim_3_ppm_start,
    458             (int) &_binary_gfx_anim_3_ppm_size);
     477            (size_t) &_binary_gfx_anim_3_ppm_size);
    459478        async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    460479       
    461480        pm = make_pixmap(_binary_gfx_anim_4_ppm_start,
    462             (int) &_binary_gfx_anim_4_ppm_size);
     481            (size_t) &_binary_gfx_anim_4_ppm_size);
    463482        async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    464483       
     
    467486        animation = an;
    468487}
    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;
    478488
    479489/** Initialize nice graphical console environment */
     
    500510       
    501511        /* Create status buttons */
    502         size_t status_start = STATUS_START + (xres - 800) / 2;
     512        ipcarg_t status_start = STATUS_START + (xres - 800) / 2;
    503513        size_t i;
    504514        for (i = 0; i < CONSOLE_COUNT; i++) {
     
    511521               
    512522                vp_switch(cstatus_vp[i]);
    513                 set_rgb_color(0x202020, 0xffffff);
     523                set_rgb_color(COLOR_FOREGROUND, COLOR_BACKGROUND);
    514524        }
    515525       
  • uspace/srv/hid/console/gcons.h

    r24a2517 rc621f4aa  
    3838#include <sys/types.h>
    3939
    40 void gcons_init(int phone);
     40void gcons_init(int);
    4141
    4242void gcons_redraw_console(void);
    43 void gcons_change_console(size_t index);
    44 void gcons_notify_char(size_t index);
     43void gcons_change_console(size_t);
     44void gcons_notify_char(size_t);
    4545void gcons_in_kernel(void);
    4646
    47 void gcons_notify_connect(size_t index);
    48 void gcons_notify_disconnect(size_t index);
     47void gcons_notify_connect(size_t);
     48void gcons_notify_disconnect(size_t);
    4949
    50 void gcons_mouse_move(ssize_t dx, ssize_t dy);
     50void gcons_mouse_move(ssize_t, ssize_t);
    5151int gcons_mouse_btn(bool state);
    5252
  • uspace/srv/hid/console/keybuffer.h

    r24a2517 rc621f4aa  
    4747typedef struct {
    4848        console_event_t fifo[KEYBUFFER_SIZE];
    49         unsigned long head;
    50         unsigned long tail;
    51         unsigned long items;
     49        size_t head;
     50        size_t tail;
     51        size_t items;
    5252} keybuffer_t;
    5353
  • uspace/srv/hid/fb/Makefile

    r24a2517 rc621f4aa  
    2828#
    2929
    30 include Makefile.common
     30USPACE_PREFIX = ../../..
     31ROOT_PATH = $(USPACE_PREFIX)/..
    3132
    32 .PHONY: all clean
     33COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common
     34CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
    3335
    34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
    35         -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
    36         $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
     36BINARY = fb
    3737
    38 clean:
    39         rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
    40         find . -name '*.o' -follow -exec rm \{\} \;
     38-include $(COMMON_MAKEFILE)
     39-include $(CONFIG_MAKEFILE)
     40
     41SOURCES = \
     42        main.c \
     43        ppm.c
     44
     45ifneq ($(UARCH),ia64)
     46        SOURCES += \
     47                fb.c \
     48                font-8x16.c
     49        EXTRA_CFLAGS += -DFB_ENABLED
     50endif
     51
     52ifeq ($(UARCH),ia32)
     53        SOURCES += \
     54                ega.c
     55        EXTRA_CFLAGS += -DEGA_ENABLED
     56endif
     57
     58ifeq ($(UARCH),ia64)
     59        SOURCES += \
     60                ega.c \
     61                ski.c \
     62                serial_console.c
     63        EXTRA_CFLAGS += -DSKI_ENABLED -DEGA_ENABLED
     64endif
     65
     66ifeq ($(UARCH),amd64)
     67        SOURCES += \
     68                ega.c
     69        EXTRA_CFLAGS += -DEGA_ENABLED
     70endif
     71
     72ifeq ($(UARCH),mips32)
     73        SOURCES += \
     74                msim.c \
     75                serial_console.c
     76        EXTRA_CFLAGS += -DMSIM_ENABLED
     77endif
     78
     79ifeq ($(UARCH),sparc64)
     80        ifeq ($(PROCESSOR),sun4v)
     81                SOURCES += \
     82                        niagara.c \
     83                        serial_console.c
     84                EXTRA_CFLAGS += -DNIAGARA_ENABLED
     85        endif
     86       
     87        ifeq ($(MACHINE),serengeti)
     88                SOURCES += \
     89                        sgcn.c \
     90                        serial_console.c
     91                EXTRA_CFLAGS += -DSGCN_ENABLED
     92        endif
     93endif
     94
     95EXTRA_CFLAGS += -D$(UARCH)
     96
     97include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hid/fb/ega.c

    r24a2517 rc621f4aa  
    2828
    2929/** @defgroup egafb EGA framebuffer
    30  * @brief       HelenOS EGA framebuffer.
     30 * @brief HelenOS EGA framebuffer.
    3131 * @ingroup fbs
    3232 * @{
    33  */ 
     33 */
    3434/** @file
    3535 */
     
    5252#include <io/style.h>
    5353#include <io/color.h>
     54#include <io/screenbuffer.h>
    5455#include <sys/types.h>
    5556
    5657#include "ega.h"
    57 #include "../console/screenbuffer.h"
    5858#include "main.h"
    5959
    60 #define MAX_SAVED_SCREENS 256
     60#define MAX_SAVED_SCREENS  256
     61
    6162typedef struct saved_screen {
    6263        short *data;
     
    6566saved_screen saved_screens[MAX_SAVED_SCREENS];
    6667
    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
    7570
    7671/* Allow only 1 connection */
    7772static int client_connected = 0;
    7873
    79 static unsigned int scr_width;
    80 static unsigned int scr_height;
     74static sysarg_t scr_width;
     75static sysarg_t scr_height;
    8176static uint8_t *scr_addr;
    8277
    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);
     78static uint8_t style_normal = 0xf0;
     79static uint8_t style_inverted = 0x0f;
     80static uint8_t style;
     81
     82static 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
     96static 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
     107static uint8_t rgb_to_ega_style(uint32_t fg, uint32_t bg)
     108{
     109        return (fg > bg) ? style_inverted : style_normal;
     110}
     111
     112static 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
     127static uint8_t ega_glyph(wchar_t ch)
     128{
     129        if (ch >= 0 && ch < 128)
     130                return ch;
     131       
     132        return '?';
     133}
    87134
    88135static void clrscr(void)
     
    96143}
    97144
    98 static void cursor_goto(unsigned int col, unsigned int row)
    99 {
    100         int ega_cursor;
    101 
    102         ega_cursor = col + scr_width * row;
     145static void cursor_goto(sysarg_t col, sysarg_t row)
     146{
     147        sysarg_t cursor = col + scr_width * row;
    103148       
    104149        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);
    106151        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);
    108153}
    109154
    110155static void cursor_disable(void)
    111156{
    112         uint8_t stat;
    113 
    114157        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       
    116161        pio_write_8(EGA_IO_BASE, 0xa);
    117162        pio_write_8(EGA_IO_BASE + 1, stat | (1 << 5));
     
    120165static void cursor_enable(void)
    121166{
    122         uint8_t stat;
    123 
    124167        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       
    126171        pio_write_8(EGA_IO_BASE, 0xa);
    127172        pio_write_8(EGA_IO_BASE + 1, stat & (~(1 << 5)));
    128173}
    129174
    130 static void scroll(int rows)
    131 {
    132         unsigned i;
    133 
     175static void scroll(ssize_t rows)
     176{
     177        size_t i;
     178       
    134179        if (rows > 0) {
    135180                memmove(scr_addr, ((char *) scr_addr) + rows * scr_width * 2,
     
    142187                    scr_width * scr_height * 2 + rows * scr_width * 2);
    143188                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
     193static void printchar(wchar_t c, sysarg_t col, sysarg_t row)
    149194{
    150195        scr_addr[(row * scr_width + col) * 2] = ega_glyph(c);
     
    158203 * @param vport Viewport id
    159204 * @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 *
    164210 */
    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;
     211static 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;
    169216        keyfield_t *field;
    170217        uint8_t *dp;
    171 
     218       
    172219        for (j = 0; j < h; j++) {
    173220                for (i = 0; i < w; i++) {
    174221                        field = &data[j * w + i];
    175222                        dp = &scr_addr[2 * ((y + j) * scr_width + (x + i))];
    176 
     223                       
    177224                        dp[0] = ega_glyph(field->character);
    178225                        dp[1] = attr_to_ega_style(&field->attrs);
     
    183230static int save_screen(void)
    184231{
    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)
    190238                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)))
    192241                return ENOMEM;
     242       
    193243        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
     247static int print_screen(ipcarg_t i)
     248{
     249        if ((i >= MAX_SAVED_SCREENS) || (saved_screens[i].data))
    201250                memcpy(scr_addr, saved_screens[i].data, 2 * scr_width *
    202251                    scr_height);
    203252        else
    204253                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;
    263256}
    264257
    265258static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall)
    266259{
    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;
    274261        keyfield_t *interbuf = NULL;
    275         size_t intersize = 0;
    276         int i;
    277 
     262       
    278263        if (client_connected) {
    279264                ipc_answer_0(iid, ELIMIT);
    280265                return;
    281266        }
     267       
     268        /* Accept connection */
    282269        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)) {
    288296                case IPC_M_PHONE_HUNGUP:
    289297                        client_connected = 0;
    290298                        ipc_answer_0(callid, EOK);
    291                         return; /* Exit thread */
     299                       
     300                        /* Exit thread */
     301                        return;
    292302                case IPC_M_SHARE_OUT:
    293303                        /* We accept one area for data interchange */
     
    299309                                continue;
    300310                        }
     311                       
    301312                        retval = EINVAL;
    302313                        break;
    303314                case FB_DRAW_TEXT_DATA:
     315                        if (!interbuf) {
     316                                retval = EINVAL;
     317                                break;
     318                        }
     319                       
    304320                        col = IPC_GET_ARG1(call);
    305321                        row = IPC_GET_ARG2(call);
    306322                        w = IPC_GET_ARG3(call);
    307323                        h = IPC_GET_ARG4(call);
    308                         if (!interbuf) {
     324                       
     325                        if ((col + w > scr_width) || (row + h > scr_height)) {
    309326                                retval = EINVAL;
    310327                                break;
    311328                        }
    312                         if (col + w > scr_width || row + h > scr_height) {
    313                                 retval = EINVAL;
    314                                 break;
    315                         }
     329                       
    316330                        draw_text_data(interbuf, col, row, w, h);
    317331                        retval = 0;
     
    331345                        col = IPC_GET_ARG2(call);
    332346                        row = IPC_GET_ARG3(call);
    333                         if (col >= scr_width || row >= scr_height) {
     347                       
     348                        if ((col >= scr_width) || (row >= scr_height)) {
    334349                                retval = EINVAL;
    335350                                break;
    336351                        }
     352                       
    337353                        printchar(c, col, row);
    338354                        retval = 0;
    339355                        break;
    340                 case FB_CURSOR_GOTO:
    341                         col = IPC_GET_ARG1(call);
     356                case FB_CURSOR_GOTO:
     357                        col = IPC_GET_ARG1(call);
    342358                        row = IPC_GET_ARG2(call);
    343                         if (row >= scr_height || col >= scr_width) {
     359                       
     360                        if ((row >= scr_height) || (col >= scr_width)) {
    344361                                retval = EINVAL;
    345362                                break;
    346363                        }
     364                       
    347365                        cursor_goto(col, row);
    348                         retval = 0;
    349                         break;
     366                        retval = 0;
     367                        break;
    350368                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);
    357384                        retval = 0;
    358385                        break;
     
    362389                        else
    363390                                cursor_disable();
     391                       
    364392                        retval = 0;
    365393                        break;
     
    372400                        bg_color = IPC_GET_ARG2(call);
    373401                        attr = IPC_GET_ARG3(call);
     402                       
    374403                        style = color_to_ega_style(fg_color, bg_color, attr);
    375404                        retval = 0;
     
    378407                        fg_rgb = IPC_GET_ARG1(call);
    379408                        bg_rgb = IPC_GET_ARG2(call);
     409                       
    380410                        style = rgb_to_ega_style(fg_rgb, bg_rgb);
    381411                        retval = 0;
    382412                        break;
    383413                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);
    386416                        break;
    387417                case FB_VP2PIXMAP:
     
    389419                        break;
    390420                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) {
    393424                                retval = EINVAL;
    394425                                break;
    395426                        }
    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                       
    400433                        retval = 0;
    401434                        break;
     
    413446int ega_init(void)
    414447{
    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       
    429470        iospace_enable(task_get_id(), (void *) EGA_IO_BASE, 2);
    430 
    431         sz = scr_width * scr_height * 2;
     471       
     472        size_t sz = scr_width * scr_height * 2;
    432473        scr_addr = as_get_mappable_page(sz);
    433 
     474       
    434475        if (physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >>
    435476            PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0)
    436477                return -1;
    437 
     478       
    438479        async_set_client_connection(ega_client_connection);
    439 
     480       
    440481        return 0;
    441482}
    442 
    443483
    444484/**
  • uspace/srv/hid/fb/fb.c

    r24a2517 rc621f4aa  
    4141#include <stdlib.h>
    4242#include <unistd.h>
    43 #include <string.h>
     43#include <str.h>
    4444#include <ddi.h>
    4545#include <sysinfo.h>
     
    5959#include <stdio.h>
    6060#include <byteorder.h>
     61#include <io/screenbuffer.h>
    6162
    6263#include "font-8x16.h"
    6364#include "fb.h"
    6465#include "main.h"
    65 #include "../console/screenbuffer.h"
    6666#include "ppm.h"
    6767
     
    7272#define DEFAULT_FGCOLOR  0x000000
    7373
    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 */
     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 */
    8080
    8181/** Function to render a pixel from a RGB value. */
     
    956956        bb_cell_t *bbp;
    957957        attrs_t *a;
    958         attr_rgb_t rgb;
    959958       
    960959        for (j = 0; j < h; j++) {
     
    966965                       
    967966                        a = &data[j * w + i].attrs;
     967                       
     968                        attr_rgb_t rgb;
     969                        rgb.fg_color = 0;
     970                        rgb.bg_color = 0;
    968971                        rgb_from_attr(&rgb, a);
    969972                       
     
    15111514                rgb->bg_color = color_table[COLOR_WHITE];
    15121515                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;
    15131524        default:
    15141525                return EINVAL;
    15151526        }
    1516 
     1527       
    15171528        return EOK;
    15181529}
     
    17561767        async_set_client_connection(fb_client_connection);
    17571768       
    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;
    17661794        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,
    17691797            ALIGN_UP(fbsize, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0)
    17701798                return -1;
    1771 
     1799       
    17721800        if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual))
    17731801                return 0;
    1774 
     1802       
    17751803        return -1;
    17761804}
  • uspace/srv/hid/fb/main.c

    r24a2517 rc621f4aa  
    4141#include "ski.h"
    4242#include "sgcn.h"
     43#include "niagara.h"
    4344#include "main.h"
    4445
     
    5960int main(int argc, char *argv[])
    6061{
    61         printf(NAME ": HelenOS Framebuffer service\n");
     62        printf("%s: HelenOS Framebuffer service\n", NAME);
    6263       
    63         ipcarg_t phonead;
    6464        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        }
    6575       
    6676#ifdef FB_ENABLED
    67         if (sysinfo_value("fb.kind") == 1) {
     77        if ((!initialized) && (fb_kind == 1)) {
    6878                if (fb_init() == 0)
    6979                        initialized = true;
     
    7181#endif
    7282#ifdef EGA_ENABLED
    73         if ((!initialized) && (sysinfo_value("fb.kind") == 2)) {
     83        if ((!initialized) && (fb_kind == 2)) {
    7484                if (ega_init() == 0)
    7585                        initialized = true;
     
    7787#endif
    7888#ifdef MSIM_ENABLED
    79         if ((!initialized) && (sysinfo_value("fb.kind") == 3)) {
     89        if ((!initialized) && (fb_kind == 3)) {
    8090                if (msim_init() == 0)
    8191                        initialized = true;
     
    8393#endif
    8494#ifdef SGCN_ENABLED
    85         if ((!initialized) && (sysinfo_value("fb.kind") == 4)) {
     95        if ((!initialized) && (fb_kind == 4)) {
    8696                if (sgcn_init() == 0)
    8797                        initialized = true;
    8898        }
    8999#endif
     100#ifdef NIAGARA_ENABLED
     101        if ((!initialized) && (fb_kind == 5)) {
     102                if (niagara_init() == 0)
     103                        initialized = true;
     104        }
     105#endif
    90106#ifdef SKI_ENABLED
    91         if ((!initialized) && (sysinfo_value("fb") != true)) {
     107        if ((!initialized) && (fb_kind == 6)) {
    92108                if (ski_init() == 0)
    93109                        initialized = true;
     
    98114                return -1;
    99115       
     116        ipcarg_t phonead;
    100117        if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, &phonead) != 0)
    101118                return -1;
    102119       
    103         printf(NAME ": Accepting connections\n");
     120        printf("%s: Accepting connections\n", NAME);
    104121        async_manager();
    105122       
  • uspace/srv/hid/fb/msim.c

    r24a2517 rc621f4aa  
    2929
    3030/** @defgroup msimfb MSIM text console
    31  * @brief       HelenOS MSIM text console.
     31 * @brief HelenOS MSIM text console.
    3232 * @ingroup fbs
    3333 * @{
    34  */ 
     34 */
    3535/** @file
    3636 */
     
    4141#include <as.h>
    4242#include <ddi.h>
     43#include <errno.h>
    4344
    4445#include "serial_console.h"
     
    5758int msim_init(void)
    5859{
    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       
    6064        virt_addr = (char *) as_get_mappable_page(1);
    6165       
    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)
    6368                return -1;
    6469       
     
    6974}
    7075
    71 /**
    72  * @}
     76/** @}
    7377 */
  • uspace/srv/hid/fb/serial_console.c

    r24a2517 rc621f4aa  
    3131/**
    3232 * @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,...)
    3434 * @{
    35  */ 
     35 */
    3636
    3737/** @file
     
    4646#include <io/color.h>
    4747#include <io/style.h>
    48 #include <string.h>
    49 
    50 #include "../console/screenbuffer.h"
     48#include <str.h>
     49#include <io/screenbuffer.h>
     50
    5151#include "main.h"
    5252#include "serial_console.h"
     
    5454#define MAX_CONTROL 20
    5555
    56 static void serial_sgr(const unsigned int mode);
    57 void serial_putchar(wchar_t ch);
    58 
    59 static int scr_width;
    60 static int scr_height;
    61 static bool color = true;       /** True if producing color output. */
    62 static bool utf8 = false;       /** True if producing UTF8 output. */
     56static ipcarg_t scr_width;
     57static ipcarg_t scr_height;
     58static bool color = true;    /**< True if producing color output. */
     59static bool utf8 = false;    /**< True if producing UTF8 output. */
    6360static putc_function_t putc_function;
     61
     62static ipcarg_t lastcol = 0;
     63static ipcarg_t lastrow = 0;
     64static attrs_t cur_attr = {
     65        .t = at_style,
     66        .a.s.style = STYLE_NORMAL
     67};
    6468
    6569/* Allow only 1 connection */
     
    6771
    6872enum 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
    7781};
    7882
    7983enum 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,
    86         SGR_REVERSE_OFF = 27,
    87         SGR_FGCOLOR     = 30,
    88         SGR_BGCOLOR     = 40
     84        SGR_RESET       = 0,
     85        SGR_BOLD        = 1,
     86        SGR_UNDERLINE   = 4,
     87        SGR_BLINK       = 5,
     88        SGR_REVERSE     = 7,
     89        SGR_FGCOLOR     = 30,
     90        SGR_BGCOLOR     = 40
    8991};
    9092
    9193static 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,
     94        [COLOR_BLACK]   = CI_BLACK,
     95        [COLOR_BLUE]    = CI_RED,
     96        [COLOR_GREEN]   = CI_GREEN,
     97        [COLOR_CYAN]    = CI_CYAN,
     98        [COLOR_RED]     = CI_RED,
    9799        [COLOR_MAGENTA] = CI_MAGENTA,
    98         [COLOR_YELLOW]  = CI_BROWN,
    99         [COLOR_WHITE]   = CI_WHITE
     100        [COLOR_YELLOW]  = CI_BROWN,
     101        [COLOR_WHITE]   = CI_WHITE
    100102};
    101103
    102 void serial_puts(char *str)
     104void serial_puts(const char *str)
    103105{
    104106        while (*str)
     
    106108}
    107109
    108 void serial_putchar(wchar_t ch)
    109 {
    110         uint8_t buf[STR_BOUNDS(1)];
    111         size_t offs;
    112         size_t i;
    113 
     110static void serial_putchar(wchar_t ch)
     111{
    114112        if (utf8 != true) {
    115113                if (ch >= 0 && ch < 128)
    116114                        (*putc_function)((uint8_t) ch);
    117                 else 
     115                else
    118116                        (*putc_function)('?');
     117               
    119118                return;
    120119        }
    121 
    122         offs = 0;
     120       
     121        size_t offs = 0;
     122        char buf[STR_BOUNDS(1)];
    123123        if (chr_encode(ch, buf, &offs, STR_BOUNDS(1)) == EOK) {
     124                size_t i;
    124125                for (i = 0; i < offs; i++)
    125126                        (*putc_function)(buf[i]);
    126         } else {
     127        } else
    127128                (*putc_function)('?');
    128         }
    129 
    130 }
    131 
    132 void serial_goto(const unsigned int col, const unsigned int row)
     129}
     130
     131void serial_goto(const ipcarg_t col, const ipcarg_t row)
    133132{
    134133        if ((col > scr_width) || (row > scr_height))
     
    138137        snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1);
    139138        serial_puts(control);
     139}
     140
     141/** ECMA-48 Set Graphics Rendition. */
     142static void serial_sgr(const unsigned int mode)
     143{
     144        char control[MAX_CONTROL];
     145        snprintf(control, MAX_CONTROL, "\033[%um", mode);
     146        serial_puts(control);
     147}
     148
     149static void serial_set_style(console_style_t style)
     150{
     151        switch (style) {
     152        case STYLE_EMPHASIS:
     153                serial_sgr(SGR_RESET);
     154                if (color) {
     155                        serial_sgr(SGR_FGCOLOR + CI_RED);
     156                        serial_sgr(SGR_BGCOLOR + CI_WHITE);
     157                }
     158                serial_sgr(SGR_BOLD);
     159                break;
     160        case STYLE_INVERTED:
     161                serial_sgr(SGR_RESET);
     162                if (color) {
     163                        serial_sgr(SGR_FGCOLOR + CI_WHITE);
     164                        serial_sgr(SGR_BGCOLOR + CI_BLACK);
     165                } else
     166                        serial_sgr(SGR_REVERSE);
     167                break;
     168        case STYLE_SELECTED:
     169                serial_sgr(SGR_RESET);
     170                if (color) {
     171                        serial_sgr(SGR_FGCOLOR + CI_WHITE);
     172                        serial_sgr(SGR_BGCOLOR + CI_RED);
     173                } else
     174                        serial_sgr(SGR_UNDERLINE);
     175                break;
     176        default:
     177                serial_sgr(SGR_RESET);
     178                if (color) {
     179                        serial_sgr(SGR_FGCOLOR + CI_BLACK);
     180                        serial_sgr(SGR_BGCOLOR + CI_WHITE);
     181                }
     182        }
     183}
     184
     185static void serial_set_idx(uint8_t fgcolor, uint8_t bgcolor,
     186    uint8_t flags)
     187{
     188        serial_sgr(SGR_RESET);
     189        if (color) {
     190                serial_sgr(SGR_FGCOLOR + color_map[fgcolor & 7]);
     191                serial_sgr(SGR_BGCOLOR + color_map[bgcolor & 7]);
     192                if (flags & CATTR_BRIGHT)
     193                        serial_sgr(SGR_BOLD);
     194        } else {
     195                if (fgcolor >= bgcolor)
     196                        serial_sgr(SGR_REVERSE);
     197        }
     198}
     199
     200static void serial_set_rgb(uint32_t fgcolor, uint32_t bgcolor)
     201{
     202        serial_sgr(SGR_RESET);
     203       
     204        if (fgcolor >= bgcolor)
     205                serial_sgr(SGR_REVERSE);
     206}
     207
     208static void serial_set_attrs(attrs_t *a)
     209{
     210        switch (a->t) {
     211        case at_style:
     212                serial_set_style(a->a.s.style);
     213                break;
     214        case at_rgb:
     215                serial_set_rgb(a->a.r.fg_color, a->a.r.bg_color);
     216                break;
     217        case at_idx:
     218                serial_set_idx(a->a.i.fg_color, a->a.i.bg_color,
     219                    a->a.i.flags);
     220                break;
     221        }
    140222}
    141223
     
    148230                serial_sgr(SGR_BGCOLOR + CI_WHITE);
    149231        }
    150 
     232       
    151233        serial_puts("\033[2J");
    152 }
    153 
    154 void serial_scroll(int i)
     234       
     235        serial_set_attrs(&cur_attr);
     236}
     237
     238void serial_scroll(ssize_t i)
    155239{
    156240        if (i > 0) {
     
    165249}
    166250
    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 
    175251/** Set scrolling region. */
    176 void serial_set_scroll_region(unsigned last_row)
     252void serial_set_scroll_region(ipcarg_t last_row)
    177253{
    178254        char control[MAX_CONTROL];
     
    191267}
    192268
    193 void serial_console_init(putc_function_t putc_fn, uint32_t w, uint32_t h)
     269void serial_console_init(putc_function_t putc_fn, ipcarg_t w, ipcarg_t h)
    194270{
    195271        scr_width = w;
     
    198274}
    199275
    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 }
    259 
    260276/** Draw text data to viewport.
    261277 *
    262  * @param vport Viewport id
    263  * @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 
    276         serial_goto(x, y);
    277         a0 = &data[0].attrs;
     278 * @param vport  Viewport id
     279 * @param data   Text data.
     280 * @param x0     Leftmost column of the area.
     281 * @param y0     Topmost row of the area.
     282 * @param width  Number of rows.
     283 * @param height Number of columns.
     284 *
     285 */
     286static void draw_text_data(keyfield_t *data, ipcarg_t x0, ipcarg_t y0,
     287    ipcarg_t width, ipcarg_t height)
     288{
     289        attrs_t *a0 = &data[0].attrs;
    278290        serial_set_attrs(a0);
    279 
    280         for (j = 0; j < h; j++) {
    281                 if (j > 0 && w != scr_width)
    282                         serial_goto(x, j);
    283 
    284                 for (i = 0; i < w; i++) {
    285                         field = &data[j * w + i];
    286 
    287                         a1 = &field->attrs;
    288                         if (!attrs_same(*a0, *a1))
    289                                 serial_set_attrs(a1);
    290                         serial_putchar(field->character);
    291                         a0 = a1;
     291       
     292        ipcarg_t y;
     293        for (y = 0; y < height; y++) {
     294                serial_goto(x0, y0 + y);
     295               
     296                ipcarg_t x;
     297                for (x = 0; x < width; x++) {
     298                        attrs_t *attr = &data[y * width + x].attrs;
     299                       
     300                        if (!attrs_same(*a0, *attr)) {
     301                                serial_set_attrs(attr);
     302                                a0 = attr;
     303                        }
     304                       
     305                        serial_putchar(data[y * width + x].character);
    292306                }
    293307        }
    294308}
    295 
    296 int lastcol = 0;
    297 int lastrow = 0;
    298309
    299310/**
     
    302313void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall)
    303314{
    304         int retval;
    305         ipc_callid_t callid;
    306         ipc_call_t call;
    307315        keyfield_t *interbuf = NULL;
    308316        size_t intersize = 0;
    309 
    310         wchar_t c;
    311         int col, row, w, h;
    312         int i;
    313 
    314         attrs_t cur_attr;
    315317       
    316318        if (client_connected) {
     
    321323        client_connected = 1;
    322324        ipc_answer_0(iid, EOK);
    323 
    324         cur_attr.t = at_style;
    325         cur_attr.a.s.style = STYLE_NORMAL;
    326325       
    327326        /* Clear the terminal, set scrolling region
     
    332331       
    333332        while (true) {
    334                 callid = async_get_call(&call);
     333                ipc_call_t call;
     334                ipc_callid_t callid = async_get_call(&call);
     335               
     336                wchar_t c;
     337                ipcarg_t col;
     338                ipcarg_t row;
     339                ipcarg_t w;
     340                ipcarg_t h;
     341                ssize_t rows;
     342               
     343                int retval;
     344               
    335345                switch (IPC_GET_METHOD(call)) {
    336346                case IPC_M_PHONE_HUNGUP:
    337347                        client_connected = 0;
    338348                        ipc_answer_0(callid, EOK);
     349                       
     350                        /* Exit thread */
    339351                        return;
    340352                case IPC_M_SHARE_OUT:
     
    347359                                continue;
    348360                        }
     361                       
    349362                        retval = EINVAL;
    350363                        break;
     
    354367                        w = IPC_GET_ARG3(call);
    355368                        h = IPC_GET_ARG4(call);
     369                       
    356370                        if (!interbuf) {
    357371                                retval = EINVAL;
    358372                                break;
    359373                        }
    360                         if (col + w > scr_width || row + h > scr_height) {
     374                       
     375                        if ((col + w > scr_width) || (row + h > scr_height)) {
    361376                                retval = EINVAL;
    362377                                break;
    363378                        }
     379                       
    364380                        draw_text_data(interbuf, col, row, w, h);
    365381                        lastcol = col + w;
     
    371387                        col = IPC_GET_ARG2(call);
    372388                        row = IPC_GET_ARG3(call);
     389                       
    373390                        if ((lastcol != col) || (lastrow != row))
    374391                                serial_goto(col, row);
     392                       
    375393                        lastcol = col + 1;
    376394                        lastrow = row;
     
    400418                        cur_attr.t = at_style;
    401419                        cur_attr.a.s.style = IPC_GET_ARG1(call);
    402                         cur_attr.a.i.bg_color = IPC_GET_ARG2(call);
    403420                        serial_set_attrs(&cur_attr);
    404 
    405421                        retval = 0;
    406422                        break;
     
    411427                        cur_attr.a.i.flags = IPC_GET_ARG3(call);
    412428                        serial_set_attrs(&cur_attr);
    413 
    414429                        retval = 0;
    415430                        break;
    416431                case FB_SET_RGB_COLOR:
    417432                        cur_attr.t = at_rgb;
    418                         cur_attr.a.i.fg_color = IPC_GET_ARG1(call);
    419                         cur_attr.a.i.bg_color = IPC_GET_ARG2(call);
     433                        cur_attr.a.r.fg_color = IPC_GET_ARG1(call);
     434                        cur_attr.a.r.bg_color = IPC_GET_ARG2(call);
    420435                        serial_set_attrs(&cur_attr);
    421 
    422436                        retval = 0;
    423437                        break;
    424438                case FB_SCROLL:
    425                         i = IPC_GET_ARG1(call);
    426                         if ((i > scr_height) || (i < -scr_height)) {
    427                                 retval = EINVAL;
    428                                 break;
     439                        rows = IPC_GET_ARG1(call);
     440                       
     441                        if (rows >= 0) {
     442                                if ((ipcarg_t) rows > scr_height) {
     443                                        retval = EINVAL;
     444                                        break;
     445                                }
     446                        } else {
     447                                if ((ipcarg_t) (-rows) > scr_height) {
     448                                        retval = EINVAL;
     449                                        break;
     450                                }
    429451                        }
    430                         serial_scroll(i);
     452                       
     453                        serial_scroll(rows);
    431454                        serial_goto(lastcol, lastrow);
    432455                        retval = 0;
     
    448471                case FB_SCREEN_RECLAIM:
    449472                        serial_clrscr();
    450                         serial_set_attrs(&cur_attr);
    451473                        retval = 0;
    452474                        break;
  • uspace/srv/hid/fb/serial_console.h

    r24a2517 rc621f4aa  
    2929/**
    3030 * @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,...)
    3232 * @{
    33  */ 
     33 */
    3434
    3535/** @file
     
    4343typedef void (*putc_function_t)(char);
    4444
    45 void serial_puts(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 
     45extern void serial_puts(const char *);
     46extern void serial_goto(const ipcarg_t, const ipcarg_t);
     47extern void serial_clrscr(void);
     48extern void serial_scroll(ssize_t);
     49extern void serial_cursor_disable(void);
     50extern void serial_cursor_enable(void);
     51extern void serial_set_scroll_region(ipcarg_t);
     52extern void serial_console_init(putc_function_t, ipcarg_t, ipcarg_t);
     53extern void serial_client_connection(ipc_callid_t, ipc_call_t *);
    5554
    5655#endif
  • uspace/srv/hid/fb/sgcn.c

    r24a2517 rc621f4aa  
    122122int sgcn_init(void)
    123123{
    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;
    125127       
    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)
    129139                return -1;
    130140       
    131141        serial_console_init(sgcn_putc, WIDTH, HEIGHT);
    132        
    133         sram_buffer_offset = sysinfo_value("sram.buffer.offset");
    134142       
    135143        async_set_client_connection(serial_client_connection);
  • uspace/srv/hid/kbd/Makefile

    r24a2517 rc621f4aa  
    2828#
    2929
    30 include Makefile.common
     30USPACE_PREFIX = ../../..
     31ROOT_PATH = $(USPACE_PREFIX)/..
    3132
    32 .PHONY: all clean
     33COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common
     34CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
    3335
    34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
    35         -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
    36         $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
     36EXTRA_CFLAGS = -Iinclude
     37BINARY = kbd
    3738
    38 clean:
    39         rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
    40         find . -name '*.o' -follow -exec rm \{\} \;
     39-include $(COMMON_MAKEFILE)
     40-include $(CONFIG_MAKEFILE)
     41
     42## Sources
     43#
     44
     45SOURCES = \
     46        generic/kbd.c \
     47        genarch/gsp.c \
     48        genarch/stroke.c \
     49        layout/cz.c \
     50        layout/us_qwerty.c \
     51        layout/us_dvorak.c
     52
     53ifeq ($(UARCH),amd64)
     54        SOURCES += \
     55                port/chardev.c \
     56                ctl/pc.c
     57endif
     58
     59ifeq ($(UARCH),arm32)
     60        ifeq ($(MACHINE),gta02)
     61                SOURCES += \
     62                        port/dummy.c \
     63                        ctl/pc.c
     64        endif
     65        ifeq ($(MACHINE),testarm)
     66                SOURCES += \
     67                        port/gxemul.c
     68               
     69                ifeq ($(CONFIG_FB),y)
     70                        SOURCES += \
     71                                ctl/gxe_fb.c
     72                else
     73                        SOURCES += \
     74                                ctl/stty.c
     75                endif
     76        endif
     77        ifeq ($(MACHINE),integratorcp)
     78                SOURCES += \
     79                        port/pl050.c \
     80                        ctl/pl050.c
     81        endif
     82endif
     83
     84ifeq ($(UARCH),ia32)
     85        SOURCES += \
     86                port/chardev.c \
     87                ctl/pc.c
     88endif
     89
     90ifeq ($(MACHINE),i460GX)
     91        SOURCES += \
     92                port/chardev.c \
     93                ctl/pc.c
     94endif
     95
     96ifeq ($(MACHINE),ski)
     97        SOURCES += \
     98                port/ski.c \
     99                ctl/stty.c
     100endif
     101
     102ifeq ($(MACHINE),msim)
     103        SOURCES += \
     104                port/msim.c \
     105                ctl/stty.c
     106endif
     107
     108ifeq ($(MACHINE),lgxemul)
     109        SOURCES += \
     110                port/gxemul.c
     111       
     112        ifeq ($(CONFIG_FB),y)
     113                SOURCES += \
     114                        ctl/gxe_fb.c
     115        else
     116                SOURCES += \
     117                        ctl/stty.c
     118        endif
     119endif
     120
     121ifeq ($(MACHINE),bgxemul)
     122        SOURCES += \
     123                port/gxemul.c
     124       
     125        ifeq ($(CONFIG_FB),y)
     126                SOURCES += \
     127                        ctl/gxe_fb.c
     128        else
     129                SOURCES += \
     130                        ctl/stty.c
     131        endif
     132endif
     133
     134ifeq ($(UARCH),ppc32)
     135        SOURCES += \
     136                port/adb.c \
     137                ctl/apple.c
     138endif
     139
     140ifeq ($(UARCH),sparc64)
     141        ifeq ($(PROCESSOR),sun4v)
     142                SOURCES += \
     143                        port/niagara.c \
     144                        ctl/stty.c
     145        else
     146                ifeq ($(MACHINE),serengeti)
     147                        SOURCES += \
     148                                port/sgcn.c \
     149                                ctl/stty.c
     150                endif
     151                ifeq ($(MACHINE),generic)
     152                        SOURCES += \
     153                        port/sun.c \
     154                        port/z8530.c \
     155                        port/ns16550.c \
     156                        ctl/sun.c
     157                endif
     158        endif
     159endif
     160
     161ifeq ($(UARCH),abs32le)
     162        SOURCES += \
     163                port/dummy.c \
     164                ctl/pc.c
     165endif
     166
     167include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hid/kbd/generic/kbd.c

    r24a2517 rc621f4aa  
    212212int main(int argc, char **argv)
    213213{
    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))
    217220                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))
    219222                cir_service = SERVICE_OBIO;
    220223       
     
    240243        int rc = devmap_driver_register(NAME, client_connection);
    241244        if (rc < 0) {
    242                 printf(NAME ": Unable to register driver (%d)\n", rc);
     245                printf("%s: Unable to register driver (%d)\n", NAME, rc);
    243246                return -1;
    244247        }
     
    249252        dev_handle_t dev_handle;
    250253        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);
    252255                return -1;
    253256        }
  • uspace/srv/hid/kbd/port/adb.c

    r24a2517 rc621f4aa  
    5353int kbd_port_init(void)
    5454{
    55         char *input = "/dev/adb/kbd";
     55        const char *input = "/dev/adb/kbd";
    5656        int input_fd;
    5757
  • uspace/srv/hid/kbd/port/chardev.c

    r24a2517 rc621f4aa  
    5252int kbd_port_init(void)
    5353{
    54         char *input = "/dev/char/ps2a";
     54        const char *input = "/dev/char/ps2a";
    5555        int input_fd;
    5656
  • uspace/srv/hid/kbd/port/gxemul.c

    r24a2517 rc621f4aa  
    4141#include <kbd.h>
    4242#include <ddi.h>
     43#include <errno.h>
    4344
    4445static irq_cmd_t gxemul_cmds[] = {
     
    6364int kbd_port_init(void)
    6465{
     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       
    6574        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);
    6977        return 0;
    7078}
  • uspace/srv/hid/kbd/port/msim.c

    r24a2517 rc621f4aa  
    3030 * @ingroup  kbd
    3131 * @{
    32  */ 
     32 */
    3333/** @file
    34  * @brief       Msim keyboard port driver.
     34 * @brief Msim keyboard port driver.
    3535 */
    3636
     
    4141#include <kbd.h>
    4242#include <ddi.h>
     43#include <errno.h>
    4344
    4445irq_cmd_t msim_cmds[] = {
     
    6364int kbd_port_init(void)
    6465{
     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;
    6575        async_set_interrupt_received(msim_irq_handler);
    66         msim_cmds[0].addr = 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       
    6978        return 0;
    7079}
  • uspace/srv/hid/kbd/port/ns16550.c

    r24a2517 rc621f4aa  
    3030 * @ingroup  kbd
    3131 * @{
    32  */ 
     32 */
    3333/** @file
    34  * @brief       NS16550 port driver.
     34 * @brief NS16550 port driver.
    3535 */
    3636
     
    4343#include <sun.h>
    4444#include <ddi.h>
     45#include <errno.h>
    4546
    4647/* 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. */
    5455
    55 #define LSR_DATA_READY  0x01
     56#define LSR_DATA_READY  0x01
    5657
    5758static irq_cmd_t ns16550_cmds[] = {
    5859        {
    5960                .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 */
    6162                .dstarg = 1
    6263        },
     
    7475        {
    7576                .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 */
    7778                .dstarg = 2
    7879        },
     
    9697        void *vaddr;
    9798
    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       
    102109        ns16550_kbd.cmds[0].addr = (void *) (ns16550_kernel + LSR_REG);
    103110        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       
    106115        return pio_enable((void *) ns16550_physical, 8, &vaddr);
    107 }
    108 
    109 void ns16550_port_yield(void)
    110 {
    111 }
    112 
    113 void ns16550_port_reclaim(void)
    114 {
    115116}
    116117
  • uspace/srv/hid/kbd/port/pl050.c

    r24a2517 rc621f4aa  
    4545#include <ddi.h>
    4646#include <stdio.h>
     47#include <errno.h>
    4748
    48 #define PL050_STAT_RXFULL (1 << 4)
     49#define PL050_STAT_RXFULL  (1 << 4)
     50
    4951static irq_cmd_t pl050_cmds[] = {
    5052        {
     
    6668        {
    6769                .cmd = CMD_PIO_READ_8,
    68                 .addr = NULL,   /* will be patched in run-time */
     70                .addr = NULL,  /* Will be patched in run-time */
    6971                .dstarg = 2
    7072        },
     
    8385int kbd_port_init(void)
    8486{
    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       
    89102        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       
    93105        return 0;
    94106}
  • uspace/srv/hid/kbd/port/sgcn.c

    r24a2517 rc621f4aa  
    3030 * @ingroup  kbd
    3131 * @{
    32  */ 
     32 */
    3333/** @file
    34  * @brief       SGCN (Serengeti Console) keyboard port driver.
     34 * @brief SGCN (Serengeti Console) keyboard port driver.
    3535 */
    3636
     
    4444#include <thread.h>
    4545#include <bool.h>
     46#include <errno.h>
    4647
    47 #define POLL_INTERVAL           10000
     48#define POLL_INTERVAL  10000
    4849
    4950/**
    5051 * SGCN buffer header. It is placed at the very beginning of the SGCN
    51  * buffer. 
     52 * buffer.
    5253 */
    5354typedef struct {
     
    9293
    9394/* polling thread */
    94 static void *sgcn_thread_impl(void *arg);
     95static void sgcn_thread_impl(void *arg);
    9596
    9697static volatile bool polling_disabled = false;
     
    102103int kbd_port_init(void)
    103104{
    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) {
    108120                printf("SGCN: uspace driver could not map physical memory.");
    109121                return -1;
    110122        }
    111123       
    112         sram_buffer_offset = sysinfo_value("sram.buffer.offset");
    113 
    114124        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)
    119127                return rc;
    120         }
    121 
     128       
    122129        return 0;
    123130}
     
    167174 * Thread to poll SGCN for keypresses.
    168175 */
    169 static void *sgcn_thread_impl(void *arg)
     176static void sgcn_thread_impl(void *arg)
    170177{
    171178        (void) arg;
  • uspace/srv/hid/kbd/port/ski.c

    r24a2517 rc621f4aa  
    4949#define POLL_INTERVAL           10000
    5050
    51 static void *ski_thread_impl(void *arg);
     51static void ski_thread_impl(void *arg);
    5252static int32_t ski_getchar(void);
    5353
     
    8484
    8585/** Thread to poll Ski for keypresses. */
    86 static void *ski_thread_impl(void *arg)
     86static void ski_thread_impl(void *arg)
    8787{
    8888        int32_t c;
  • uspace/srv/hid/kbd/port/sun.c

    r24a2517 rc621f4aa  
    3939#include <sun.h>
    4040#include <sysinfo.h>
     41#include <errno.h>
     42#include <bool.h>
    4143
    4244/** Sun keyboard virtual port driver.
     
    5052int kbd_port_init(void)
    5153{
    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) {
    5363                if (z8530_port_init() == 0)
    5464                        return 0;
    5565        }
    5666       
    57         if (sysinfo_value("kbd.type.ns16550")) {
     67        if (ns16550) {
    5868                if (ns16550_port_init() == 0)
    5969                        return 0;
  • uspace/srv/hid/kbd/port/z8530.c

    r24a2517 rc621f4aa  
    3030 * @ingroup  kbd
    3131 * @{
    32  */ 
     32 */
    3333/** @file
    34  * @brief       Z8530 keyboard port driver.
     34 * @brief Z8530 keyboard port driver.
    3535 */
    3636
     
    4444#include <sys/types.h>
    4545#include <ddi.h>
     46#include <errno.h>
    4647
    47 #define CHAN_A_STATUS   4
    48 #define CHAN_A_DATA     6
     48#define CHAN_A_STATUS  4
     49#define CHAN_A_DATA    6
    4950
    50 #define RR0_RCA 1
     51#define RR0_RCA  1
    5152
    5253static irq_cmd_t z8530_cmds[] = {
    5354        {
    5455                .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 */
    5657                .dstarg = 1
    5758        },
     
    6970        {
    7071                .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 */
    7273                .dstarg = 2
    7374        },
     
    8687int z8530_port_init(void)
    8788{
     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       
    88100        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       
    95103        return 0;
    96 }
    97 
    98 void z8530_port_yield(void)
    99 {
    100 }
    101 
    102 void z8530_port_reclaim(void)
    103 {
    104104}
    105105
Note: See TracChangeset for help on using the changeset viewer.