Changeset 6d5e378 in mainline for uspace/srv


Ignore:
Timestamp:
2012-08-16T19:27:44Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4f351432, 7d27f422
Parents:
c9d011e4
Message:

cherrypick GUI implementation (originally by Petr Koupy), with several major changes

  • for character-oriented devices a new output server and output protocol was created based on the original fb server
  • DDF visualizer drivers are pixel-oriented only
  • console and compositor can coexist in the same build
  • terminal widget is self-sufficient, no strange console nesting is needed
Location:
uspace/srv
Files:
7 added
12 deleted
4 edited
17 moved

Legend:

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

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    4444#include <event.h>
    4545#include <io/keycode.h>
    46 #include <screenbuffer.h>
    47 #include <fb.h>
    48 #include <imgmap.h>
     46#include <io/chargrid.h>
     47#include <io/console.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;
    77 
    78 #define UTF8_CHAR_BUFFER_SIZE (STR_BOUNDS(1) + 1)
     58#define UTF8_CHAR_BUFFER_SIZE  (STR_BOUNDS(1) + 1)
    7959
    8060typedef struct {
    81         atomic_t refcnt;           /**< Connection reference count */
    82         prodcons_t input_pc;       /**< Incoming keyboard events */
    83         char char_remains[UTF8_CHAR_BUFFER_SIZE]; /**< Not yet sent bytes of last char event. */
    84         size_t char_remains_len;   /**< Number of not yet sent bytes. */
    85        
    86         fibril_mutex_t mtx;        /**< Lock protecting mutable fields */
    87        
    88         size_t index;              /**< Console index */
    89         console_state_t state;     /**< Console state */
    90         service_id_t dsid;         /**< Service handle */
    91        
    92         vp_handle_t state_vp;      /**< State icon viewport */
    93         sysarg_t cols;             /**< Number of columns */
    94         sysarg_t rows;             /**< Number of rows */
    95         console_caps_t ccaps;      /**< Console capabilities */
    96        
    97         screenbuffer_t *frontbuf;  /**< Front buffer */
    98         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 */
    9981} console_t;
    100 
    101 typedef enum {
    102         GRAPHICS_NONE = 0,
    103         GRAPHICS_BASIC = 1,
    104         GRAPHICS_FULL = 2
    105 } graphics_state_t;
    106 
    107 /** Current console state */
    108 static graphics_state_t graphics_state = GRAPHICS_NONE;
    109 
    110 /** State icons */
    111 static imagemap_handle_t state_icons[CONS_LAST];
    11282
    11383/** Session to the input server */
    11484static async_sess_t *input_sess;
    11585
    116 /** Session to the framebuffer server */
    117 static async_sess_t *fb_sess;
    118 
    119 /** Framebuffer resolution */
    120 static sysarg_t xres;
    121 static sysarg_t yres;
     86/** Session to the output server */
     87static async_sess_t *output_sess;
     88
     89/** Output dimensions */
     90static sysarg_t cols;
     91static sysarg_t rows;
    12292
    12393/** Array of data for virtual consoles */
     
    131101static console_t *kernel_console = &consoles[KERNEL_CONSOLE];
    132102
    133 static imgmap_t *logo_img;
    134 static imgmap_t *nameic_img;
    135 
    136 static imgmap_t *anim_1_img;
    137 static imgmap_t *anim_2_img;
    138 static imgmap_t *anim_3_img;
    139 static imgmap_t *anim_4_img;
    140 
    141 static imagemap_handle_t anim_1;
    142 static imagemap_handle_t anim_2;
    143 static imagemap_handle_t anim_3;
    144 static imagemap_handle_t anim_4;
    145 
    146 static sequence_handle_t anim_seq;
    147 
    148 static imgmap_t *cons_data_img;
    149 static imgmap_t *cons_dis_img;
    150 static imgmap_t *cons_dis_sel_img;
    151 static imgmap_t *cons_idle_img;
    152 static imgmap_t *cons_kernel_img;
    153 static imgmap_t *cons_sel_img;
    154 
    155 static vp_handle_t logo_vp;
    156 static imagemap_handle_t logo_handle;
    157 
    158 static vp_handle_t nameic_vp;
    159 static imagemap_handle_t nameic_handle;
    160 
    161 static vp_handle_t screen_vp;
    162 static vp_handle_t console_vp;
    163 
    164 struct {
    165         sysarg_t x;
    166         sysarg_t y;
    167        
    168         sysarg_t btn_x;
    169         sysarg_t btn_y;
    170        
    171         bool pressed;
    172 } mouse;
    173 
    174 static void cons_redraw_state(console_t *cons)
    175 {
    176         if (graphics_state == GRAPHICS_FULL) {
    177                 fibril_mutex_lock(&cons->mtx);
    178                
    179                 fb_vp_imagemap_damage(fb_sess, cons->state_vp,
    180                     state_icons[cons->state], 0, 0, STATE_WIDTH, STATE_HEIGHT);
    181                
    182                 if ((cons->state != CONS_DISCONNECTED) &&
    183                     (cons->state != CONS_KERNEL) &&
    184                     (cons->state != CONS_DISCONNECTED_SELECTED)) {
    185                         char data[5];
    186                         snprintf(data, 5, "%zu", cons->index + 1);
    187                        
    188                         for (size_t i = 0; data[i] != 0; i++)
    189                                 fb_vp_putchar(fb_sess, cons->state_vp, i + 2, 1, data[i]);
    190                 }
    191                
    192                 fibril_mutex_unlock(&cons->mtx);
    193         }
    194 }
    195 
    196 static void cons_kernel_sequence_start(console_t *cons)
    197 {
    198         if (graphics_state == GRAPHICS_FULL) {
    199                 fibril_mutex_lock(&cons->mtx);
    200                
    201                 fb_vp_sequence_start(fb_sess, cons->state_vp, anim_seq);
    202                 fb_vp_imagemap_damage(fb_sess, cons->state_vp,
    203                     state_icons[cons->state], 0, 0, STATE_WIDTH, STATE_HEIGHT);
    204                
    205                 fibril_mutex_unlock(&cons->mtx);
    206         }
    207 }
    208 
    209 static void cons_update_state(console_t *cons, console_state_t state)
    210 {
    211         bool update = false;
    212        
    213         fibril_mutex_lock(&cons->mtx);
    214        
    215         if (cons->state != state) {
    216                 cons->state = state;
    217                 update = true;
    218         }
    219        
    220         fibril_mutex_unlock(&cons->mtx);
    221        
    222         if (update)
    223                 cons_redraw_state(cons);
    224 }
    225 
    226 static void cons_notify_data(console_t *cons)
     103static void cons_update(console_t *cons)
    227104{
    228105        fibril_mutex_lock(&switch_mtx);
    229        
    230         if (cons != active_console)
    231                 cons_update_state(cons, CONS_DATA);
    232        
     106        fibril_mutex_lock(&cons->mtx);
     107       
     108        if ((cons == active_console) && (active_console != kernel_console)) {
     109                output_update(output_sess, cons->fbid);
     110                output_cursor_update(output_sess, cons->fbid);
     111        }
     112       
     113        fibril_mutex_unlock(&cons->mtx);
    233114        fibril_mutex_unlock(&switch_mtx);
    234115}
    235116
    236 static void cons_notify_connect(console_t *cons)
     117static void cons_update_cursor(console_t *cons)
    237118{
    238119        fibril_mutex_lock(&switch_mtx);
    239        
    240         if (cons == active_console)
    241                 cons_update_state(cons, CONS_SELECTED);
    242         else
    243                 cons_update_state(cons, CONS_IDLE);
    244        
     120        fibril_mutex_lock(&cons->mtx);
     121       
     122        if ((cons == active_console) && (active_console != kernel_console))
     123                output_cursor_update(output_sess, cons->fbid);
     124       
     125        fibril_mutex_unlock(&cons->mtx);
    245126        fibril_mutex_unlock(&switch_mtx);
    246127}
    247128
    248 static void cons_notify_disconnect(console_t *cons)
     129static void cons_clear(console_t *cons)
     130{
     131        fibril_mutex_lock(&cons->mtx);
     132        chargrid_clear(cons->frontbuf);
     133        fibril_mutex_unlock(&cons->mtx);
     134       
     135        cons_update(cons);
     136}
     137
     138static void cons_damage(console_t *cons)
    249139{
    250140        fibril_mutex_lock(&switch_mtx);
    251        
    252         if (cons == active_console)
    253                 cons_update_state(cons, CONS_DISCONNECTED_SELECTED);
    254         else
    255                 cons_update_state(cons, CONS_DISCONNECTED);
    256        
    257         fibril_mutex_unlock(&switch_mtx);
    258 }
    259 
    260 static void cons_update(console_t *cons)
    261 {
    262         fibril_mutex_lock(&switch_mtx);
    263141        fibril_mutex_lock(&cons->mtx);
    264142       
    265143        if ((cons == active_console) && (active_console != kernel_console)) {
    266                 fb_vp_update(fb_sess, console_vp, cons->fbid);
    267                 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid);
    268         }
    269        
    270         fibril_mutex_unlock(&cons->mtx);
    271         fibril_mutex_unlock(&switch_mtx);
    272 }
    273 
    274 static void cons_update_cursor(console_t *cons)
    275 {
    276         fibril_mutex_lock(&switch_mtx);
    277         fibril_mutex_lock(&cons->mtx);
    278        
    279         if ((cons == active_console) && (active_console != kernel_console))
    280                 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid);
    281        
    282         fibril_mutex_unlock(&cons->mtx);
    283         fibril_mutex_unlock(&switch_mtx);
    284 }
    285 
    286 static void cons_clear(console_t *cons)
    287 {
    288         fibril_mutex_lock(&cons->mtx);
    289         screenbuffer_clear(cons->frontbuf);
    290         fibril_mutex_unlock(&cons->mtx);
    291        
    292         cons_update(cons);
    293 }
    294 
    295 static void cons_damage_all(console_t *cons)
    296 {
    297         fibril_mutex_lock(&switch_mtx);
    298         fibril_mutex_lock(&cons->mtx);
    299        
    300         if ((cons == active_console) && (active_console != kernel_console)) {
    301                 fb_vp_damage(fb_sess, console_vp, cons->fbid, 0, 0, cons->cols,
     144                output_damage(output_sess, cons->fbid, 0, 0, cons->cols,
    302145                    cons->rows);
    303                 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid);
     146                output_cursor_update(output_sess, cons->fbid);
    304147        }
    305148       
     
    318161       
    319162        if (cons == kernel_console) {
    320                 fb_yield(fb_sess);
     163                output_yield(output_sess);
    321164                if (!console_kcon()) {
    322                         fb_claim(fb_sess);
     165                        output_claim(output_sess);
    323166                        fibril_mutex_unlock(&switch_mtx);
    324167                        return;
     
    327170       
    328171        if (active_console == kernel_console)
    329                 fb_claim(fb_sess);
     172                output_claim(output_sess);
    330173       
    331174        prev_console = active_console;
    332175        active_console = cons;
    333176       
    334         if (prev_console->state == CONS_DISCONNECTED_SELECTED)
    335                 cons_update_state(prev_console, CONS_DISCONNECTED);
    336         else
    337                 cons_update_state(prev_console, CONS_IDLE);
    338        
    339         if ((cons->state == CONS_DISCONNECTED) ||
    340             (cons->state == CONS_DISCONNECTED_SELECTED))
    341                 cons_update_state(cons, CONS_DISCONNECTED_SELECTED);
    342         else
    343                 cons_update_state(cons, CONS_SELECTED);
    344        
    345177        fibril_mutex_unlock(&switch_mtx);
    346178       
    347         cons_damage_all(cons);
     179        cons_damage(cons);
    348180}
    349181
     
    351183{
    352184        fibril_mutex_lock(&switch_mtx);
    353 
     185       
    354186        console_t *active_uspace = active_console;
    355         if (active_uspace == kernel_console) {
     187        if (active_uspace == kernel_console)
    356188                active_uspace = prev_console;
    357         }
     189       
    358190        assert(active_uspace != kernel_console);
    359 
     191       
    360192        fibril_mutex_unlock(&switch_mtx);
    361 
     193       
    362194        return active_uspace;
    363 }
    364 
    365 static ssize_t limit(ssize_t val, ssize_t lo, ssize_t hi)
    366 {
    367         if (val > hi)
    368                 return hi;
    369        
    370         if (val < lo)
    371                 return lo;
    372        
    373         return val;
    374 }
    375 
    376 static void cons_mouse_move(sysarg_t dx, sysarg_t dy)
    377 {
    378         ssize_t sx = (ssize_t) dx;
    379         ssize_t sy = (ssize_t) dy;
    380        
    381         mouse.x = limit(mouse.x + sx, 0, xres);
    382         mouse.y = limit(mouse.y + sy, 0, yres);
    383        
    384         fb_pointer_update(fb_sess, mouse.x, mouse.y, true);
    385 }
    386 
    387 static void cons_mouse_abs_move(sysarg_t x, sysarg_t y,
    388     sysarg_t max_x, sysarg_t max_y)
    389 {
    390         if (max_x && max_y) {
    391                 mouse.x = limit(x * xres / max_x, 0, xres);
    392                 mouse.y = limit(y * yres / max_y, 0, yres);
    393                
    394                 fb_pointer_update(fb_sess, mouse.x, mouse.y, true);
    395         }
    396 }
    397 
    398 static console_t *cons_find_icon(sysarg_t x, sysarg_t y)
    399 {
    400         sysarg_t status_start =
    401             STATE_START + (xres - 800) / 2 + CONSOLE_MARGIN;
    402        
    403         if ((y < STATE_TOP) || (y >= STATE_TOP + STATE_HEIGHT))
    404                 return NULL;
    405        
    406         if (x < status_start)
    407                 return NULL;
    408        
    409         if (x >= status_start + (STATE_WIDTH + STATE_SPACE) * CONSOLE_COUNT)
    410                 return NULL;
    411        
    412         if (((x - status_start) % (STATE_WIDTH + STATE_SPACE)) >= STATE_WIDTH)
    413                 return NULL;
    414        
    415         sysarg_t btn = (x - status_start) / (STATE_WIDTH + STATE_SPACE);
    416        
    417         if (btn < CONSOLE_COUNT)
    418                 return consoles + btn;
    419        
    420         return NULL;
    421 }
    422 
    423 /** Handle mouse click
    424  *
    425  * @param state Button state (true - pressed, false - depressed)
    426  *
    427  */
    428 static console_t *cons_mouse_button(bool state)
    429 {
    430         if (graphics_state != GRAPHICS_FULL)
    431                 return NULL;
    432        
    433         if (state) {
    434                 console_t *cons = cons_find_icon(mouse.x, mouse.y);
    435                 if (cons != NULL) {
    436                         mouse.btn_x = mouse.x;
    437                         mouse.btn_y = mouse.y;
    438                         mouse.pressed = true;
    439                 }
    440                
    441                 return NULL;
    442         }
    443        
    444         if ((!state) && (!mouse.pressed))
    445                 return NULL;
    446        
    447         console_t *cons = cons_find_icon(mouse.x, mouse.y);
    448         if (cons == cons_find_icon(mouse.btn_x, mouse.btn_y))
    449                 return cons;
    450        
    451         mouse.pressed = false;
    452         return NULL;
    453195}
    454196
     
    511253                        break;
    512254                case INPUT_EVENT_MOVE:
    513                         cons_mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    514                         async_answer_0(callid, EOK);
    515                         break;
    516                 case INPUT_EVENT_ABS_MOVE:
    517                         cons_mouse_abs_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call),
    518                             IPC_GET_ARG3(call), IPC_GET_ARG4(call));
    519255                        async_answer_0(callid, EOK);
    520256                        break;
    521257                case INPUT_EVENT_BUTTON:
    522                         /* Got pointer button press/release event */
    523                         if (IPC_GET_ARG1(call) == 1) {
    524                                 console_t *cons =
    525                                     cons_mouse_button((bool) IPC_GET_ARG2(call));
    526                                 if (cons != NULL)
    527                                         cons_switch(cons);
    528                         }
    529258                        async_answer_0(callid, EOK);
    530259                        break;
     
    544273        switch (ch) {
    545274        case '\n':
    546                 updated = screenbuffer_newline(cons->frontbuf);
     275                updated = chargrid_newline(cons->frontbuf);
    547276                break;
    548277        case '\r':
    549278                break;
    550279        case '\t':
    551                 updated = screenbuffer_tabstop(cons->frontbuf, 8);
     280                updated = chargrid_tabstop(cons->frontbuf, 8);
    552281                break;
    553282        case '\b':
    554                 updated = screenbuffer_backspace(cons->frontbuf);
     283                updated = chargrid_backspace(cons->frontbuf);
    555284                break;
    556285        default:
    557                 updated = screenbuffer_putchar(cons->frontbuf, ch, true);
     286                updated = chargrid_putchar(cons->frontbuf, ch, true);
    558287        }
    559288       
     
    567296{
    568297        fibril_mutex_lock(&cons->mtx);
    569         screenbuffer_set_cursor(cons->frontbuf, col, row);
     298        chargrid_set_cursor(cons->frontbuf, col, row);
    570299        fibril_mutex_unlock(&cons->mtx);
    571300       
     
    576305{
    577306        fibril_mutex_lock(&cons->mtx);
    578         screenbuffer_set_cursor_visibility(cons->frontbuf, visible);
     307        chargrid_set_cursor_visibility(cons->frontbuf, visible);
    579308        fibril_mutex_unlock(&cons->mtx);
    580309       
     
    588317       
    589318        fibril_mutex_lock(&cons->mtx);
    590         screenbuffer_get_cursor(cons->frontbuf, &col, &row);
     319        chargrid_get_cursor(cons->frontbuf, &col, &row);
    591320        fibril_mutex_unlock(&cons->mtx);
    592321       
     
    611340        async_answer_1(iid, EOK, size);
    612341        free(buf);
    613        
    614         cons_notify_data(cons);
    615342}
    616343
     
    676403{
    677404        fibril_mutex_lock(&cons->mtx);
    678         screenbuffer_set_style(cons->frontbuf, style);
     405        chargrid_set_style(cons->frontbuf, style);
    679406        fibril_mutex_unlock(&cons->mtx);
    680407}
     
    684411{
    685412        fibril_mutex_lock(&cons->mtx);
    686         screenbuffer_set_color(cons->frontbuf, bgcolor, fgcolor, attr);
     413        chargrid_set_color(cons->frontbuf, bgcolor, fgcolor, attr);
    687414        fibril_mutex_unlock(&cons->mtx);
    688415}
     
    692419{
    693420        fibril_mutex_lock(&cons->mtx);
    694         screenbuffer_set_rgb_color(cons->frontbuf, bgcolor, fgcolor);
     421        chargrid_set_rgb_color(cons->frontbuf, bgcolor, fgcolor);
    695422        fibril_mutex_unlock(&cons->mtx);
    696423}
     
    724451        }
    725452       
    726         if (atomic_postinc(&cons->refcnt) == 0) {
     453        if (atomic_postinc(&cons->refcnt) == 0)
    727454                cons_set_cursor_visibility(cons, true);
    728                 cons_notify_connect(cons);
    729         }
    730455       
    731456        /* Accept the connection */
     
    736461                ipc_callid_t callid = async_get_call(&call);
    737462               
    738                 if (!IPC_GET_IMETHOD(call)) {
    739                         if (atomic_postdec(&cons->refcnt) == 1)
    740                                 cons_notify_disconnect(cons);
    741                        
     463                if (!IPC_GET_IMETHOD(call))
    742464                        return;
    743                 }
    744465               
    745466                switch (IPC_GET_IMETHOD(call)) {
     
    832553}
    833554
    834 static async_sess_t *fb_connect(const char *svc)
     555static async_sess_t *output_connect(const char *svc)
    835556{
    836557        async_sess_t *sess;
     
    841562                sess = loc_service_connect(EXCHANGE_SERIALIZE, dsid, 0);
    842563                if (sess == NULL) {
    843                         printf("%s: Unable to connect to framebuffer service %s\n",
     564                        printf("%s: Unable to connect to output service %s\n",
    844565                            NAME, svc);
    845566                        return NULL;
     
    851572}
    852573
    853 static bool console_srv_init(char *input_svc, char *fb_svc)
    854 {
    855         /* Avoid double initialization */
    856         if (graphics_state != GRAPHICS_NONE)
    857                 return false;
    858        
     574static bool console_srv_init(char *input_svc, char *output_svc)
     575{
    859576        /* Connect to input service */
    860577        input_sess = input_connect(input_svc);
     
    862579                return false;
    863580       
    864         /* Connect to framebuffer service */
    865         fb_sess = fb_connect(fb_svc);
    866         if (fb_sess == NULL)
     581        /* Connect to output service */
     582        output_sess = output_connect(output_svc);
     583        if (output_sess == NULL)
    867584                return false;
    868585       
     
    876593        }
    877594       
    878         fb_get_resolution(fb_sess, &xres, &yres);
    879        
    880         /* Initialize the screen */
    881         screen_vp = fb_vp_create(fb_sess, 0, 0, xres, yres);
    882        
    883         if ((xres >= 800) && (yres >= 600)) {
    884                 logo_vp = fb_vp_create(fb_sess, xres - 66, 2, 64, 60);
    885                 logo_img = imgmap_decode_tga((void *) helenos_tga,
    886                     helenos_tga_size, IMGMAP_FLAG_SHARED);
    887                 logo_handle = fb_imagemap_create(fb_sess, logo_img);
    888                
    889                 nameic_vp = fb_vp_create(fb_sess, 5, 17, 100, 26);
    890                 nameic_img = imgmap_decode_tga((void *) nameic_tga,
    891                     nameic_tga_size, IMGMAP_FLAG_SHARED);
    892                 nameic_handle = fb_imagemap_create(fb_sess, nameic_img);
    893                
    894                 cons_data_img = imgmap_decode_tga((void *) cons_data_tga,
    895                     cons_data_tga_size, IMGMAP_FLAG_SHARED);
    896                 cons_dis_img = imgmap_decode_tga((void *) cons_dis_tga,
    897                     cons_dis_tga_size, IMGMAP_FLAG_SHARED);
    898                 cons_dis_sel_img = imgmap_decode_tga((void *) cons_dis_sel_tga,
    899                     cons_dis_sel_tga_size, IMGMAP_FLAG_SHARED);
    900                 cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga,
    901                     cons_idle_tga_size, IMGMAP_FLAG_SHARED);
    902                 cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga,
    903                     cons_kernel_tga_size, IMGMAP_FLAG_SHARED);
    904                 cons_sel_img = imgmap_decode_tga((void *) cons_sel_tga,
    905                     cons_sel_tga_size, IMGMAP_FLAG_SHARED);
    906                
    907                 state_icons[CONS_DISCONNECTED] =
    908                     fb_imagemap_create(fb_sess, cons_dis_img);
    909                 state_icons[CONS_DISCONNECTED_SELECTED] =
    910                     fb_imagemap_create(fb_sess, cons_dis_sel_img);
    911                 state_icons[CONS_SELECTED] =
    912                     fb_imagemap_create(fb_sess, cons_sel_img);
    913                 state_icons[CONS_IDLE] =
    914                     fb_imagemap_create(fb_sess, cons_idle_img);
    915                 state_icons[CONS_DATA] =
    916                     fb_imagemap_create(fb_sess, cons_data_img);
    917                 state_icons[CONS_KERNEL] =
    918                     fb_imagemap_create(fb_sess, cons_kernel_img);
    919                
    920                 anim_1_img = imgmap_decode_tga((void *) anim_1_tga,
    921                     anim_1_tga_size, IMGMAP_FLAG_SHARED);
    922                 anim_2_img = imgmap_decode_tga((void *) anim_2_tga,
    923                     anim_2_tga_size, IMGMAP_FLAG_SHARED);
    924                 anim_3_img = imgmap_decode_tga((void *) anim_3_tga,
    925                     anim_3_tga_size, IMGMAP_FLAG_SHARED);
    926                 anim_4_img = imgmap_decode_tga((void *) anim_4_tga,
    927                     anim_4_tga_size, IMGMAP_FLAG_SHARED);
    928                
    929                 anim_1 = fb_imagemap_create(fb_sess, anim_1_img);
    930                 anim_2 = fb_imagemap_create(fb_sess, anim_2_img);
    931                 anim_3 = fb_imagemap_create(fb_sess, anim_3_img);
    932                 anim_4 = fb_imagemap_create(fb_sess, anim_4_img);
    933                
    934                 anim_seq = fb_sequence_create(fb_sess);
    935                 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_1);
    936                 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_2);
    937                 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_3);
    938                 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_4);
    939                
    940                 console_vp = fb_vp_create(fb_sess, CONSOLE_MARGIN, CONSOLE_TOP,
    941                     xres - 2 * CONSOLE_MARGIN, yres - (CONSOLE_TOP + CONSOLE_MARGIN));
    942                
    943                 fb_vp_clear(fb_sess, screen_vp);
    944                 fb_vp_imagemap_damage(fb_sess, logo_vp, logo_handle,
    945                     0, 0, 64, 60);
    946                 fb_vp_imagemap_damage(fb_sess, nameic_vp, nameic_handle,
    947                     0, 0, 100, 26);
    948                
    949                 graphics_state = GRAPHICS_FULL;
    950         } else {
    951                 console_vp = screen_vp;
    952                 graphics_state = GRAPHICS_BASIC;
    953         }
    954        
    955         fb_vp_set_style(fb_sess, console_vp, STYLE_NORMAL);
    956         fb_vp_clear(fb_sess, console_vp);
    957        
    958         sysarg_t cols;
    959         sysarg_t rows;
    960         fb_vp_get_dimensions(fb_sess, console_vp, &cols, &rows);
     595        output_get_dimensions(output_sess, &cols, &rows);
     596        output_set_style(output_sess, STYLE_NORMAL);
    961597       
    962598        console_caps_t ccaps;
    963         fb_vp_get_caps(fb_sess, console_vp, &ccaps);
    964        
    965         mouse.x = xres / 2;
    966         mouse.y = yres / 2;
    967         mouse.pressed = false;
     599        output_get_caps(output_sess, &ccaps);
    968600       
    969601        /* Inititalize consoles */
     
    975607                consoles[i].char_remains_len = 0;
    976608               
    977                 if (graphics_state == GRAPHICS_FULL) {
    978                         /* Create state buttons */
    979                         consoles[i].state_vp =
    980                             fb_vp_create(fb_sess, STATE_START + (xres - 800) / 2 +
    981                             CONSOLE_MARGIN + i * (STATE_WIDTH + STATE_SPACE),
    982                             STATE_TOP, STATE_WIDTH, STATE_HEIGHT);
    983                 }
    984                
    985                 if (i == KERNEL_CONSOLE) {
    986                         consoles[i].state = CONS_KERNEL;
    987                         cons_redraw_state(&consoles[i]);
    988                         cons_kernel_sequence_start(&consoles[i]);
     609                if (i == KERNEL_CONSOLE)
    989610                        continue;
    990                 }
    991                
    992                 if (i == 0)
    993                         consoles[i].state = CONS_DISCONNECTED_SELECTED;
    994                 else
    995                         consoles[i].state = CONS_DISCONNECTED;
    996611               
    997612                consoles[i].cols = cols;
     
    999614                consoles[i].ccaps = ccaps;
    1000615                consoles[i].frontbuf =
    1001                     screenbuffer_create(cols, rows, SCREENBUFFER_FLAG_SHARED);
     616                    chargrid_create(cols, rows, CHARGRID_FLAG_SHARED);
    1002617               
    1003618                if (consoles[i].frontbuf == NULL) {
     
    1006621                }
    1007622               
    1008                 consoles[i].fbid = fb_frontbuf_create(fb_sess, consoles[i].frontbuf);
     623                consoles[i].fbid = output_frontbuf_create(output_sess,
     624                    consoles[i].frontbuf);
    1009625                if (consoles[i].fbid == 0) {
    1010626                        printf("%s: Unable to create frontbuffer %zu\n", NAME, i);
     
    1012628                }
    1013629               
    1014                 cons_redraw_state(&consoles[i]);
    1015                
    1016630                char vc[LOC_NAME_MAXLEN + 1];
    1017631                snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
     
    1022636                }
    1023637        }
     638       
     639        cons_damage(active_console);
    1024640       
    1025641        /* Receive kernel notifications */
     
    1033649}
    1034650
    1035 static void usage(void)
    1036 {
    1037         printf("Usage: console <input_dev> <framebuffer_dev>\n");
     651static void usage(char *name)
     652{
     653        printf("Usage: %s <input_dev> <output_dev>\n", name);
    1038654}
    1039655
     
    1041657{
    1042658        if (argc < 3) {
    1043                 usage();
     659                usage(argv[0]);
    1044660                return -1;
    1045661        }
     
    1054670        async_manager();
    1055671       
     672        /* Never reached */
    1056673        return 0;
    1057674}
  • uspace/srv/hid/output/Makefile

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    3333#include <errno.h>
    3434#include <sysinfo.h>
    35 #include <task.h>
     35#include <align.h>
     36#include <as.h>
    3637#include <ddi.h>
    3738#include <libarch/ddi.h>
    38 #include <as.h>
    39 #include <malloc.h>
    40 #include <align.h>
    41 #include <screenbuffer.h>
    42 #include "../fb.h"
     39#include <io/chargrid.h>
     40#include "../output.h"
    4341#include "ega.h"
    4442
     
    4644#define EGA_IO_SIZE  2
    4745
    48 #define FB_POS(x, y)  (((y) * ega.width + (x)) << 1)
     46#define FB_POS(x, y)  (((y) * ega.cols + (x)) << 1)
    4947
    5048typedef struct {
    51         sysarg_t width;
    52         sysarg_t height;
     49        sysarg_t cols;
     50        sysarg_t rows;
     51       
     52        uint8_t style_normal;
     53        uint8_t style_inverted;
    5354       
    5455        size_t size;
    5556        uint8_t *addr;
    56        
    57         uint8_t style_normal;
    58         uint8_t style_inverted;
    59        
    60         uint8_t *backbuf;
    6157} ega_t;
    6258
     
    10197}
    10298
    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        
     99/** Draw the character at the specified position.
     100 *
     101 * @param field Character field.
     102 * @param col   Horizontal screen position.
     103 * @param row   Vertical screen position.
     104 *
     105 */
     106static void draw_char(charfield_t *field, sysarg_t col, sysarg_t row)
     107{
    117108        uint8_t glyph;
    118109       
     
    124115        uint8_t attr = attrs_attr(field->attrs);
    125116       
    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);
     117        ega.addr[FB_POS(col, row)] = glyph;
     118        ega.addr[FB_POS(col, row) + 1] = attr;
     119}
     120
     121static int ega_yield(outdev_t *dev)
     122{
    139123        return EOK;
    140124}
    141125
    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);
     126static int ega_claim(outdev_t *dev)
     127{
    148128        return EOK;
    149129}
    150130
    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)
     131static void ega_get_dimensions(outdev_t *dev, sysarg_t *cols, sysarg_t *rows)
     132{
     133        *cols = ega.cols;
     134        *rows = ega.rows;
     135}
     136
     137static console_caps_t ega_get_caps(outdev_t *dev)
    195138{
    196139        return (CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED);
    197140}
    198141
    199 static void ega_vp_cursor_update(fbdev_t *dev, fbvp_t *vp, sysarg_t prev_col,
     142static void ega_cursor_update(outdev_t *dev, sysarg_t prev_col,
    200143    sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible)
    201144{
    202145        /* Cursor position */
    203         uint16_t cursor = row * ega.width + col;
     146        uint16_t cursor = row * ega.cols + col;
    204147       
    205148        pio_write_8(EGA_IO_BASE, 0x0e);
     
    220163}
    221164
    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 = {
     165static void ega_char_update(outdev_t *dev, sysarg_t col, sysarg_t row)
     166{
     167        charfield_t *field =
     168            chargrid_charfield_at(dev->backbuf, col, row);
     169       
     170        draw_char(field, col, row);
     171}
     172
     173static outdev_ops_t ega_ops = {
    229174        .yield = ega_yield,
    230175        .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
     176        .get_dimensions = ega_get_dimensions,
     177        .get_caps = ega_get_caps,
     178        .cursor_update = ega_cursor_update,
     179        .char_update = ega_char_update
    239180};
    240181
     
    262203                return rc;
    263204       
    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;
     205        rc = sysinfo_get_value("fb.width", &ega.cols);
     206        if (rc != EOK)
     207                return rc;
     208       
     209        rc = sysinfo_get_value("fb.height", &ega.rows);
     210        if (rc != EOK)
     211                return rc;
     212       
     213        rc = iospace_enable(task_get_id(), (void *) EGA_IO_BASE,
     214            EGA_IO_SIZE);
     215        if (rc != EOK)
     216                return rc;
     217       
     218        ega.size = (ega.cols * ega.rows) << 1;
    282219       
    283220        rc = physmem_map((void *) paddr,
     
    300237        }
    301238       
    302         ega.backbuf = NULL;
    303        
    304         fbdev_t *dev = fbdev_register(&ega_ops, (void *) &ega);
     239        outdev_t *dev = outdev_register(&ega_ops, (void *) &ega);
    305240        if (dev == NULL) {
    306241                as_area_destroy(ega.addr);
     
    311246}
    312247
    313 /**
    314  * @}
    315  */
     248/** @}
     249 */
  • uspace/srv/hid/output/port/ega.h

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    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

    rc9d011e4 r6d5e378  
    363363
    364364        printf("%s: HelenOS Remote console service\n", NAME);
     365        task_retval(0);
    365366
    366367        while (true) {
  • uspace/srv/locsrv/locsrv.c

    rc9d011e4 r6d5e378  
    13671367        cat = category_new("nic");
    13681368        categ_dir_add_cat(&cdir, cat);
     1369
     1370        cat = category_new("visualizer");
     1371        categ_dir_add_cat(&cdir, cat);
     1372
     1373        cat = category_new("renderer");
     1374        categ_dir_add_cat(&cdir, cat);
    13691375       
    13701376        return true;
Note: See TracChangeset for help on using the changeset viewer.