Deleted Added
full compact
dcons.c (130640) dcons.c (131912)
1/*
2 * Copyright (C) 2003
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

--- 18 unchanged lines hidden (view full) ---

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 * $Id: dcons.c,v 1.65 2003/10/24 03:24:55 simokawa Exp $
1/*
2 * Copyright (C) 2003
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

--- 18 unchanged lines hidden (view full) ---

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 * $Id: dcons.c,v 1.65 2003/10/24 03:24:55 simokawa Exp $
35 * $FreeBSD: head/sys/dev/dcons/dcons.c 130640 2004-06-17 17:16:53Z phk $
35 * $FreeBSD: head/sys/dev/dcons/dcons.c 131912 2004-07-10 21:02:17Z marcel $
36 */
37
38#include <sys/param.h>
36 */
37
38#include <sys/param.h>
39#include <sys/kdb.h>
39#include <sys/kernel.h>
40#include <sys/module.h>
41#include <sys/systm.h>
42#include <sys/types.h>
43#include <sys/conf.h>
44#include <sys/cons.h>
45#include <sys/consio.h>
46#include <sys/tty.h>

--- 21 unchanged lines hidden (view full) ---

68#ifndef DCONS_BUF_SIZE
69#define DCONS_BUF_SIZE (16*1024)
70#endif
71
72#ifndef DCONS_FORCE_CONSOLE
73#define DCONS_FORCE_CONSOLE 0 /* mostly for FreeBSD-4 */
74#endif
75
40#include <sys/kernel.h>
41#include <sys/module.h>
42#include <sys/systm.h>
43#include <sys/types.h>
44#include <sys/conf.h>
45#include <sys/cons.h>
46#include <sys/consio.h>
47#include <sys/tty.h>

--- 21 unchanged lines hidden (view full) ---

69#ifndef DCONS_BUF_SIZE
70#define DCONS_BUF_SIZE (16*1024)
71#endif
72
73#ifndef DCONS_FORCE_CONSOLE
74#define DCONS_FORCE_CONSOLE 0 /* mostly for FreeBSD-4 */
75#endif
76
76#ifndef DCONS_FORCE_GDB
77#define DCONS_FORCE_GDB 1
78#endif
79
80#if __FreeBSD_version >= 500101
81#define CONS_NODEV 1 /* for latest current */
77#if __FreeBSD_version >= 500101
78#define CONS_NODEV 1 /* for latest current */
82static struct consdev gdbconsdev;
83#endif
84
85
86static d_open_t dcons_open;
87static d_close_t dcons_close;
88
89static struct cdevsw dcons_cdevsw = {
90#if __FreeBSD_version >= 500104

--- 36 unchanged lines hidden (view full) ---

127static struct callout dcons_callout;
128struct dcons_buf *dcons_buf; /* for local dconschat */
129
130/* per device data */
131static struct dcons_softc {
132 struct cdev *dev;
133 struct dcons_ch o, i;
134 int brk_state;
79#endif
80
81
82static d_open_t dcons_open;
83static d_close_t dcons_close;
84
85static struct cdevsw dcons_cdevsw = {
86#if __FreeBSD_version >= 500104

--- 36 unchanged lines hidden (view full) ---

123static struct callout dcons_callout;
124struct dcons_buf *dcons_buf; /* for local dconschat */
125
126/* per device data */
127static struct dcons_softc {
128 struct cdev *dev;
129 struct dcons_ch o, i;
130 int brk_state;
135#define DC_GDB 1
136 int flags;
137} sc[DCONS_NPORT];
138static void dcons_tty_start(struct tty *);
139static int dcons_tty_param(struct tty *, struct termios *);
140static void dcons_timeout(void *);
141static int dcons_drv_init(int);
142static int dcons_getc(struct dcons_softc *);
143static int dcons_checkc(struct dcons_softc *);

--- 224 unchanged lines hidden (view full) ---

368
369 c = ch->buf[ch->pos];
370 ch->pos ++;
371 if (ch->pos >= ch->size) {
372 ch->gen = next_gen;
373 ch->pos = 0;
374 }
375
131 int flags;
132} sc[DCONS_NPORT];
133static void dcons_tty_start(struct tty *);
134static int dcons_tty_param(struct tty *, struct termios *);
135static void dcons_timeout(void *);
136static int dcons_drv_init(int);
137static int dcons_getc(struct dcons_softc *);
138static int dcons_checkc(struct dcons_softc *);

--- 224 unchanged lines hidden (view full) ---

363
364 c = ch->buf[ch->pos];
365 ch->pos ++;
366 if (ch->pos >= ch->size) {
367 ch->gen = next_gen;
368 ch->pos = 0;
369 }
370
376#if DDB && ALT_BREAK_TO_DEBUGGER
377 switch (dc->brk_state) {
378 case STATE1:
379 if (c == KEY_TILDE)
380 dc->brk_state = STATE2;
381 else
382 dc->brk_state = STATE0;
383 break;
384 case STATE2:
385 dc->brk_state = STATE0;
386 if (c == KEY_CTRLB) {
387#if DCONS_FORCE_GDB
388 if (dc->flags & DC_GDB)
389 boothowto |= RB_GDB;
371#if KDB && ALT_BREAK_TO_DEBUGGER
372 if (kdb_alt_break(c, &dc->brk_state))
373 breakpoint();
390#endif
374#endif
391 breakpoint();
392 }
393 }
394 if (c == KEY_CR)
395 dc->brk_state = STATE1;
396#endif
397 return (c);
398}
399
400static void
401dcons_putc(struct dcons_softc *dc, int c)
402{
403 struct dcons_ch *ch;
404

--- 76 unchanged lines hidden (view full) ---

481 size = (dg.size - offset);
482 size0 = size * 3 / 4;
483
484 dcons_init_port(0, offset, size0);
485 offset += size0;
486 dcons_init_port(1, offset, size - size0);
487 dg.buf->version = htonl(DCONS_VERSION);
488 dg.buf->magic = ntohl(DCONS_MAGIC);
375 return (c);
376}
377
378static void
379dcons_putc(struct dcons_softc *dc, int c)
380{
381 struct dcons_ch *ch;
382

--- 76 unchanged lines hidden (view full) ---

459 size = (dg.size - offset);
460 size0 = size * 3 / 4;
461
462 dcons_init_port(0, offset, size0);
463 offset += size0;
464 dcons_init_port(1, offset, size - size0);
465 dg.buf->version = htonl(DCONS_VERSION);
466 dg.buf->magic = ntohl(DCONS_MAGIC);
489
490#if DDB && DCONS_FORCE_GDB
491#if CONS_NODEV
492 gdbconsdev.cn_arg = (void *)&sc[DCONS_GDB];
493#if __FreeBSD_version >= 501109
494 sprintf(gdbconsdev.cn_name, "dgdb");
495#endif
496 gdb_arg = &gdbconsdev;
497#else
498 gdbdev = makedev(CDEV_MAJOR, DCONS_GDB);
499#endif
500 gdb_getc = dcons_cngetc;
501 gdb_putc = dcons_cnputc;
502#endif
503 drv_init = 1;
504
505 return 0;
506}
507
508
509static int
510dcons_attach_port(int port, char *name, int flags)

--- 19 unchanged lines hidden (view full) ---

530}
531
532static int
533dcons_attach(void)
534{
535 int polltime;
536
537 dcons_attach_port(DCONS_CON, "dcons", 0);
467 drv_init = 1;
468
469 return 0;
470}
471
472
473static int
474dcons_attach_port(int port, char *name, int flags)

