#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/device.h>
#include <ddb/db_var.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
#include <machine/autoconf.h>
struct pgs_softc {
struct device sc_dev;
int sc_node;
int sc_intr;
};
void pgs_attach(struct device *, struct device *, void *);
int pgs_match(struct device *, void *, void *);
int pgs_intr(void *);
const struct cfattach pgs_ca = {
sizeof(struct pgs_softc), pgs_match, pgs_attach
};
struct cfdriver pgs_cd = {
NULL, "pgs", DV_DULL
};
int
pgs_match(struct device *parent, void *arg, void *aux)
{
struct confargs *ca = aux;
char type[32];
if (strcmp(ca->ca_name, "programmer-switch") != 0)
return 0;
OF_getprop(ca->ca_node, "device_type", type, sizeof(type));
if (strcmp(type, "programmer-switch") != 0)
return 0;
return 1;
}
void
pgs_attach(struct device *parent, struct device *self, void *aux)
{
struct pgs_softc *sc = (struct pgs_softc *)self;
struct confargs *ca = aux;
int intr[2];
sc->sc_node = ca->ca_node;
OF_getprop(sc->sc_node, "interrupts", intr, sizeof(intr));
sc->sc_intr = intr[0];
printf(": irq %d\n", sc->sc_intr);
mac_intr_establish(parent, sc->sc_intr, IST_LEVEL,
IPL_HIGH, pgs_intr, sc, sc->sc_dev.dv_xname);
}
int
pgs_intr(void *v)
{
#ifdef DDB
if (db_console)
db_enter();
#else
printf("programmer-switch pressed, debugger not available.\n");
#endif
return 1;
}