summaryrefslogtreecommitdiff
path: root/sys/arch/hp300/dev/sti_sgc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/hp300/dev/sti_sgc.c')
-rw-r--r--sys/arch/hp300/dev/sti_sgc.c108
1 files changed, 27 insertions, 81 deletions
diff --git a/sys/arch/hp300/dev/sti_sgc.c b/sys/arch/hp300/dev/sti_sgc.c
index 7e57692ae77..06302a79196 100644
--- a/sys/arch/hp300/dev/sti_sgc.c
+++ b/sys/arch/hp300/dev/sti_sgc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sti_sgc.c,v 1.5 2005/12/30 18:14:09 miod Exp $ */
+/* $OpenBSD: sti_sgc.c,v 1.6 2005/12/31 18:13:41 miod Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -35,8 +35,6 @@
#include <machine/bus.h>
#include <machine/cpu.h>
-#include <dev/cons.h>
-
#include <hp300/dev/sgcreg.h>
#include <hp300/dev/sgcvar.h>
@@ -48,8 +46,9 @@
#include <uvm/uvm_extern.h>
-int sti_sgc_match(struct device *, void *, void *);
-void sti_sgc_attach(struct device *, struct device *, void *);
+void sti_sgc_attach(struct device *, struct device *, void *);
+int sti_sgc_match(struct device *, void *, void *);
+int sti_sgc_probe(bus_space_tag_t, int);
struct cfattach sti_sgc_ca = {
sizeof(struct sti_softc), sti_sgc_match, sti_sgc_attach
@@ -60,8 +59,6 @@ sti_sgc_match(struct device *parent, void *match, void *aux)
{
struct sgc_attach_args *saa = aux;
bus_space_tag_t iot;
- bus_space_handle_t ioh;
- int devtype;
/*
* If we already probed it succesfully as a console device, go ahead,
@@ -72,24 +69,7 @@ sti_sgc_match(struct device *parent, void *match, void *aux)
iot = HP300_BUS_TAG(HP300_BUS_SGC, saa->saa_slot);
- if (bus_space_map(iot, (bus_addr_t)sgc_slottopa(saa->saa_slot),
- PAGE_SIZE, 0, &ioh))
- return (0);
-
- devtype = bus_space_read_1(iot, ioh, 3);
-
- bus_space_unmap(iot, ioh, PAGE_SIZE);
-
- /*
- * This might not be reliable enough. On the other hand, non-STI
- * SGC cards will apparently not initialize in an hp300, to the
- * point of not even answering bus probes (checked with an
- * Harmony/FDDI SGC card).
- */
- if (devtype != STI_DEVTYPE1 && devtype != STI_DEVTYPE4)
- return (0);
-
- return (1);
+ return (sti_sgc_probe(iot, saa->saa_slot));
}
void
@@ -153,85 +133,51 @@ sti_sgc_attach(struct device *parent, struct device *self, void *aux)
sti_end_attach(sc);
}
-/*
- * Console code
- */
-
-int sti_console_scan(int, caddr_t, void *);
-cons_decl(sti);
-
int
-sti_console_scan(int slot, caddr_t va, void *arg)
+sti_sgc_probe(bus_space_tag_t iot, int slot)
{
- struct consdev *cp = arg;
- bus_space_tag_t iot;
bus_space_handle_t ioh;
int devtype;
- u_int pri;
- iot = HP300_BUS_TAG(HP300_BUS_SGC, slot);
-
- if (bus_space_map(iot, (bus_addr_t)sgc_slottopa(slot), PAGE_SIZE, 0,
- &ioh))
+ if (bus_space_map(iot, (bus_addr_t)sgc_slottopa(slot),
+ PAGE_SIZE, 0, &ioh))
return (0);
devtype = bus_space_read_1(iot, ioh, 3);
bus_space_unmap(iot, ioh, PAGE_SIZE);
- /* XXX this is not reliable enough */
- if (devtype != STI_DEVTYPE1 && devtype != STI_DEVTYPE4)
- return (0);
-
- pri = CN_INTERNAL;
-
-#ifdef CONSCODE
- /*
- * Raise our priority, if appropriate.
- */
- if (SGC_SLOT_TO_CONSCODE(slot) == CONSCODE)
- pri = CN_FORCED;
-#endif
-
- /* Only raise priority. */
- if (pri > cp->cn_pri)
- cp->cn_pri = pri;
-
/*
- * If our priority is higher than the currently-remembered
- * console, stash our priority.
+ * This might not be reliable enough. On the other hand, non-STI
+ * SGC cards will apparently not initialize in an hp300, to the
+ * point of not even answering bus probes (checked with an
+ * Harmony/FDDI SGC card).
*/
- if (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri) {
- cn_tab = cp;
- conscode = SGC_SLOT_TO_CONSCODE(slot);
- return (1);
- }
+ if (devtype != STI_DEVTYPE1 && devtype != STI_DEVTYPE4)
+ return (0);
- return (0);
+ return (1);
}
-void
-sticnprobe(struct consdev *cp)
-{
- int maj;
+/*
+ * Console code
+ */
- for (maj = 0; maj < nchrdev; maj++) {
- if (cdevsw[maj].d_open == wsdisplayopen)
- break;
- }
+int sti_console_scan(int);
+void sticninit(void);
- if (maj == nchrdev)
- return;
+int
+sti_console_scan(int slot)
+{
+ bus_space_tag_t iot;
- cp->cn_dev = makedev(maj, 0);
- cp->cn_pri = CN_DEAD;
+ iot = HP300_BUS_TAG(HP300_BUS_SGC, slot);
- /* Search for an sti device */
- console_scan(sti_console_scan, cp, HP300_BUS_SGC);
+ return (sti_sgc_probe(iot, slot));
}
void
-sticninit(struct consdev *cp)
+sticninit()
{
extern struct sti_screen stifb_cn;
bus_space_tag_t iot;