1 /* $NetBSD: platform.c,v 1.1 2001/06/13 15:08:05 soda Exp $ */ 2 3 /*- 4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by SODA Noriyuki. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #include <sys/param.h> 40 #include <sys/systm.h> 41 #include <sys/kcore.h> 42 43 #include <machine/platform.h> 44 #include <arc/arc/arcbios.h> 45 46 struct platform *platform = NULL; 47 48 void print_platform __P((struct platform *)); 49 50 void 51 print_platform(p) 52 struct platform *p; 53 { 54 printf("\"%s %s%s\" (%s, %s)", 55 p->vendor, p->model, p->variant, 56 p->vendor_id ? p->vendor_id : "NULL", 57 p->system_id); 58 } 59 60 int 61 ident_platform() 62 { 63 int i, rv, matched = -1, match = 0, ambiguous_match = 0; 64 65 for (i = 0; i < nplattab; i++) { 66 rv = (*plattab[i]->match)(plattab[i]); 67 if (rv > match) { 68 match = rv; 69 matched = i; 70 ambiguous_match = 0; 71 } else if (rv == match) { 72 ++ambiguous_match; 73 } 74 } 75 if (ambiguous_match) { 76 /* assumes that ARC Firmware printf() can be used. */ 77 printf("ambiguous platform detection between "); 78 print_platform(plattab[matched]); 79 for (i = 0; i < nplattab; i++) { 80 if (i == matched) 81 continue; 82 rv = (*plattab[i]->match)(plattab[i]); 83 if (rv < match) 84 continue; 85 if (--ambiguous_match) 86 printf(", "); 87 else 88 printf(" and "); 89 print_platform(plattab[i]); 90 } 91 printf(". "); 92 print_platform(plattab[matched]); 93 printf(" is choosed.\n"); 94 } 95 if (match) 96 platform = plattab[matched]; 97 return (match); 98 } 99 100 int 101 platform_generic_match(p) 102 struct platform *p; 103 { 104 if (strcmp(arc_id, p->system_id) == 0 && 105 (p->vendor_id == NULL || strcmp(arc_vendor_id, p->vendor_id) == 0)) 106 return (1); 107 108 return (0); 109 } 110 111 void 112 platform_nop() 113 { 114 } 115