1 /* 2 * Copyright (C) 2003,2004 3 * Hidetoshi Shimokawa. 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 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * 16 * This product includes software developed by Hidetoshi Shimokawa. 17 * 18 * 4. Neither the name of the author nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * $FreeBSD: src/sys/dev/dcons/dcons_os.c,v 1.4 2004/10/24 12:41:04 simokawa Exp $ 35 * $DragonFly: src/sys/dev/misc/dcons/dcons_os.c,v 1.1 2004/10/25 13:53:26 simokawa Exp $ 36 */ 37 38 #include <sys/param.h> 39 #if __FreeBSD_version >= 502122 40 #include <sys/kdb.h> 41 #include <gdb/gdb.h> 42 #endif 43 #include <sys/kernel.h> 44 #include <sys/module.h> 45 #include <sys/systm.h> 46 #include <sys/types.h> 47 #include <sys/conf.h> 48 #include <sys/cons.h> 49 #include <sys/consio.h> 50 #include <sys/tty.h> 51 #include <sys/malloc.h> 52 #include <sys/proc.h> 53 #include <sys/ucred.h> 54 55 #include <machine/bus.h> 56 57 #ifdef __DragonFly__ 58 #include "dcons.h" 59 #include "dcons_os.h" 60 #else 61 #include <dev/dcons/dcons.h> 62 #include <dev/dcons/dcons_os.h> 63 #endif 64 65 #include <ddb/ddb.h> 66 #include <sys/reboot.h> 67 68 #include <sys/sysctl.h> 69 70 #include <vm/vm.h> 71 #include <vm/vm_param.h> 72 #include <vm/pmap.h> 73 74 #include "opt_ddb.h" 75 #include "opt_comconsole.h" 76 #include "opt_dcons.h" 77 78 #ifndef DCONS_POLL_HZ 79 #define DCONS_POLL_HZ 100 80 #endif 81 82 #ifndef DCONS_BUF_SIZE 83 #define DCONS_BUF_SIZE (16*1024) 84 #endif 85 86 #ifndef DCONS_FORCE_CONSOLE 87 #define DCONS_FORCE_CONSOLE 0 /* Mostly for FreeBSD-4/DragonFly */ 88 #endif 89 90 #ifndef DCONS_FORCE_GDB 91 #define DCONS_FORCE_GDB 1 92 #endif 93 94 #if __FreeBSD_version >= 500101 95 #define CONS_NODEV 1 96 #if __FreeBSD_version < 502122 97 static struct consdev gdbconsdev; 98 #endif 99 #endif 100 101 static d_open_t dcons_open; 102 static d_close_t dcons_close; 103 #if defined(__DragonFly__) || __FreeBSD_version < 500104 104 static d_ioctl_t dcons_ioctl; 105 #endif 106 107 static struct cdevsw dcons_cdevsw = { 108 #ifdef __DragonFly__ 109 #define CDEV_MAJOR 184 110 "dcons", CDEV_MAJOR, D_TTY, NULL, 0, 111 dcons_open, dcons_close, ttyread, ttywrite, dcons_ioctl, 112 ttypoll, nommap, nostrategy, nodump, nopsize, 113 #elif __FreeBSD_version >= 500104 114 .d_version = D_VERSION, 115 .d_open = dcons_open, 116 .d_close = dcons_close, 117 .d_name = "dcons", 118 .d_flags = D_TTY | D_NEEDGIANT, 119 #else 120 #define CDEV_MAJOR 184 121 /* open */ dcons_open, 122 /* close */ dcons_close, 123 /* read */ ttyread, 124 /* write */ ttywrite, 125 /* ioctl */ dcons_ioctl, 126 /* poll */ ttypoll, 127 /* mmap */ nommap, 128 /* strategy */ nostrategy, 129 /* name */ "dcons", 130 /* major */ CDEV_MAJOR, 131 /* dump */ nodump, 132 /* psize */ nopsize, 133 /* flags */ D_TTY, 134 #endif 135 }; 136 137 #ifndef KLD_MODULE 138 static char bssbuf[DCONS_BUF_SIZE]; /* buf in bss */ 139 #endif 140 141 /* global data */ 142 static struct dcons_global dg; 143 struct dcons_global *dcons_conf; 144 static int poll_hz = DCONS_POLL_HZ; 145 146 static struct dcons_softc sc[DCONS_NPORT]; 147 148 SYSCTL_NODE(_kern, OID_AUTO, dcons, CTLFLAG_RD, 0, "Dumb Console"); 149 SYSCTL_INT(_kern_dcons, OID_AUTO, poll_hz, CTLFLAG_RW, &poll_hz, 0, 150 "dcons polling rate"); 151 152 static int drv_init = 0; 153 static struct callout dcons_callout; 154 struct dcons_buf *dcons_buf; /* for local dconschat */ 155 156 #ifdef __DragonFly__ 157 #define DEV dev_t 158 #define THREAD d_thread_t 159 #elif __FreeBSD_version < 500000 160 #define DEV dev_t 161 #define THREAD struct proc 162 #else 163 #define DEV struct cdev * 164 #define THREAD struct thread 165 #endif 166 167 168 static void dcons_tty_start(struct tty *); 169 static int dcons_tty_param(struct tty *, struct termios *); 170 static void dcons_timeout(void *); 171 static int dcons_drv_init(int); 172 173 static cn_probe_t dcons_cnprobe; 174 static cn_init_t dcons_cninit; 175 static cn_getc_t dcons_cngetc; 176 static cn_checkc_t dcons_cncheckc; 177 static cn_putc_t dcons_cnputc; 178 179 CONS_DRIVER(dcons, dcons_cnprobe, dcons_cninit, NULL, dcons_cngetc, 180 dcons_cncheckc, dcons_cnputc, NULL); 181 182 #if __FreeBSD_version >= 502122 183 static gdb_probe_f dcons_dbg_probe; 184 static gdb_init_f dcons_dbg_init; 185 static gdb_term_f dcons_dbg_term; 186 static gdb_getc_f dcons_dbg_getc; 187 static gdb_checkc_f dcons_dbg_checkc; 188 static gdb_putc_f dcons_dbg_putc; 189 190 GDB_DBGPORT(dcons, dcons_dbg_probe, dcons_dbg_init, dcons_dbg_term, 191 dcons_dbg_checkc, dcons_dbg_getc, dcons_dbg_putc); 192 193 extern struct gdb_dbgport *gdb_cur; 194 #endif 195 196 #if (KDB || DDB) && ALT_BREAK_TO_DEBUGGER 197 static int 198 dcons_check_break(struct dcons_softc *dc, int c) 199 { 200 if (c < 0) 201 return (c); 202 203 #if __FreeBSD_version >= 502122 204 if (kdb_alt_break(c, &dc->brk_state)) { 205 if ((dc->flags & DC_GDB) != 0) { 206 if (gdb_cur == &dcons_gdb_dbgport) { 207 kdb_dbbe_select("gdb"); 208 breakpoint(); 209 } 210 } else 211 breakpoint(); 212 } 213 #else 214 switch (dc->brk_state) { 215 case STATE1: 216 if (c == KEY_TILDE) 217 dc->brk_state = STATE2; 218 else 219 dc->brk_state = STATE0; 220 break; 221 case STATE2: 222 dc->brk_state = STATE0; 223 if (c == KEY_CTRLB) { 224 #if DCONS_FORCE_GDB 225 if (dc->flags & DC_GDB) 226 boothowto |= RB_GDB; 227 #endif 228 breakpoint(); 229 } 230 } 231 if (c == KEY_CR) 232 dc->brk_state = STATE1; 233 #endif 234 return (c); 235 } 236 #else 237 #define dcons_check_break(dc, c) (c) 238 #endif 239 240 static int 241 dcons_os_checkc(struct dcons_softc *dc) 242 { 243 int c; 244 245 if (dg.dma_tag != NULL) 246 bus_dmamap_sync(dg.dma_tag, dg.dma_map, BUS_DMASYNC_POSTREAD); 247 248 c = dcons_check_break(dc, dcons_checkc(dc)); 249 250 if (dg.dma_tag != NULL) 251 bus_dmamap_sync(dg.dma_tag, dg.dma_map, BUS_DMASYNC_PREREAD); 252 253 return (c); 254 } 255 256 static int 257 dcons_os_getc(struct dcons_softc *dc) 258 { 259 int c; 260 261 while ((c = dcons_os_checkc(dc)) == -1); 262 263 return (c & 0xff); 264 } 265 266 static void 267 dcons_os_putc(struct dcons_softc *dc, int c) 268 { 269 if (dg.dma_tag != NULL) 270 bus_dmamap_sync(dg.dma_tag, dg.dma_map, BUS_DMASYNC_POSTWRITE); 271 272 dcons_putc(dc, c); 273 274 if (dg.dma_tag != NULL) 275 bus_dmamap_sync(dg.dma_tag, dg.dma_map, BUS_DMASYNC_PREWRITE); 276 } 277 static int 278 dcons_open(DEV dev, int flag, int mode, THREAD *td) 279 { 280 struct tty *tp; 281 int unit, error, s; 282 283 unit = minor(dev); 284 if (unit != 0) 285 return (ENXIO); 286 287 tp = dev->si_tty = ttymalloc(dev->si_tty); 288 tp->t_oproc = dcons_tty_start; 289 tp->t_param = dcons_tty_param; 290 tp->t_stop = nottystop; 291 tp->t_dev = dev; 292 293 error = 0; 294 295 s = spltty(); 296 if ((tp->t_state & TS_ISOPEN) == 0) { 297 tp->t_state |= TS_CARR_ON; 298 ttychars(tp); 299 tp->t_iflag = TTYDEF_IFLAG; 300 tp->t_oflag = TTYDEF_OFLAG; 301 tp->t_cflag = TTYDEF_CFLAG|CLOCAL; 302 tp->t_lflag = TTYDEF_LFLAG; 303 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; 304 ttsetwater(tp); 305 } else if ((tp->t_state & TS_XCLUDE) && suser(td)) { 306 splx(s); 307 return (EBUSY); 308 } 309 splx(s); 310 311 #if __FreeBSD_version < 502113 312 error = (*linesw[tp->t_line].l_open)(dev, tp); 313 #else 314 error = ttyld_open(tp, dev); 315 #endif 316 317 return (error); 318 } 319 320 static int 321 dcons_close(DEV dev, int flag, int mode, THREAD *td) 322 { 323 int unit; 324 struct tty *tp; 325 326 unit = minor(dev); 327 if (unit != 0) 328 return (ENXIO); 329 330 tp = dev->si_tty; 331 if (tp->t_state & TS_ISOPEN) { 332 #if __FreeBSD_version < 502113 333 (*linesw[tp->t_line].l_close)(tp, flag); 334 ttyclose(tp); 335 #else 336 ttyld_close(tp, flag); 337 tty_close(tp); 338 #endif 339 } 340 341 return (0); 342 } 343 344 #if defined(__DragonFly__) || __FreeBSD_version < 500104 345 static int 346 dcons_ioctl(DEV dev, u_long cmd, caddr_t data, int flag, THREAD *td) 347 { 348 int unit; 349 struct tty *tp; 350 int error; 351 352 unit = minor(dev); 353 if (unit != 0) 354 return (ENXIO); 355 356 tp = dev->si_tty; 357 error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); 358 if (error != ENOIOCTL) 359 return (error); 360 361 error = ttioctl(tp, cmd, data, flag); 362 if (error != ENOIOCTL) 363 return (error); 364 365 return (ENOTTY); 366 } 367 #endif 368 369 static int 370 dcons_tty_param(struct tty *tp, struct termios *t) 371 { 372 tp->t_ispeed = t->c_ispeed; 373 tp->t_ospeed = t->c_ospeed; 374 tp->t_cflag = t->c_cflag; 375 return 0; 376 } 377 378 static void 379 dcons_tty_start(struct tty *tp) 380 { 381 struct dcons_softc *dc; 382 int s; 383 384 dc = (struct dcons_softc *)tp->t_dev->si_drv1; 385 s = spltty(); 386 if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) { 387 ttwwakeup(tp); 388 return; 389 } 390 391 tp->t_state |= TS_BUSY; 392 while (tp->t_outq.c_cc != 0) 393 dcons_os_putc(dc, getc(&tp->t_outq)); 394 tp->t_state &= ~TS_BUSY; 395 396 ttwwakeup(tp); 397 splx(s); 398 } 399 400 static void 401 dcons_timeout(void *v) 402 { 403 struct tty *tp; 404 struct dcons_softc *dc; 405 int i, c, polltime; 406 407 for (i = 0; i < DCONS_NPORT; i ++) { 408 dc = &sc[i]; 409 tp = ((DEV)dc->dev)->si_tty; 410 while ((c = dcons_os_checkc(dc)) != -1) 411 if (tp->t_state & TS_ISOPEN) 412 #if __FreeBSD_version < 502113 413 (*linesw[tp->t_line].l_rint)(c, tp); 414 #else 415 ttyld_rint(tp, c); 416 #endif 417 } 418 polltime = hz / poll_hz; 419 if (polltime < 1) 420 polltime = 1; 421 callout_reset(&dcons_callout, polltime, dcons_timeout, tp); 422 } 423 424 static void 425 dcons_cnprobe(struct consdev *cp) 426 { 427 #ifdef __DragonFly__ 428 cp->cn_dev = make_dev(&dcons_cdevsw, DCONS_CON, 429 UID_ROOT, GID_WHEEL, 0600, "dcons"); 430 #elif __FreeBSD_version >= 501109 431 sprintf(cp->cn_name, "dcons"); 432 #else 433 cp->cn_dev = makedev(CDEV_MAJOR, DCONS_CON); 434 #endif 435 #if DCONS_FORCE_CONSOLE 436 cp->cn_pri = CN_REMOTE; 437 #else 438 cp->cn_pri = CN_NORMAL; 439 #endif 440 } 441 442 static void 443 dcons_cninit(struct consdev *cp) 444 { 445 dcons_drv_init(0); 446 #if CONS_NODEV 447 cp->cn_arg 448 #else 449 cp->cn_dev->si_drv1 450 #endif 451 = (void *)&sc[DCONS_CON]; /* share port0 with unit0 */ 452 } 453 454 #if CONS_NODEV 455 static int 456 dcons_cngetc(struct consdev *cp) 457 { 458 struct dcons_softc *dc = (struct dcons_softc *)cp->cn_arg; 459 return (dcons_os_getc(dc)); 460 } 461 static int 462 dcons_cncheckc(struct consdev *cp) 463 { 464 struct dcons_softc *dc = (struct dcons_softc *)cp->cn_arg; 465 return (dcons_os_checkc(dc)); 466 } 467 static void 468 dcons_cnputc(struct consdev *cp, int c) 469 { 470 struct dcons_softc *dc = (struct dcons_softc *)cp->cn_arg; 471 dcons_os_putc(dc, c); 472 } 473 #else 474 static int 475 dcons_cngetc(DEV dev) 476 { 477 struct dcons_softc *dc = (struct dcons_softc *)dev->si_drv1; 478 return (dcons_os_getc(dc)); 479 } 480 static int 481 dcons_cncheckc(DEV dev) 482 { 483 struct dcons_softc *dc = (struct dcons_softc *)dev->si_drv1; 484 return (dcons_os_checkc(dc)); 485 } 486 static void 487 dcons_cnputc(DEV dev, int c) 488 { 489 struct dcons_softc *dc = (struct dcons_softc *)dev->si_drv1; 490 dcons_os_putc(dc, c); 491 } 492 #endif 493 494 static int 495 dcons_drv_init(int stage) 496 { 497 #ifdef __i386__ 498 quad_t addr, size; 499 #endif 500 501 if (drv_init) 502 return(drv_init); 503 504 drv_init = -1; 505 506 bzero(&dg, sizeof(dg)); 507 dcons_conf = &dg; 508 dg.cdev = &dcons_consdev; 509 dg.buf = NULL; 510 dg.size = DCONS_BUF_SIZE; 511 512 #ifdef __i386__ 513 if (getenv_quad("dcons.addr", &addr) > 0 && 514 getenv_quad("dcons.size", &size) > 0) { 515 vm_paddr_t pa; 516 /* 517 * Allow read/write access to dcons buffer. 518 */ 519 for (pa = trunc_page(addr); pa < addr + size; pa += PAGE_SIZE) 520 *vtopte(KERNBASE + pa) |= PG_RW; 521 cpu_invltlb(); 522 /* XXX P to V */ 523 dg.buf = (struct dcons_buf *)(vm_offset_t)(KERNBASE + addr); 524 dg.size = size; 525 if (dcons_load_buffer(dg.buf, dg.size, sc) < 0) 526 dg.buf = NULL; 527 } 528 #endif 529 if (dg.buf != NULL) 530 goto ok; 531 532 #ifndef KLD_MODULE 533 if (stage == 0) { /* XXX or cold */ 534 /* 535 * DCONS_FORCE_CONSOLE == 1 and statically linked. 536 * called from cninit(). can't use contigmalloc yet . 537 */ 538 dg.buf = (struct dcons_buf *) bssbuf; 539 dcons_init(dg.buf, dg.size, sc); 540 } else 541 #endif 542 { 543 /* 544 * DCONS_FORCE_CONSOLE == 0 or kernel module case. 545 * if the module is loaded after boot, 546 * bssbuf could be non-continuous. 547 */ 548 dg.buf = (struct dcons_buf *) contigmalloc(dg.size, 549 M_DEVBUF, 0, 0x10000, 0xffffffff, PAGE_SIZE, 0ul); 550 dcons_init(dg.buf, dg.size, sc); 551 } 552 553 ok: 554 dcons_buf = dg.buf; 555 556 #if __FreeBSD_version < 502122 557 #if DDB && DCONS_FORCE_GDB 558 #if CONS_NODEV 559 gdbconsdev.cn_arg = (void *)&sc[DCONS_GDB]; 560 #if __FreeBSD_version >= 501109 561 sprintf(gdbconsdev.cn_name, "dgdb"); 562 #endif 563 gdb_arg = &gdbconsdev; 564 #elif defined(__DragonFly__) 565 gdbdev = make_dev(&dcons_cdevsw, DCONS_GDB, 566 UID_ROOT, GID_WHEEL, 0600, "dgdb"); 567 #else 568 gdbdev = makedev(CDEV_MAJOR, DCONS_GDB); 569 #endif 570 gdb_getc = dcons_cngetc; 571 gdb_putc = dcons_cnputc; 572 #endif 573 #endif 574 drv_init = 1; 575 576 return 0; 577 } 578 579 580 static int 581 dcons_attach_port(int port, char *name, int flags) 582 { 583 struct dcons_softc *dc; 584 struct tty *tp; 585 DEV dev; 586 587 dc = &sc[port]; 588 dc->flags = flags; 589 dev = make_dev(&dcons_cdevsw, port, 590 UID_ROOT, GID_WHEEL, 0600, name); 591 dc->dev = (void *)dev; 592 tp = ttymalloc(NULL); 593 594 dev->si_drv1 = (void *)dc; 595 dev->si_tty = tp; 596 597 tp->t_oproc = dcons_tty_start; 598 tp->t_param = dcons_tty_param; 599 tp->t_stop = nottystop; 600 tp->t_dev = dc->dev; 601 602 return(0); 603 } 604 605 static int 606 dcons_attach(void) 607 { 608 int polltime; 609 610 #ifdef __DragonFly__ 611 cdevsw_add(&dcons_cdevsw, -1, 0); 612 #endif 613 dcons_attach_port(DCONS_CON, "dcons", 0); 614 dcons_attach_port(DCONS_GDB, "dgdb", DC_GDB); 615 #if __FreeBSD_version < 500000 616 callout_init(&dcons_callout); 617 #else 618 callout_init(&dcons_callout, 0); 619 #endif 620 polltime = hz / poll_hz; 621 if (polltime < 1) 622 polltime = 1; 623 callout_reset(&dcons_callout, polltime, dcons_timeout, NULL); 624 return(0); 625 } 626 627 static int 628 dcons_detach(int port) 629 { 630 struct tty *tp; 631 struct dcons_softc *dc; 632 633 dc = &sc[port]; 634 635 tp = ((DEV)dc->dev)->si_tty; 636 637 if (tp->t_state & TS_ISOPEN) { 638 printf("dcons: still opened\n"); 639 #if __FreeBSD_version < 502113 640 (*linesw[tp->t_line].l_close)(tp, 0); 641 tp->t_gen++; 642 ttyclose(tp); 643 ttwakeup(tp); 644 ttwwakeup(tp); 645 #else 646 ttyld_close(tp, 0); 647 tty_close(tp); 648 #endif 649 } 650 /* XXX 651 * must wait until all device are closed. 652 */ 653 #ifdef __DragonFly__ 654 tsleep((void *)dc, 0, "dcodtc", hz/4); 655 #else 656 tsleep((void *)dc, PWAIT, "dcodtc", hz/4); 657 #endif 658 destroy_dev(dc->dev); 659 660 return(0); 661 } 662 663 664 /* cnXXX works only for FreeBSD-5 */ 665 static int 666 dcons_modevent(module_t mode, int type, void *data) 667 { 668 int err = 0, ret; 669 670 switch (type) { 671 case MOD_LOAD: 672 ret = dcons_drv_init(1); 673 dcons_attach(); 674 #if __FreeBSD_version >= 500000 675 if (ret == 0) { 676 dcons_cnprobe(&dcons_consdev); 677 dcons_cninit(&dcons_consdev); 678 cnadd(&dcons_consdev); 679 } 680 #endif 681 break; 682 case MOD_UNLOAD: 683 printf("dcons: unload\n"); 684 callout_stop(&dcons_callout); 685 #if __FreeBSD_version < 502122 686 #if DDB && DCONS_FORCE_GDB 687 #if CONS_NODEV 688 gdb_arg = NULL; 689 #else 690 gdbdev = NULL; 691 #endif 692 #endif 693 #endif 694 #if __FreeBSD_version >= 500000 695 cnremove(&dcons_consdev); 696 #endif 697 dcons_detach(DCONS_CON); 698 dcons_detach(DCONS_GDB); 699 dg.buf->magic = 0; 700 701 contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF); 702 703 break; 704 case MOD_SHUTDOWN: 705 dg.buf->magic = 0; 706 break; 707 default: 708 err = EOPNOTSUPP; 709 break; 710 } 711 return(err); 712 } 713 714 #if __FreeBSD_version >= 502122 715 /* Debugger interface */ 716 717 static int 718 dcons_dbg_probe(void) 719 { 720 return(DCONS_FORCE_GDB); 721 } 722 723 static void 724 dcons_dbg_init(void) 725 { 726 } 727 728 static void 729 dcons_dbg_term(void) 730 { 731 } 732 733 static void 734 dcons_dbg_putc(int c) 735 { 736 struct dcons_softc *dc = &sc[DCONS_GDB]; 737 dcons_os_putc(dc, c); 738 } 739 740 static int 741 dcons_dbg_checkc(void) 742 { 743 struct dcons_softc *dc = &sc[DCONS_GDB]; 744 return (dcons_os_checkc(dc)); 745 } 746 747 static int 748 dcons_dbg_getc(void) 749 { 750 struct dcons_softc *dc = &sc[DCONS_GDB]; 751 return (dcons_os_getc(dc)); 752 } 753 #endif 754 755 DEV_MODULE(dcons, dcons_modevent, NULL); 756 MODULE_VERSION(dcons, DCONS_VERSION); 757