Changeset 4c53333 in mainline for uspace/srv/hid


Ignore:
Timestamp:
2013-07-11T08:21:10Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
64e63ce1
Parents:
80445cf (diff), c8bb1633 (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 mainline changes

Location:
uspace/srv/hid
Files:
12 added
15 deleted
27 edited
30 moved

Legend:

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

    r80445cf r4c53333  
    2929
    3030USPACE_PREFIX = ../../..
    31 LIBS = $(LIBFB_PREFIX)/libfb.a
    32 EXTRA_CFLAGS += -I$(LIBFB_PREFIX)
    3331BINARY = console
    3432
    3533SOURCES = \
    36         console.c \
    37         images.c
    38 
    39 IMAGES = \
    40         gfx/helenos.tga \
    41         gfx/nameic.tga \
    42         gfx/cons_data.tga \
    43         gfx/cons_dis.tga \
    44         gfx/cons_dis_sel.tga \
    45         gfx/cons_idle.tga \
    46         gfx/cons_sel.tga \
    47         gfx/cons_kernel.tga \
    48         gfx/anim_1.tga \
    49         gfx/anim_2.tga \
    50         gfx/anim_3.tga \
    51         gfx/anim_4.tga
    52 
    53 PRE_DEPEND = images.c images.h
    54 EXTRA_CLEAN = images.c images.h
     34        console.c
    5535
    5636include $(USPACE_PREFIX)/Makefile.common
    57 
    58 images.c images.h: $(IMAGES)
    59         $(ROOT_PATH)/tools/mkarray.py images CONSOLE_IMAGES $^
  • uspace/srv/hid/console/console.c

    r80445cf r4c53333  
    3636#include <stdio.h>
    3737#include <adt/prodcons.h>
    38 #include <ipc/input.h>
    39 #include <ipc/console.h>
     38#include <io/input.h>
    4039#include <ipc/vfs.h>
    4140#include <errno.h>
     
    4342#include <loc.h>
    4443#include <event.h>
     44#include <io/con_srv.h>
     45#include <io/kbd_event.h>
    4546#include <io/keycode.h>
    46 #include <screenbuffer.h>
    47 #include <fb.h>
    48 #include <imgmap.h>
     47#include <io/chargrid.h>
     48#include <io/output.h>
    4949#include <align.h>
    5050#include <malloc.h>
    5151#include <as.h>
    5252#include <fibril_synch.h>
    53 #include "images.h"
    5453#include "console.h"
    5554
     
    5756#define NAMESPACE  "term"
    5857
    59 #define CONSOLE_TOP     66
    60 #define CONSOLE_MARGIN  12
    61 
    62 #define STATE_START   100
    63 #define STATE_TOP     8
    64 #define STATE_SPACE   4
    65 #define STATE_WIDTH   48
    66 #define STATE_HEIGHT  48
    67 
    68 typedef enum {
    69         CONS_DISCONNECTED = 0,
    70         CONS_DISCONNECTED_SELECTED,
    71         CONS_SELECTED,
    72         CONS_IDLE,
    73         CONS_DATA,
    74         CONS_KERNEL,
    75         CONS_LAST
    76 } console_state_t;
     58#define UTF8_CHAR_BUFFER_SIZE  (STR_BOUNDS(1) + 1)
    7759
    7860typedef struct {
    79         atomic_t refcnt;           /**< Connection reference count */
    80         prodcons_t input_pc;       /**< Incoming keyboard events */
    81        
    82         fibril_mutex_t mtx;        /**< Lock protecting mutable fields */
    83        
    84         size_t index;              /**< Console index */
    85         console_state_t state;     /**< Console state */
    86         service_id_t dsid;         /**< Service handle */
    87        
    88         vp_handle_t state_vp;      /**< State icon viewport */
    89         sysarg_t cols;             /**< Number of columns */
    90         sysarg_t rows;             /**< Number of rows */
    91         console_caps_t ccaps;      /**< Console capabilities */
    92        
    93         screenbuffer_t *frontbuf;  /**< Front buffer */
    94         frontbuf_handle_t fbid;    /**< Front buffer handle */
     61        atomic_t refcnt;      /**< Connection reference count */
     62        prodcons_t input_pc;  /**< Incoming keyboard events */
     63       
     64        /**
     65         * Not yet sent bytes of last char event.
     66         */
     67        char char_remains[UTF8_CHAR_BUFFER_SIZE];
     68        size_t char_remains_len;  /**< Number of not yet sent bytes. */
     69       
     70        fibril_mutex_t mtx;  /**< Lock protecting mutable fields */
     71       
     72        size_t index;           /**< Console index */
     73        service_id_t dsid;      /**< Service handle */
     74       
     75        sysarg_t cols;         /**< Number of columns */
     76        sysarg_t rows;         /**< Number of rows */
     77        console_caps_t ccaps;  /**< Console capabilities */
     78       
     79        chargrid_t *frontbuf;    /**< Front buffer */
     80        frontbuf_handle_t fbid;  /**< Front buffer handle */
     81        con_srvs_t srvs;         /**< Console service setup */
    9582} console_t;
    9683
    97 typedef enum {
    98         GRAPHICS_NONE = 0,
    99         GRAPHICS_BASIC = 1,
    100         GRAPHICS_FULL = 2
    101 } graphics_state_t;
    102 
    103 /** Current console state */
    104 static graphics_state_t graphics_state = GRAPHICS_NONE;
    105 
    106 /** State icons */
    107 static imagemap_handle_t state_icons[CONS_LAST];
    108 
    109 /** Session to the input server */
    110 static async_sess_t *input_sess;
    111 
    112 /** Session to the framebuffer server */
    113 static async_sess_t *fb_sess;
    114 
    115 /** Framebuffer resolution */
    116 static sysarg_t xres;
    117 static sysarg_t yres;
     84/** Input server proxy */
     85static input_t *input;
     86
     87/** Session to the output server */
     88static async_sess_t *output_sess;
     89
     90/** Output dimensions */
     91static sysarg_t cols;
     92static sysarg_t rows;
    11893
    11994/** Array of data for virtual consoles */
     
    127102static console_t *kernel_console = &consoles[KERNEL_CONSOLE];
    128103
    129 static imgmap_t *logo_img;
    130 static imgmap_t *nameic_img;
    131 
    132 static imgmap_t *anim_1_img;
    133 static imgmap_t *anim_2_img;
    134 static imgmap_t *anim_3_img;
    135 static imgmap_t *anim_4_img;
    136 
    137 static imagemap_handle_t anim_1;
    138 static imagemap_handle_t anim_2;
    139 static imagemap_handle_t anim_3;
    140 static imagemap_handle_t anim_4;
    141 
    142 static sequence_handle_t anim_seq;
    143 
    144 static imgmap_t *cons_data_img;
    145 static imgmap_t *cons_dis_img;
    146 static imgmap_t *cons_dis_sel_img;
    147 static imgmap_t *cons_idle_img;
    148 static imgmap_t *cons_kernel_img;
    149 static imgmap_t *cons_sel_img;
    150 
    151 static vp_handle_t logo_vp;
    152 static imagemap_handle_t logo_handle;
    153 
    154 static vp_handle_t nameic_vp;
    155 static imagemap_handle_t nameic_handle;
    156 
    157 static vp_handle_t screen_vp;
    158 static vp_handle_t console_vp;
    159 
    160 struct {
    161         sysarg_t x;
    162         sysarg_t y;
    163        
    164         sysarg_t btn_x;
    165         sysarg_t btn_y;
    166        
    167         bool pressed;
    168 } mouse;
    169 
    170 static void cons_redraw_state(console_t *cons)
    171 {
    172         if (graphics_state == GRAPHICS_FULL) {
    173                 fibril_mutex_lock(&cons->mtx);
    174                
    175                 fb_vp_imagemap_damage(fb_sess, cons->state_vp,
    176                     state_icons[cons->state], 0, 0, STATE_WIDTH, STATE_HEIGHT);
    177                
    178                 if ((cons->state != CONS_DISCONNECTED) &&
    179                     (cons->state != CONS_KERNEL) &&
    180                     (cons->state != CONS_DISCONNECTED_SELECTED)) {
    181                         char data[5];
    182                         snprintf(data, 5, "%zu", cons->index + 1);
    183                        
    184                         for (size_t i = 0; data[i] != 0; i++)
    185                                 fb_vp_putchar(fb_sess, cons->state_vp, i + 2, 1, data[i]);
    186                 }
    187                
    188                 fibril_mutex_unlock(&cons->mtx);
    189         }
    190 }
    191 
    192 static void cons_kernel_sequence_start(console_t *cons)
    193 {
    194         if (graphics_state == GRAPHICS_FULL) {
    195                 fibril_mutex_lock(&cons->mtx);
    196                
    197                 fb_vp_sequence_start(fb_sess, cons->state_vp, anim_seq);
    198                 fb_vp_imagemap_damage(fb_sess, cons->state_vp,
    199                     state_icons[cons->state], 0, 0, STATE_WIDTH, STATE_HEIGHT);
    200                
    201                 fibril_mutex_unlock(&cons->mtx);
    202         }
    203 }
    204 
    205 static void cons_update_state(console_t *cons, console_state_t state)
    206 {
    207         bool update = false;
    208        
    209         fibril_mutex_lock(&cons->mtx);
    210        
    211         if (cons->state != state) {
    212                 cons->state = state;
    213                 update = true;
    214         }
    215        
    216         fibril_mutex_unlock(&cons->mtx);
    217        
    218         if (update)
    219                 cons_redraw_state(cons);
    220 }
    221 
    222 static void cons_notify_data(console_t *cons)
     104static int input_ev_key(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
     105static int input_ev_move(input_t *, int, int);
     106static int input_ev_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned);
     107static int input_ev_button(input_t *, int, int);
     108
     109static input_ev_ops_t input_ev_ops = {
     110        .key = input_ev_key,
     111        .move = input_ev_move,
     112        .abs_move = input_ev_abs_move,
     113        .button = input_ev_button
     114};
     115
     116static int cons_open(con_srvs_t *, con_srv_t *);
     117static int cons_close(con_srv_t *);
     118static int cons_read(con_srv_t *, void *, size_t);
     119static int cons_write(con_srv_t *, void *, size_t);
     120static void cons_sync(con_srv_t *);
     121static void cons_clear(con_srv_t *);
     122static void cons_set_pos(con_srv_t *, sysarg_t col, sysarg_t row);
     123static int cons_get_pos(con_srv_t *, sysarg_t *, sysarg_t *);
     124static int cons_get_size(con_srv_t *, sysarg_t *, sysarg_t *);
     125static int cons_get_color_cap(con_srv_t *, console_caps_t *);
     126static void cons_set_style(con_srv_t *, console_style_t);
     127static void cons_set_color(con_srv_t *, console_color_t, console_color_t,
     128    console_color_attr_t);
     129static void cons_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
     130static void cons_set_cursor_visibility(con_srv_t *, bool);
     131static int cons_get_event(con_srv_t *, cons_event_t *);
     132
     133static con_ops_t con_ops = {
     134        .open = cons_open,
     135        .close = cons_close,
     136        .read = cons_read,
     137        .write = cons_write,
     138        .sync = cons_sync,
     139        .clear = cons_clear,
     140        .set_pos = cons_set_pos,
     141        .get_pos = cons_get_pos,
     142        .get_size = cons_get_size,
     143        .get_color_cap = cons_get_color_cap,
     144        .set_style = cons_set_style,
     145        .set_color = cons_set_color,
     146        .set_rgb_color = cons_set_rgb_color,
     147        .set_cursor_visibility = cons_set_cursor_visibility,
     148        .get_event = cons_get_event
     149};
     150
     151static console_t *srv_to_console(con_srv_t *srv)
     152{
     153        return srv->srvs->sarg;
     154}
     155
     156static void cons_update(console_t *cons)
    223157{
    224158        fibril_mutex_lock(&switch_mtx);
    225        
    226         if (cons != active_console)
    227                 cons_update_state(cons, CONS_DATA);
    228        
     159        fibril_mutex_lock(&cons->mtx);
     160       
     161        if ((cons == active_console) && (active_console != kernel_console)) {
     162                output_update(output_sess, cons->fbid);
     163                output_cursor_update(output_sess, cons->fbid);
     164        }
     165       
     166        fibril_mutex_unlock(&cons->mtx);
    229167        fibril_mutex_unlock(&switch_mtx);
    230168}
    231169
    232 static void cons_notify_connect(console_t *cons)
     170static void cons_update_cursor(console_t *cons)
    233171{
    234172        fibril_mutex_lock(&switch_mtx);
    235        
    236         if (cons == active_console)
    237                 cons_update_state(cons, CONS_SELECTED);
    238         else
    239                 cons_update_state(cons, CONS_IDLE);
    240        
     173        fibril_mutex_lock(&cons->mtx);
     174       
     175        if ((cons == active_console) && (active_console != kernel_console))
     176                output_cursor_update(output_sess, cons->fbid);
     177       
     178        fibril_mutex_unlock(&cons->mtx);
    241179        fibril_mutex_unlock(&switch_mtx);
    242180}
    243181
    244 static void cons_notify_disconnect(console_t *cons)
     182static void cons_damage(console_t *cons)
    245183{
    246184        fibril_mutex_lock(&switch_mtx);
    247        
    248         if (cons == active_console)
    249                 cons_update_state(cons, CONS_DISCONNECTED_SELECTED);
    250         else
    251                 cons_update_state(cons, CONS_DISCONNECTED);
    252        
    253         fibril_mutex_unlock(&switch_mtx);
    254 }
    255 
    256 static void cons_update(console_t *cons)
    257 {
    258         fibril_mutex_lock(&switch_mtx);
    259185        fibril_mutex_lock(&cons->mtx);
    260186       
    261187        if ((cons == active_console) && (active_console != kernel_console)) {
    262                 fb_vp_update(fb_sess, console_vp, cons->fbid);
    263                 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid);
    264         }
    265        
    266         fibril_mutex_unlock(&cons->mtx);
    267         fibril_mutex_unlock(&switch_mtx);
    268 }
    269 
    270 static void cons_update_cursor(console_t *cons)
    271 {
    272         fibril_mutex_lock(&switch_mtx);
    273         fibril_mutex_lock(&cons->mtx);
    274        
    275         if ((cons == active_console) && (active_console != kernel_console))
    276                 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid);
    277        
    278         fibril_mutex_unlock(&cons->mtx);
    279         fibril_mutex_unlock(&switch_mtx);
    280 }
    281 
    282 static void cons_clear(console_t *cons)
    283 {
    284         fibril_mutex_lock(&cons->mtx);
    285         screenbuffer_clear(cons->frontbuf);
    286         fibril_mutex_unlock(&cons->mtx);
    287        
    288         cons_update(cons);
    289 }
    290 
    291 static void cons_damage_all(console_t *cons)
    292 {
    293         fibril_mutex_lock(&switch_mtx);
    294         fibril_mutex_lock(&cons->mtx);
    295        
    296         if ((cons == active_console) && (active_console != kernel_console)) {
    297                 fb_vp_damage(fb_sess, console_vp, cons->fbid, 0, 0, cons->cols,
     188                output_damage(output_sess, cons->fbid, 0, 0, cons->cols,
    298189                    cons->rows);
    299                 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid);
     190                output_cursor_update(output_sess, cons->fbid);
    300191        }
    301192       
     
    314205       
    315206        if (cons == kernel_console) {
    316                 fb_yield(fb_sess);
     207                output_yield(output_sess);
    317208                if (!console_kcon()) {
    318                         fb_claim(fb_sess);
     209                        output_claim(output_sess);
    319210                        fibril_mutex_unlock(&switch_mtx);
    320211                        return;
     
    323214       
    324215        if (active_console == kernel_console)
    325                 fb_claim(fb_sess);
     216                output_claim(output_sess);
    326217       
    327218        prev_console = active_console;
    328219        active_console = cons;
    329220       
    330         if (prev_console->state == CONS_DISCONNECTED_SELECTED)
    331                 cons_update_state(prev_console, CONS_DISCONNECTED);
    332         else
    333                 cons_update_state(prev_console, CONS_IDLE);
    334        
    335         if ((cons->state == CONS_DISCONNECTED) ||
    336             (cons->state == CONS_DISCONNECTED_SELECTED))
    337                 cons_update_state(cons, CONS_DISCONNECTED_SELECTED);
    338         else
    339                 cons_update_state(cons, CONS_SELECTED);
    340        
    341221        fibril_mutex_unlock(&switch_mtx);
    342222       
    343         cons_damage_all(cons);
     223        cons_damage(cons);
    344224}
    345225
     
    347227{
    348228        fibril_mutex_lock(&switch_mtx);
    349 
     229       
    350230        console_t *active_uspace = active_console;
    351         if (active_uspace == kernel_console) {
     231        if (active_uspace == kernel_console)
    352232                active_uspace = prev_console;
    353         }
     233       
    354234        assert(active_uspace != kernel_console);
    355 
     235       
    356236        fibril_mutex_unlock(&switch_mtx);
    357 
     237       
    358238        return active_uspace;
    359239}
    360240
    361 static ssize_t limit(ssize_t val, ssize_t lo, ssize_t hi)
    362 {
    363         if (val > hi)
    364                 return hi;
    365        
    366         if (val < lo)
    367                 return lo;
    368        
    369         return val;
    370 }
    371 
    372 static void cons_mouse_move(sysarg_t dx, sysarg_t dy)
    373 {
    374         ssize_t sx = (ssize_t) dx;
    375         ssize_t sy = (ssize_t) dy;
    376        
    377         mouse.x = limit(mouse.x + sx, 0, xres);
    378         mouse.y = limit(mouse.y + sy, 0, yres);
    379        
    380         fb_pointer_update(fb_sess, mouse.x, mouse.y, true);
    381 }
    382 
    383 static console_t *cons_find_icon(sysarg_t x, sysarg_t y)
    384 {
    385         sysarg_t status_start =
    386             STATE_START + (xres - 800) / 2 + CONSOLE_MARGIN;
    387        
    388         if ((y < STATE_TOP) || (y >= STATE_TOP + STATE_HEIGHT))
    389                 return NULL;
    390        
    391         if (x < status_start)
    392                 return NULL;
    393        
    394         if (x >= status_start + (STATE_WIDTH + STATE_SPACE) * CONSOLE_COUNT)
    395                 return NULL;
    396        
    397         if (((x - status_start) % (STATE_WIDTH + STATE_SPACE)) >= STATE_WIDTH)
    398                 return NULL;
    399        
    400         sysarg_t btn = (x - status_start) / (STATE_WIDTH + STATE_SPACE);
    401        
    402         if (btn < CONSOLE_COUNT)
    403                 return consoles + btn;
    404        
    405         return NULL;
    406 }
    407 
    408 /** Handle mouse click
    409  *
    410  * @param state Button state (true - pressed, false - depressed)
    411  *
    412  */
    413 static console_t *cons_mouse_button(bool state)
    414 {
    415         if (graphics_state != GRAPHICS_FULL)
    416                 return NULL;
    417        
    418         if (state) {
    419                 console_t *cons = cons_find_icon(mouse.x, mouse.y);
    420                 if (cons != NULL) {
    421                         mouse.btn_x = mouse.x;
    422                         mouse.btn_y = mouse.y;
    423                         mouse.pressed = true;
    424                 }
    425                
    426                 return NULL;
    427         }
    428        
    429         if ((!state) && (!mouse.pressed))
    430                 return NULL;
    431        
    432         console_t *cons = cons_find_icon(mouse.x, mouse.y);
    433         if (cons == cons_find_icon(mouse.btn_x, mouse.btn_y))
    434                 return cons;
    435        
    436         mouse.pressed = false;
    437         return NULL;
    438 }
    439 
    440 static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    441 {
    442         /* Ignore parameters, the connection is already opened */
    443         while (true) {
    444                 ipc_call_t call;
    445                 ipc_callid_t callid = async_get_call(&call);
    446                
    447                 if (!IPC_GET_IMETHOD(call)) {
    448                         /* TODO: Handle hangup */
    449                         async_hangup(input_sess);
    450                         return;
    451                 }
    452                
    453                 kbd_event_type_t type;
    454                 keycode_t key;
    455                 keymod_t mods;
    456                 wchar_t c;
    457                
    458                 switch (IPC_GET_IMETHOD(call)) {
    459                 case INPUT_EVENT_KEY:
    460                         type = IPC_GET_ARG1(call);
    461                         key = IPC_GET_ARG2(call);
    462                         mods = IPC_GET_ARG3(call);
    463                         c = IPC_GET_ARG4(call);
    464                        
    465                         if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) &&
    466                             ((mods & KM_CTRL) == 0))
    467                                 cons_switch(&consoles[key - KC_F1]);
    468                         else {
    469                                 /* Got key press/release event */
    470                                 kbd_event_t *event =
    471                                     (kbd_event_t *) malloc(sizeof(kbd_event_t));
    472                                 if (event == NULL) {
    473                                         async_answer_0(callid, ENOMEM);
    474                                         break;
    475                                 }
    476                                
    477                                 link_initialize(&event->link);
    478                                 event->type = type;
    479                                 event->key = key;
    480                                 event->mods = mods;
    481                                 event->c = c;
    482                                
    483                                 /*
    484                                  * Kernel console does not read events
    485                                  * from us, so we will redirect them
    486                                  * to the (last) active userspace console
    487                                  * if necessary.
    488                                  */
    489                                 console_t *target_console = cons_get_active_uspace();
    490                                
    491                                 prodcons_produce(&target_console->input_pc,
    492                                     &event->link);
    493                         }
    494                        
    495                         async_answer_0(callid, EOK);
    496                         break;
    497                 case INPUT_EVENT_MOVE:
    498                         cons_mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    499                         async_answer_0(callid, EOK);
    500                         break;
    501                 case INPUT_EVENT_BUTTON:
    502                         /* Got pointer button press/release event */
    503                         if (IPC_GET_ARG1(call) == 1) {
    504                                 console_t *cons =
    505                                     cons_mouse_button((bool) IPC_GET_ARG2(call));
    506                                 if (cons != NULL)
    507                                         cons_switch(cons);
    508                         }
    509                         async_answer_0(callid, EOK);
    510                         break;
    511                 default:
    512                         async_answer_0(callid, EINVAL);
    513                 }
    514         }
     241static int input_ev_key(input_t *input, kbd_event_type_t type, keycode_t key,
     242    keymod_t mods, wchar_t c)
     243{
     244        if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) &&
     245            ((mods & KM_CTRL) == 0)) {
     246                cons_switch(&consoles[key - KC_F1]);
     247        } else {
     248                /* Got key press/release event */
     249                kbd_event_t *event =
     250                    (kbd_event_t *) malloc(sizeof(kbd_event_t));
     251                if (event == NULL) {
     252                        return ENOMEM;
     253                }
     254               
     255                link_initialize(&event->link);
     256                event->type = type;
     257                event->key = key;
     258                event->mods = mods;
     259                event->c = c;
     260               
     261                /*
     262                 * Kernel console does not read events
     263                 * from us, so we will redirect them
     264                 * to the (last) active userspace console
     265                 * if necessary.
     266                 */
     267                console_t *target_console = cons_get_active_uspace();
     268               
     269                prodcons_produce(&target_console->input_pc,
     270                    &event->link);
     271        }
     272       
     273        return EOK;
     274}
     275
     276static int input_ev_move(input_t *input, int dx, int dy)
     277{
     278        return EOK;
     279}
     280
     281static int input_ev_abs_move(input_t *input, unsigned x , unsigned y,
     282    unsigned max_x, unsigned max_y)
     283{
     284        return EOK;
     285}
     286
     287static int input_ev_button(input_t *input, int bnum, int bpress)
     288{
     289        return EOK;
    515290}
    516291
     
    524299        switch (ch) {
    525300        case '\n':
    526                 updated = screenbuffer_newline(cons->frontbuf);
     301                updated = chargrid_newline(cons->frontbuf);
    527302                break;
    528303        case '\r':
    529304                break;
    530305        case '\t':
    531                 updated = screenbuffer_tabstop(cons->frontbuf, 8);
     306                updated = chargrid_tabstop(cons->frontbuf, 8);
    532307                break;
    533308        case '\b':
    534                 updated = screenbuffer_backspace(cons->frontbuf);
     309                updated = chargrid_backspace(cons->frontbuf);
    535310                break;
    536311        default:
    537                 updated = screenbuffer_putchar(cons->frontbuf, ch, true);
     312                updated = chargrid_putchar(cons->frontbuf, ch, true);
    538313        }
    539314       
     
    544319}
    545320
    546 static void cons_set_cursor(console_t *cons, sysarg_t col, sysarg_t row)
    547 {
    548         fibril_mutex_lock(&cons->mtx);
    549         screenbuffer_set_cursor(cons->frontbuf, col, row);
     321static void cons_set_cursor_vis(console_t *cons, bool visible)
     322{
     323        fibril_mutex_lock(&cons->mtx);
     324        chargrid_set_cursor_visibility(cons->frontbuf, visible);
    550325        fibril_mutex_unlock(&cons->mtx);
    551326       
     
    553328}
    554329
    555 static void cons_set_cursor_visibility(console_t *cons, bool visible)
    556 {
    557         fibril_mutex_lock(&cons->mtx);
    558         screenbuffer_set_cursor_visibility(cons->frontbuf, visible);
    559         fibril_mutex_unlock(&cons->mtx);
    560        
    561         cons_update_cursor(cons);
    562 }
    563 
    564 static void cons_get_cursor(console_t *cons, ipc_callid_t iid, ipc_call_t *icall)
    565 {
    566         sysarg_t col;
    567         sysarg_t row;
    568        
    569         fibril_mutex_lock(&cons->mtx);
    570         screenbuffer_get_cursor(cons->frontbuf, &col, &row);
    571         fibril_mutex_unlock(&cons->mtx);
    572        
    573         async_answer_2(iid, EOK, col, row);
    574 }
    575 
    576 static void cons_write(console_t *cons, ipc_callid_t iid, ipc_call_t *icall)
    577 {
    578         void *buf;
    579         size_t size;
    580         int rc = async_data_write_accept(&buf, false, 0, 0, 0, &size);
    581        
    582         if (rc != EOK) {
    583                 async_answer_0(iid, rc);
    584                 return;
    585         }
    586        
     330static int cons_open(con_srvs_t *srvs, con_srv_t *srv)
     331{
     332        return EOK;
     333}
     334
     335static int cons_close(con_srv_t *srv)
     336{
     337        return EOK;
     338}
     339
     340static int cons_read(con_srv_t *srv, void *buf, size_t size)
     341{
     342        uint8_t *bbuf = buf;
     343        console_t *cons = srv_to_console(srv);
     344        size_t pos = 0;
     345       
     346        /*
     347         * Read input from keyboard and copy it to the buffer.
     348         * We need to handle situation when wchar is split by 2 following
     349         * reads.
     350         */
     351        while (pos < size) {
     352                /* Copy to the buffer remaining characters. */
     353                while ((pos < size) && (cons->char_remains_len > 0)) {
     354                        bbuf[pos] = cons->char_remains[0];
     355                        pos++;
     356                       
     357                        /* Unshift the array. */
     358                        for (size_t i = 1; i < cons->char_remains_len; i++)
     359                                cons->char_remains[i - 1] = cons->char_remains[i];
     360                       
     361                        cons->char_remains_len--;
     362                }
     363               
     364                /* Still not enough? Then get another key from the queue. */
     365                if (pos < size) {
     366                        link_t *link = prodcons_consume(&cons->input_pc);
     367                        kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
     368                       
     369                        /* Accept key presses of printable chars only. */
     370                        if ((event->type == KEY_PRESS) && (event->c != 0)) {
     371                                wchar_t tmp[2] = { event->c, 0 };
     372                                wstr_to_str(cons->char_remains, UTF8_CHAR_BUFFER_SIZE, tmp);
     373                                cons->char_remains_len = str_size(cons->char_remains);
     374                        }
     375                       
     376                        free(event);
     377                }
     378        }
     379
     380        return size;
     381}
     382
     383static int cons_write(con_srv_t *srv, void *data, size_t size)
     384{
     385        console_t *cons = srv_to_console(srv);
     386
    587387        size_t off = 0;
    588388        while (off < size)
    589                 cons_write_char(cons, str_decode(buf, &off, size));
    590        
    591         async_answer_1(iid, EOK, size);
    592         free(buf);
    593        
    594         cons_notify_data(cons);
    595 }
    596 
    597 static void cons_read(console_t *cons, ipc_callid_t iid, ipc_call_t *icall)
    598 {
    599         ipc_callid_t callid;
    600         size_t size;
    601         if (!async_data_read_receive(&callid, &size)) {
    602                 async_answer_0(callid, EINVAL);
    603                 async_answer_0(iid, EINVAL);
    604                 return;
    605         }
    606        
    607         char *buf = (char *) malloc(size);
    608         if (buf == NULL) {
    609                 async_answer_0(callid, ENOMEM);
    610                 async_answer_0(iid, ENOMEM);
    611                 return;
    612         }
    613        
    614         size_t pos = 0;
    615         while (pos < size) {
    616                 link_t *link = prodcons_consume(&cons->input_pc);
    617                 kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
    618                
    619                 if (event->type == KEY_PRESS) {
    620                         buf[pos] = event->c;
    621                         pos++;
    622                 }
    623                
    624                 free(event);
    625         }
    626        
    627         (void) async_data_read_finalize(callid, buf, size);
    628         async_answer_1(iid, EOK, size);
    629         free(buf);
    630 }
    631 
    632 static void cons_set_style(console_t *cons, console_style_t style)
    633 {
    634         fibril_mutex_lock(&cons->mtx);
    635         screenbuffer_set_style(cons->frontbuf, style);
    636         fibril_mutex_unlock(&cons->mtx);
    637 }
    638 
    639 static void cons_set_color(console_t *cons, console_color_t bgcolor,
     389                cons_write_char(cons, str_decode(data, &off, size));
     390        return size;
     391}
     392
     393static void cons_sync(con_srv_t *srv)
     394{
     395        console_t *cons = srv_to_console(srv);
     396       
     397        cons_update(cons);
     398}
     399
     400static void cons_clear(con_srv_t *srv)
     401{
     402        console_t *cons = srv_to_console(srv);
     403       
     404        fibril_mutex_lock(&cons->mtx);
     405        chargrid_clear(cons->frontbuf);
     406        fibril_mutex_unlock(&cons->mtx);
     407       
     408        cons_update(cons);
     409}
     410
     411static void cons_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row)
     412{
     413        console_t *cons = srv_to_console(srv);
     414       
     415        fibril_mutex_lock(&cons->mtx);
     416        chargrid_set_cursor(cons->frontbuf, col, row);
     417        fibril_mutex_unlock(&cons->mtx);
     418       
     419        cons_update_cursor(cons);
     420}
     421
     422static int cons_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row)
     423{
     424        console_t *cons = srv_to_console(srv);
     425       
     426        fibril_mutex_lock(&cons->mtx);
     427        chargrid_get_cursor(cons->frontbuf, col, row);
     428        fibril_mutex_unlock(&cons->mtx);
     429       
     430        return EOK;
     431}
     432
     433static int cons_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows)
     434{
     435        console_t *cons = srv_to_console(srv);
     436       
     437        fibril_mutex_lock(&cons->mtx);
     438        *cols = cons->cols;
     439        *rows = cons->rows;
     440        fibril_mutex_unlock(&cons->mtx);
     441       
     442        return EOK;
     443}
     444
     445static int cons_get_color_cap(con_srv_t *srv, console_caps_t *ccaps)
     446{
     447        console_t *cons = srv_to_console(srv);
     448       
     449        fibril_mutex_lock(&cons->mtx);
     450        *ccaps = cons->ccaps;
     451        fibril_mutex_unlock(&cons->mtx);
     452       
     453        return EOK;
     454}
     455
     456static void cons_set_style(con_srv_t *srv, console_style_t style)
     457{
     458        console_t *cons = srv_to_console(srv);
     459       
     460        fibril_mutex_lock(&cons->mtx);
     461        chargrid_set_style(cons->frontbuf, style);
     462        fibril_mutex_unlock(&cons->mtx);
     463}
     464
     465static void cons_set_color(con_srv_t *srv, console_color_t bgcolor,
    640466    console_color_t fgcolor, console_color_attr_t attr)
    641467{
    642         fibril_mutex_lock(&cons->mtx);
    643         screenbuffer_set_color(cons->frontbuf, bgcolor, fgcolor, attr);
    644         fibril_mutex_unlock(&cons->mtx);
    645 }
    646 
    647 static void cons_set_rgb_color(console_t *cons, pixel_t bgcolor,
     468        console_t *cons = srv_to_console(srv);
     469       
     470        fibril_mutex_lock(&cons->mtx);
     471        chargrid_set_color(cons->frontbuf, bgcolor, fgcolor, attr);
     472        fibril_mutex_unlock(&cons->mtx);
     473}
     474
     475static void cons_set_rgb_color(con_srv_t *srv, pixel_t bgcolor,
    648476    pixel_t fgcolor)
    649477{
    650         fibril_mutex_lock(&cons->mtx);
    651         screenbuffer_set_rgb_color(cons->frontbuf, bgcolor, fgcolor);
    652         fibril_mutex_unlock(&cons->mtx);
    653 }
    654 
    655 static void cons_get_event(console_t *cons, ipc_callid_t iid, ipc_call_t *icall)
    656 {
     478        console_t *cons = srv_to_console(srv);
     479       
     480        fibril_mutex_lock(&cons->mtx);
     481        chargrid_set_rgb_color(cons->frontbuf, bgcolor, fgcolor);
     482        fibril_mutex_unlock(&cons->mtx);
     483}
     484
     485static void cons_set_cursor_visibility(con_srv_t *srv, bool visible)
     486{
     487        console_t *cons = srv_to_console(srv);
     488       
     489        cons_set_cursor_vis(cons, visible);
     490}
     491
     492static int cons_get_event(con_srv_t *srv, cons_event_t *event)
     493{
     494        console_t *cons = srv_to_console(srv);
    657495        link_t *link = prodcons_consume(&cons->input_pc);
    658         kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
    659        
    660         async_answer_4(iid, EOK, event->type, event->key, event->mods, event->c);
    661         free(event);
     496        kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
     497       
     498        event->type = CEV_KEY;
     499        event->ev.key = *kevent;
     500        free(kevent);
     501        return EOK;
    662502}
    663503
     
    681521        }
    682522       
    683         if (atomic_postinc(&cons->refcnt) == 0) {
    684                 cons_set_cursor_visibility(cons, true);
    685                 cons_notify_connect(cons);
    686         }
    687        
    688         /* Accept the connection */
    689         async_answer_0(iid, EOK);
    690        
    691         while (true) {
    692                 ipc_call_t call;
    693                 ipc_callid_t callid = async_get_call(&call);
    694                
    695                 if (!IPC_GET_IMETHOD(call)) {
    696                         if (atomic_postdec(&cons->refcnt) == 1)
    697                                 cons_notify_disconnect(cons);
    698                        
    699                         return;
    700                 }
    701                
    702                 switch (IPC_GET_IMETHOD(call)) {
    703                 case VFS_OUT_READ:
    704                         cons_read(cons, callid, &call);
    705                         break;
    706                 case VFS_OUT_WRITE:
    707                         cons_write(cons, callid, &call);
    708                         break;
    709                 case VFS_OUT_SYNC:
    710                         cons_update(cons);
    711                         async_answer_0(callid, EOK);
    712                         break;
    713                 case CONSOLE_CLEAR:
    714                         cons_clear(cons);
    715                         async_answer_0(callid, EOK);
    716                         break;
    717                 case CONSOLE_GOTO:
    718                         cons_set_cursor(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    719                         async_answer_0(callid, EOK);
    720                         break;
    721                 case CONSOLE_GET_POS:
    722                         cons_get_cursor(cons, callid, &call);
    723                         break;
    724                 case CONSOLE_GET_SIZE:
    725                         async_answer_2(callid, EOK, cons->cols, cons->rows);
    726                         break;
    727                 case CONSOLE_GET_COLOR_CAP:
    728                         async_answer_1(callid, EOK, cons->ccaps);
    729                         break;
    730                 case CONSOLE_SET_STYLE:
    731                         cons_set_style(cons, IPC_GET_ARG1(call));
    732                         async_answer_0(callid, EOK);
    733                         break;
    734                 case CONSOLE_SET_COLOR:
    735                         cons_set_color(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call),
    736                             IPC_GET_ARG3(call));
    737                         async_answer_0(callid, EOK);
    738                         break;
    739                 case CONSOLE_SET_RGB_COLOR:
    740                         cons_set_rgb_color(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    741                         async_answer_0(callid, EOK);
    742                         break;
    743                 case CONSOLE_CURSOR_VISIBILITY:
    744                         cons_set_cursor_visibility(cons, IPC_GET_ARG1(call));
    745                         async_answer_0(callid, EOK);
    746                         break;
    747                 case CONSOLE_GET_EVENT:
    748                         cons_get_event(cons, callid, &call);
    749                         break;
    750                 default:
    751                         async_answer_0(callid, EINVAL);
    752                 }
    753         }
    754 }
    755 
    756 static async_sess_t *input_connect(const char *svc)
     523        if (atomic_postinc(&cons->refcnt) == 0)
     524                cons_set_cursor_vis(cons, true);
     525       
     526        con_conn(iid, icall, &cons->srvs);
     527}
     528
     529
     530static int input_connect(const char *svc)
    757531{
    758532        async_sess_t *sess;
     
    760534       
    761535        int rc = loc_service_get_id(svc, &dsid, 0);
    762         if (rc == EOK) {
    763                 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0);
    764                 if (sess == NULL) {
    765                         printf("%s: Unable to connect to input service %s\n", NAME,
    766                             svc);
    767                         return NULL;
    768                 }
    769         } else
    770                 return NULL;
    771        
    772         async_exch_t *exch = async_exchange_begin(sess);
    773         rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL);
    774         async_exchange_end(exch);
    775        
     536        if (rc != EOK) {
     537                printf("%s: Input service %s not found\n", NAME, svc);
     538                return rc;
     539        }
     540
     541        sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0);
     542        if (sess == NULL) {
     543                printf("%s: Unable to connect to input service %s\n", NAME,
     544                    svc);
     545                return EIO;
     546        }
     547       
     548        rc = input_open(sess, &input_ev_ops, NULL, &input);
    776549        if (rc != EOK) {
    777550                async_hangup(sess);
    778                 printf("%s: Unable to create callback connection to service %s (%s)\n",
     551                printf("%s: Unable to communicate with service %s (%s)\n",
    779552                    NAME, svc, str_error(rc));
    780                 return NULL;
    781         }
    782        
    783         return sess;
     553                return rc;
     554        }
     555       
     556        return EOK;
    784557}
    785558
     
    789562}
    790563
    791 static async_sess_t *fb_connect(const char *svc)
     564static async_sess_t *output_connect(const char *svc)
    792565{
    793566        async_sess_t *sess;
     
    798571                sess = loc_service_connect(EXCHANGE_SERIALIZE, dsid, 0);
    799572                if (sess == NULL) {
    800                         printf("%s: Unable to connect to framebuffer service %s\n",
     573                        printf("%s: Unable to connect to output service %s\n",
    801574                            NAME, svc);
    802575                        return NULL;
     
    808581}
    809582
    810 static bool console_srv_init(char *input_svc, char *fb_svc)
    811 {
    812         /* Avoid double initialization */
    813         if (graphics_state != GRAPHICS_NONE)
     583static bool console_srv_init(char *input_svc, char *output_svc)
     584{
     585        int rc;
     586       
     587        /* Connect to input service */
     588        rc = input_connect(input_svc);
     589        if (rc != EOK)
    814590                return false;
    815591       
    816         /* Connect to input service */
    817         input_sess = input_connect(input_svc);
    818         if (input_sess == NULL)
    819                 return false;
    820        
    821         /* Connect to framebuffer service */
    822         fb_sess = fb_connect(fb_svc);
    823         if (fb_sess == NULL)
     592        /* Connect to output service */
     593        output_sess = output_connect(output_svc);
     594        if (output_sess == NULL)
    824595                return false;
    825596       
    826597        /* Register server */
    827598        async_set_client_connection(client_connection);
    828         int rc = loc_server_register(NAME);
    829         if (rc < 0) {
     599        rc = loc_server_register(NAME);
     600        if (rc != EOK) {
    830601                printf("%s: Unable to register server (%s)\n", NAME,
    831602                    str_error(rc));
     
    833604        }
    834605       
    835         fb_get_resolution(fb_sess, &xres, &yres);
    836        
    837         /* Initialize the screen */
    838         screen_vp = fb_vp_create(fb_sess, 0, 0, xres, yres);
    839        
    840         if ((xres >= 800) && (yres >= 600)) {
    841                 logo_vp = fb_vp_create(fb_sess, xres - 66, 2, 64, 60);
    842                 logo_img = imgmap_decode_tga((void *) helenos_tga,
    843                     helenos_tga_size, IMGMAP_FLAG_SHARED);
    844                 logo_handle = fb_imagemap_create(fb_sess, logo_img);
    845                
    846                 nameic_vp = fb_vp_create(fb_sess, 5, 17, 100, 26);
    847                 nameic_img = imgmap_decode_tga((void *) nameic_tga,
    848                     nameic_tga_size, IMGMAP_FLAG_SHARED);
    849                 nameic_handle = fb_imagemap_create(fb_sess, nameic_img);
    850                
    851                 cons_data_img = imgmap_decode_tga((void *) cons_data_tga,
    852                     cons_data_tga_size, IMGMAP_FLAG_SHARED);
    853                 cons_dis_img = imgmap_decode_tga((void *) cons_dis_tga,
    854                     cons_dis_tga_size, IMGMAP_FLAG_SHARED);
    855                 cons_dis_sel_img = imgmap_decode_tga((void *) cons_dis_sel_tga,
    856                     cons_dis_sel_tga_size, IMGMAP_FLAG_SHARED);
    857                 cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga,
    858                     cons_idle_tga_size, IMGMAP_FLAG_SHARED);
    859                 cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga,
    860                     cons_kernel_tga_size, IMGMAP_FLAG_SHARED);
    861                 cons_sel_img = imgmap_decode_tga((void *) cons_sel_tga,
    862                     cons_sel_tga_size, IMGMAP_FLAG_SHARED);
    863                
    864                 state_icons[CONS_DISCONNECTED] =
    865                     fb_imagemap_create(fb_sess, cons_dis_img);
    866                 state_icons[CONS_DISCONNECTED_SELECTED] =
    867                     fb_imagemap_create(fb_sess, cons_dis_sel_img);
    868                 state_icons[CONS_SELECTED] =
    869                     fb_imagemap_create(fb_sess, cons_sel_img);
    870                 state_icons[CONS_IDLE] =
    871                     fb_imagemap_create(fb_sess, cons_idle_img);
    872                 state_icons[CONS_DATA] =
    873                     fb_imagemap_create(fb_sess, cons_data_img);
    874                 state_icons[CONS_KERNEL] =
    875                     fb_imagemap_create(fb_sess, cons_kernel_img);
    876                
    877                 anim_1_img = imgmap_decode_tga((void *) anim_1_tga,
    878                     anim_1_tga_size, IMGMAP_FLAG_SHARED);
    879                 anim_2_img = imgmap_decode_tga((void *) anim_2_tga,
    880                     anim_2_tga_size, IMGMAP_FLAG_SHARED);
    881                 anim_3_img = imgmap_decode_tga((void *) anim_3_tga,
    882                     anim_3_tga_size, IMGMAP_FLAG_SHARED);
    883                 anim_4_img = imgmap_decode_tga((void *) anim_4_tga,
    884                     anim_4_tga_size, IMGMAP_FLAG_SHARED);
    885                
    886                 anim_1 = fb_imagemap_create(fb_sess, anim_1_img);
    887                 anim_2 = fb_imagemap_create(fb_sess, anim_2_img);
    888                 anim_3 = fb_imagemap_create(fb_sess, anim_3_img);
    889                 anim_4 = fb_imagemap_create(fb_sess, anim_4_img);
    890                
    891                 anim_seq = fb_sequence_create(fb_sess);
    892                 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_1);
    893                 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_2);
    894                 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_3);
    895                 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_4);
    896                
    897                 console_vp = fb_vp_create(fb_sess, CONSOLE_MARGIN, CONSOLE_TOP,
    898                     xres - 2 * CONSOLE_MARGIN, yres - (CONSOLE_TOP + CONSOLE_MARGIN));
    899                
    900                 fb_vp_clear(fb_sess, screen_vp);
    901                 fb_vp_imagemap_damage(fb_sess, logo_vp, logo_handle,
    902                     0, 0, 64, 60);
    903                 fb_vp_imagemap_damage(fb_sess, nameic_vp, nameic_handle,
    904                     0, 0, 100, 26);
    905                
    906                 graphics_state = GRAPHICS_FULL;
    907         } else {
    908                 console_vp = screen_vp;
    909                 graphics_state = GRAPHICS_BASIC;
    910         }
    911        
    912         fb_vp_set_style(fb_sess, console_vp, STYLE_NORMAL);
    913         fb_vp_clear(fb_sess, console_vp);
    914        
    915         sysarg_t cols;
    916         sysarg_t rows;
    917         fb_vp_get_dimensions(fb_sess, console_vp, &cols, &rows);
     606        output_get_dimensions(output_sess, &cols, &rows);
     607        output_set_style(output_sess, STYLE_NORMAL);
    918608       
    919609        console_caps_t ccaps;
    920         fb_vp_get_caps(fb_sess, console_vp, &ccaps);
    921        
    922         mouse.x = xres / 2;
    923         mouse.y = yres / 2;
    924         mouse.pressed = false;
     610        output_get_caps(output_sess, &ccaps);
    925611       
    926612        /* Inititalize consoles */
     
    930616                fibril_mutex_initialize(&consoles[i].mtx);
    931617                prodcons_initialize(&consoles[i].input_pc);
    932                
    933                 if (graphics_state == GRAPHICS_FULL) {
    934                         /* Create state buttons */
    935                         consoles[i].state_vp =
    936                             fb_vp_create(fb_sess, STATE_START + (xres - 800) / 2 +
    937                             CONSOLE_MARGIN + i * (STATE_WIDTH + STATE_SPACE),
    938                             STATE_TOP, STATE_WIDTH, STATE_HEIGHT);
    939                 }
    940                
    941                 if (i == KERNEL_CONSOLE) {
    942                         consoles[i].state = CONS_KERNEL;
    943                         cons_redraw_state(&consoles[i]);
    944                         cons_kernel_sequence_start(&consoles[i]);
     618                consoles[i].char_remains_len = 0;
     619               
     620                if (i == KERNEL_CONSOLE)
    945621                        continue;
    946                 }
    947                
    948                 if (i == 0)
    949                         consoles[i].state = CONS_DISCONNECTED_SELECTED;
    950                 else
    951                         consoles[i].state = CONS_DISCONNECTED;
    952622               
    953623                consoles[i].cols = cols;
     
    955625                consoles[i].ccaps = ccaps;
    956626                consoles[i].frontbuf =
    957                     screenbuffer_create(cols, rows, SCREENBUFFER_FLAG_SHARED);
     627                    chargrid_create(cols, rows, CHARGRID_FLAG_SHARED);
    958628               
    959629                if (consoles[i].frontbuf == NULL) {
     
    962632                }
    963633               
    964                 consoles[i].fbid = fb_frontbuf_create(fb_sess, consoles[i].frontbuf);
     634                consoles[i].fbid = output_frontbuf_create(output_sess,
     635                    consoles[i].frontbuf);
    965636                if (consoles[i].fbid == 0) {
    966637                        printf("%s: Unable to create frontbuffer %zu\n", NAME, i);
     
    968639                }
    969640               
    970                 cons_redraw_state(&consoles[i]);
     641                con_srvs_init(&consoles[i].srvs);
     642                consoles[i].srvs.ops = &con_ops;
     643                consoles[i].srvs.sarg = &consoles[i];
    971644               
    972645                char vc[LOC_NAME_MAXLEN + 1];
     
    978651                }
    979652        }
     653       
     654        cons_damage(active_console);
    980655       
    981656        /* Receive kernel notifications */
     
    989664}
    990665
    991 static void usage(void)
    992 {
    993         printf("Usage: console <input_dev> <framebuffer_dev>\n");
     666static void usage(char *name)
     667{
     668        printf("Usage: %s <input_dev> <output_dev>\n", name);
    994669}
    995670
     
    997672{
    998673        if (argc < 3) {
    999                 usage();
     674                usage(argv[0]);
    1000675                return -1;
    1001676        }
     
    1010685        async_manager();
    1011686       
     687        /* Never reached */
    1012688        return 0;
    1013689}
  • uspace/srv/hid/input/Makefile

    r80445cf r4c53333  
    2929
    3030USPACE_PREFIX = ../../..
    31 EXTRA_CFLAGS = -Iinclude
    3231BINARY = input
    3332
    3433SOURCES = \
    35         generic/gsp.c \
    36         generic/input.c \
    37         generic/layout.c \
    38         generic/stroke.c \
    3934        layout/cz.c \
    4035        layout/us_qwerty.c \
    4136        layout/us_dvorak.c \
     37        layout/ar.c \
    4238        port/adb.c \
    4339        port/adb_mouse.c \
    4440        port/chardev.c \
    45         port/gxemul.c \
    4641        port/msim.c \
    4742        port/niagara.c \
     
    5247        proto/mousedev.c \
    5348        ctl/apple.c \
    54         ctl/gxe_fb.c \
    5549        ctl/kbdev.c \
    5650        ctl/pc.c \
    5751        ctl/stty.c \
    58         ctl/sun.c
     52        ctl/sun.c \
     53        gsp.c \
     54        input.c \
     55        layout.c \
     56        stroke.c
    5957
    6058include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hid/input/ctl/apple.c

    r80445cf r4c53333  
    3636 */
    3737
    38 #include <kbd.h>
    3938#include <io/console.h>
    4039#include <io/keycode.h>
    41 #include <kbd_ctl.h>
    42 #include <kbd_port.h>
     40#include "../kbd.h"
     41#include "../kbd_ctl.h"
     42#include "../kbd_port.h"
    4343
    4444static void apple_ctl_parse(sysarg_t);
  • uspace/srv/hid/input/ctl/kbdev.c

    r80445cf r4c53333  
    3737
    3838#include <async.h>
    39 #include <bool.h>
     39#include <stdbool.h>
    4040#include <errno.h>
    4141#include <fcntl.h>
    42 #include <gsp.h>
    4342#include <io/console.h>
    4443#include <io/keycode.h>
    4544#include <ipc/kbdev.h>
    46 #include <input.h>
    47 #include <kbd.h>
    48 #include <kbd_ctl.h>
    49 #include <kbd_port.h>
    5045#include <loc.h>
    5146#include <stdlib.h>
    5247#include <vfs/vfs_sess.h>
    5348#include <sys/typefmt.h>
     49#include "../gsp.h"
     50#include "../input.h"
     51#include "../kbd.h"
     52#include "../kbd_ctl.h"
     53#include "../kbd_port.h"
    5454
    5555static int kbdev_ctl_init(kbd_dev_t *);
     
    6868        /** Link to generic keyboard device */
    6969        kbd_dev_t *kbd_dev;
    70 
     70       
    7171        /** Session with kbdev device */
    7272        async_sess_t *sess;
     
    7575static kbdev_t *kbdev_new(kbd_dev_t *kdev)
    7676{
    77         kbdev_t *kbdev;
    78 
    79         kbdev = calloc(1, sizeof(kbdev_t));
     77        kbdev_t *kbdev = calloc(1, sizeof(kbdev_t));
    8078        if (kbdev == NULL)
    8179                return NULL;
    82 
     80       
    8381        kbdev->kbd_dev = kdev;
    8482
     
    9088        if (kbdev->sess != NULL)
    9189                async_hangup(kbdev->sess);
     90       
    9291        free(kbdev);
    9392}
     
    9594static int kbdev_ctl_init(kbd_dev_t *kdev)
    9695{
    97         async_sess_t *sess;
    98         async_exch_t *exch;
    99         kbdev_t *kbdev;
    100         int rc;
    101 
    102         sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->svc_id, 0);
     96        async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
     97            kdev->svc_id, 0);
    10398        if (sess == NULL) {
    10499                printf("%s: Failed starting session with '%s.'\n", NAME,
    105100                    kdev->svc_name);
    106                 return -1;
     101                return ENOENT;
    107102        }
    108 
    109         kbdev = kbdev_new(kdev);
     103       
     104        kbdev_t *kbdev = kbdev_new(kdev);
    110105        if (kbdev == NULL) {
    111106                printf("%s: Failed allocating device structure for '%s'.\n",
    112107                    NAME, kdev->svc_name);
    113108                async_hangup(sess);
    114                 return -1;
     109                return ENOMEM;
    115110        }
    116 
     111       
    117112        kbdev->sess = sess;
    118 
    119         exch = async_exchange_begin(sess);
     113       
     114        async_exch_t *exch = async_exchange_begin(sess);
    120115        if (exch == NULL) {
    121116                printf("%s: Failed starting exchange with '%s'.\n", NAME,
    122117                    kdev->svc_name);
    123118                kbdev_destroy(kbdev);
    124                 return -1;
     119                return ENOENT;
    125120        }
    126 
    127         rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev);
     121       
     122        int rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev);
    128123        if (rc != EOK) {
    129124                printf("%s: Failed creating callback connection from '%s'.\n",
     
    131126                async_exchange_end(exch);
    132127                kbdev_destroy(kbdev);
    133                 return -1;
     128                return rc;
    134129        }
    135 
     130       
    136131        async_exchange_end(exch);
    137 
     132       
    138133        kdev->ctl_private = (void *) kbdev;
    139134        return 0;
     
    142137static void kbdev_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    143138{
    144         async_sess_t *sess;
    145         async_exch_t *exch;
    146 
    147         sess = ((kbdev_t *) kdev->ctl_private)->sess;
    148 
    149         exch = async_exchange_begin(sess);
     139        async_sess_t *sess = ((kbdev_t *) kdev->ctl_private)->sess;
     140        async_exch_t *exch = async_exchange_begin(sess);
    150141        if (!exch)
    151142                return;
    152 
     143       
    153144        async_msg_1(exch, KBDEV_SET_IND, mods);
    154145        async_exchange_end(exch);
  • uspace/srv/hid/input/ctl/pc.c

    r80445cf r4c53333  
    3636 */
    3737
    38 #include <kbd.h>
    3938#include <io/console.h>
    4039#include <io/keycode.h>
    41 #include <kbd_ctl.h>
    42 #include <kbd_port.h>
    43 #include <gsp.h>
     40#include "../gsp.h"
     41#include "../kbd.h"
     42#include "../kbd_port.h"
     43#include "../kbd_ctl.h"
    4444
    4545static void pc_ctl_parse(sysarg_t);
  • uspace/srv/hid/input/ctl/stty.c

    r80445cf r4c53333  
    3838 */
    3939
    40 #include <kbd.h>
    4140#include <io/keycode.h>
    42 #include <kbd_ctl.h>
    43 #include <kbd_port.h>
    44 #include <gsp.h>
    45 #include <stroke.h>
     41#include "../stroke.h"
     42#include "../gsp.h"
     43#include "../kbd.h"
     44#include "../kbd_port.h"
     45#include "../kbd_ctl.h"
    4646
    4747static void stty_ctl_parse(sysarg_t);
  • uspace/srv/hid/input/ctl/sun.c

    r80445cf r4c53333  
    3737 */
    3838
    39 #include <kbd.h>
    4039#include <io/console.h>
    4140#include <io/keycode.h>
    42 #include <kbd_ctl.h>
    43 #include <kbd_port.h>
     41#include "../kbd.h"
     42#include "../kbd_port.h"
     43#include "../kbd_ctl.h"
    4444
    4545static void sun_ctl_parse(sysarg_t);
  • uspace/srv/hid/input/gsp.c

    r80445cf r4c53333  
    3131 * @ingroup  input
    3232 * @{
    33  */ 
     33 */
    3434/** @file
    35  * @brief       Generic scancode parser.
     35 * @brief Generic scancode parser.
    3636 *
    3737 * The scancode parser is a simple finite state machine. It is described
     
    4949 */
    5050
    51 #include <gsp.h>
    5251#include <adt/hash_table.h>
     52#include <adt/hash.h>
    5353#include <stdlib.h>
    5454#include <stdio.h>
    55 
    56 #define TRANS_TABLE_CHAINS 256
     55#include "gsp.h"
    5756
    5857/*
    59  * Hash table operations for the transition function.
    60  */
    61 
    62 static hash_index_t trans_op_hash(unsigned long key[]);
    63 static int trans_op_compare(unsigned long key[], hash_count_t keys,
    64     link_t *item);
    65 static void trans_op_remove_callback(link_t *item);
    66 
    67 static hash_table_operations_t trans_ops = {
    68         .hash = trans_op_hash,
    69         .compare = trans_op_compare,
    70         .remove_callback = trans_op_remove_callback
     58 * Transition function hash table operations.
     59 */
     60typedef struct {
     61        int old_state;
     62        int input;
     63} trans_key_t;
     64
     65static size_t trans_key_hash(void *key)
     66{
     67        trans_key_t *trans_key = (trans_key_t *)key;
     68        return hash_combine(trans_key->input, trans_key->old_state);
     69}
     70
     71static size_t trans_hash(const ht_link_t *item)
     72{
     73        gsp_trans_t *t = hash_table_get_inst(item, gsp_trans_t, link);
     74        return hash_combine(t->input, t->old_state);
     75}
     76
     77static bool trans_key_equal(void *key, const ht_link_t *item)
     78{
     79        trans_key_t *trans_key = (trans_key_t *)key;
     80        gsp_trans_t *t = hash_table_get_inst(item, gsp_trans_t, link);
     81       
     82        return trans_key->input == t->input && trans_key->old_state == t->old_state;
     83}
     84
     85static hash_table_ops_t trans_ops = {
     86        .hash = trans_hash,
     87        .key_hash = trans_key_hash,
     88        .key_equal = trans_key_equal,
     89        .equal = NULL,
     90        .remove_callback = NULL
    7191};
     92
    7293
    7394static gsp_trans_t *trans_lookup(gsp_t *p, int state, int input);
     
    7596static gsp_trans_t *trans_new(void);
    7697
    77 /** Initialise scancode parser. */
     98/** Initialize scancode parser. */
    7899void gsp_init(gsp_t *p)
    79100{
    80101        p->states = 1;
    81         hash_table_create(&p->trans, TRANS_TABLE_CHAINS, 2, &trans_ops);
     102        hash_table_create(&p->trans, 0, 0, &trans_ops);
    82103}
    83104
     
    223244static gsp_trans_t *trans_lookup(gsp_t *p, int state, int input)
    224245{
    225         link_t *item;
    226         unsigned long key[2];
    227 
    228         key[0] = state;
    229         key[1] = input;
    230 
    231         item = hash_table_find(&p->trans, key);
     246        ht_link_t *item;
     247       
     248        trans_key_t key = {
     249                .input = input,
     250                .old_state = state
     251        };
     252
     253        item = hash_table_find(&p->trans, &key);
    232254        if (item == NULL) return NULL;
    233255
    234         return hash_table_get_instance(item, gsp_trans_t, link);
     256        return hash_table_get_inst(item, gsp_trans_t, link);
    235257}
    236258
     
    242264static void trans_insert(gsp_t *p, gsp_trans_t *t)
    243265{
    244         unsigned long key[2];
    245 
    246         key[0] = t->old_state;
    247         key[1] = t->input;
    248 
    249         hash_table_insert(&p->trans, key, &t->link);
     266        hash_table_insert(&p->trans, &t->link);
    250267}
    251268
     
    264281}
    265282
    266 /*
    267  * Transition function hash table operations.
    268  */
    269 
    270 static hash_index_t trans_op_hash(unsigned long key[])
    271 {
    272         return (key[0] * 17 + key[1]) % TRANS_TABLE_CHAINS;
    273 }
    274 
    275 static int trans_op_compare(unsigned long key[], hash_count_t keys,
    276     link_t *item)
    277 {
    278         gsp_trans_t *t;
    279 
    280         t = hash_table_get_instance(item, gsp_trans_t, link);
    281         return ((key[0] == (unsigned long) t->old_state)
    282             && (key[1] == (unsigned long) t->input));
    283 }
    284 
    285 static void trans_op_remove_callback(link_t *item)
    286 {
    287 }
    288283
    289284/**
  • uspace/srv/hid/input/gsp.h

    r80445cf r4c53333  
    5656/** Scancode parser transition. */
    5757typedef struct {
    58         link_t link;            /**< Link to hash table in @c gsp_t */
     58        ht_link_t link;         /**< Link to hash table in @c gsp_t */
    5959
    6060        /* Preconditions */
  • uspace/srv/hid/input/input.c

    r80445cf r4c53333  
    3838
    3939#include <adt/list.h>
    40 #include <bool.h>
     40#include <stdbool.h>
    4141#include <fibril_synch.h>
    4242#include <ipc/services.h>
     
    5454#include <io/keycode.h>
    5555#include <loc.h>
    56 #include <input.h>
    57 #include <kbd.h>
    58 #include <kbd_port.h>
    59 #include <kbd_ctl.h>
    60 #include <mouse_proto.h>
    61 #include <layout.h>
    62 #include <mouse.h>
    63 
    64 #define NUM_LAYOUTS  3
     56#include "layout.h"
     57#include "kbd.h"
     58#include "kbd_port.h"
     59#include "kbd_ctl.h"
     60#include "mouse.h"
     61#include "mouse_proto.h"
     62#include "input.h"
     63
     64#define NUM_LAYOUTS  4
    6565
    6666static layout_ops_t *layout[NUM_LAYOUTS] = {
    6767        &us_qwerty_ops,
    6868        &us_dvorak_ops,
    69         &cz_ops
     69        &cz_ops,
     70        &ar_ops
    7071};
    7172
     
    163164        }
    164165       
     166        if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) &&
     167            key == KC_F4) {
     168                layout_destroy(kdev->active_layout);
     169                kdev->active_layout = layout_create(layout[3]);
     170                return;
     171        }
     172       
    165173        ev.type = type;
    166174        ev.key = key;
     
    189197        }
    190198        async_exchange_end(exch);
     199}
     200
     201/** Mouse pointer has moved in absolute mode. */
     202void mouse_push_event_abs_move(mouse_dev_t *mdev, unsigned int x, unsigned int y,
     203    unsigned int max_x, unsigned int max_y)
     204{
     205        if (max_x && max_y) {
     206                async_exch_t *exch = async_exchange_begin(client_sess);
     207                async_msg_4(exch, INPUT_EVENT_ABS_MOVE, x, y, max_x, max_y);
     208                async_exchange_end(exch);
     209        }
    191210}
    192211
     
    412431        kbd_add_dev(&chardev_port, &stty_ctl);
    413432#endif
    414 #if defined(UARCH_arm32) && defined(MACHINE_testarm) && defined(CONFIG_FB)
    415         kbd_add_dev(&gxemul_port, &gxe_fb_ctl);
    416 #endif
    417 #if defined(UARCH_arm32) && defined(MACHINE_testarm) && !defined(CONFIG_FB)
    418         kbd_add_dev(&gxemul_port, &stty_ctl);
    419 #endif
    420433#if defined(UARCH_arm32) && defined(MACHINE_integratorcp)
    421434        kbd_add_dev(&pl050_port, &pc_ctl);
     
    426439#if defined(MACHINE_msim)
    427440        kbd_add_dev(&msim_port, &stty_ctl);
    428 #endif
    429 #if (defined(MACHINE_lgxemul) || defined(MACHINE_bgxemul)) && defined(CONFIG_FB)
    430         kbd_add_dev(&gxemul_port, &gxe_fb_ctl);
    431 #endif
    432 #if defined(MACHINE_lgxemul) || defined(MACHINE_bgxemul) && !defined(CONFIG_FB)
    433         kbd_add_dev(&gxemul_port, &stty_ctl);
    434441#endif
    435442#if defined(UARCH_ppc32)
     
    635642}
    636643
     644static void usage(char *name)
     645{
     646        printf("Usage: %s <service_name>\n", name);
     647}
     648
    637649int main(int argc, char **argv)
    638650{
     651        if (argc < 2) {
     652                usage(argv[0]);
     653                return 1;
     654        }
     655       
    639656        printf("%s: HelenOS input service\n", NAME);
    640657       
     
    662679        async_set_client_connection(client_connection);
    663680        int rc = loc_server_register(NAME);
    664         if (rc < 0) {
    665                 printf("%s: Unable to register server (%d)\n", NAME, rc);
    666                 return -1;
    667         }
    668        
    669         char kbd[LOC_NAME_MAXLEN + 1];
    670         snprintf(kbd, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);
     681        if (rc != EOK) {
     682                printf("%s: Unable to register server\n", NAME);
     683                return rc;
     684        }
    671685       
    672686        service_id_t service_id;
    673         if (loc_service_register(kbd, &service_id) != EOK) {
    674                 printf("%s: Unable to register service %s\n", NAME, kbd);
    675                 return -1;
     687        rc = loc_service_register(argv[1], &service_id);
     688        if (rc != EOK) {
     689                printf("%s: Unable to register service %s\n", NAME, argv[1]);
     690                return rc;
    676691        }
    677692       
     
    680695       
    681696        printf("%s: Accepting connections\n", NAME);
     697        task_retval(0);
    682698        async_manager();
    683699       
  • uspace/srv/hid/input/input.h

    r80445cf r4c53333  
    3939#define INPUT_H_
    4040
    41 #include <bool.h>
     41#include <stdbool.h>
    4242#include <async.h>
    4343
    44 #define NAME       "input"
    45 #define NAMESPACE  "hid"
     44#define NAME  "input"
    4645
    4746extern bool irc_service;
  • uspace/srv/hid/input/kbd_ctl.h

    r80445cf r4c53333  
    3838#define KBD_CTL_H_
    3939
    40 #include <kbd_port.h>
     40#include "kbd_port.h"
    4141
    4242struct kbd_dev;
     
    4949
    5050extern kbd_ctl_ops_t apple_ctl;
    51 extern kbd_ctl_ops_t gxe_fb_ctl;
    5251extern kbd_ctl_ops_t kbdev_ctl;
    5352extern kbd_ctl_ops_t pc_ctl;
  • uspace/srv/hid/input/kbd_port.h

    r80445cf r4c53333  
    5151extern kbd_port_ops_t adb_port;
    5252extern kbd_port_ops_t chardev_port;
    53 extern kbd_port_ops_t gxemul_port;
    5453extern kbd_port_ops_t msim_port;
    5554extern kbd_port_ops_t niagara_port;
  • uspace/srv/hid/input/layout.c

    r80445cf r4c53333  
    3737
    3838#include <errno.h>
    39 #include <input.h>
    40 #include <layout.h>
    4139#include <stdlib.h>
     40#include "input.h"
     41#include "layout.h"
    4242
    4343/** Create a new layout instance. */
  • uspace/srv/hid/input/layout.h

    r80445cf r4c53333  
    6060extern layout_ops_t us_dvorak_ops;
    6161extern layout_ops_t cz_ops;
     62extern layout_ops_t ar_ops;
    6263
    6364extern layout_t *layout_create(layout_ops_t *);
  • uspace/srv/hid/input/layout/cz.c

    r80445cf r4c53333  
    3333
    3434#include <errno.h>
    35 #include <input.h>
    3635#include <io/console.h>
    3736#include <io/keycode.h>
    38 #include <bool.h>
    39 #include <layout.h>
     37#include <stdbool.h>
    4038#include <stdlib.h>
     39#include "../input.h"
     40#include "../layout.h"
    4141
    4242static int cz_create(layout_t *);
  • uspace/srv/hid/input/layout/us_dvorak.c

    r80445cf r4c53333  
    3333
    3434#include <errno.h>
    35 #include <kbd.h>
    3635#include <io/console.h>
    3736#include <io/keycode.h>
    38 #include <layout.h>
     37#include "../layout.h"
     38#include "../kbd.h"
    3939
    4040static int us_dvorak_create(layout_t *);
  • uspace/srv/hid/input/layout/us_qwerty.c

    r80445cf r4c53333  
    2828
    2929/** @addtogroup input
    30  * @brief       US QWERTY layout.
     30 * @brief US QWERTY layout.
    3131 * @{
    3232 */
    3333
    3434#include <errno.h>
    35 #include <kbd.h>
    3635#include <io/console.h>
    3736#include <io/keycode.h>
    38 #include <layout.h>
     37#include "../layout.h"
     38#include "../kbd.h"
    3939
    4040static int us_qwerty_create(layout_t *);
  • uspace/srv/hid/input/mouse.h

    r80445cf r4c53333  
    6363extern void mouse_push_data(mouse_dev_t *, sysarg_t);
    6464extern void mouse_push_event_move(mouse_dev_t *, int, int, int);
     65extern void mouse_push_event_abs_move(mouse_dev_t *, unsigned int, unsigned int,
     66    unsigned int, unsigned int);
    6567extern void mouse_push_event_button(mouse_dev_t *, int, int);
    6668
  • uspace/srv/hid/input/mouse_proto.h

    r80445cf r4c53333  
    3838#define MOUSE_PROTO_H_
    3939
    40 #include <mouse_port.h>
     40#include "mouse_port.h"
    4141
    4242struct mouse_dev;
  • uspace/srv/hid/input/port/adb.c

    r80445cf r4c53333  
    3737#include <ipc/adb.h>
    3838#include <async.h>
    39 #include <input.h>
    40 #include <kbd_port.h>
    41 #include <kbd.h>
    4239#include <vfs/vfs.h>
    4340#include <fcntl.h>
    4441#include <errno.h>
    4542#include <loc.h>
     43#include "../input.h"
     44#include "../kbd_port.h"
     45#include "../kbd.h"
    4646
    4747static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    6565static int adb_port_init(kbd_dev_t *kdev)
    6666{
     67        kbd_dev = kdev;
     68       
    6769        const char *dev = "adb/kbd";
    6870        service_id_t service_id;
    69         async_exch_t *exch;
    70         int rc;
    71        
    72         kbd_dev = kdev;
    73        
    74         rc = loc_service_get_id(dev, &service_id, 0);
     71        int rc = loc_service_get_id(dev, &service_id, 0);
    7572        if (rc != EOK)
    7673                return rc;
     
    8279        }
    8380       
    84         exch = async_exchange_begin(dev_sess);
     81        async_exch_t *exch = async_exchange_begin(dev_sess);
    8582        if (exch == NULL) {
    8683                printf("%s: Failed starting exchange with device\n", NAME);
     
    8986        }
    9087       
    91         /* NB: The callback connection is slotted for removal */
    9288        rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL);
    9389        async_exchange_end(exch);
     
    122118                ipc_callid_t callid = async_get_call(&call);
    123119
    124                 int retval;
     120                int retval = EOK;
    125121               
    126122                if (!IPC_GET_IMETHOD(call)) {
  • uspace/srv/hid/input/port/adb_mouse.c

    r80445cf r4c53333  
    3737#include <ipc/adb.h>
    3838#include <async.h>
    39 #include <input.h>
    40 #include <mouse_port.h>
    41 #include <mouse.h>
    4239#include <errno.h>
    4340#include <loc.h>
    4441#include <stdio.h>
     42#include "../mouse.h"
     43#include "../mouse_port.h"
     44#include "../input.h"
    4545
    4646static mouse_dev_t *mouse_dev;
     
    5454                ipc_callid_t callid = async_get_call(&call);
    5555               
    56                 int retval;
     56                int retval = EOK;
    5757               
    5858                if (!IPC_GET_IMETHOD(call)) {
  • uspace/srv/hid/input/port/chardev.c

    r80445cf r4c53333  
    3737#include <ipc/char.h>
    3838#include <async.h>
    39 #include <input.h>
    40 #include <kbd_port.h>
    41 #include <kbd.h>
    4239#include <loc.h>
    4340#include <errno.h>
    4441#include <stdio.h>
     42#include "../input.h"
     43#include "../kbd_port.h"
     44#include "../kbd.h"
    4545
    4646static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    6363/** List of devices to try connecting to. */
    6464static const char *in_devs[] = {
    65         "char/s3c24ser"
     65        "char/s3c24xx_uart"
    6666};
    6767
     
    148148                }
    149149
    150                 int retval;
     150                int retval = EOK;
    151151
    152152                switch (IPC_GET_IMETHOD(call)) {
  • uspace/srv/hid/input/port/msim.c

    r80445cf r4c53333  
    3838#include <async.h>
    3939#include <sysinfo.h>
    40 #include <kbd_port.h>
    41 #include <kbd.h>
    4240#include <ddi.h>
    4341#include <errno.h>
     42#include "../kbd_port.h"
     43#include "../kbd.h"
    4444
    4545static int msim_port_init(kbd_dev_t *);
  • uspace/srv/hid/input/port/niagara.c

    r80445cf r4c53333  
    3131 * @ingroup  kbd
    3232 * @{
    33  */ 
     33 */
    3434/** @file
    35  * @brief       Niagara console keyboard port driver.
     35 * @brief Niagara console keyboard port driver.
    3636 */
    3737
     
    3939#include <ddi.h>
    4040#include <async.h>
    41 #include <kbd.h>
    42 #include <kbd_port.h>
    4341#include <sysinfo.h>
    4442#include <stdio.h>
    4543#include <thread.h>
    46 #include <bool.h>
     44#include <stdbool.h>
    4745#include <errno.h>
     46#include "../kbd_port.h"
     47#include "../kbd.h"
    4848
    4949static int niagara_port_init(kbd_dev_t *);
  • uspace/srv/hid/input/port/ns16550.c

    r80445cf r4c53333  
    3939#include <async.h>
    4040#include <sysinfo.h>
    41 #include <input.h>
    42 #include <kbd.h>
    43 #include <kbd_port.h>
    4441#include <ddi.h>
    4542#include <errno.h>
     43#include "../input.h"
     44#include "../kbd_port.h"
     45#include "../kbd.h"
    4646
    4747static int ns16550_port_init(kbd_dev_t *);
     
    8484        },
    8585        {
    86                 .cmd = CMD_BTEST,
     86                .cmd = CMD_AND,
    8787                .value = LSR_DATA_READY,
    8888                .srcarg = 1,
  • uspace/srv/hid/input/port/pl050.c

    r80445cf r4c53333  
    3737
    3838#include <ddi.h>
    39 #include <libarch/ddi.h>
    4039#include <async.h>
    4140#include <unistd.h>
    4241#include <sysinfo.h>
    43 #include <kbd_port.h>
    44 #include <kbd.h>
    45 #include <ddi.h>
    4642#include <stdio.h>
    4743#include <errno.h>
     44#include "../kbd_port.h"
     45#include "../kbd.h"
    4846
    4947static int pl050_port_init(kbd_dev_t *);
     
    8078        },
    8179        {
    82                 .cmd = CMD_BTEST,
     80                .cmd = CMD_AND,
    8381                .value = PL050_STAT_RXFULL,
    8482                .srcarg = 1,
  • uspace/srv/hid/input/port/ski.c

    r80445cf r4c53333  
    3131 * @ingroup  kbd
    3232 * @{
    33  */ 
     33 */
    3434/** @file
    35  * @brief       Ski console keyboard port driver.
     35 * @brief Ski console keyboard port driver.
    3636 */
    37 
    3837
    3938#include <stdlib.h>
    4039#include <unistd.h>
    41 #include <kbd.h>
    42 #include <kbd_port.h>
    4340#include <sys/types.h>
    4441#include <thread.h>
    45 #include <bool.h>
     42#include <stdbool.h>
     43#include "../kbd_port.h"
     44#include "../kbd.h"
    4645
    4746static int ski_port_init(kbd_dev_t *);
  • uspace/srv/hid/input/proto/adb.c

    r80445cf r4c53333  
    3636 */
    3737
    38 #include <bool.h>
    39 #include <mouse.h>
    40 #include <mouse_port.h>
    41 #include <mouse_proto.h>
     38#include <stdbool.h>
     39#include "../mouse.h"
     40#include "../mouse_port.h"
     41#include "../mouse_proto.h"
    4242
    4343static mouse_dev_t *mouse_dev;
  • uspace/srv/hid/input/proto/mousedev.c

    r80445cf r4c53333  
    4343#include <errno.h>
    4444#include <ipc/mouseev.h>
    45 #include <input.h>
    4645#include <loc.h>
    47 #include <mouse.h>
    48 #include <mouse_port.h>
    49 #include <mouse_proto.h>
    5046#include <sys/typefmt.h>
     47#include "../mouse.h"
     48#include "../mouse_port.h"
     49#include "../mouse_proto.h"
     50#include "../input.h"
    5151
    5252/** Mousedev softstate */
     
    9696                        retval = EOK;
    9797                        break;
     98                case MOUSEEV_ABS_MOVE_EVENT:
     99                        mouse_push_event_abs_move(mousedev->mouse_dev,
     100                                IPC_GET_ARG1(call), IPC_GET_ARG2(call),
     101                                IPC_GET_ARG3(call), IPC_GET_ARG4(call));
     102                        retval = EOK;
     103                        break;
    98104                case MOUSEEV_BUTTON_EVENT:
    99105                        mouse_push_event_button(mousedev->mouse_dev,
     
    117123                printf("%s: Failed starting session with '%s'\n", NAME,
    118124                    mdev->svc_name);
    119                 return -1;
     125                return ENOENT;
    120126        }
    121127       
     
    125131                    NAME, mdev->svc_name);
    126132                async_hangup(sess);
    127                 return -1;
     133                return ENOMEM;
    128134        }
    129135       
     
    134140                mousedev_destroy(mousedev);
    135141                async_hangup(sess);
    136                 return -1;
     142                return ENOENT;
    137143        }
    138144       
     
    145151                    NAME, mdev->svc_name);
    146152                mousedev_destroy(mousedev);
    147                 return -1;
     153                return rc;
    148154        }
    149155       
    150         return 0;
     156        return EOK;
    151157}
    152158
  • uspace/srv/hid/input/stroke.c

    r80445cf r4c53333  
    4040 */
    4141
    42 #include <stroke.h>
    43 #include <kbd.h>
    4442#include <io/console.h>
    4543#include <io/keycode.h>
     44#include "stroke.h"
     45#include "kbd.h"
    4646
    4747/** Correspondence between modifers and the modifier keycodes. */
  • uspace/srv/hid/input/stroke.h

    r80445cf r4c53333  
    2828
    2929/** @addtogroup inputgen generic
    30  * @brief       Generic scancode parser.
    31  * @ingroup  input
     30 * @brief Generic scancode parser.
     31 * @ingroup input
    3232 * @{
    33  */ 
     33 */
    3434/** @file
    3535 */
     
    3838#define KBD_STROKE_H_
    3939
    40 #include <kbd.h>
     40#include "kbd.h"
    4141
    4242extern void stroke_sim(kbd_dev_t *, unsigned, unsigned);
     
    4646/**
    4747 * @}
    48  */
    49 
     48 */
  • uspace/srv/hid/output/Makefile

    r80445cf r4c53333  
    2929
    3030USPACE_PREFIX = ../../..
    31 LIBS = $(LIBFB_PREFIX)/libfb.a
    32 EXTRA_CFLAGS += -I$(LIBFB_PREFIX)
    33 BINARY = fb
     31BINARY = output
    3432
    3533SOURCES = \
    36         gfx/font-8x16.c \
    3734        ctl/serial.c \
    3835        port/ega.c \
    39         port/kfb.c \
    4036        port/kchar.c \
    4137        port/niagara.c \
    4238        port/ski.c \
    4339        proto/vt100.c \
    44         fb.c
     40        output.c
    4541
    4642include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hid/output/ctl/serial.c

    r80445cf r4c53333  
    2828 */
    2929
    30 /** @file
     30/** @addtogroup console
     31 * @{
     32 */
     33/**
     34 * @file
    3135 */
    3236
    3337#include <sys/types.h>
    3438#include <errno.h>
    35 #include <malloc.h>
    36 #include <screenbuffer.h>
     39#include <io/chargrid.h>
     40#include "../output.h"
    3741#include "../proto/vt100.h"
    38 #include "../fb.h"
    3942#include "serial.h"
    4043
    41 /** Draw the character at the specified position in viewport.
     44#define SERIAL_COLS  80
     45#define SERIAL_ROWS  24
     46
     47/** Draw the character at the specified position.
    4248 *
    4349 * @param state VT100 protocol state.
    44  * @param vp    Viewport.
    45  * @param col   Screen position relative to viewport.
    46  * @param row   Screen position relative to viewport.
     50 * @param field Character field.
     51 * @param col   Horizontal screen position.
     52 * @param row   Vertical screen position.
    4753 *
    4854 */
    49 static void draw_vp_char(vt100_state_t *state, fbvp_t *vp, sysarg_t col,
    50     sysarg_t row)
     55static void draw_char(vt100_state_t *state, charfield_t *field,
     56    sysarg_t col, sysarg_t row)
    5157{
    52         sysarg_t x = vp->x + col;
    53         sysarg_t y = vp->y + row;
    54        
    55         charfield_t *field = screenbuffer_field_at(vp->backbuf, col, row);
    56        
    57         vt100_goto(state, x, y);
     58        vt100_goto(state, col, row);
    5859        vt100_set_attr(state, field->attrs);
    5960        vt100_putchar(state, field->ch);
    6061}
    6162
    62 static int serial_yield(fbdev_t *dev)
     63static int serial_yield(outdev_t *dev)
    6364{
    6465        vt100_state_t *state = (vt100_state_t *) dev->data;
     66       
    6567        return vt100_yield(state);
    6668}
    6769
    68 static int serial_claim(fbdev_t *dev)
     70static int serial_claim(outdev_t *dev)
    6971{
    7072        vt100_state_t *state = (vt100_state_t *) dev->data;
     73       
    7174        return vt100_claim(state);
    7275}
    7376
    74 static int serial_get_resolution(fbdev_t *dev, sysarg_t *width, sysarg_t *height)
    75 {
    76         vt100_state_t *state = (vt100_state_t *) dev->data;
    77         vt100_get_resolution(state, width, height);
    78         return EOK;
    79 }
    80 
    81 static void serial_font_metrics(fbdev_t *dev, sysarg_t width, sysarg_t height,
    82     sysarg_t *cols, sysarg_t *rows)
    83 {
    84         *cols = width;
    85         *rows = height;
    86 }
    87 
    88 static int serial_vp_create(fbdev_t *dev, fbvp_t *vp)
    89 {
    90         vp->attrs.type = CHAR_ATTR_STYLE;
    91         vp->attrs.val.style = STYLE_NORMAL;
    92         vp->data = NULL;
    93        
    94         return EOK;
    95 }
    96 
    97 static void serial_vp_destroy(fbdev_t *dev, fbvp_t *vp)
    98 {
    99         /* No-op */
    100 }
    101 
    102 static void serial_vp_clear(fbdev_t *dev, fbvp_t *vp)
     77static void serial_get_dimensions(outdev_t *dev, sysarg_t *cols,
     78    sysarg_t *rows)
    10379{
    10480        vt100_state_t *state = (vt100_state_t *) dev->data;
    10581       
    106         for (sysarg_t row = 0; row < vp->rows; row++) {
    107                 for (sysarg_t col = 0; col < vp->cols; col++) {
    108                         charfield_t *field =
    109                             screenbuffer_field_at(vp->backbuf, col, row);
    110                        
    111                         field->ch = 0;
    112                         field->attrs = vp->attrs;
    113                        
    114                         draw_vp_char(state, vp, col, row);
    115                 }
    116         }
     82        vt100_get_dimensions(state, cols, rows);
    11783}
    11884
    119 static console_caps_t serial_vp_get_caps(fbdev_t *dev, fbvp_t *vp)
     85static console_caps_t serial_get_caps(outdev_t *dev)
    12086{
    12187        return (CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED);
    12288}
    12389
    124 static void serial_vp_cursor_update(fbdev_t *dev, fbvp_t *vp,
    125     sysarg_t prev_col, sysarg_t prev_row, sysarg_t col, sysarg_t row,
    126     bool visible)
     90static void serial_cursor_update(outdev_t *dev, sysarg_t prev_col,
     91    sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible)
    12792{
    12893        vt100_state_t *state = (vt100_state_t *) dev->data;
    12994       
    130         vt100_goto(state, vp->x + col, vp->y + row);
     95        vt100_goto(state, col, row);
    13196        vt100_cursor_visibility(state, visible);
    13297}
    13398
    134 static void serial_vp_char_update(fbdev_t *dev, fbvp_t *vp, sysarg_t col,
    135     sysarg_t row)
     99static void serial_char_update(outdev_t *dev, sysarg_t col, sysarg_t row)
    136100{
    137101        vt100_state_t *state = (vt100_state_t *) dev->data;
    138         draw_vp_char(state, vp, col, row);
     102        charfield_t *field =
     103            chargrid_charfield_at(dev->backbuf, col, row);
     104       
     105        draw_char(state, field, col, row);
    139106}
    140107
    141 static fbdev_ops_t serial_ops = {
     108static outdev_ops_t serial_ops = {
    142109        .yield = serial_yield,
    143110        .claim = serial_claim,
    144         .get_resolution = serial_get_resolution,
    145         .font_metrics = serial_font_metrics,
    146         .vp_create = serial_vp_create,
    147         .vp_destroy = serial_vp_destroy,
    148         .vp_clear = serial_vp_clear,
    149         .vp_get_caps = serial_vp_get_caps,
    150         .vp_cursor_update = serial_vp_cursor_update,
    151         .vp_char_update = serial_vp_char_update
     111        .get_dimensions = serial_get_dimensions,
     112        .get_caps = serial_get_caps,
     113        .cursor_update = serial_cursor_update,
     114        .char_update = serial_char_update
    152115};
    153116
     
    156119{
    157120        vt100_state_t *state =
    158             vt100_state_create(80, 24, putchar_fn, control_puts_fn);
     121            vt100_state_create(SERIAL_COLS, SERIAL_ROWS, putchar_fn,
     122            control_puts_fn);
    159123        if (state == NULL)
    160124                return ENOMEM;
    161125       
    162         fbdev_t *dev = fbdev_register(&serial_ops, state);
    163         if (dev == NULL)
    164                 return EINVAL;
     126        outdev_t *dev = outdev_register(&serial_ops, state);
     127        if (dev == NULL) {
     128                vt100_state_destroy(state);
     129                return ENOMEM;
     130        }
    165131       
    166132        return EOK;
  • uspace/srv/hid/output/ctl/serial.h

    r80445cf r4c53333  
    3131 */
    3232
    33 #ifndef FB_CTL_SERIAL_H_
    34 #define FB_CTL_SERIAL_H_
     33#ifndef OUTPUT_CTL_SERIAL_H_
     34#define OUTPUT_CTL_SERIAL_H_
    3535
    3636#include "../proto/vt100.h"
  • uspace/srv/hid/output/port/ega.c

    r80445cf r4c53333  
    3333#include <errno.h>
    3434#include <sysinfo.h>
    35 #include <task.h>
     35#include <align.h>
     36#include <as.h>
    3637#include <ddi.h>
    37 #include <libarch/ddi.h>
    38 #include <as.h>
    39 #include <malloc.h>
    40 #include <align.h>
    41 #include <screenbuffer.h>
    42 #include "../fb.h"
     38#include <io/chargrid.h>
     39#include "../output.h"
    4340#include "ega.h"
    4441
     
    4643#define EGA_IO_SIZE  2
    4744
    48 #define FB_POS(x, y)  (((y) * ega.width + (x)) << 1)
     45#define FB_POS(x, y)  (((y) * ega.cols + (x)) << 1)
    4946
    5047typedef struct {
    51         sysarg_t width;
    52         sysarg_t height;
     48        sysarg_t cols;
     49        sysarg_t rows;
     50       
     51        uint8_t style_normal;
     52        uint8_t style_inverted;
    5353       
    5454        size_t size;
    5555        uint8_t *addr;
    56        
    57         uint8_t style_normal;
    58         uint8_t style_inverted;
    59        
    60         uint8_t *backbuf;
    6156} ega_t;
    6257
     
    10196}
    10297
    103 /** Draw the character at the specified position in viewport.
    104  *
    105  * @param vp     Viewport.
    106  * @param col    Screen position relative to viewport.
    107  * @param row    Screen position relative to viewport.
    108  *
    109  */
    110 static void draw_vp_char(fbvp_t *vp, sysarg_t col, sysarg_t row)
    111 {
    112         sysarg_t x = vp->x + col;
    113         sysarg_t y = vp->y + row;
    114        
    115         charfield_t *field = screenbuffer_field_at(vp->backbuf, col, row);
    116        
     98/** Draw the character at the specified position.
     99 *
     100 * @param field Character field.
     101 * @param col   Horizontal screen position.
     102 * @param row   Vertical screen position.
     103 *
     104 */
     105static void draw_char(charfield_t *field, sysarg_t col, sysarg_t row)
     106{
    117107        uint8_t glyph;
    118108       
     
    124114        uint8_t attr = attrs_attr(field->attrs);
    125115       
    126         ega.addr[FB_POS(x, y)] = glyph;
    127         ega.addr[FB_POS(x, y) + 1] = attr;
    128 }
    129 
    130 static int ega_yield(fbdev_t *dev)
    131 {
    132         if (ega.backbuf == NULL) {
    133                 ega.backbuf = malloc(ega.size);
    134                 if (ega.backbuf == NULL)
    135                         return ENOMEM;
    136         }
    137        
    138         memcpy(ega.backbuf, ega.addr, ega.size);
     116        ega.addr[FB_POS(col, row)] = glyph;
     117        ega.addr[FB_POS(col, row) + 1] = attr;
     118}
     119
     120static int ega_yield(outdev_t *dev)
     121{
    139122        return EOK;
    140123}
    141124
    142 static int ega_claim(fbdev_t *dev)
    143 {
    144         if (ega.backbuf == NULL)
    145                 return ENOENT;
    146        
    147         memcpy(ega.addr, ega.backbuf, ega.size);
     125static int ega_claim(outdev_t *dev)
     126{
    148127        return EOK;
    149128}
    150129
    151 static int ega_get_resolution(fbdev_t *dev, sysarg_t *width, sysarg_t *height)
    152 {
    153         *width = ega.width;
    154         *height = ega.height;
    155         return EOK;
    156 }
    157 
    158 static void ega_font_metrics(fbdev_t *dev, sysarg_t width, sysarg_t height,
    159     sysarg_t *cols, sysarg_t *rows)
    160 {
    161         *cols = width;
    162         *rows = height;
    163 }
    164 
    165 static int ega_vp_create(fbdev_t *dev, fbvp_t *vp)
    166 {
    167         vp->attrs.type = CHAR_ATTR_STYLE;
    168         vp->attrs.val.style = STYLE_NORMAL;
    169         vp->data = NULL;
    170        
    171         return EOK;
    172 }
    173 
    174 static void ega_vp_destroy(fbdev_t *dev, fbvp_t *vp)
    175 {
    176         /* No-op */
    177 }
    178 
    179 static void ega_vp_clear(fbdev_t *dev, fbvp_t *vp)
    180 {
    181         for (sysarg_t row = 0; row < vp->rows; row++) {
    182                 for (sysarg_t col = 0; col < vp->cols; col++) {
    183                         charfield_t *field =
    184                             screenbuffer_field_at(vp->backbuf, col, row);
    185                        
    186                         field->ch = 0;
    187                         field->attrs = vp->attrs;
    188                        
    189                         draw_vp_char(vp, col, row);
    190                 }
    191         }
    192 }
    193 
    194 static console_caps_t ega_vp_get_caps(fbdev_t *dev, fbvp_t *vp)
     130static void ega_get_dimensions(outdev_t *dev, sysarg_t *cols, sysarg_t *rows)
     131{
     132        *cols = ega.cols;
     133        *rows = ega.rows;
     134}
     135
     136static console_caps_t ega_get_caps(outdev_t *dev)
    195137{
    196138        return (CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED);
    197139}
    198140
    199 static void ega_vp_cursor_update(fbdev_t *dev, fbvp_t *vp, sysarg_t prev_col,
     141static void ega_cursor_update(outdev_t *dev, sysarg_t prev_col,
    200142    sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible)
    201143{
    202144        /* Cursor position */
    203         uint16_t cursor = row * ega.width + col;
     145        uint16_t cursor = row * ega.cols + col;
    204146       
    205147        pio_write_8(EGA_IO_BASE, 0x0e);
     
    220162}
    221163
    222 static void ega_vp_char_update(fbdev_t *dev, fbvp_t *vp, sysarg_t col,
    223     sysarg_t row)
    224 {
    225         draw_vp_char(vp, col, row);
    226 }
    227 
    228 static fbdev_ops_t ega_ops = {
     164static void ega_char_update(outdev_t *dev, sysarg_t col, sysarg_t row)
     165{
     166        charfield_t *field =
     167            chargrid_charfield_at(dev->backbuf, col, row);
     168       
     169        draw_char(field, col, row);
     170}
     171
     172static outdev_ops_t ega_ops = {
    229173        .yield = ega_yield,
    230174        .claim = ega_claim,
    231         .get_resolution = ega_get_resolution,
    232         .font_metrics = ega_font_metrics,
    233         .vp_create = ega_vp_create,
    234         .vp_destroy = ega_vp_destroy,
    235         .vp_clear = ega_vp_clear,
    236         .vp_get_caps = ega_vp_get_caps,
    237         .vp_cursor_update = ega_vp_cursor_update,
    238         .vp_char_update = ega_vp_char_update
     175        .get_dimensions = ega_get_dimensions,
     176        .get_caps = ega_get_caps,
     177        .cursor_update = ega_cursor_update,
     178        .char_update = ega_char_update
    239179};
    240180
     
    262202                return rc;
    263203       
    264         sysarg_t width;
    265         rc = sysinfo_get_value("fb.width", &width);
    266         if (rc != EOK)
    267                 return rc;
    268        
    269         sysarg_t height;
    270         rc = sysinfo_get_value("fb.height", &height);
    271         if (rc != EOK)
    272                 return rc;
    273        
    274         rc = iospace_enable(task_get_id(), (void *) EGA_IO_BASE, EGA_IO_SIZE);
    275         if (rc != EOK)
    276                 return rc;
    277        
    278         ega.width = width;
    279         ega.height = height;
    280        
    281         ega.size = (width * height) << 1;
     204        rc = sysinfo_get_value("fb.width", &ega.cols);
     205        if (rc != EOK)
     206                return rc;
     207       
     208        rc = sysinfo_get_value("fb.height", &ega.rows);
     209        if (rc != EOK)
     210                return rc;
     211       
     212        rc = pio_enable((void*)EGA_IO_BASE, EGA_IO_SIZE, NULL);
     213        if (rc != EOK)
     214                return rc;
     215       
     216        ega.size = (ega.cols * ega.rows) << 1;
    282217       
    283218        rc = physmem_map((void *) paddr,
     
    300235        }
    301236       
    302         ega.backbuf = NULL;
    303        
    304         fbdev_t *dev = fbdev_register(&ega_ops, (void *) &ega);
     237        outdev_t *dev = outdev_register(&ega_ops, (void *) &ega);
    305238        if (dev == NULL) {
    306239                as_area_destroy(ega.addr);
     
    311244}
    312245
    313 /**
    314  * @}
    315  */
     246/** @}
     247 */
  • uspace/srv/hid/output/port/ega.h

    r80445cf r4c53333  
    3030 */
    3131
    32 #ifndef FB_PORT_EGA_H_
    33 #define FB_PORT_EGA_H_
     32#ifndef OUTPUT_PORT_EGA_H_
     33#define OUTPUT_PORT_EGA_H_
    3434
    3535extern int ega_init(void);
  • uspace/srv/hid/output/port/kchar.c

    r80445cf r4c53333  
    3333#include <sys/types.h>
    3434#include <errno.h>
     35#include <str.h>
    3536#include <sysinfo.h>
    3637#include <ddi.h>
     38#include <align.h>
    3739#include <as.h>
    38 #include <align.h>
    3940#include "../ctl/serial.h"
    4041#include "kchar.h"
  • uspace/srv/hid/output/port/kchar.h

    r80445cf r4c53333  
    3131 */
    3232
    33 #ifndef FB_PORT_KCHAR_H_
    34 #define FB_PORT_KCHAR_H_
     33#ifndef OUTPUT_PORT_KCHAR_H_
     34#define OUTPUT_PORT_KCHAR_H_
    3535
    3636extern int kchar_init(void);
  • uspace/srv/hid/output/port/niagara.c

    r80445cf r4c53333  
    3838#include <as.h>
    3939#include <align.h>
     40#include <str.h>
    4041#include "../ctl/serial.h"
    4142#include "niagara.h"
  • uspace/srv/hid/output/port/niagara.h

    r80445cf r4c53333  
    3030 */
    3131
    32 #ifndef FB_PORT_NIAGARA_H_
    33 #define FB_PORT_NIAGARA_H_
     32#ifndef OUTPUT_PORT_NIAGARA_H_
     33#define OUTPUT_PORT_NIAGARA_H_
    3434
    3535extern int niagara_init(void);
     
    3737#endif
    3838
    39 /**
    40  * @}
     39/** @}
    4140 */
  • uspace/srv/hid/output/port/ski.h

    r80445cf r4c53333  
    2727 */
    2828
    29 /** @file
     29/** @addtogroup console
     30 * @{
     31 */
     32/**
     33 * @file
    3034 */
    3135
    32 #ifndef FB_PORT_SKI_H_
    33 #define FB_PORT_SKI_H_
     36#ifndef OUTPUT_PORT_SKI_H_
     37#define OUTPUT_PORT_SKI_H_
    3438
    3539extern int ski_init(void);
  • uspace/srv/hid/output/proto/vt100.c

    r80445cf r4c53333  
    3232#include <sys/types.h>
    3333#include <inttypes.h>
     34#include <errno.h>
    3435#include <stdio.h>
     36#include <unistd.h>
     37#include <malloc.h>
    3538#include <io/color.h>
    36 #include <malloc.h>
    37 #include <errno.h>
    3839#include "vt100.h"
    3940
    4041#define MAX_CONTROL  20
    41 
    42 #define BACKBUF_POS(state, x, y)  ((y) * ((state)->width) + (x))
    43 
    44 struct vt100_state {
    45         vt100_putchar_t putchar;
    46         vt100_control_puts_t control_puts;
    47        
    48         sysarg_t width;
    49         sysarg_t height;
    50        
    51         sysarg_t cur_col;
    52         sysarg_t cur_row;
    53        
    54         char_attrs_t cur_attrs;
    55        
    56         charfield_t backbuf[];
    57 };
    5842
    5943typedef enum {
     
    154138}
    155139
    156 vt100_state_t *vt100_state_create(sysarg_t width, sysarg_t height,
     140vt100_state_t *vt100_state_create(sysarg_t cols, sysarg_t rows,
    157141    vt100_putchar_t putchar_fn, vt100_control_puts_t control_puts_fn)
    158142{
    159         size_t sz = width * height * sizeof(charfield_t);
    160        
    161143        vt100_state_t *state =
    162             malloc(sizeof(vt100_state_t) + sz);
     144            malloc(sizeof(vt100_state_t));
    163145        if (state == NULL)
    164146                return NULL;
     
    167149        state->control_puts = control_puts_fn;
    168150       
    169         state->width = width;
    170         state->height = height;
     151        state->cols = cols;
     152        state->rows = rows;
    171153       
    172154        state->cur_col = (sysarg_t) -1;
     
    175157        state->cur_attrs.type = CHAR_ATTR_STYLE;
    176158        state->cur_attrs.val.style = STYLE_NORMAL;
    177        
    178         memset(state->backbuf, 0, sz);
    179159       
    180160        /* Initialize graphic rendition attributes */
     
    183163        vt100_sgr(state, SGR_BGCOLOR + CI_WHITE);
    184164        state->control_puts("\033[2J");
     165        state->control_puts("\033[?25l");
    185166       
    186167        return state;
    187168}
    188169
    189 void vt100_get_resolution(vt100_state_t *state, sysarg_t *width,
    190     sysarg_t *height)
    191 {
    192         *width = state->width;
    193         *height = state->height;
     170void vt100_state_destroy(vt100_state_t *state)
     171{
     172        free(state);
     173}
     174
     175void vt100_get_dimensions(vt100_state_t *state, sysarg_t *cols,
     176    sysarg_t *rows)
     177{
     178        *cols = state->cols;
     179        *rows = state->rows;
    194180}
    195181
     
    201187int vt100_claim(vt100_state_t *state)
    202188{
    203         for (sysarg_t row = 0; row < state->height; row++) {
    204                 vt100_set_pos(state, 0, row);
    205                 for (sysarg_t col = 0; col < state->width; col++) {
    206                         charfield_t *field = state->backbuf +
    207                             BACKBUF_POS(state, col, row);
    208                         vt100_set_sgr(state, field->attrs);
    209                         state->putchar(field->ch);
    210                 }
    211         }
    212        
    213         vt100_set_pos(state, state->cur_col, state->cur_row);
    214         vt100_set_sgr(state, state->cur_attrs);
    215        
    216189        return EOK;
    217190}
    218191
    219 void vt100_putchar(vt100_state_t *state, wchar_t ch)
    220 {
    221         charfield_t *field = state->backbuf +
    222             BACKBUF_POS(state, state->cur_col, state->cur_row);
    223         field->ch = ch;
    224         field->attrs = state->cur_attrs;
    225        
    226         state->putchar(ch);
    227         state->cur_col++;
    228        
    229         if (state->cur_col >= state->width) {
    230                 state->cur_row += state->cur_col / state->width;
    231                 state->cur_col %= state->width;
    232         }
    233 }
    234 
    235 void vt100_set_attr(vt100_state_t *state, char_attrs_t attrs)
    236 {
    237         if (!attrs_same(state->cur_attrs, attrs)) {
    238                 vt100_set_sgr(state, attrs);
    239                 state->cur_attrs = attrs;
    240         }
    241 }
    242 
    243192void vt100_goto(vt100_state_t *state, sysarg_t col, sysarg_t row)
    244193{
    245         if ((col >= state->width) || (row >= state->height))
     194        if ((col >= state->cols) || (row >= state->rows))
    246195                return;
    247196       
     
    253202}
    254203
     204void vt100_set_attr(vt100_state_t *state, char_attrs_t attrs)
     205{
     206        if (!attrs_same(state->cur_attrs, attrs)) {
     207                vt100_set_sgr(state, attrs);
     208                state->cur_attrs = attrs;
     209        }
     210}
     211
    255212void vt100_cursor_visibility(vt100_state_t *state, bool visible)
    256213{
     
    261218}
    262219
     220void vt100_putchar(vt100_state_t *state, wchar_t ch)
     221{
     222        state->putchar(ch == 0 ? ' ' : ch);
     223        state->cur_col++;
     224       
     225        if (state->cur_col >= state->cols) {
     226                state->cur_row += state->cur_col / state->cols;
     227                state->cur_col %= state->cols;
     228        }
     229}
     230
    263231/** @}
    264232 */
  • uspace/srv/hid/output/proto/vt100.h

    r80445cf r4c53333  
    3030 */
    3131
    32 #ifndef FB_PROTO_VT100_H_
    33 #define FB_PROTO_VT100_H_
     32#ifndef OUTPUT_PROTO_VT100_H_
     33#define OUTPUT_PROTO_VT100_H_
    3434
    3535#include <sys/types.h>
    36 #include <screenbuffer.h>
     36#include <io/charfield.h>
    3737
    3838typedef void (* vt100_putchar_t)(wchar_t ch);
    3939typedef void (* vt100_control_puts_t)(const char *str);
    4040
    41 /** Forward declaration */
    42 struct vt100_state;
    43 typedef struct vt100_state vt100_state_t;
     41typedef struct {
     42        sysarg_t cols;
     43        sysarg_t rows;
     44       
     45        sysarg_t cur_col;
     46        sysarg_t cur_row;
     47        char_attrs_t cur_attrs;
     48       
     49        vt100_putchar_t putchar;
     50        vt100_control_puts_t control_puts;
     51} vt100_state_t;
    4452
    4553extern vt100_state_t *vt100_state_create(sysarg_t, sysarg_t, vt100_putchar_t,
    4654    vt100_control_puts_t);
    47 extern void vt100_get_resolution(vt100_state_t *, sysarg_t *, sysarg_t *);
     55extern void vt100_state_destroy(vt100_state_t *);
     56
    4857extern int vt100_yield(vt100_state_t *);
    4958extern int vt100_claim(vt100_state_t *);
     59extern void vt100_get_dimensions(vt100_state_t *, sysarg_t *, sysarg_t *);
    5060
     61extern void vt100_goto(vt100_state_t *, sysarg_t, sysarg_t);
     62extern void vt100_set_attr(vt100_state_t *, char_attrs_t);
     63extern void vt100_cursor_visibility(vt100_state_t *, bool);
    5164extern void vt100_putchar(vt100_state_t *, wchar_t);
    52 
    53 extern void vt100_set_attr(vt100_state_t *, char_attrs_t);
    54 extern void vt100_goto(vt100_state_t *, sysarg_t, sysarg_t);
    55 extern void vt100_cursor_visibility(vt100_state_t *, bool);
    5665
    5766#endif
  • uspace/srv/hid/remcons/remcons.c

    r80445cf r4c53333  
    3434
    3535#include <async.h>
     36#include <errno.h>
     37#include <io/con_srv.h>
    3638#include <stdio.h>
    37 #include <adt/prodcons.h>
    38 #include <ipc/input.h>
    39 #include <ipc/console.h>
    40 #include <ipc/vfs.h>
    41 #include <errno.h>
     39#include <stdlib.h>
    4240#include <str_error.h>
    4341#include <loc.h>
     
    4543#include <io/keycode.h>
    4644#include <align.h>
    47 #include <malloc.h>
    48 #include <as.h>
    4945#include <fibril_synch.h>
    5046#include <task.h>
     
    7167        TELNET_IAC, TELNET_WONT, TELNET_LINEMODE
    7268};
     69
    7370static const size_t telnet_force_character_mode_command_count =
    7471    sizeof(telnet_force_character_mode_command) / sizeof(telnet_cmd_t);
    7572
    76 
    77 /** Handling client requests (VFS and console interface).
    78  *
    79  * @param user Telnet user the requests belong to.
    80  */
    81 static void client_connection_message_loop(telnet_user_t *user)
    82 {
    83         while (true) {
    84                 ipc_call_t call;
    85                 ipc_callid_t callid = 0;
    86 
    87                 /*
    88                  * The getterm task might terminate while we are here,
    89                  * waiting for a call. Also, the socket might be closed
    90                  * meanwhile.
    91                  * We want to detect this situation early, so we use a
    92                  * timeout variant of async_get_call().
    93                  */
    94                 while (callid == 0) {
    95                         callid = async_get_call_timeout(&call, 1000);
    96 
    97                         if (telnet_user_is_zombie(user)) {
    98                                 if (callid != 0) {
    99                                         async_answer_0(callid, EINTR);
    100                                 }
    101                                 return;
    102                         }
    103                 }
    104                
    105                 if (!IPC_GET_IMETHOD(call)) {
    106                         return;
    107                 }
    108 
    109                 switch (IPC_GET_IMETHOD(call)) {
    110                 case CONSOLE_GET_SIZE:
    111                         async_answer_2(callid, EOK, 100, 1);
    112                         break;
    113                 case CONSOLE_GET_POS:
    114                         fibril_mutex_lock(&user->guard);
    115                         async_answer_2(callid, EOK, user->cursor_x, 0);
    116                         fibril_mutex_unlock(&user->guard);
    117                         break;
    118                 case CONSOLE_GET_EVENT: {
    119                         kbd_event_t event;
    120                         int rc = telnet_user_get_next_keyboard_event(user, &event);
    121                         if (rc != EOK) {
    122                                 /* Silently ignore. */
    123                                 async_answer_0(callid, EOK);
    124                                 break;
    125                         }
    126                         async_answer_4(callid, EOK, event.type, event.key, event.mods, event.c);
    127                         break;
    128                 }
    129                 case CONSOLE_GOTO: {
    130                         int new_x = IPC_GET_ARG1(call);
    131                         telnet_user_update_cursor_x(user, new_x);
    132                         async_answer_0(callid, ENOTSUP);
    133                         break;
    134                 }
    135                 case VFS_OUT_READ:
    136                         async_answer_0(callid, ENOTSUP);
    137                         break;
    138                 case VFS_OUT_WRITE: {
    139                         uint8_t *buf;
    140                         size_t size;
    141                         int rc = async_data_write_accept((void **)&buf, false, 0, 0, 0, &size);
    142 
    143                         if (rc != EOK) {
    144                                 async_answer_0(callid, rc);
    145                                 break;
    146                         }
    147 
    148                         rc = telnet_user_send_data(user, buf, size);
    149                         free(buf);
    150 
    151                         if (rc != EOK) {
    152                                 async_answer_0(callid, rc);
    153                                 break;
    154                         }
    155 
    156                         async_answer_1(callid, EOK, size);
    157                         break;
    158                 }
    159                 case VFS_OUT_SYNC:
    160                         async_answer_0(callid, EOK);
    161                         break;
    162                 case CONSOLE_CLEAR:
    163                         async_answer_0(callid, EOK);
    164                         break;
    165 
    166                 case CONSOLE_GET_COLOR_CAP:
    167                         async_answer_1(callid, EOK, CONSOLE_CAP_NONE);
    168                         break;
    169                 case CONSOLE_SET_STYLE:
    170                         async_answer_0(callid, ENOTSUP);
    171                         break;
    172                 case CONSOLE_SET_COLOR:
    173                         async_answer_0(callid, ENOTSUP);
    174                         break;
    175                 case CONSOLE_SET_RGB_COLOR:
    176                         async_answer_0(callid, ENOTSUP);
    177                         break;
    178 
    179                 case CONSOLE_CURSOR_VISIBILITY:
    180                         async_answer_0(callid, ENOTSUP);
    181                         break;
    182 
    183                 default:
    184                         async_answer_0(callid, EINVAL);
    185                         break;
    186                 }
    187         }
     73static int remcons_open(con_srvs_t *, con_srv_t *);
     74static int remcons_close(con_srv_t *);
     75static int remcons_write(con_srv_t *, void *, size_t);
     76static void remcons_sync(con_srv_t *);
     77static void remcons_clear(con_srv_t *);
     78static void remcons_set_pos(con_srv_t *, sysarg_t col, sysarg_t row);
     79static int remcons_get_pos(con_srv_t *, sysarg_t *, sysarg_t *);
     80static int remcons_get_size(con_srv_t *, sysarg_t *, sysarg_t *);
     81static int remcons_get_color_cap(con_srv_t *, console_caps_t *);
     82static int remcons_get_event(con_srv_t *, cons_event_t *);
     83
     84static con_ops_t con_ops = {
     85        .open = remcons_open,
     86        .close = remcons_close,
     87        .read = NULL,
     88        .write = remcons_write,
     89        .sync = remcons_sync,
     90        .clear = remcons_clear,
     91        .set_pos = remcons_set_pos,
     92        .get_pos = remcons_get_pos,
     93        .get_size = remcons_get_size,
     94        .get_color_cap = remcons_get_color_cap,
     95        .set_style = NULL,
     96        .set_color = NULL,
     97        .set_rgb_color = NULL,
     98        .set_cursor_visibility = NULL,
     99        .get_event = remcons_get_event
     100};
     101
     102static telnet_user_t *srv_to_user(con_srv_t *srv)
     103{
     104        return srv->srvs->sarg;
     105}
     106
     107static int remcons_open(con_srvs_t *srvs, con_srv_t *srv)
     108{
     109        telnet_user_t *user = srv_to_user(srv);
     110
     111        telnet_user_log(user, "New client connected (%p).", srv);
     112
     113        /* Force character mode. */
     114        send(user->socket, (void *)telnet_force_character_mode_command,
     115            telnet_force_character_mode_command_count, 0);
     116
     117        return EOK;
     118}
     119
     120static int remcons_close(con_srv_t *srv)
     121{
     122        telnet_user_t *user = srv_to_user(srv);
     123
     124        telnet_user_notify_client_disconnected(user);
     125        telnet_user_log(user, "Client disconnected (%p).", srv);
     126
     127        return EOK;
     128}
     129
     130static int remcons_write(con_srv_t *srv, void *data, size_t size)
     131{
     132        telnet_user_t *user = srv_to_user(srv);
     133        int rc;
     134
     135        rc = telnet_user_send_data(user, data, size);
     136        if (rc != EOK)
     137                return rc;
     138
     139        return size;
     140}
     141
     142static void remcons_sync(con_srv_t *srv)
     143{
     144        (void) srv;
     145}
     146
     147static void remcons_clear(con_srv_t *srv)
     148{
     149        (void) srv;
     150}
     151
     152static void remcons_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row)
     153{
     154        telnet_user_t *user = srv_to_user(srv);
     155
     156        telnet_user_update_cursor_x(user, col);
     157}
     158
     159static int remcons_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row)
     160{
     161        telnet_user_t *user = srv_to_user(srv);
     162
     163        *col = user->cursor_x;
     164        *row = 0;
     165
     166        return EOK;
     167}
     168
     169static int remcons_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows)
     170{
     171        (void) srv;
     172
     173        *cols = 100;
     174        *rows = 1;
     175
     176        return EOK;
     177}
     178
     179static int remcons_get_color_cap(con_srv_t *srv, console_caps_t *ccaps)
     180{
     181        (void) srv;
     182        *ccaps = CONSOLE_CAP_NONE;
     183
     184        return EOK;
     185}
     186
     187static int remcons_get_event(con_srv_t *srv, cons_event_t *event)
     188{
     189        telnet_user_t *user = srv_to_user(srv);
     190        kbd_event_t kevent;
     191        int rc;
     192
     193        rc = telnet_user_get_next_keyboard_event(user, &kevent);
     194        if (rc != EOK) {
     195                /* XXX What? */
     196                memset(event, 0, sizeof(*event));
     197                return EOK;
     198        }
     199
     200        event->type = CEV_KEY;
     201        event->ev.key = kevent;
     202
     203        return EOK;
    188204}
    189205
     
    197213                return;
    198214        }
    199         async_answer_0(iid, EOK);
    200 
    201         telnet_user_log(user, "New client connected (%" PRIxn").", iid);
    202 
    203         /* Force character mode. */
    204         send(user->socket, (void *)telnet_force_character_mode_command,
    205             telnet_force_character_mode_command_count, 0);
    206215
    207216        /* Handle messages. */
    208         client_connection_message_loop(user);
    209 
    210         telnet_user_notify_client_disconnected(user);
    211         telnet_user_log(user, "Client disconnected (%" PRIxn").", iid);
     217        con_conn(iid, icall, &user->srvs);
    212218}
    213219
     
    231237                fibril_mutex_lock(&user->guard);
    232238                user->task_finished = true;
     239                user->srvs.aborted = true;
    233240                fibril_condvar_signal(&user->refcount_cv);
    234241                fibril_mutex_unlock(&user->guard);
     
    250257        fibril_mutex_lock(&user->guard);
    251258        user->task_finished = true;
     259        user->srvs.aborted = true;
    252260        fibril_condvar_signal(&user->refcount_cv);
    253261        fibril_mutex_unlock(&user->guard);
     
    272280static int network_user_fibril(void *arg)
    273281{
    274         int rc;
    275282        telnet_user_t *user = arg;
    276283
    277         rc = loc_service_register(user->service_name, &user->service_id);
     284        int rc = loc_service_register(user->service_name, &user->service_id);
    278285        if (rc != EOK) {
    279286                telnet_user_error(user, "Unable to register %s with loc: %s.",
     
    284291        telnet_user_log(user, "Service %s registerd with id %" PRIun ".",
    285292            user->service_name, user->service_id);
    286 
     293       
    287294        fid_t spawn_fibril = fibril_create(spawn_task_fibril, user);
    288295        assert(spawn_fibril);
    289296        fibril_add_ready(spawn_fibril);
    290 
     297       
    291298        /* Wait for all clients to exit. */
    292299        fibril_mutex_lock(&user->guard);
     
    295302                        closesocket(user->socket);
    296303                        user->socket_closed = true;
     304                        user->srvs.aborted = true;
    297305                        continue;
    298306                } else if (user->socket_closed) {
     
    304312        }
    305313        fibril_mutex_unlock(&user->guard);
    306 
     314       
    307315        rc = loc_service_unregister(user->service_id);
    308316        if (rc != EOK) {
     
    324332        async_set_client_connection(client_connection);
    325333        int rc = loc_server_register(NAME);
    326         if (rc < 0) {
    327                 fprintf(stderr, NAME ": Unable to register server: %s.\n",
    328                     str_error(rc));
    329                 return 1;
    330         }
    331 
     334        if (rc != EOK) {
     335                fprintf(stderr, "%s: Unable to register server\n", NAME);
     336                return rc;
     337        }
     338       
    332339        struct sockaddr_in addr;
    333 
     340       
    334341        addr.sin_family = AF_INET;
    335342        addr.sin_port = htons(port);
    336 
     343       
    337344        rc = inet_pton(AF_INET, "127.0.0.1", (void *)
    338345            &addr.sin_addr.s_addr);
     
    364371
    365372        printf("%s: HelenOS Remote console service\n", NAME);
     373        task_retval(0);
    366374
    367375        while (true) {
     
    380388                assert(user);
    381389
     390                con_srvs_init(&user->srvs);
     391                user->srvs.ops = &con_ops;
     392                user->srvs.sarg = user;
     393                user->srvs.abort_timeout = 1000;
     394
     395                telnet_user_add(user);
     396
    382397                fid_t fid = fibril_create(network_user_fibril, user);
    383398                assert(fid);
  • uspace/srv/hid/remcons/telnet.h

    r80445cf r4c53333  
    5757#define TELNET_LINEMODE 34
    5858
    59 
    6059#endif
    6160
  • uspace/srv/hid/remcons/user.c

    r80445cf r4c53333  
    3535#include <stdio.h>
    3636#include <adt/prodcons.h>
    37 #include <ipc/input.h>
    38 #include <ipc/console.h>
    39 #include <ipc/vfs.h>
    4037#include <errno.h>
    4138#include <str_error.h>
     
    9592        user->locsrv_connection_count = 0;
    9693
    97 
     94        user->cursor_x = 0;
     95
     96        return user;
     97}
     98
     99void telnet_user_add(telnet_user_t *user)
     100{
    98101        fibril_mutex_lock(&users_guard);
    99102        list_append(&user->link, &users);
    100103        fibril_mutex_unlock(&users_guard);
    101 
    102         user->cursor_x = 0;
    103 
    104         return user;
    105104}
    106105
     
    199198                if ((recv_length == 0) || (recv_length == ENOTCONN)) {
    200199                        user->socket_closed = true;
     200                        user->srvs.aborted = true;
    201201                        return ENOENT;
    202202                }
  • uspace/srv/hid/remcons/user.h

    r80445cf r4c53333  
    3636#define TELNET_USER_H_
    3737
     38#include <adt/prodcons.h>
    3839#include <fibril_synch.h>
    3940#include <inttypes.h>
     41#include <io/con_srv.h>
    4042#include "remcons.h"
    4143
     
    5557        /** Path name of the service. */
    5658        char *service_name;
     59        /** Console service setup */
     60        con_srvs_t srvs;
    5761
    5862        /** Producer-consumer of kbd_event_t. */
     
    7680} telnet_user_t;
    7781
    78 telnet_user_t *telnet_user_create(int socket);
    79 void telnet_user_destroy(telnet_user_t *user);
    80 telnet_user_t *telnet_user_get_for_client_connection(service_id_t id);
    81 bool telnet_user_is_zombie(telnet_user_t *user);
    82 void telnet_user_notify_client_disconnected(telnet_user_t *user);
    83 int telnet_user_get_next_keyboard_event(telnet_user_t *user, kbd_event_t *event);
    84 int telnet_user_send_data(telnet_user_t *user, uint8_t *data, size_t size);
    85 void telnet_user_update_cursor_x(telnet_user_t *user, int new_x);
     82extern telnet_user_t *telnet_user_create(int);
     83extern void telnet_user_add(telnet_user_t *);
     84extern void telnet_user_destroy(telnet_user_t *);
     85extern telnet_user_t *telnet_user_get_for_client_connection(service_id_t);
     86extern bool telnet_user_is_zombie(telnet_user_t *);
     87extern void telnet_user_notify_client_disconnected(telnet_user_t *);
     88extern int telnet_user_get_next_keyboard_event(telnet_user_t *, kbd_event_t *);
     89extern int telnet_user_send_data(telnet_user_t *, uint8_t *, size_t);
     90extern void telnet_user_update_cursor_x(telnet_user_t *, int);
    8691
    8792/** Print informational message about connected user. */
    8893#ifdef CONFIG_DEBUG
    8994#define telnet_user_log(user, fmt, ...) \
    90         printf(NAME " [console %d (%d)]: " fmt "\n", user->id, (int) user->service_id, ##__VA_ARGS__)
     95        printf(NAME " [console %d (%d)]: " fmt "\n", \
     96            user->id, (int) user->service_id, ##__VA_ARGS__)
    9197#else
    92 #define telnet_user_log(user, fmt, ...) (void)0
     98#define telnet_user_log(user, fmt, ...) ((void) 0)
    9399#endif
    94100
    95101/** Print error message associated with connected user. */
    96102#define telnet_user_error(user, fmt, ...) \
    97         fprintf(stderr, NAME " [console %d (%d)]: ERROR: " fmt "\n", user->id, (int) user->service_id, ##__VA_ARGS__)
     103        fprintf(stderr, NAME " [console %d (%d)]: ERROR: " fmt "\n", \
     104            user->id, (int) user->service_id, ##__VA_ARGS__)
    98105
    99106#endif
  • uspace/srv/hid/s3c24xx_ts/Makefile

    r80445cf r4c53333  
    2929USPACE_PREFIX = ../../..
    3030
    31 # Need to use short name because of FAT 8+3 limit
    32 BINARY = s3c24ts
     31BINARY = s3c24xx_ts
    3332
    3433SOURCES = \
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c

    r80445cf r4c53333  
    3838
    3939#include <ddi.h>
    40 #include <libarch/ddi.h>
    4140#include <loc.h>
    4241#include <io/console.h>
     
    5251#include "s3c24xx_ts.h"
    5352
    54 #define NAME       "s3c24ser"
     53#define NAME       "s3c24xx_ts"
    5554#define NAMESPACE  "hid"
    5655
     
    8483int main(int argc, char *argv[])
    8584{
    86         int rc;
    87 
    88         printf(NAME ": S3C24xx touchscreen driver\n");
     85        printf("%s: S3C24xx touchscreen driver\n", NAME);
    8986       
    9087        async_set_client_connection(s3c24xx_ts_connection);
    91         rc = loc_server_register(NAME);
    92         if (rc < 0) {
    93                 printf(NAME ": Unable to register driver.\n");
    94                 return -1;
     88        int rc = loc_server_register(NAME);
     89        if (rc != EOK) {
     90                printf("%s: Unable to register driver.\n", NAME);
     91                return rc;
    9592        }
    9693
Note: See TracChangeset for help on using the changeset viewer.