1*eb7eaf8dSmpi /* $OpenBSD: cmp.c,v 1.3 2021/10/24 17:05:03 mpi Exp $ */
29079f3edSkettenis /*
39079f3edSkettenis * Copyright (c) 2008 Mark Kettenis
49079f3edSkettenis *
59079f3edSkettenis * Permission to use, copy, modify, and distribute this software for any
69079f3edSkettenis * purpose with or without fee is hereby granted, provided that the above
79079f3edSkettenis * copyright notice and this permission notice appear in all copies.
89079f3edSkettenis *
99079f3edSkettenis * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
109079f3edSkettenis * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
119079f3edSkettenis * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
129079f3edSkettenis * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
139079f3edSkettenis * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
149079f3edSkettenis * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
159079f3edSkettenis * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
169079f3edSkettenis */
179079f3edSkettenis
189079f3edSkettenis #include <sys/param.h>
199079f3edSkettenis #include <sys/device.h>
209079f3edSkettenis #include <sys/systm.h>
219079f3edSkettenis
229079f3edSkettenis #include <machine/autoconf.h>
239079f3edSkettenis #include <machine/openfirm.h>
249079f3edSkettenis
259079f3edSkettenis int cmp_match(struct device *, void *, void *);
269079f3edSkettenis void cmp_attach(struct device *, struct device *, void *);
279079f3edSkettenis
28*eb7eaf8dSmpi const struct cfattach cmp_ca = {
299079f3edSkettenis sizeof(struct device), cmp_match, cmp_attach
309079f3edSkettenis };
319079f3edSkettenis
329079f3edSkettenis struct cfdriver cmp_cd = {
339079f3edSkettenis NULL, "cmp", DV_DULL
349079f3edSkettenis };
359079f3edSkettenis
369079f3edSkettenis int cmp_print(void *, const char *);
379079f3edSkettenis
389079f3edSkettenis int
cmp_match(struct device * parent,void * match,void * aux)399079f3edSkettenis cmp_match(struct device *parent, void *match, void *aux)
409079f3edSkettenis {
419079f3edSkettenis struct mainbus_attach_args *ma = aux;
429079f3edSkettenis
439079f3edSkettenis if (strcmp(ma->ma_name, "cmp") == 0)
449079f3edSkettenis return (1);
459079f3edSkettenis
469079f3edSkettenis return (0);
479079f3edSkettenis }
489079f3edSkettenis
499079f3edSkettenis void
cmp_attach(struct device * parent,struct device * self,void * aux)509079f3edSkettenis cmp_attach(struct device *parent, struct device *self, void *aux)
519079f3edSkettenis {
529079f3edSkettenis struct mainbus_attach_args *ma = aux;
539079f3edSkettenis struct mainbus_attach_args nma;
549079f3edSkettenis char buf[32];
559079f3edSkettenis int node;
569079f3edSkettenis
579079f3edSkettenis printf("\n");
589079f3edSkettenis
599079f3edSkettenis for (node = OF_child(ma->ma_node); node; node = OF_peer(node)) {
609079f3edSkettenis if (!checkstatus(node))
619079f3edSkettenis continue;
629079f3edSkettenis
639079f3edSkettenis OF_getprop(node, "name", buf, sizeof(buf));
649079f3edSkettenis if (strcmp(buf, "cpu") == 0)
659079f3edSkettenis OF_getprop(node, "compatible", buf, sizeof(buf));
669079f3edSkettenis
679079f3edSkettenis bzero(&nma, sizeof(nma));
689079f3edSkettenis nma.ma_node = node;
699079f3edSkettenis nma.ma_name = buf;
709079f3edSkettenis config_found(self, &nma, cmp_print);
719079f3edSkettenis }
729079f3edSkettenis }
739079f3edSkettenis
749079f3edSkettenis int
cmp_print(void * aux,const char * name)759079f3edSkettenis cmp_print(void *aux, const char *name)
769079f3edSkettenis {
779079f3edSkettenis struct mainbus_attach_args *ma = aux;
789079f3edSkettenis
799079f3edSkettenis if (name)
809079f3edSkettenis printf("\"%s\" at %s", ma->ma_name, name);
819079f3edSkettenis return (UNCONF);
829079f3edSkettenis }
83