Changeset 03362fbd in mainline for uspace/srv/hid/output/port/ega.c
- Timestamp:
- 2013-02-09T23:14:45Z (13 years ago)
- 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. - File:
-
- 1 moved
-
uspace/srv/hid/output/port/ega.c (moved) (moved from uspace/srv/hid/fb/port/ega.c ) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/output/port/ega.c
rb5d2e57 r03362fbd 33 33 #include <errno.h> 34 34 #include <sysinfo.h> 35 #include <task.h> 35 #include <align.h> 36 #include <as.h> 36 37 #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" 43 40 #include "ega.h" 44 41 … … 46 43 #define EGA_IO_SIZE 2 47 44 48 #define FB_POS(x, y) (((y) * ega. width+ (x)) << 1)45 #define FB_POS(x, y) (((y) * ega.cols + (x)) << 1) 49 46 50 47 typedef 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; 53 53 54 54 size_t size; 55 55 uint8_t *addr; 56 57 uint8_t style_normal;58 uint8_t style_inverted;59 60 uint8_t *backbuf;61 56 } ega_t; 62 57 … … 101 96 } 102 97 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 */ 105 static void draw_char(charfield_t *field, sysarg_t col, sysarg_t row) 106 { 117 107 uint8_t glyph; 118 108 … … 124 114 uint8_t attr = attrs_attr(field->attrs); 125 115 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 120 static int ega_yield(outdev_t *dev) 121 { 139 122 return EOK; 140 123 } 141 124 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); 125 static int ega_claim(outdev_t *dev) 126 { 148 127 return EOK; 149 128 } 150 129 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) 130 static void ega_get_dimensions(outdev_t *dev, sysarg_t *cols, sysarg_t *rows) 131 { 132 *cols = ega.cols; 133 *rows = ega.rows; 134 } 135 136 static console_caps_t ega_get_caps(outdev_t *dev) 195 137 { 196 138 return (CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED); 197 139 } 198 140 199 static void ega_ vp_cursor_update(fbdev_t *dev, fbvp_t *vp, sysarg_t prev_col,141 static void ega_cursor_update(outdev_t *dev, sysarg_t prev_col, 200 142 sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible) 201 143 { 202 144 /* Cursor position */ 203 uint16_t cursor = row * ega. width+ col;145 uint16_t cursor = row * ega.cols + col; 204 146 205 147 pio_write_8(EGA_IO_BASE, 0x0e); … … 220 162 } 221 163 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 = { 164 static 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 172 static outdev_ops_t ega_ops = { 229 173 .yield = ega_yield, 230 174 .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 239 179 }; 240 180 … … 262 202 return rc; 263 203 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; 282 217 283 218 rc = physmem_map((void *) paddr, … … 300 235 } 301 236 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); 305 238 if (dev == NULL) { 306 239 as_area_destroy(ega.addr); … … 311 244 } 312 245 313 /** 314 * @} 315 */ 246 /** @} 247 */
Note:
See TracChangeset
for help on using the changeset viewer.
