Changeset 03362fbd in mainline for uspace/srv/hid/output/port/ega.c


Ignore:
Timestamp:
2013-02-09T23:14:45Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
22dfd38
Parents:
b5d2e57 (diff), 005b765 (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.

Conflict resulting from bool.h → stdbool.h move and ddf structs turning opaque.
Fails to boot to shell console.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/output/port/ega.c

    rb5d2e57 r03362fbd  
    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 */
Note: See TracChangeset for help on using the changeset viewer.