~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/m68k/sun3/idprom.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * idprom.c: Routines to load the idprom into kernel addresses and
  4  *           interpret the data contained within.
  5  *
  6  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  7  * Sun3/3x models added by David Monro (davidm@psrg.cs.usyd.edu.au)
  8  */
  9 
 10 #include <linux/module.h>
 11 #include <linux/kernel.h>
 12 #include <linux/types.h>
 13 #include <linux/init.h>
 14 #include <linux/string.h>
 15 
 16 #include <asm/oplib.h>
 17 #include <asm/idprom.h>
 18 #include <asm/machines.h>  /* Fun with Sun released architectures. */
 19 
 20 #include "sun3.h"
 21 
 22 struct idprom *idprom;
 23 EXPORT_SYMBOL(idprom);
 24 
 25 static struct idprom idprom_buffer;
 26 
 27 /* Here is the master table of Sun machines which use some implementation
 28  * of the Sparc CPU and have a meaningful IDPROM machtype value that we
 29  * know about.  See asm-sparc/machines.h for empirical constants.
 30  */
 31 static struct Sun_Machine_Models Sun_Machines[NUM_SUN_MACHINES] = {
 32 /* First, Sun3's */
 33     { .name = "Sun 3/160 Series",       .id_machtype = (SM_SUN3 | SM_3_160) },
 34     { .name = "Sun 3/50",               .id_machtype = (SM_SUN3 | SM_3_50) },
 35     { .name = "Sun 3/260 Series",       .id_machtype = (SM_SUN3 | SM_3_260) },
 36     { .name = "Sun 3/110 Series",       .id_machtype = (SM_SUN3 | SM_3_110) },
 37     { .name = "Sun 3/60",               .id_machtype = (SM_SUN3 | SM_3_60) },
 38     { .name = "Sun 3/E",                .id_machtype = (SM_SUN3 | SM_3_E) },
 39 /* Now, Sun3x's */
 40     { .name = "Sun 3/460 Series",       .id_machtype = (SM_SUN3X | SM_3_460) },
 41     { .name = "Sun 3/80",               .id_machtype = (SM_SUN3X | SM_3_80) },
 42 /* Then, Sun4's */
 43 // { .name = "Sun 4/100 Series",        .id_machtype = (SM_SUN4 | SM_4_110) },
 44 // { .name = "Sun 4/200 Series",        .id_machtype = (SM_SUN4 | SM_4_260) },
 45 // { .name = "Sun 4/300 Series",        .id_machtype = (SM_SUN4 | SM_4_330) },
 46 // { .name = "Sun 4/400 Series",        .id_machtype = (SM_SUN4 | SM_4_470) },
 47 /* And now, Sun4c's */
 48 // { .name = "Sun4c SparcStation 1",    .id_machtype = (SM_SUN4C | SM_4C_SS1) },
 49 // { .name = "Sun4c SparcStation IPC",  .id_machtype = (SM_SUN4C | SM_4C_IPC) },
 50 // { .name = "Sun4c SparcStation 1+",   .id_machtype = (SM_SUN4C | SM_4C_SS1PLUS) },
 51 // { .name = "Sun4c SparcStation SLC",  .id_machtype = (SM_SUN4C | SM_4C_SLC) },
 52 // { .name = "Sun4c SparcStation 2",    .id_machtype = (SM_SUN4C | SM_4C_SS2) },
 53 // { .name = "Sun4c SparcStation ELC",  .id_machtype = (SM_SUN4C | SM_4C_ELC) },
 54 // { .name = "Sun4c SparcStation IPX",  .id_machtype = (SM_SUN4C | SM_4C_IPX) },
 55 /* Finally, early Sun4m's */
 56 // { .name = "Sun4m SparcSystem600",    .id_machtype = (SM_SUN4M | SM_4M_SS60) },
 57 // { .name = "Sun4m SparcStation10/20", .id_machtype = (SM_SUN4M | SM_4M_SS50) },
 58 // { .name = "Sun4m SparcStation5",     .id_machtype = (SM_SUN4M | SM_4M_SS40) },
 59 /* One entry for the OBP arch's which are sun4d, sun4e, and newer sun4m's */
 60 // { .name = "Sun4M OBP based system",  .id_machtype = (SM_SUN4M_OBP | 0x0) }
 61 };
 62 
 63 static void __init display_system_type(unsigned char machtype)
 64 {
 65         register int i;
 66 
 67         for (i = 0; i < NUM_SUN_MACHINES; i++) {
 68                 if(Sun_Machines[i].id_machtype == machtype) {
 69                         if (machtype != (SM_SUN4M_OBP | 0x00))
 70                                 pr_info("TYPE: %s\n", Sun_Machines[i].name);
 71                         else {
 72 #if 0
 73                                 char sysname[128];
 74 
 75                                 prom_getproperty(prom_root_node, "banner-name",
 76                                                  sysname, sizeof(sysname));
 77                                 pr_info("TYPE: %s\n", sysname);
 78 #endif
 79                         }
 80                         return;
 81                 }
 82         }
 83 
 84         prom_printf("IDPROM: Bogus id_machtype value, 0x%x\n", machtype);
 85         prom_halt();
 86 }
 87 
 88 void sun3_get_model(char *model)
 89 {
 90         register int i;
 91 
 92         for (i = 0; i < NUM_SUN_MACHINES; i++) {
 93                 if(Sun_Machines[i].id_machtype == idprom->id_machtype) {
 94                         strcpy(model, Sun_Machines[i].name);
 95                         return;
 96                 }
 97         }
 98 }
 99 
100 
101 
102 /* Calculate the IDPROM checksum (xor of the data bytes). */
103 static unsigned char __init calc_idprom_cksum(struct idprom *idprom)
104 {
105         unsigned char cksum, i, *ptr = (unsigned char *)idprom;
106 
107         for (i = cksum = 0; i <= 0x0E; i++)
108                 cksum ^= *ptr++;
109 
110         return cksum;
111 }
112 
113 /* Create a local IDPROM copy, verify integrity, and display information. */
114 void __init idprom_init(void)
115 {
116         prom_get_idprom((char *) &idprom_buffer, sizeof(idprom_buffer));
117 
118         idprom = &idprom_buffer;
119 
120         if (idprom->id_format != 0x01)  {
121                 prom_printf("IDPROM: Unknown format type!\n");
122                 prom_halt();
123         }
124 
125         if (idprom->id_cksum != calc_idprom_cksum(idprom)) {
126                 prom_printf("IDPROM: Checksum failure (nvram=%x, calc=%x)!\n",
127                             idprom->id_cksum, calc_idprom_cksum(idprom));
128                 prom_halt();
129         }
130 
131         display_system_type(idprom->id_machtype);
132 
133         pr_info("Ethernet address: %pM\n", idprom->id_ethaddr);
134 }
135 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php