1
2
3
4
5
6
7
8
9#include <linux/module.h>
10#include <linux/kernel.h>
11#include <linux/types.h>
12#include <linux/init.h>
13#include <linux/string.h>
14
15#include <asm/oplib.h>
16#include <asm/idprom.h>
17#include <asm/machines.h>
18
19struct idprom *idprom;
20EXPORT_SYMBOL(idprom);
21
22static struct idprom idprom_buffer;
23
24
25
26
27
28static struct Sun_Machine_Models Sun_Machines[NUM_SUN_MACHINES] = {
29
30 { .name = "Sun 3/160 Series", .id_machtype = (SM_SUN3 | SM_3_160) },
31 { .name = "Sun 3/50", .id_machtype = (SM_SUN3 | SM_3_50) },
32 { .name = "Sun 3/260 Series", .id_machtype = (SM_SUN3 | SM_3_260) },
33 { .name = "Sun 3/110 Series", .id_machtype = (SM_SUN3 | SM_3_110) },
34 { .name = "Sun 3/60", .id_machtype = (SM_SUN3 | SM_3_60) },
35 { .name = "Sun 3/E", .id_machtype = (SM_SUN3 | SM_3_E) },
36
37 { .name = "Sun 3/460 Series", .id_machtype = (SM_SUN3X | SM_3_460) },
38 { .name = "Sun 3/80", .id_machtype = (SM_SUN3X | SM_3_80) },
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58};
59
60static void __init display_system_type(unsigned char machtype)
61{
62 register int i;
63
64 for (i = 0; i < NUM_SUN_MACHINES; i++) {
65 if(Sun_Machines[i].id_machtype == machtype) {
66 if (machtype != (SM_SUN4M_OBP | 0x00))
67 printk("TYPE: %s\n", Sun_Machines[i].name);
68 else {
69#if 0
70 prom_getproperty(prom_root_node, "banner-name",
71 sysname, sizeof(sysname));
72 printk("TYPE: %s\n", sysname);
73#endif
74 }
75 return;
76 }
77 }
78
79 prom_printf("IDPROM: Bogus id_machtype value, 0x%x\n", machtype);
80 prom_halt();
81}
82
83void sun3_get_model(unsigned char* model)
84{
85 register int i;
86
87 for (i = 0; i < NUM_SUN_MACHINES; i++) {
88 if(Sun_Machines[i].id_machtype == idprom->id_machtype) {
89 strcpy(model, Sun_Machines[i].name);
90 return;
91 }
92 }
93}
94
95
96
97
98static unsigned char __init calc_idprom_cksum(struct idprom *idprom)
99{
100 unsigned char cksum, i, *ptr = (unsigned char *)idprom;
101
102 for (i = cksum = 0; i <= 0x0E; i++)
103 cksum ^= *ptr++;
104
105 return cksum;
106}
107
108
109void __init idprom_init(void)
110{
111 prom_get_idprom((char *) &idprom_buffer, sizeof(idprom_buffer));
112
113 idprom = &idprom_buffer;
114
115 if (idprom->id_format != 0x01) {
116 prom_printf("IDPROM: Unknown format type!\n");
117 prom_halt();
118 }
119
120 if (idprom->id_cksum != calc_idprom_cksum(idprom)) {
121 prom_printf("IDPROM: Checksum failure (nvram=%x, calc=%x)!\n",
122 idprom->id_cksum, calc_idprom_cksum(idprom));
123 prom_halt();
124 }
125
126 display_system_type(idprom->id_machtype);
127
128 printk("Ethernet address: %x:%x:%x:%x:%x:%x\n",
129 idprom->id_ethaddr[0], idprom->id_ethaddr[1],
130 idprom->id_ethaddr[2], idprom->id_ethaddr[3],
131 idprom->id_ethaddr[4], idprom->id_ethaddr[5]);
132}
133