1 /*- 2 * Copyright (c) 2003 Peter Grehan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 #include <sys/cdefs.h> 30 __FBSDID("$FreeBSD$"); 31 32 #include <sys/param.h> 33 #include <sys/systm.h> 34 #include <sys/module.h> 35 #include <sys/bus.h> 36 #include <sys/kernel.h> 37 #include <sys/limits.h> 38 #include <sys/conf.h> 39 #include <sys/cons.h> 40 #include <sys/proc.h> 41 #include <sys/fcntl.h> 42 #include <sys/malloc.h> 43 #include <sys/fbio.h> 44 #include <sys/consio.h> 45 46 #include <machine/bus.h> 47 #include <machine/sc_machdep.h> 48 49 #include <sys/rman.h> 50 51 #include <dev/fb/fbreg.h> 52 #include <dev/syscons/syscons.h> 53 54 #include <dev/ofw/openfirm.h> 55 #include <powerpc/ofw/ofw_syscons.h> 56 #include <machine/nexusvar.h> 57 58 extern u_char dflt_font_16[]; 59 extern u_char dflt_font_14[]; 60 extern u_char dflt_font_8[]; 61 62 static int ofwfb_configure(int flags); 63 64 static vi_probe_t ofwfb_probe; 65 static vi_init_t ofwfb_init; 66 static vi_get_info_t ofwfb_get_info; 67 static vi_query_mode_t ofwfb_query_mode; 68 static vi_set_mode_t ofwfb_set_mode; 69 static vi_save_font_t ofwfb_save_font; 70 static vi_load_font_t ofwfb_load_font; 71 static vi_show_font_t ofwfb_show_font; 72 static vi_save_palette_t ofwfb_save_palette; 73 static vi_load_palette_t ofwfb_load_palette; 74 static vi_set_border_t ofwfb_set_border; 75 static vi_save_state_t ofwfb_save_state; 76 static vi_load_state_t ofwfb_load_state; 77 static vi_set_win_org_t ofwfb_set_win_org; 78 static vi_read_hw_cursor_t ofwfb_read_hw_cursor; 79 static vi_set_hw_cursor_t ofwfb_set_hw_cursor; 80 static vi_set_hw_cursor_shape_t ofwfb_set_hw_cursor_shape; 81 static vi_blank_display_t ofwfb_blank_display; 82 static vi_mmap_t ofwfb_mmap; 83 static vi_ioctl_t ofwfb_ioctl; 84 static vi_clear_t ofwfb_clear; 85 static vi_fill_rect_t ofwfb_fill_rect; 86 static vi_bitblt_t ofwfb_bitblt; 87 static vi_diag_t ofwfb_diag; 88 static vi_save_cursor_palette_t ofwfb_save_cursor_palette; 89 static vi_load_cursor_palette_t ofwfb_load_cursor_palette; 90 static vi_copy_t ofwfb_copy; 91 static vi_putp_t ofwfb_putp; 92 static vi_putc_t ofwfb_putc; 93 static vi_puts_t ofwfb_puts; 94 static vi_putm_t ofwfb_putm; 95 96 static video_switch_t ofwfbvidsw = { 97 .probe = ofwfb_probe, 98 .init = ofwfb_init, 99 .get_info = ofwfb_get_info, 100 .query_mode = ofwfb_query_mode, 101 .set_mode = ofwfb_set_mode, 102 .save_font = ofwfb_save_font, 103 .load_font = ofwfb_load_font, 104 .show_font = ofwfb_show_font, 105 .save_palette = ofwfb_save_palette, 106 .load_palette = ofwfb_load_palette, 107 .set_border = ofwfb_set_border, 108 .save_state = ofwfb_save_state, 109 .load_state = ofwfb_load_state, 110 .set_win_org = ofwfb_set_win_org, 111 .read_hw_cursor = ofwfb_read_hw_cursor, 112 .set_hw_cursor = ofwfb_set_hw_cursor, 113 .set_hw_cursor_shape = ofwfb_set_hw_cursor_shape, 114 .blank_display = ofwfb_blank_display, 115 .mmap = ofwfb_mmap, 116 .ioctl = ofwfb_ioctl, 117 .clear = ofwfb_clear, 118 .fill_rect = ofwfb_fill_rect, 119 .bitblt = ofwfb_bitblt, 120 .diag = ofwfb_diag, 121 .save_cursor_palette = ofwfb_save_cursor_palette, 122 .load_cursor_palette = ofwfb_load_cursor_palette, 123 .copy = ofwfb_copy, 124 .putp = ofwfb_putp, 125 .putc = ofwfb_putc, 126 .puts = ofwfb_puts, 127 .putm = ofwfb_putm, 128 }; 129 130 /* 131 * bitmap depth-specific routines 132 */ 133 static vi_blank_display_t ofwfb_blank_display8; 134 static vi_putc_t ofwfb_putc8; 135 136 static vi_blank_display_t ofwfb_blank_display32; 137 static vi_putc_t ofwfb_putc32; 138 139 VIDEO_DRIVER(ofwfb, ofwfbvidsw, ofwfb_configure); 140 141 extern sc_rndr_sw_t txtrndrsw; 142 RENDERER(ofwfb, 0, txtrndrsw, gfb_set); 143 144 RENDERER_MODULE(ofwfb, gfb_set); 145 146 /* 147 * Define the iso6429-1983 colormap 148 */ 149 static struct { 150 uint8_t red; 151 uint8_t green; 152 uint8_t blue; 153 } ofwfb_cmap[16] = { /* # R G B Color */ 154 /* - - - - ----- */ 155 { 0x00, 0x00, 0x00 }, /* 0 0 0 0 Black */ 156 { 0x00, 0x00, 0xaa }, /* 1 0 0 2/3 Blue */ 157 { 0x00, 0xaa, 0x00 }, /* 2 0 2/3 0 Green */ 158 { 0x00, 0xaa, 0xaa }, /* 3 0 2/3 2/3 Cyan */ 159 { 0xaa, 0x00, 0x00 }, /* 4 2/3 0 0 Red */ 160 { 0xaa, 0x00, 0xaa }, /* 5 2/3 0 2/3 Magenta */ 161 { 0xaa, 0x55, 0x00 }, /* 6 2/3 1/3 0 Brown */ 162 { 0xaa, 0xaa, 0xaa }, /* 7 2/3 2/3 2/3 White */ 163 { 0x55, 0x55, 0x55 }, /* 8 1/3 1/3 1/3 Gray */ 164 { 0x55, 0x55, 0xff }, /* 9 1/3 1/3 1 Bright Blue */ 165 { 0x55, 0xff, 0x55 }, /* 10 1/3 1 1/3 Bright Green */ 166 { 0x55, 0xff, 0xff }, /* 11 1/3 1 1 Bright Cyan */ 167 { 0xff, 0x55, 0x55 }, /* 12 1 1/3 1/3 Bright Red */ 168 { 0xff, 0x55, 0xff }, /* 13 1 1/3 1 Bright Magenta */ 169 { 0xff, 0xff, 0x80 }, /* 14 1 1 1/3 Bright Yellow */ 170 { 0xff, 0xff, 0xff } /* 15 1 1 1 Bright White */ 171 }; 172 173 #define TODO printf("%s: unimplemented\n", __func__) 174 175 static u_int16_t ofwfb_static_window[ROW*COL]; 176 177 static struct ofwfb_softc ofwfb_softc; 178 179 static int 180 ofwfb_background(uint8_t attr) 181 { 182 return (attr >> 4); 183 } 184 185 static int 186 ofwfb_foreground(uint8_t attr) 187 { 188 return (attr & 0x0f); 189 } 190 191 static u_int 192 ofwfb_pix32(int attr) 193 { 194 u_int retval; 195 196 retval = (ofwfb_cmap[attr].blue << 16) | 197 (ofwfb_cmap[attr].green << 8) | 198 ofwfb_cmap[attr].red; 199 200 return (retval); 201 } 202 203 static int 204 ofwfb_configure(int flags) 205 { 206 struct ofwfb_softc *sc; 207 phandle_t chosen; 208 ihandle_t stdout; 209 phandle_t node; 210 int depth; 211 int disable; 212 char type[16]; 213 static int done = 0; 214 215 disable = 0; 216 TUNABLE_INT_FETCH("hw.syscons.disable", &disable); 217 if (disable != 0) 218 return (0); 219 220 if (done != 0) 221 return (0); 222 done = 1; 223 224 sc = &ofwfb_softc; 225 226 chosen = OF_finddevice("/chosen"); 227 OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); 228 node = OF_instance_to_package(stdout); 229 OF_getprop(node, "device_type", type, sizeof(type)); 230 if (strcmp(type, "display") != 0) 231 return (0); 232 233 /* Only support 8-bit framebuffers */ 234 OF_getprop(node, "depth", &depth, sizeof(depth)); 235 if (depth == 8) { 236 sc->sc_blank = ofwfb_blank_display8; 237 sc->sc_putc = ofwfb_putc8; 238 } else if (depth == 32) { 239 sc->sc_blank = ofwfb_blank_display32; 240 sc->sc_putc = ofwfb_putc32; 241 } else 242 return (0); 243 244 sc->sc_depth = depth; 245 sc->sc_node = node; 246 sc->sc_console = 1; 247 OF_getprop(node, "height", &sc->sc_height, sizeof(sc->sc_height)); 248 OF_getprop(node, "width", &sc->sc_width, sizeof(sc->sc_width)); 249 OF_getprop(node, "linebytes", &sc->sc_stride, sizeof(sc->sc_stride)); 250 251 /* 252 * XXX the physical address of the frame buffer is assumed to be 253 * BAT-mapped so it can be accessed directly 254 */ 255 OF_getprop(node, "address", &sc->sc_addr, sizeof(sc->sc_addr)); 256 257 ofwfb_init(0, &sc->sc_va, 0); 258 259 return (0); 260 } 261 262 static int 263 ofwfb_probe(int unit, video_adapter_t **adp, void *arg, int flags) 264 { 265 TODO; 266 return (0); 267 } 268 269 static int 270 ofwfb_init(int unit, video_adapter_t *adp, int flags) 271 { 272 struct ofwfb_softc *sc; 273 video_info_t *vi; 274 char name[64]; 275 ihandle_t ih; 276 int i; 277 int cborder; 278 int font_height; 279 int retval; 280 281 sc = (struct ofwfb_softc *)adp; 282 vi = &adp->va_info; 283 284 vid_init_struct(adp, "ofwfb", -1, unit); 285 286 if (sc->sc_depth == 8) { 287 /* 288 * Install the ISO6429 colormap - older OFW systems 289 * don't do this by default 290 */ 291 memset(name, 0, sizeof(name)); 292 OF_package_to_path(sc->sc_node, name, sizeof(name)); 293 ih = OF_open(name); 294 for (i = 0; i < 16; i++) { 295 OF_call_method("color!", ih, 4, 1, 296 ofwfb_cmap[i].red, 297 ofwfb_cmap[i].green, 298 ofwfb_cmap[i].blue, 299 i, 300 &retval); 301 } 302 } 303 304 /* The default font size can be overridden by loader */ 305 font_height = 16; 306 TUNABLE_INT_FETCH("hw.syscons.fsize", &font_height); 307 if (font_height == 8) { 308 sc->sc_font = dflt_font_8; 309 sc->sc_font_height = 8; 310 } else if (font_height == 14) { 311 sc->sc_font = dflt_font_14; 312 sc->sc_font_height = 14; 313 } else { 314 /* default is 8x16 */ 315 sc->sc_font = dflt_font_16; 316 sc->sc_font_height = 16; 317 } 318 319 /* The user can set a border in chars - default is 1 char width */ 320 cborder = 1; 321 TUNABLE_INT_FETCH("hw.syscons.border", &cborder); 322 323 vi->vi_cheight = sc->sc_font_height; 324 vi->vi_width = sc->sc_width/8 - 2*cborder; 325 vi->vi_height = sc->sc_height/sc->sc_font_height - 2*cborder; 326 vi->vi_cwidth = 8; 327 328 /* 329 * Clamp width/height to syscons maximums 330 */ 331 if (vi->vi_width > COL) 332 vi->vi_width = COL; 333 if (vi->vi_height > ROW) 334 vi->vi_height = ROW; 335 336 sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2; 337 sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight))/2; 338 339 /* 340 * Avoid huge amounts of conditional code in syscons by 341 * defining a dummy h/w text display buffer. 342 */ 343 adp->va_window = (vm_offset_t) ofwfb_static_window; 344 345 /* Enable future font-loading... */ 346 adp->va_flags |= V_ADP_FONT; 347 348 ofwfb_blank_display(&sc->sc_va, V_DISPLAY_ON); 349 350 ofwfb_set_mode(&sc->sc_va, 0); 351 352 vid_register(&sc->sc_va); 353 354 return (0); 355 } 356 357 static int 358 ofwfb_get_info(video_adapter_t *adp, int mode, video_info_t *info) 359 { 360 bcopy(&adp->va_info, info, sizeof(*info)); 361 return (0); 362 } 363 364 static int 365 ofwfb_query_mode(video_adapter_t *adp, video_info_t *info) 366 { 367 TODO; 368 return (0); 369 } 370 371 static int 372 ofwfb_set_mode(video_adapter_t *adp, int mode) 373 { 374 375 return (0); 376 } 377 378 static int 379 ofwfb_save_font(video_adapter_t *adp, int page, int size, u_char *data, 380 int c, int count) 381 { 382 TODO; 383 return (0); 384 } 385 386 static int 387 ofwfb_load_font(video_adapter_t *adp, int page, int size, u_char *data, 388 int c, int count) 389 { 390 struct ofwfb_softc *sc; 391 392 sc = (struct ofwfb_softc *)adp; 393 394 /* 395 * syscons code has already determined that current width/height 396 * are unchanged for this new font 397 */ 398 sc->sc_font = data; 399 return (0); 400 } 401 402 static int 403 ofwfb_show_font(video_adapter_t *adp, int page) 404 { 405 TODO; 406 return (0); 407 } 408 409 static int 410 ofwfb_save_palette(video_adapter_t *adp, u_char *palette) 411 { 412 /* TODO; */ 413 return (0); 414 } 415 416 static int 417 ofwfb_load_palette(video_adapter_t *adp, u_char *palette) 418 { 419 /* TODO; */ 420 return (0); 421 } 422 423 static int 424 ofwfb_set_border(video_adapter_t *adp, int border) 425 { 426 /* TODO; */ 427 return (0); 428 } 429 430 static int 431 ofwfb_save_state(video_adapter_t *adp, void *p, size_t size) 432 { 433 TODO; 434 return (0); 435 } 436 437 static int 438 ofwfb_load_state(video_adapter_t *adp, void *p) 439 { 440 TODO; 441 return (0); 442 } 443 444 static int 445 ofwfb_set_win_org(video_adapter_t *adp, off_t offset) 446 { 447 TODO; 448 return (0); 449 } 450 451 static int 452 ofwfb_read_hw_cursor(video_adapter_t *adp, int *col, int *row) 453 { 454 *col = 0; 455 *row = 0; 456 457 return (0); 458 } 459 460 static int 461 ofwfb_set_hw_cursor(video_adapter_t *adp, int col, int row) 462 { 463 464 return (0); 465 } 466 467 static int 468 ofwfb_set_hw_cursor_shape(video_adapter_t *adp, int base, int height, 469 int celsize, int blink) 470 { 471 return (0); 472 } 473 474 static int 475 ofwfb_blank_display8(video_adapter_t *adp, int mode) 476 { 477 struct ofwfb_softc *sc; 478 int i; 479 uint8_t *addr; 480 481 sc = (struct ofwfb_softc *)adp; 482 addr = (uint8_t *) sc->sc_addr; 483 484 /* Could be done a lot faster e.g. 32-bits, or Altivec'd */ 485 for (i = 0; i < sc->sc_stride*sc->sc_height; i++) 486 *(addr + i) = ofwfb_background(SC_NORM_ATTR); 487 488 return (0); 489 } 490 491 static int 492 ofwfb_blank_display32(video_adapter_t *adp, int mode) 493 { 494 struct ofwfb_softc *sc; 495 int i; 496 uint32_t *addr; 497 498 sc = (struct ofwfb_softc *)adp; 499 addr = (uint32_t *) sc->sc_addr; 500 501 for (i = 0; i < (sc->sc_stride/4)*sc->sc_height; i++) 502 *(addr + i) = ofwfb_pix32(ofwfb_background(SC_NORM_ATTR)); 503 504 return (0); 505 } 506 507 static int 508 ofwfb_blank_display(video_adapter_t *adp, int mode) 509 { 510 struct ofwfb_softc *sc; 511 512 sc = (struct ofwfb_softc *)adp; 513 514 return ((*sc->sc_blank)(adp, mode)); 515 } 516 517 static int 518 ofwfb_mmap(video_adapter_t *adp, vm_offset_t offset, vm_paddr_t *paddr, 519 int prot) 520 { 521 TODO; 522 return (0); 523 } 524 525 static int 526 ofwfb_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data) 527 { 528 TODO; 529 return (0); 530 } 531 532 static int 533 ofwfb_clear(video_adapter_t *adp) 534 { 535 TODO; 536 return (0); 537 } 538 539 static int 540 ofwfb_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy) 541 { 542 TODO; 543 return (0); 544 } 545 546 static int 547 ofwfb_bitblt(video_adapter_t *adp, ...) 548 { 549 TODO; 550 return (0); 551 } 552 553 static int 554 ofwfb_diag(video_adapter_t *adp, int level) 555 { 556 TODO; 557 return (0); 558 } 559 560 static int 561 ofwfb_save_cursor_palette(video_adapter_t *adp, u_char *palette) 562 { 563 TODO; 564 return (0); 565 } 566 567 static int 568 ofwfb_load_cursor_palette(video_adapter_t *adp, u_char *palette) 569 { 570 TODO; 571 return (0); 572 } 573 574 static int 575 ofwfb_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n) 576 { 577 TODO; 578 return (0); 579 } 580 581 static int 582 ofwfb_putp(video_adapter_t *adp, vm_offset_t off, uint32_t p, uint32_t a, 583 int size, int bpp, int bit_ltor, int byte_ltor) 584 { 585 TODO; 586 return (0); 587 } 588 589 static int 590 ofwfb_putc8(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a) 591 { 592 struct ofwfb_softc *sc; 593 int row; 594 int col; 595 int i, j, k; 596 uint8_t *addr; 597 u_char *p; 598 599 sc = (struct ofwfb_softc *)adp; 600 row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight; 601 col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth; 602 p = sc->sc_font + c*sc->sc_font_height; 603 addr = (uint8_t *)sc->sc_addr + (row + sc->sc_ymargin)*sc->sc_stride 604 + col + sc->sc_xmargin; 605 606 for (i = 0; i < sc->sc_font_height; i++) { 607 for (j = 0, k = 7; j < 8; j++, k--) { 608 if ((p[i] & (1 << k)) == 0) 609 *(addr + j) = ofwfb_background(a); 610 else 611 *(addr + j) = ofwfb_foreground(a); 612 } 613 addr += sc->sc_stride; 614 } 615 616 return (0); 617 } 618 619 static int 620 ofwfb_putc32(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a) 621 { 622 struct ofwfb_softc *sc; 623 int row; 624 int col; 625 int i, j, k; 626 uint32_t *addr; 627 u_char *p; 628 629 sc = (struct ofwfb_softc *)adp; 630 row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight; 631 col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth; 632 p = sc->sc_font + c*sc->sc_font_height; 633 addr = (uint32_t *)sc->sc_addr 634 + (row + sc->sc_ymargin)*(sc->sc_stride/4) 635 + col + sc->sc_xmargin; 636 637 for (i = 0; i < sc->sc_font_height; i++) { 638 for (j = 0, k = 7; j < 8; j++, k--) { 639 if ((p[i] & (1 << k)) == 0) 640 *(addr + j) = ofwfb_pix32(ofwfb_background(a)); 641 else 642 *(addr + j) = ofwfb_pix32(ofwfb_foreground(a)); 643 } 644 addr += (sc->sc_stride/4); 645 } 646 647 return (0); 648 } 649 650 static int 651 ofwfb_putc(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a) 652 { 653 struct ofwfb_softc *sc; 654 655 sc = (struct ofwfb_softc *)adp; 656 657 return ((*sc->sc_putc)(adp, off, c, a)); 658 } 659 660 static int 661 ofwfb_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len) 662 { 663 int i; 664 665 for (i = 0; i < len; i++) { 666 ofwfb_putc(adp, off + i, s[i] & 0xff, (s[i] & 0xff00) >> 8); 667 } 668 return (0); 669 } 670 671 static int 672 ofwfb_putm(video_adapter_t *adp, int x, int y, uint8_t *pixel_image, 673 uint32_t pixel_mask, int size) 674 { 675 struct ofwfb_softc *sc; 676 677 sc = (struct ofwfb_softc *)adp; 678 679 /* put mouse */ 680 681 return (0); 682 } 683 684 /* 685 * Define the syscons nexus device attachment 686 */ 687 static void 688 ofwfb_scidentify(driver_t *driver, device_t parent) 689 { 690 device_t child; 691 692 /* 693 * Add with a priority guaranteed to make it last on 694 * the device list 695 */ 696 child = BUS_ADD_CHILD(parent, INT_MAX, SC_DRIVER_NAME, 0); 697 if (child != NULL) 698 nexus_set_device_type(child, "syscons"); 699 } 700 701 static int 702 ofwfb_scprobe(device_t dev) 703 { 704 char *name; 705 706 name = nexus_get_name(dev); 707 if (strcmp(SC_DRIVER_NAME, name) != 0) 708 return (ENXIO); 709 710 device_set_desc(dev, "System console"); 711 return (sc_probe_unit(device_get_unit(dev), 712 device_get_flags(dev) | SC_AUTODETECT_KBD)); 713 } 714 715 static int 716 ofwfb_scattach(device_t dev) 717 { 718 return (sc_attach_unit(device_get_unit(dev), 719 device_get_flags(dev) | SC_AUTODETECT_KBD)); 720 } 721 722 static device_method_t ofwfb_sc_methods[] = { 723 DEVMETHOD(device_identify, ofwfb_scidentify), 724 DEVMETHOD(device_probe, ofwfb_scprobe), 725 DEVMETHOD(device_attach, ofwfb_scattach), 726 { 0, 0 } 727 }; 728 729 static driver_t ofwfb_sc_driver = { 730 SC_DRIVER_NAME, 731 ofwfb_sc_methods, 732 sizeof(sc_softc_t), 733 }; 734 735 static devclass_t sc_devclass; 736 737 DRIVER_MODULE(sc, nexus, ofwfb_sc_driver, sc_devclass, 0, 0); 738 739 /* 740 * Define a stub keyboard driver in case one hasn't been 741 * compiled into the kernel 742 */ 743 #include <sys/kbio.h> 744 #include <dev/kbd/kbdreg.h> 745 746 static int dummy_kbd_configure(int flags); 747 748 keyboard_switch_t dummysw; 749 750 static int 751 dummy_kbd_configure(int flags) 752 { 753 754 return (0); 755 } 756 KEYBOARD_DRIVER(dummy, dummysw, dummy_kbd_configure); 757 758 /* 759 * Utility routines from <dev/fb/fbreg.h> 760 */ 761 void 762 ofwfb_bcopy(const void *s, void *d, size_t c) 763 { 764 bcopy(s, d, c); 765 } 766 767 void 768 ofwfb_bzero(void *d, size_t c) 769 { 770 bzero(d, c); 771 } 772 773 void 774 ofwfb_fillw(int pat, void *base, size_t cnt) 775 { 776 u_int16_t *bptr = base; 777 778 while (cnt--) 779 *bptr++ = pat; 780 } 781 782 u_int16_t 783 ofwfb_readw(u_int16_t *addr) 784 { 785 return (*addr); 786 } 787 788 void 789 ofwfb_writew(u_int16_t *addr, u_int16_t val) 790 { 791 *addr = val; 792 } 793