1 /* $OpenBSD: cmp.c,v 1.2 2008/07/11 13:47:20 kettenis Exp $ */ 2 /* 3 * Copyright (c) 2008 Mark Kettenis 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #include <sys/param.h> 19 #include <sys/device.h> 20 #include <sys/systm.h> 21 22 #include <machine/autoconf.h> 23 #include <machine/openfirm.h> 24 25 int cmp_match(struct device *, void *, void *); 26 void cmp_attach(struct device *, struct device *, void *); 27 28 struct cfattach cmp_ca = { 29 sizeof(struct device), cmp_match, cmp_attach 30 }; 31 32 struct cfdriver cmp_cd = { 33 NULL, "cmp", DV_DULL 34 }; 35 36 int cmp_print(void *, const char *); 37 38 int 39 cmp_match(struct device *parent, void *match, void *aux) 40 { 41 struct mainbus_attach_args *ma = aux; 42 43 if (strcmp(ma->ma_name, "cmp") == 0) 44 return (1); 45 46 return (0); 47 } 48 49 void 50 cmp_attach(struct device *parent, struct device *self, void *aux) 51 { 52 struct mainbus_attach_args *ma = aux; 53 struct mainbus_attach_args nma; 54 char buf[32]; 55 int node; 56 57 printf("\n"); 58 59 for (node = OF_child(ma->ma_node); node; node = OF_peer(node)) { 60 if (!checkstatus(node)) 61 continue; 62 63 OF_getprop(node, "name", buf, sizeof(buf)); 64 if (strcmp(buf, "cpu") == 0) 65 OF_getprop(node, "compatible", buf, sizeof(buf)); 66 67 bzero(&nma, sizeof(nma)); 68 nma.ma_node = node; 69 nma.ma_name = buf; 70 config_found(self, &nma, cmp_print); 71 } 72 } 73 74 int 75 cmp_print(void *aux, const char *name) 76 { 77 struct mainbus_attach_args *ma = aux; 78 79 if (name) 80 printf("\"%s\" at %s", ma->ma_name, name); 81 return (UNCONF); 82 } 83