--- 19 unchanged lines hidden (view full) ---

494}
495
496static int
497dcons_attach(void)
498{
499 int polltime;
500
501 dcons_attach_port(DCONS_CON, "dcons", 0);
538 dcons_attach_port(DCONS_GDB, "dgdb", DC_GDB);
539#if __FreeBSD_version < 500000
540 callout_init(&dcons_callout);
541#else
542 callout_init(&dcons_callout, 0);
543#endif
544 polltime = hz / poll_hz;
545 if (polltime < 1)
546 polltime = 1;

--- 42 unchanged lines hidden (view full) ---

589 dcons_cninit(&dcons_consdev);
590 cnadd(&dcons_consdev);
591 }
592#endif
593 break;
594 case MOD_UNLOAD:
595 printf("dcons: unload\n");
596 callout_stop(&dcons_callout);
502#if __FreeBSD_version < 500000
503 callout_init(&dcons_callout);
504#else
505 callout_init(&dcons_callout, 0);
506#endif
507 polltime = hz / poll_hz;
508 if (polltime < 1)
509 polltime = 1;

--- 42 unchanged lines hidden (view full) ---

552 dcons_cninit(&dcons_consdev);
553 cnadd(&dcons_consdev);
554 }
555#endif
556 break;
557 case MOD_UNLOAD:
558 printf("dcons: unload\n");
559 callout_stop(&dcons_callout);
597#if DDB && DCONS_FORCE_GDB
598#if CONS_NODEV
599 gdb_arg = NULL;
600#else
601 gdbdev = NULL;
602#endif
603#endif
604#if __FreeBSD_version >= 500000
605 cnremove(&dcons_consdev);
606#endif
607 dcons_detach(DCONS_CON);
560#if __FreeBSD_version >= 500000
561 cnremove(&dcons_consdev);
562#endif
563 dcons_detach(DCONS_CON);
608 dcons_detach(DCONS_GDB);
609 dg.buf->magic = 0;
610
611 contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF);
612
613 break;
614 case MOD_SHUTDOWN:
615 break;
616 }
617 return(err);
618}
619
620DEV_MODULE(dcons, dcons_modevent, NULL);
621MODULE_VERSION(dcons, DCONS_VERSION);
564 dg.buf->magic = 0;
565
566 contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF);
567
568 break;
569 case MOD_SHUTDOWN:
570 break;
571 }
572 return(err);
573}
574
575DEV_MODULE(dcons, dcons_modevent, NULL);
576MODULE_VERSION(dcons, DCONS_VERSION);