-/* $OpenBSD: exuart.c,v 1.4 2021/02/05 00:42:25 patrick Exp $ */
+/* $OpenBSD: exuart.c,v 1.5 2021/02/11 23:53:42 patrick Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@motorola.com>
*
/* XXX - we imitate 'com' serial ports and take over their entry points */
/* XXX: These belong elsewhere */
+cdev_decl(com);
cdev_decl(exuart);
struct cfdriver exuart_cd = {
void
exuartcnprobe(struct consdev *cp)
{
- cp->cn_dev = makedev(12 /* XXX */, 0);
- cp->cn_pri = CN_MIDPRI;
}
void
NULL, NULL, exuartcngetc, exuartcnputc, exuartcnpollc, NULL,
NODEV, CN_MIDPRI
};
+ int maj;
if (bus_space_map(iot, iobase, 0x100, 0, &exuartconsioh))
return ENOMEM;
+ /* Look for major of com(4) to replace. */
+ for (maj = 0; maj < nchrdev; maj++)
+ if (cdevsw[maj].d_open == comopen)
+ break;
+ if (maj == nchrdev)
+ return ENXIO;
+
cn_tab = &exuartcons;
- cn_tab->cn_dev = makedev(12 /* XXX */, 0);
- cdevsw[12] = exuartdev; /* KLUDGE */
+ cn_tab->cn_dev = makedev(maj, 0);
+ cdevsw[maj] = exuartdev; /* KLUDGE */
exuartconsiot = iot;
exuartconsaddr = iobase;