Blame view
arch/sparc/kernel/idprom.c
2.89 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
88278ca27 sparc: remove CVS... |
2 |
/* |
1da177e4c Linux-2.6.12-rc2 |
3 4 5 6 7 |
* idprom.c: Routines to load the idprom into kernel addresses and * interpret the data contained within. * * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) */ |
1da177e4c Linux-2.6.12-rc2 |
8 9 10 |
#include <linux/kernel.h> #include <linux/types.h> #include <linux/init.h> |
066bcaca5 sparc: move symbo... |
11 |
#include <linux/export.h> |
c7f5d1054 net: Add eth_plat... |
12 |
#include <linux/etherdevice.h> |
1da177e4c Linux-2.6.12-rc2 |
13 14 15 |
#include <asm/oplib.h> #include <asm/idprom.h> |
1da177e4c Linux-2.6.12-rc2 |
16 17 |
struct idprom *idprom; |
6943f3da3 sparc: move EXPOR... |
18 |
EXPORT_SYMBOL(idprom); |
1da177e4c Linux-2.6.12-rc2 |
19 |
static struct idprom idprom_buffer; |
680e58f80 sparc: unify kern... |
20 |
#ifdef CONFIG_SPARC32 |
7d3a70012 sparc: idprom_32.... |
21 |
#include <asm/machines.h> /* Fun with Sun released architectures. */ |
1da177e4c Linux-2.6.12-rc2 |
22 23 24 25 |
/* Here is the master table of Sun machines which use some implementation * of the Sparc CPU and have a meaningful IDPROM machtype value that we * know about. See asm-sparc/machines.h for empirical constants. */ |
58fa4dcbc sparc: Clear out ... |
26 27 |
static struct Sun_Machine_Models Sun_Machines[] = { /* First, Leon */ |
0fd7ef1fe sparc,leon: Intro... |
28 |
{ .name = "Leon3 System-on-a-Chip", .id_machtype = (M_LEON | M_LEON3_SOC) }, |
1da177e4c Linux-2.6.12-rc2 |
29 |
/* Finally, early Sun4m's */ |
7d3a70012 sparc: idprom_32.... |
30 31 32 |
{ .name = "Sun4m SparcSystem600", .id_machtype = (SM_SUN4M | SM_4M_SS60) }, { .name = "Sun4m SparcStation10/20", .id_machtype = (SM_SUN4M | SM_4M_SS50) }, { .name = "Sun4m SparcStation5", .id_machtype = (SM_SUN4M | SM_4M_SS40) }, |
1da177e4c Linux-2.6.12-rc2 |
33 |
/* One entry for the OBP arch's which are sun4d, sun4e, and newer sun4m's */ |
7d3a70012 sparc: idprom_32.... |
34 |
{ .name = "Sun4M OBP based system", .id_machtype = (SM_SUN4M_OBP | 0x0) } }; |
1da177e4c Linux-2.6.12-rc2 |
35 36 37 38 39 |
static void __init display_system_type(unsigned char machtype) { char sysname[128]; register int i; |
58fa4dcbc sparc: Clear out ... |
40 |
for (i = 0; i < ARRAY_SIZE(Sun_Machines); i++) { |
7d3a70012 sparc: idprom_32.... |
41 |
if (Sun_Machines[i].id_machtype == machtype) { |
1da177e4c Linux-2.6.12-rc2 |
42 43 44 |
if (machtype != (SM_SUN4M_OBP | 0x00) || prom_getproperty(prom_root_node, "banner-name", sysname, sizeof(sysname)) <= 0) |
7d3a70012 sparc: idprom_32.... |
45 46 47 |
printk(KERN_WARNING "TYPE: %s ", Sun_Machines[i].name); |
1da177e4c Linux-2.6.12-rc2 |
48 |
else |
7d3a70012 sparc: idprom_32.... |
49 50 |
printk(KERN_WARNING "TYPE: %s ", sysname); |
1da177e4c Linux-2.6.12-rc2 |
51 52 53 |
return; } } |
7d3a70012 sparc: idprom_32.... |
54 55 |
prom_printf("IDPROM: Warning, bogus id_machtype value, 0x%x ", machtype); |
1da177e4c Linux-2.6.12-rc2 |
56 |
} |
680e58f80 sparc: unify kern... |
57 58 59 60 61 |
#else static void __init display_system_type(unsigned char machtype) { } #endif |
c7f5d1054 net: Add eth_plat... |
62 63 64 65 66 |
unsigned char *arch_get_platform_mac_address(void) { return idprom->id_ethaddr; } |
1da177e4c Linux-2.6.12-rc2 |
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
/* Calculate the IDPROM checksum (xor of the data bytes). */ static unsigned char __init calc_idprom_cksum(struct idprom *idprom) { unsigned char cksum, i, *ptr = (unsigned char *)idprom; for (i = cksum = 0; i <= 0x0E; i++) cksum ^= *ptr++; return cksum; } /* Create a local IDPROM copy, verify integrity, and display information. */ void __init idprom_init(void) { prom_get_idprom((char *) &idprom_buffer, sizeof(idprom_buffer)); idprom = &idprom_buffer; |
680e58f80 sparc: unify kern... |
84 |
if (idprom->id_format != 0x01) |
7d3a70012 sparc: idprom_32.... |
85 86 |
prom_printf("IDPROM: Warning, unknown format type! "); |
1da177e4c Linux-2.6.12-rc2 |
87 |
|
680e58f80 sparc: unify kern... |
88 |
if (idprom->id_cksum != calc_idprom_cksum(idprom)) |
7d3a70012 sparc: idprom_32.... |
89 90 |
prom_printf("IDPROM: Warning, checksum failure (nvram=%x, calc=%x)! ", |
1da177e4c Linux-2.6.12-rc2 |
91 |
idprom->id_cksum, calc_idprom_cksum(idprom)); |
1da177e4c Linux-2.6.12-rc2 |
92 93 |
display_system_type(idprom->id_machtype); |
e3c6d4ee5 Merge branch 'mas... |
94 95 |
printk(KERN_WARNING "Ethernet address: %pM ", idprom->id_ethaddr); |
1da177e4c Linux-2.6.12-rc2 |
96 |
} |