Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ofw/ofw_console.c
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | if (ofw_consdev.cn_pri != CN_DEAD && | ||||
* XXX: devices on platforms where the sab driver works. | * XXX: devices on platforms where the sab driver works. | ||||
*/ | */ | ||||
if ((options = OF_finddevice("/options")) == -1 || | if ((options = OF_finddevice("/options")) == -1 || | ||||
OF_getprop(options, "output-device", output, | OF_getprop(options, "output-device", output, | ||||
sizeof(output)) == -1) | sizeof(output)) == -1) | ||||
return; | return; | ||||
if (strlen(output) > 0) | if (strlen(output) > 0) | ||||
tty_makealias(tp, "%s", output); | tty_makealias(tp, "%s", output); | ||||
callout_init_mtx(&ofw_timer, tty_getlock(tp), 0); | callout_init_mtx(&ofw_timer, ttydisc_getlock(tp), 0); | ||||
} | } | ||||
} | } | ||||
SYSINIT(cndev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, cn_drvinit, NULL); | SYSINIT(cndev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, cn_drvinit, NULL); | ||||
static pcell_t stdin; | static pcell_t stdin; | ||||
static pcell_t stdout; | static pcell_t stdout; | ||||
static int | static int | ||||
ofwtty_open(struct tty *tp) | ofwtty_open(struct tty *tp) | ||||
{ | { | ||||
ttydisc_assert_locked(tp); | |||||
polltime = hz / OFWCONS_POLL_HZ; | polltime = hz / OFWCONS_POLL_HZ; | ||||
if (polltime < 1) | if (polltime < 1) | ||||
polltime = 1; | polltime = 1; | ||||
callout_reset(&ofw_timer, polltime, ofw_timeout, tp); | callout_reset(&ofw_timer, polltime, ofw_timeout, tp); | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
ofwtty_close(struct tty *tp) | ofwtty_close(struct tty *tp) | ||||
{ | { | ||||
ttydisc_assert_locked(tp); | |||||
callout_stop(&ofw_timer); | callout_stop(&ofw_timer); | ||||
} | } | ||||
static void | static void | ||||
ofwtty_outwakeup(struct tty *tp) | ofwtty_outwakeup(struct tty *tp) | ||||
{ | { | ||||
int len; | int len; | ||||
u_char buf[OFBURSTLEN]; | u_char buf[OFBURSTLEN]; | ||||
ttydisc_assert_locked(tp); | |||||
for (;;) { | for (;;) { | ||||
len = ttydisc_getc(tp, buf, sizeof buf); | len = ttydisc_getc(tp, buf, sizeof buf); | ||||
if (len == 0) | if (len == 0) | ||||
break; | break; | ||||
OF_write(stdout, buf, len); | OF_write(stdout, buf, len); | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
ofw_timeout(void *v) | ofw_timeout(void *v) | ||||
{ | { | ||||
struct tty *tp; | struct tty *tp; | ||||
int c; | int c; | ||||
tp = (struct tty *)v; | tp = (struct tty *)v; | ||||
tty_assert_locked(tp); | ttydisc_assert_locked(tp); | ||||
while ((c = ofw_cngetc(NULL)) != -1) | while ((c = ofw_cngetc(NULL)) != -1) | ||||
ttydisc_rint(tp, c, 0); | ttydisc_rint(tp, c, 0); | ||||
ttydisc_rint_done(tp); | ttydisc_rint_done(tp); | ||||
callout_schedule(&ofw_timer, polltime); | callout_schedule(&ofw_timer, polltime); | ||||
} | } | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |