Changeset a35b458 in mainline for uspace/srv/hid/output
- Timestamp:
- 2018-03-02T20:10:49Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- uspace/srv/hid/output
- Files:
-
- 8 edited
-
ctl/serial.c (modified) (7 diffs)
-
gfx/font-8x16.c (modified) (2 diffs)
-
output.c (modified) (32 diffs)
-
output.h (modified) (2 diffs)
-
port/ega.c (modified) (10 diffs)
-
port/kfb.c (modified) (31 diffs)
-
proto/vt100.c (modified) (6 diffs)
-
proto/vt100.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/output/ctl/serial.c
r3061bc1 ra35b458 63 63 { 64 64 vt100_state_t *state = (vt100_state_t *) dev->data; 65 65 66 66 return vt100_yield(state); 67 67 } … … 70 70 { 71 71 vt100_state_t *state = (vt100_state_t *) dev->data; 72 72 73 73 return vt100_claim(state); 74 74 } … … 78 78 { 79 79 vt100_state_t *state = (vt100_state_t *) dev->data; 80 80 81 81 vt100_get_dimensions(state, cols, rows); 82 82 } … … 91 91 { 92 92 vt100_state_t *state = (vt100_state_t *) dev->data; 93 93 94 94 vt100_goto(state, col, row); 95 95 vt100_cursor_visibility(state, visible); … … 101 101 charfield_t *field = 102 102 chargrid_charfield_at(dev->backbuf, col, row); 103 103 104 104 draw_char(state, field, col, row); 105 105 } … … 130 130 if (state == NULL) 131 131 return ENOMEM; 132 132 133 133 outdev_t *dev = outdev_register(&serial_ops, state); 134 134 if (dev == NULL) { … … 136 136 return ENOMEM; 137 137 } 138 138 139 139 return EOK; 140 140 } -
uspace/srv/hid/output/gfx/font-8x16.c
r3061bc1 ra35b458 49 49 if (ch == 0x0000) 50 50 return 0; 51 51 52 52 if ((ch >= 0x0020) && (ch <= 0x007f)) 53 53 return (ch - 32); 54 54 55 55 if ((ch >= 0x00a0) && (ch <= 0x021f)) 56 56 return (ch - 64); 57 57 58 58 if ((ch >= 0x0222) && (ch <= 0x0233)) 59 59 return (ch - 66); 60 60 61 61 if ((ch >= 0x0250) && (ch <= 0x02ad)) 62 62 return (ch - 94); 63 63 64 64 if ((ch >= 0x02b0) && (ch <= 0x02cf)) 65 65 return (ch - 96); 66 66 67 67 if ((ch >= 0x02d8) && (ch <= 0x02dd)) 68 68 return (ch - 104); 69 69 70 70 if (ch == 0x02ee) 71 71 return 630; 72 72 73 73 if ((ch >= 0x0300) && (ch <= 0x0301)) 74 74 return (ch - 137); 75 75 76 76 if (ch == 0x0303) 77 77 return 633; 78 78 79 79 if (ch == 0x0309) 80 80 return 634; 81 81 82 82 if ((ch >= 0x0312) && (ch <= 0x0314)) 83 83 return (ch - 151); 84 84 85 85 if (ch == 0x0323) 86 86 return 638; 87 87 88 88 if ((ch >= 0x0340) && (ch <= 0x0341)) 89 89 return (ch - 193); 90 90 91 91 if ((ch >= 0x0374) && (ch <= 0x0375)) 92 92 return (ch - 243); 93 93 94 94 if (ch == 0x037a) 95 95 return 643; 96 96 97 97 if (ch == 0x037e) 98 98 return 644; 99 99 100 100 if ((ch >= 0x0384) && (ch <= 0x038a)) 101 101 return (ch - 255); 102 102 103 103 if (ch == 0x038c) 104 104 return 652; 105 105 106 106 if ((ch >= 0x038e) && (ch <= 0x03a1)) 107 107 return (ch - 257); 108 108 109 109 if ((ch >= 0x03a3) && (ch <= 0x03ce)) 110 110 return (ch - 258); 111 111 112 112 if ((ch >= 0x03d0) && (ch <= 0x03d7)) 113 113 return (ch - 259); 114 114 115 115 if ((ch >= 0x03da) && (ch <= 0x03f3)) 116 116 return (ch - 261); 117 117 118 118 if ((ch >= 0x0400) && (ch <= 0x0486)) 119 119 return (ch - 273); 120 120 121 121 if ((ch >= 0x0488) && (ch <= 0x04ce)) 122 122 return (ch - 274); 123 123 124 124 if ((ch >= 0x04d0) && (ch <= 0x04f5)) 125 125 return (ch - 275); 126 126 127 127 if ((ch >= 0x04f8) && (ch <= 0x04f9)) 128 128 return (ch - 277); 129 129 130 130 if ((ch >= 0x0500) && (ch <= 0x050f)) 131 131 return (ch - 283); 132 132 133 133 if ((ch >= 0x0530) && (ch <= 0x0556)) 134 134 return (ch - 315); 135 135 136 136 if ((ch >= 0x0559) && (ch <= 0x055f)) 137 137 return (ch - 317); 138 138 139 139 if ((ch >= 0x0561) && (ch <= 0x0587)) 140 140 return (ch - 318); 141 141 142 142 if ((ch >= 0x0589) && (ch <= 0x058a)) 143 143 return (ch - 319); 144 144 145 145 if ((ch >= 0x0591) && (ch <= 0x05a1)) 146 146 return (ch - 325); 147 147 148 148 if ((ch >= 0x05a3) && (ch <= 0x05b9)) 149 149 return (ch - 326); 150 150 151 151 if ((ch >= 0x05bb) && (ch <= 0x05c4)) 152 152 return (ch - 327); 153 153 154 154 if ((ch >= 0x05d0) && (ch <= 0x05ea)) 155 155 return (ch - 338); 156 156 157 157 if ((ch >= 0x05f0) && (ch <= 0x05f4)) 158 158 return (ch - 343); 159 159 160 160 if (ch == 0x060c) 161 161 return 1182; 162 162 163 163 if (ch == 0x061b) 164 164 return 1183; 165 165 166 166 if (ch == 0x061f) 167 167 return 1184; 168 168 169 169 if ((ch >= 0x0621) && (ch <= 0x063a)) 170 170 return (ch - 384); 171 171 172 172 if ((ch >= 0x0640) && (ch <= 0x0655)) 173 173 return (ch - 389); 174 174 175 175 if ((ch >= 0x0660) && (ch <= 0x066d)) 176 176 return (ch - 399); 177 177 178 178 if ((ch >= 0x0670) && (ch <= 0x06ed)) 179 179 return (ch - 401); 180 180 181 181 if ((ch >= 0x06f0) && (ch <= 0x06fe)) 182 182 return (ch - 403); 183 183 184 184 if (ch == 0x10d3) 185 185 return 1388; 186 186 187 187 if (ch == 0x10d7) 188 188 return 1389; 189 189 190 190 if (ch == 0x10da) 191 191 return 1390; 192 192 193 193 if (ch == 0x10dd) 194 194 return 1391; 195 195 196 196 if (ch == 0x10e6) 197 197 return 1392; 198 198 199 199 if ((ch >= 0x1e00) && (ch <= 0x1e9b)) 200 200 return (ch - 6287); 201 201 202 202 if ((ch >= 0x1ea0) && (ch <= 0x1ef9)) 203 203 return (ch - 6291); 204 204 205 205 if ((ch >= 0x1f00) && (ch <= 0x1f07)) 206 206 return (ch - 6297); 207 207 208 208 if ((ch >= 0x2000) && (ch <= 0x2027)) 209 209 return (ch - 6545); 210 210 211 211 if ((ch >= 0x2030) && (ch <= 0x2046)) 212 212 return (ch - 6553); 213 213 214 214 if ((ch >= 0x2048) && (ch <= 0x204d)) 215 215 return (ch - 6554); 216 216 217 217 if (ch == 0x2070) 218 218 return 1716; 219 219 220 220 if ((ch >= 0x2074) && (ch <= 0x208f)) 221 221 return (ch - 6591); 222 222 223 223 if ((ch >= 0x20a0) && (ch <= 0x20af)) 224 224 return (ch - 6607); 225 225 226 226 if ((ch >= 0x2100) && (ch <= 0x213a)) 227 227 return (ch - 6687); 228 228 229 229 if ((ch >= 0x2153) && (ch <= 0x2183)) 230 230 return (ch - 6711); 231 231 232 232 if ((ch >= 0x2190) && (ch <= 0x21f3)) 233 233 return (ch - 6723); 234 234 235 235 if ((ch >= 0x2200) && (ch <= 0x22f1)) 236 236 return (ch - 6735); 237 237 238 238 if (ch == 0x2300) 239 239 return 2211; 240 240 241 241 if (ch == 0x2302) 242 242 return 2212; 243 243 244 244 if ((ch >= 0x2308) && (ch <= 0x230b)) 245 245 return (ch - 6755); 246 246 247 247 if (ch == 0x2310) 248 248 return 2217; 249 249 250 250 if (ch == 0x2318) 251 251 return 2218; 252 252 253 253 if ((ch >= 0x231a) && (ch <= 0x231b)) 254 254 return (ch - 6767); 255 255 256 256 if ((ch >= 0x2320) && (ch <= 0x2321)) 257 257 return (ch - 6771); 258 258 259 259 if ((ch >= 0x2329) && (ch <= 0x232a)) 260 260 return (ch - 6778); 261 261 262 262 if ((ch >= 0x239b) && (ch <= 0x23bd)) 263 263 return (ch - 6890); 264 264 265 265 if (ch == 0x23ce) 266 266 return 2260; 267 267 268 268 if ((ch >= 0x2409) && (ch <= 0x240d)) 269 269 return (ch - 6964); 270 270 271 271 if ((ch >= 0x2423) && (ch <= 0x2424)) 272 272 return (ch - 6985); 273 273 274 274 if (ch == 0x2426) 275 275 return 2268; 276 276 277 277 if ((ch >= 0x2500) && (ch <= 0x2595)) 278 278 return (ch - 7203); 279 279 280 280 if ((ch >= 0x25a0) && (ch <= 0x25f7)) 281 281 return (ch - 7213); 282 282 283 283 if ((ch >= 0x2600) && (ch <= 0x2602)) 284 284 return (ch - 7221); 285 285 286 286 if ((ch >= 0x2605) && (ch <= 0x260d)) 287 287 return (ch - 7223); 288 288 289 289 if ((ch >= 0x2610) && (ch <= 0x2613)) 290 290 return (ch - 7225); 291 291 292 292 if (ch == 0x2620) 293 293 return 2523; 294 294 295 295 if (ch == 0x2622) 296 296 return 2524; 297 297 298 298 if (ch == 0x2626) 299 299 return 2525; 300 300 301 301 if ((ch >= 0x2628) && (ch <= 0x262b)) 302 302 return (ch - 7242); 303 303 304 304 if ((ch >= 0x262e) && (ch <= 0x2637)) 305 305 return (ch - 7244); 306 306 307 307 if ((ch >= 0x2639) && (ch <= 0x2653)) 308 308 return (ch - 7245); 309 309 310 310 if ((ch >= 0x2660) && (ch <= 0x2667)) 311 311 return (ch - 7257); 312 312 313 313 if ((ch >= 0x2669) && (ch <= 0x266f)) 314 314 return (ch - 7258); 315 315 316 316 if ((ch >= 0xfb00) && (ch <= 0xfb05)) 317 317 return (ch - 61674); 318 318 319 319 if ((ch >= 0xfb50) && (ch <= 0xfbb1)) 320 320 return (ch - 61748); 321 321 322 322 if ((ch >= 0xfbd3) && (ch <= 0xfbe9)) 323 323 return (ch - 61781); 324 324 325 325 if ((ch >= 0xfbfc) && (ch <= 0xfbff)) 326 326 return (ch - 61799); 327 327 328 328 if ((ch >= 0xfc5b) && (ch <= 0xfc63)) 329 329 return (ch - 61890); 330 330 331 331 if (ch == 0xfc90) 332 332 return 2722; 333 333 334 334 if ((ch >= 0xfcf2) && (ch <= 0xfcf4)) 335 335 return (ch - 62031); 336 336 337 337 if ((ch >= 0xfd3c) && (ch <= 0xfd3f)) 338 338 return (ch - 62102); 339 339 340 340 if (ch == 0xfdf2) 341 341 return 2730; 342 342 343 343 if ((ch >= 0xfe50) && (ch <= 0xfe52)) 344 344 return (ch - 62373); 345 345 346 346 if ((ch >= 0xfe54) && (ch <= 0xfe66)) 347 347 return (ch - 62374); 348 348 349 349 if ((ch >= 0xfe68) && (ch <= 0xfe6b)) 350 350 return (ch - 62375); 351 351 352 352 if ((ch >= 0xfe70) && (ch <= 0xfe72)) 353 353 return (ch - 62379); 354 354 355 355 if (ch == 0xfe74) 356 356 return 2760; 357 357 358 358 if ((ch >= 0xfe76) && (ch <= 0xfefc)) 359 359 return (ch - 62381); 360 360 361 361 if (ch == 0xfeff) 362 362 return 2896; 363 363 364 364 return 2898; 365 365 } … … 3264 3264 {0xf1, 0x35, 0x55, 0x8a, 0xe0, 0x06, 0x95, 0xd6, 0xb5, 0x97, 0x00, 0xee, 0x8a, 0xee, 0x28, 0xe8}, 3265 3265 {0x00, 0x38, 0x7c, 0x7c, 0xc6, 0x92, 0xf2, 0xe6, 0xfe, 0xe6, 0x7c, 0x7c, 0x38, 0x00, 0x00, 0x00}, 3266 3266 3267 3267 /* Special glyph for unknown character */ 3268 3268 {0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00} -
uspace/srv/hid/output/output.c
r3061bc1 ra35b458 44 44 typedef struct { 45 45 link_t link; 46 46 47 47 size_t size; 48 48 unsigned int flags; … … 56 56 { 57 57 assert(ops->get_dimensions); 58 58 59 59 outdev_t *dev = (outdev_t *) malloc(sizeof(outdev_t)); 60 60 if (dev == NULL) 61 61 return NULL; 62 62 63 63 link_initialize(&dev->link); 64 64 65 65 dev->ops = *ops; 66 66 dev->data = data; 67 67 68 68 ops->get_dimensions(dev, &dev->cols, &dev->rows); 69 69 dev->backbuf = chargrid_create(dev->cols, dev->rows, … … 73 73 return NULL; 74 74 } 75 75 76 76 list_append(&dev->link, &outdevs); 77 77 return dev; … … 81 81 { 82 82 errno_t ret = EOK; 83 83 84 84 list_foreach(outdevs, link, outdev_t, dev) { 85 85 assert(dev->ops.yield); 86 86 87 87 errno_t rc = dev->ops.yield(dev); 88 88 if (rc != EOK) 89 89 ret = rc; 90 90 } 91 91 92 92 async_answer_0(iid, ret); 93 93 } … … 96 96 { 97 97 errno_t ret = EOK; 98 98 99 99 list_foreach(outdevs, link, outdev_t, dev) { 100 100 assert(dev->ops.claim); 101 101 102 102 errno_t rc = dev->ops.claim(dev); 103 103 if (rc != EOK) 104 104 ret = rc; 105 105 } 106 106 107 107 async_answer_0(iid, ret); 108 108 } … … 112 112 sysarg_t cols = MAX_COLS; 113 113 sysarg_t rows = MAX_ROWS; 114 114 115 115 list_foreach(outdevs, link, outdev_t, dev) { 116 116 cols = min(cols, dev->cols); 117 117 rows = min(rows, dev->rows); 118 118 } 119 119 120 120 async_answer_2(iid, EOK, cols, rows); 121 121 } … … 124 124 { 125 125 console_caps_t caps = 0; 126 126 127 127 list_foreach(outdevs, link, outdev_t, dev) { 128 128 assert(dev->ops.get_caps); 129 129 130 130 caps |= dev->ops.get_caps(dev); 131 131 } 132 132 133 133 async_answer_1(iid, EOK, caps); 134 134 } … … 143 143 } 144 144 } 145 145 146 146 if (frontbuf == NULL) { 147 147 async_answer_0(iid, ENOENT); 148 148 return NULL; 149 149 } 150 150 151 151 return frontbuf; 152 152 } … … 159 159 return; 160 160 } 161 161 162 162 link_initialize(&frontbuf->link); 163 163 164 164 ipc_callid_t callid; 165 165 if (!async_share_out_receive(&callid, &frontbuf->size, … … 169 169 return; 170 170 } 171 171 172 172 errno_t rc = async_share_out_finalize(callid, &frontbuf->data); 173 173 if ((rc != EOK) || (frontbuf->data == AS_MAP_FAILED)) { … … 176 176 return; 177 177 } 178 178 179 179 list_append(&frontbuf->link, &frontbufs); 180 180 async_answer_1(iid, EOK, (sysarg_t) frontbuf); … … 186 186 if (frontbuf == NULL) 187 187 return; 188 188 189 189 list_remove(&frontbuf->link); 190 190 as_area_destroy(frontbuf->data); 191 191 free(frontbuf); 192 192 193 193 async_answer_0(iid, EOK); 194 194 } … … 199 199 if (frontbuf == NULL) 200 200 return; 201 201 202 202 chargrid_t *buf = (chargrid_t *) frontbuf->data; 203 203 bool visible = chargrid_get_cursor_visibility(buf); 204 204 205 205 sysarg_t col; 206 206 sysarg_t row; 207 207 chargrid_get_cursor(buf, &col, &row); 208 208 209 209 list_foreach(outdevs, link, outdev_t, dev) { 210 210 assert(dev->ops.cursor_update); 211 211 212 212 sysarg_t prev_col; 213 213 sysarg_t prev_row; 214 214 chargrid_get_cursor(dev->backbuf, &prev_col, &prev_row); 215 215 216 216 chargrid_set_cursor(dev->backbuf, col, row); 217 217 chargrid_set_cursor_visibility(dev->backbuf, visible); 218 218 219 219 dev->ops.cursor_update(dev, prev_col, prev_row, col, row, 220 220 visible); … … 222 222 223 223 } 224 224 225 225 async_answer_0(iid, EOK); 226 226 } … … 233 233 (console_style_t) IPC_GET_ARG1(*icall); 234 234 } 235 235 236 236 async_answer_0(iid, EOK); 237 237 } … … 248 248 (console_color_attr_t) IPC_GET_ARG3(*icall); 249 249 } 250 250 251 251 async_answer_0(iid, EOK); 252 252 } … … 259 259 dev->attrs.val.rgb.fgcolor = IPC_GET_ARG2(*icall); 260 260 } 261 261 262 262 async_answer_0(iid, EOK); 263 263 } … … 266 266 { 267 267 assert(dev->ops.char_update); 268 268 269 269 sysarg_t top_row = chargrid_get_top_row(buf); 270 270 271 271 if (dev->top_row == top_row) 272 272 return false; 273 273 274 274 dev->top_row = top_row; 275 275 276 276 for (sysarg_t y = 0; y < dev->rows; y++) { 277 277 for (sysarg_t x = 0; x < dev->cols; x++) { … … 281 281 chargrid_charfield_at(dev->backbuf, x, y); 282 282 bool update = false; 283 283 284 284 if (front_field->ch != back_field->ch) { 285 285 back_field->ch = front_field->ch; 286 286 update = true; 287 287 } 288 288 289 289 if (!attrs_same(front_field->attrs, back_field->attrs)) { 290 290 back_field->attrs = front_field->attrs; 291 291 update = true; 292 292 } 293 293 294 294 front_field->flags &= ~CHAR_FLAG_DIRTY; 295 295 296 296 if (update) 297 297 dev->ops.char_update(dev, x, y); 298 298 } 299 299 } 300 300 301 301 return true; 302 302 } … … 307 307 if (frontbuf == NULL) 308 308 return; 309 309 310 310 chargrid_t *buf = (chargrid_t *) frontbuf->data; 311 311 312 312 list_foreach(outdevs, link, outdev_t, dev) { 313 313 assert(dev->ops.char_update); 314 314 315 315 if (srv_update_scroll(dev, buf)) 316 316 continue; 317 317 318 318 for (sysarg_t y = 0; y < dev->rows; y++) { 319 319 for (sysarg_t x = 0; x < dev->cols; x++) { … … 323 323 chargrid_charfield_at(dev->backbuf, x, y); 324 324 bool update = false; 325 325 326 326 if ((front_field->flags & CHAR_FLAG_DIRTY) == 327 327 CHAR_FLAG_DIRTY) { … … 330 330 update = true; 331 331 } 332 332 333 333 if (!attrs_same(front_field->attrs, 334 334 back_field->attrs)) { … … 336 336 update = true; 337 337 } 338 338 339 339 front_field->flags &= ~CHAR_FLAG_DIRTY; 340 340 } 341 341 342 342 if (update) 343 343 dev->ops.char_update(dev, x, y); 344 344 } 345 345 } 346 346 347 347 dev->ops.flush(dev); 348 348 } 349 350 349 350 351 351 async_answer_0(iid, EOK); 352 352 } … … 357 357 if (frontbuf == NULL) 358 358 return; 359 359 360 360 chargrid_t *buf = (chargrid_t *) frontbuf->data; 361 361 362 362 list_foreach(outdevs, link, outdev_t, dev) { 363 363 assert(dev->ops.char_update); 364 364 365 365 if (srv_update_scroll(dev, buf)) 366 366 continue; 367 367 368 368 sysarg_t col = IPC_GET_ARG2(*icall); 369 369 sysarg_t row = IPC_GET_ARG3(*icall); 370 370 371 371 sysarg_t cols = IPC_GET_ARG4(*icall); 372 372 sysarg_t rows = IPC_GET_ARG5(*icall); 373 373 374 374 for (sysarg_t y = 0; y < rows; y++) { 375 375 for (sysarg_t x = 0; x < cols; x++) { … … 378 378 charfield_t *back_field = 379 379 chargrid_charfield_at(dev->backbuf, col + x, row + y); 380 380 381 381 back_field->ch = front_field->ch; 382 382 back_field->attrs = front_field->attrs; … … 395 395 /* Accept the connection */ 396 396 async_answer_0(iid, EOK); 397 397 398 398 while (true) { 399 399 ipc_call_t call; 400 400 ipc_callid_t callid = async_get_call(&call); 401 401 402 402 if (!IPC_GET_IMETHOD(call)) { 403 403 async_answer_0(callid, EOK); 404 404 break; 405 405 } 406 406 407 407 switch (IPC_GET_IMETHOD(call)) { 408 408 case OUTPUT_YIELD: … … 418 418 srv_get_caps(callid, &call); 419 419 break; 420 420 421 421 case OUTPUT_FRONTBUF_CREATE: 422 422 srv_frontbuf_create(callid, &call); … … 425 425 srv_frontbuf_destroy(callid, &call); 426 426 break; 427 427 428 428 case OUTPUT_CURSOR_UPDATE: 429 429 srv_cursor_update(callid, &call); … … 444 444 srv_damage(callid, &call); 445 445 break; 446 446 447 447 default: 448 448 async_answer_0(callid, EINVAL); … … 462 462 return 1; 463 463 } 464 464 465 465 printf("%s: HelenOS output service\n", NAME); 466 466 467 467 /* Register server */ 468 468 async_set_fallback_port_handler(client_connection, NULL); … … 472 472 return rc; 473 473 } 474 474 475 475 service_id_t service_id; 476 476 rc = loc_service_register(argv[1], &service_id); … … 479 479 return rc; 480 480 } 481 481 482 482 if (!config_key_exists("console")) { 483 483 ega_init(); 484 484 } 485 485 486 486 chardev_init(); 487 487 488 488 printf("%s: Accepting connections\n", NAME); 489 489 task_retval(0); 490 490 async_manager(); 491 491 492 492 /* Never reached */ 493 493 return 0; -
uspace/srv/hid/output/output.h
r3061bc1 ra35b458 44 44 errno_t (*yield)(struct outdev *dev); 45 45 errno_t (*claim)(struct outdev *dev); 46 46 47 47 void (*get_dimensions)(struct outdev *dev, sysarg_t *cols, 48 48 sysarg_t *rows); 49 49 console_caps_t (*get_caps)(struct outdev *dev); 50 50 51 51 void (*cursor_update)(struct outdev *dev, sysarg_t prev_col, 52 52 sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible); … … 57 57 typedef struct outdev { 58 58 link_t link; 59 59 60 60 sysarg_t cols; 61 61 sysarg_t rows; 62 62 char_attrs_t attrs; 63 63 64 64 chargrid_t *backbuf; 65 65 sysarg_t top_row; 66 66 67 67 outdev_ops_t ops; 68 68 void *data; -
uspace/srv/hid/output/port/ega.c
r3061bc1 ra35b458 47 47 sysarg_t cols; 48 48 sysarg_t rows; 49 49 50 50 uint8_t style_normal; 51 51 uint8_t style_inverted; 52 52 53 53 size_t size; 54 54 uint8_t *addr; … … 60 60 { 61 61 uint8_t attr = 0; 62 62 63 63 switch (attrs.type) { 64 64 case CHAR_ATTR_STYLE: … … 81 81 attr = ((attrs.val.index.bgcolor & 7) << 4) | 82 82 (attrs.val.index.fgcolor & 7); 83 83 84 84 if (attrs.val.index.attr & CATTR_BRIGHT) 85 85 attr |= 0x08; 86 86 87 87 break; 88 88 case CHAR_ATTR_RGB: … … 91 91 break; 92 92 } 93 93 94 94 return attr; 95 95 } … … 105 105 { 106 106 uint8_t glyph; 107 107 108 108 if (ascii_check(field->ch)) 109 109 glyph = field->ch; 110 110 else 111 111 glyph = '?'; 112 112 113 113 uint8_t attr = attrs_attr(field->attrs); 114 114 115 115 ega.addr[FB_POS(col, row)] = glyph; 116 116 ega.addr[FB_POS(col, row) + 1] = attr; … … 143 143 /* Cursor position */ 144 144 uint16_t cursor = row * ega.cols + col; 145 145 146 146 pio_write_8(EGA_IO_BASE, 0x0e); 147 147 pio_write_8(EGA_IO_BASE + 1, (cursor >> 8) & 0xff); 148 148 pio_write_8(EGA_IO_BASE, 0x0f); 149 149 pio_write_8(EGA_IO_BASE + 1, cursor & 0xff); 150 150 151 151 /* Cursor visibility */ 152 152 pio_write_8(EGA_IO_BASE, 0x0a); 153 153 uint8_t stat = pio_read_8(EGA_IO_BASE + 1); 154 154 155 155 pio_write_8(EGA_IO_BASE, 0x0a); 156 156 157 157 if (visible) 158 158 pio_write_8(EGA_IO_BASE + 1, stat & (~(1 << 5))); … … 165 165 charfield_t *field = 166 166 chargrid_charfield_at(dev->backbuf, col, row); 167 167 168 168 draw_char(field, col, row); 169 169 } … … 189 189 if (rc != EOK) 190 190 present = false; 191 191 192 192 if (!present) 193 193 return ENOENT; 194 194 195 195 sysarg_t kind; 196 196 rc = sysinfo_get_value("fb.kind", &kind); 197 197 if (rc != EOK) 198 198 kind = (sysarg_t) -1; 199 199 200 200 if (kind != 2) 201 201 return EINVAL; 202 202 203 203 sysarg_t paddr; 204 204 rc = sysinfo_get_value("fb.address.physical", &paddr); 205 205 if (rc != EOK) 206 206 return rc; 207 207 208 208 rc = sysinfo_get_value("fb.width", &ega.cols); 209 209 if (rc != EOK) 210 210 return rc; 211 211 212 212 rc = sysinfo_get_value("fb.height", &ega.rows); 213 213 if (rc != EOK) 214 214 return rc; 215 215 216 216 rc = pio_enable((void*)EGA_IO_BASE, EGA_IO_SIZE, NULL); 217 217 if (rc != EOK) 218 218 return rc; 219 219 220 220 ega.size = (ega.cols * ega.rows) << 1; 221 221 ega.addr = AS_AREA_ANY; 222 222 223 223 rc = physmem_map(paddr, 224 224 ALIGN_UP(ega.size, PAGE_SIZE) >> PAGE_WIDTH, … … 226 226 if (rc != EOK) 227 227 return rc; 228 228 229 229 sysarg_t blinking; 230 230 rc = sysinfo_get_value("fb.blinking", &blinking); 231 231 if (rc != EOK) 232 232 blinking = false; 233 233 234 234 ega.style_normal = 0xf0; 235 235 ega.style_inverted = 0x0f; 236 236 237 237 if (blinking) { 238 238 ega.style_normal &= 0x77; 239 239 ega.style_inverted &= 0x77; 240 240 } 241 241 242 242 outdev_t *dev = outdev_register(&ega_ops, (void *) &ega); 243 243 if (dev == NULL) { … … 245 245 return EINVAL; 246 246 } 247 247 248 248 return EOK; 249 249 } -
uspace/srv/hid/output/port/kfb.c
r3061bc1 ra35b458 87 87 size_t scanline; 88 88 visual_t visual; 89 89 90 90 size_t size; 91 91 uint8_t *addr; 92 92 93 93 pixel2visual_t pixel2visual; 94 94 visual2pixel_t visual2pixel; 95 95 visual_mask_t visual_mask; 96 96 size_t pixel_bytes; 97 97 98 98 sysarg_t pointer_x; 99 99 sysarg_t pointer_y; 100 100 bool pointer_visible; 101 101 imgmap_t *pointer_imgmap; 102 102 103 103 /* 104 104 * Pre-rendered mask for rendering … … 106 106 * visual. 107 107 */ 108 108 109 109 size_t glyph_scanline; 110 110 size_t glyph_bytes; 111 111 uint8_t *glyphs; 112 112 113 113 uint8_t *backbuf; 114 114 } kfb_t; … … 135 135 [COLOR_YELLOW] = 0xf0f000, 136 136 [COLOR_WHITE] = 0xf0f0f0, 137 137 138 138 [COLOR_BLACK + 8] = 0x000000, 139 139 [COLOR_BLUE + 8] = 0x0000ff, … … 150 150 if ((x >= kfb.width) || (y >= kfb.height)) 151 151 return; 152 152 153 153 kfb.pixel2visual(kfb.addr + FB_POS(x, y), pixel); 154 154 } … … 158 158 if ((x >= kfb.width) || (y >= kfb.height)) 159 159 return 0; 160 160 161 161 return kfb.visual2pixel(kfb.addr + FB_POS(x, y)); 162 162 } … … 169 169 sysarg_t dx = kfb.pointer_x + x; 170 170 sysarg_t dy = kfb.pointer_y + y; 171 171 172 172 pixel_t pixel = get_pixel(dx, dy); 173 173 imgmap_put_pixel(kfb.pointer_imgmap, x, y, pixel); 174 174 175 175 size_t offset = y * ((POINTER_WIDTH - 1) / 8 + 1) + x / 8; 176 176 bool visible = pointer_mask[offset] & (1 << (x % 8)); 177 177 178 178 if (visible) { 179 179 pixel = (pointer[offset] & (1 << (x % 8))) ? … … 193 193 sysarg_t dx = kfb.pointer_x + x; 194 194 sysarg_t dy = kfb.pointer_y + y; 195 195 196 196 pixel_t pixel = 197 197 imgmap_get_pixel(kfb.pointer_imgmap, x, y); … … 210 210 if ((y1 >= y2) || (x1 >= x2)) 211 211 return; 212 212 213 213 uint8_t cbuf[4]; 214 214 kfb.pixel2visual(cbuf, color); 215 215 216 216 for (sysarg_t y = y1; y < y2; y++) { 217 217 uint8_t *dst = kfb.addr + FB_POS(x1, y); 218 218 219 219 for (sysarg_t x = x1; x < x2; x++) { 220 220 memcpy(dst, cbuf, kfb.pixel_bytes); … … 290 290 { 291 291 size_t word_size = sizeof(unsigned long); 292 292 293 293 /* 294 294 * Prepare a pair of words, one filled with foreground-color … … 297 297 unsigned long fg_buf; 298 298 unsigned long bg_buf; 299 299 300 300 for (size_t i = 0; i < word_size / kfb.pixel_bytes; i++) { 301 301 kfb.pixel2visual(&((uint8_t *) &bg_buf)[i * kfb.pixel_bytes], … … 304 304 fgcolor); 305 305 } 306 306 307 307 /* Pointer to the current position in the mask. */ 308 308 unsigned long *maskp = 309 309 (unsigned long *) &kfb.glyphs[GLYPH_POS( 310 310 fb_font_glyph(ch), 0, inverted)]; 311 311 312 312 /* Pointer to the current position on the screen. */ 313 313 unsigned long *dst = 314 314 (unsigned long *) &kfb.addr[FB_POS(x, y)]; 315 315 316 316 /* Width of the character cell in words. */ 317 317 size_t ww = FONT_WIDTH * kfb.pixel_bytes / word_size; 318 318 319 319 /* Offset to add when moving to another screen scanline. */ 320 320 size_t d_add = kfb.scanline - FONT_WIDTH * kfb.pixel_bytes; 321 321 322 322 for (size_t yd = 0; yd < FONT_SCANLINES; yd++) { 323 323 /* … … 329 329 *dst++ = (fg_buf & mask) | (bg_buf & ~mask); 330 330 } 331 331 332 332 /* Move to the beginning of the next scanline of the cell. */ 333 333 dst = (unsigned long *) ((uint8_t *) dst + d_add); … … 353 353 /* Character glyph */ 354 354 uint16_t glyph = fb_font_glyph(ch); 355 355 356 356 /* Pre-render the foreground and background color pixels. */ 357 357 uint8_t fg_buf[4]; 358 358 uint8_t bg_buf[4]; 359 359 360 360 if (inverted) { 361 361 kfb.pixel2visual(bg_buf, fgcolor); … … 365 365 kfb.pixel2visual(fg_buf, fgcolor); 366 366 } 367 367 368 368 /* Pointer to the current position on the screen. */ 369 369 uint8_t *dst = (uint8_t *) &kfb.addr[FB_POS(x, y)]; 370 370 371 371 /* Offset to add when moving to another screen scanline. */ 372 372 size_t d_add = kfb.scanline - FONT_WIDTH * kfb.pixel_bytes; 373 373 374 374 for (size_t yd = 0; yd < FONT_SCANLINES; yd++) { 375 375 /* Byte containing bits of the glyph scanline. */ 376 376 uint8_t byte = fb_font[glyph][yd]; 377 377 378 378 for (size_t i = 0; i < FONT_WIDTH; i++) { 379 379 /* Choose color based on the current bit. */ 380 380 uint8_t *src = (byte & 0x80) ? fg_buf : bg_buf; 381 381 382 382 /* Copy the pixel. */ 383 383 for (size_t j = 0; j < kfb.pixel_bytes; j++) 384 384 *dst++ = *src++; 385 385 386 386 /* Move to the next bit. */ 387 387 byte <<= 1; 388 388 } 389 389 390 390 /* Move to the beginning of the next scanline of the cell. */ 391 391 dst += d_add; … … 403 403 { 404 404 kfb_vp_t *kfb_vp = (kfb_vp_t *) vp->data; 405 405 406 406 sysarg_t x = vp->x + COL2X(col); 407 407 sysarg_t y = vp->y + ROW2Y(row); 408 408 409 409 charfield_t *field = screenbuffer_field_at(vp->backbuf, col, row); 410 410 411 411 pixel_t bgcolor = 0; 412 412 pixel_t fgcolor = 0; 413 413 attrs_rgb(field->attrs, &bgcolor, &fgcolor); 414 414 415 415 bool inverted = (vp->cursor_flash) && 416 416 screenbuffer_cursor_at(vp->backbuf, col, row); 417 417 418 418 (*kfb_vp->draw_char)(x, y, inverted, field->ch, bgcolor, fgcolor); 419 419 } … … 427 427 return ENOMEM; 428 428 } 429 429 430 430 for (sysarg_t y = 0; y < kfb.height; y++) 431 431 memcpy(kfb.backbuf + y * kfb.width * kfb.pixel_bytes, 432 432 kfb.addr + FB_POS(0, y), kfb.width * kfb.pixel_bytes); 433 433 434 434 return EOK; 435 435 } … … 439 439 if (kfb.backbuf == NULL) 440 440 return ENOENT; 441 441 442 442 for (sysarg_t y = 0; y < kfb.height; y++) 443 443 memcpy(kfb.addr + FB_POS(0, y), 444 444 kfb.backbuf + y * kfb.width * kfb.pixel_bytes, 445 445 kfb.width * kfb.pixel_bytes); 446 446 447 447 return EOK; 448 448 } … … 452 452 { 453 453 pointer_hide(); 454 454 455 455 kfb.pointer_x = x; 456 456 kfb.pointer_y = y; 457 457 kfb.pointer_visible = visible; 458 458 459 459 pointer_show(); 460 460 } … … 479 479 if (kfb_vp == NULL) 480 480 return ENOMEM; 481 481 482 482 /* 483 483 * Conditions necessary to select aligned glyph … … 489 489 */ 490 490 size_t word_size = sizeof(unsigned long); 491 491 492 492 if (((word_size % kfb.pixel_bytes) == 0) 493 493 && ((FONT_WIDTH * kfb.pixel_bytes) % word_size == 0) … … 497 497 else 498 498 kfb_vp->draw_char = draw_char_fallback; 499 499 500 500 vp->attrs.type = CHAR_ATTR_RGB; 501 501 vp->attrs.val.rgb.bgcolor = DEFAULT_BGCOLOR; 502 502 vp->attrs.val.rgb.fgcolor = DEFAULT_FGCOLOR; 503 503 vp->data = (void *) kfb_vp; 504 504 505 505 return EOK; 506 506 } … … 514 514 { 515 515 pointer_hide(); 516 516 517 517 for (sysarg_t row = 0; row < vp->rows; row++) { 518 518 for (sysarg_t col = 0; col < vp->cols; col++) { 519 519 charfield_t *field = 520 520 screenbuffer_field_at(vp->backbuf, col, row); 521 521 522 522 field->ch = 0; 523 523 field->attrs = vp->attrs; 524 524 } 525 525 } 526 526 527 527 pixel_t bgcolor = 0; 528 528 pixel_t fgcolor = 0; 529 529 attrs_rgb(vp->attrs, &bgcolor, &fgcolor); 530 530 531 531 draw_filled_rect(vp->x, vp->y, vp->x + vp->width, 532 532 vp->y + vp->height, bgcolor); 533 533 534 534 pointer_show(); 535 535 } … … 569 569 { 570 570 pointer_hide(); 571 571 572 572 for (sysarg_t y = 0; y < height; y++) { 573 573 for (sysarg_t x = 0; x < width; x++) { … … 576 576 } 577 577 } 578 578 579 579 pointer_show(); 580 580 } … … 605 605 { 606 606 memset(kfb.glyphs, 0, sz); 607 607 608 608 for (unsigned int glyph = 0; glyph < FONT_GLYPHS; glyph++) { 609 609 for (unsigned int y = 0; y < FONT_SCANLINES; y++) { … … 626 626 if (rc != EOK) 627 627 present = false; 628 628 629 629 if (!present) 630 630 return ENOENT; 631 631 632 632 sysarg_t kind; 633 633 rc = sysinfo_get_value("fb.kind", &kind); 634 634 if (rc != EOK) 635 635 kind = (sysarg_t) -1; 636 636 637 637 if (kind != 1) 638 638 return EINVAL; 639 639 640 640 sysarg_t paddr; 641 641 rc = sysinfo_get_value("fb.address.physical", &paddr); 642 642 if (rc != EOK) 643 643 return rc; 644 644 645 645 sysarg_t offset; 646 646 rc = sysinfo_get_value("fb.offset", &offset); 647 647 if (rc != EOK) 648 648 offset = 0; 649 649 650 650 sysarg_t width; 651 651 rc = sysinfo_get_value("fb.width", &width); 652 652 if (rc != EOK) 653 653 return rc; 654 654 655 655 sysarg_t height; 656 656 rc = sysinfo_get_value("fb.height", &height); 657 657 if (rc != EOK) 658 658 return rc; 659 659 660 660 sysarg_t scanline; 661 661 rc = sysinfo_get_value("fb.scanline", &scanline); 662 662 if (rc != EOK) 663 663 return rc; 664 664 665 665 sysarg_t visual; 666 666 rc = sysinfo_get_value("fb.visual", &visual); 667 667 if (rc != EOK) 668 668 return rc; 669 669 670 670 kfb.width = width; 671 671 kfb.height = height; … … 673 673 kfb.scanline = scanline; 674 674 kfb.visual = visual; 675 675 676 676 switch (visual) { 677 677 case VISUAL_INDIRECT_8: … … 744 744 return EINVAL; 745 745 } 746 746 747 747 kfb.glyph_scanline = FONT_WIDTH * kfb.pixel_bytes; 748 748 kfb.glyph_bytes = kfb.glyph_scanline * FONT_SCANLINES; 749 749 750 750 size_t sz = 2 * FONT_GLYPHS * kfb.glyph_bytes; 751 751 kfb.glyphs = (uint8_t *) malloc(sz); 752 752 if (kfb.glyphs == NULL) 753 753 return EINVAL; 754 754 755 755 render_glyphs(sz); 756 756 757 757 kfb.size = scanline * height; 758 758 759 759 rc = physmem_map((void *) paddr + offset, 760 760 ALIGN_UP(kfb.size, PAGE_SIZE) >> PAGE_WIDTH, … … 764 764 return rc; 765 765 } 766 766 767 767 kfb.pointer_x = 0; 768 768 kfb.pointer_y = 0; … … 770 770 kfb.pointer_imgmap = imgmap_create(POINTER_WIDTH, POINTER_HEIGHT, 771 771 VISUAL_RGB_0_8_8_8, IMGMAP_FLAG_NONE); 772 772 773 773 kfb.backbuf = NULL; 774 774 775 775 fbdev_t *dev = fbdev_register(&kfb_ops, (void *) &kfb); 776 776 if (dev == NULL) { … … 779 779 return EINVAL; 780 780 } 781 781 782 782 return EOK; 783 783 } -
uspace/srv/hid/output/proto/vt100.c
r3061bc1 ra35b458 77 77 { 78 78 char control[MAX_CONTROL]; 79 79 80 80 snprintf(control, MAX_CONTROL, "\033[%um", mode); 81 81 state->control_puts(control); … … 85 85 { 86 86 char control[MAX_CONTROL]; 87 87 88 88 snprintf(control, MAX_CONTROL, "\033[%" PRIun ";%" PRIun "f", 89 89 row + 1, col + 1); … … 123 123 vt100_sgr(state, SGR_BGCOLOR + color_map[attrs.val.index.bgcolor & 7]); 124 124 vt100_sgr(state, SGR_FGCOLOR + color_map[attrs.val.index.fgcolor & 7]); 125 125 126 126 if (attrs.val.index.attr & CATTR_BRIGHT) 127 127 vt100_sgr(state, SGR_BOLD); 128 128 129 129 break; 130 130 case CHAR_ATTR_RGB: 131 131 vt100_sgr(state, SGR_RESET); 132 132 133 133 if (attrs.val.rgb.bgcolor <= attrs.val.rgb.fgcolor) 134 134 vt100_sgr(state, SGR_REVERSE); 135 135 136 136 break; 137 137 } … … 145 145 if (state == NULL) 146 146 return NULL; 147 147 148 148 state->putchar = putchar_fn; 149 149 state->control_puts = control_puts_fn; 150 150 state->flush = flush_fn; 151 151 152 152 state->cols = cols; 153 153 state->rows = rows; 154 154 155 155 state->cur_col = (sysarg_t) -1; 156 156 state->cur_row = (sysarg_t) -1; 157 157 158 158 state->cur_attrs.type = CHAR_ATTR_STYLE; 159 159 state->cur_attrs.val.style = STYLE_NORMAL; 160 160 161 161 /* Initialize graphic rendition attributes */ 162 162 vt100_sgr(state, SGR_RESET); … … 195 195 if ((col >= state->cols) || (row >= state->rows)) 196 196 return; 197 197 198 198 if ((col != state->cur_col) || (row != state->cur_row)) { 199 199 vt100_set_pos(state, col, row); … … 223 223 state->putchar(ch == 0 ? ' ' : ch); 224 224 state->cur_col++; 225 225 226 226 if (state->cur_col >= state->cols) { 227 227 state->cur_row += state->cur_col / state->cols; -
uspace/srv/hid/output/proto/vt100.h
r3061bc1 ra35b458 42 42 sysarg_t cols; 43 43 sysarg_t rows; 44 44 45 45 sysarg_t cur_col; 46 46 sysarg_t cur_row; 47 47 char_attrs_t cur_attrs; 48 48 49 49 vt100_putchar_t putchar; 50 50 vt100_control_puts_t control_puts;
Note:
See TracChangeset
for help on using the changeset viewer.
