patch-2.1.9 linux/arch/sparc/kernel/idprom.c
Next file: linux/arch/sparc/kernel/ioport.c
Previous file: linux/arch/sparc/kernel/head.S
Back to the patch index
Back to the overall index
- Lines: 190
- Date:
Sat Nov 9 10:11:39 1996
- Orig file:
v2.1.8/linux/arch/sparc/kernel/idprom.c
- Orig date:
Thu Apr 25 13:22:05 1996
diff -u --recursive --new-file v2.1.8/linux/arch/sparc/kernel/idprom.c linux/arch/sparc/kernel/idprom.c
@@ -1,10 +1,7 @@
-/* $Id: idprom.c,v 1.19 1996/04/25 06:08:41 davem Exp $
+/* $Id: idprom.c,v 1.21 1996/10/12 13:12:48 davem Exp $
* idprom.c: Routines to load the idprom into kernel addresses and
* interpret the data contained within.
*
- * Because they use the IDPROM's machine type field, some of the
- * virtual address cache probings on the sun4c are done here.
- *
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
*/
@@ -14,10 +11,9 @@
#include <asm/oplib.h>
#include <asm/idprom.h>
#include <asm/machines.h> /* Fun with Sun released architectures. */
-#include <asm/system.h> /* For halt() macro */
-struct idp_struct *idprom;
-static struct idp_struct idprom_buff;
+struct idprom *idprom;
+static struct idprom idprom_buffer;
/* 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
@@ -44,127 +40,61 @@
/* One entry for the OBP arch's which are sun4d, sun4e, and newer sun4m's */
{ "Sun4M OBP based system", (SM_SUN4M_OBP | 0x0) } };
-void
-sparc_display_systype(unsigned char machtyp)
+static void display_system_type(unsigned char machtype)
{
- char system_name[128];
- int i;
+ char sysname[128];
+ register int i;
- for(i = 0; i<NUM_SUN_MACHINES; i++) {
- if(Sun_Machines[i].id_machtype == machtyp) {
- if(machtyp!=(SM_SUN4M_OBP | 0x0)) {
+ for (i = 0; i < NUM_SUN_MACHINES; i++) {
+ if(Sun_Machines[i].id_machtype == machtype) {
+ if (machtype != (SM_SUN4M_OBP | 0x00))
printk("TYPE: %s\n", Sun_Machines[i].name);
- break;
- } else {
+ else {
prom_getproperty(prom_root_node, "banner-name",
- system_name, sizeof(system_name));
- printk("TYPE: %s\n", system_name);
- break;
+ sysname, sizeof(sysname));
+ printk("TYPE: %s\n", sysname);
}
+ return;
}
}
- if(i == NUM_SUN_MACHINES)
- printk("Uh oh, IDPROM had bogus id_machtype value <%x>\n", machtyp);
- return;
-}
-
-void
-get_idprom(void)
-{
- prom_getidp((char *) &idprom_buff, sizeof(idprom_buff));
-
- idprom = &idprom_buff;
- sparc_display_systype(idprom->id_machtype);
-
- printk("Ethernet address: %x:%x:%x:%x:%x:%x\n",
- idprom->id_eaddr[0], idprom->id_eaddr[1], idprom->id_eaddr[2],
- idprom->id_eaddr[3], idprom->id_eaddr[4], idprom->id_eaddr[5]);
-
- return;
+ prom_printf("IDPROM: Bogus id_machtype value, 0x%x\n", machtype);
+ prom_halt();
}
-/* find_vac_size() returns the number of bytes in the VAC (virtual
- * address cache) on this machine.
- */
-
-int
-find_vac_size(void)
+/* Calculate the IDPROM checksum (xor of the data bytes). */
+static unsigned char calc_idprom_cksum(struct idprom *idprom)
{
- int vac_prop_len;
- int vacsize = 0;
+ unsigned char cksum, i, *ptr = (unsigned char *)idprom;
- vac_prop_len = prom_getproplen(prom_root_node, "vac-size");
- if(vac_prop_len != -1) {
- vacsize = prom_getint(prom_root_node, "vac-size");
- return vacsize;
- } else {
- switch(idprom->id_machtype) {
- case (SM_SUN4C | SM_4C_SS1): /* SparcStation1 */
- case (SM_SUN4C | SM_4C_IPC): /* SparcStation IPX */
- case (SM_SUN4C | SM_4C_SS1PLUS): /* SparcStation1+ */
- case (SM_SUN4C | SM_4C_SLC): /* SparcStation SLC */
- case (SM_SUN4C | SM_4C_SS2): /* SparcStation2 Cache-Chip BUG! */
- case (SM_SUN4C | SM_4C_ELC): /* SparcStation ELC */
- case (SM_SUN4C | SM_4C_IPX): /* SparcStation IPX */
- return 65536;
- default:
- printk("find_vac_size: Can't determine size of VAC, bailing out...\n");
- halt();
- break;
- };
- };
- return -1;
-}
+ for (i = cksum = 0; i <= 0x0E; i++)
+ cksum ^= *ptr++;
-/* find_vac_linesize() returns the size in bytes of the VAC linesize */
+ return cksum;
+}
-int
-find_vac_linesize(void)
+/* Create a local IDPROM copy, verify integrity, and display information. */
+void idprom_init(void)
{
- int vac_prop_len;
+ prom_get_idprom((char *) &idprom_buffer, sizeof(idprom_buffer));
- vac_prop_len = prom_getproplen(prom_root_node, "vac-linesize");
+ idprom = &idprom_buffer;
- if(vac_prop_len != -1)
- return prom_getint(prom_root_node, "vac-linesize");
- else {
- switch(idprom->id_machtype) {
- case (SM_SUN4C | SM_4C_SS1): /* SparcStation1 */
- case (SM_SUN4C | SM_4C_IPC): /* SparcStation IPC */
- case (SM_SUN4C | SM_4C_SS1PLUS): /* SparcStation1+ */
- case (SM_SUN4C | SM_4C_SLC): /* SparcStation SLC */
- return 16;
- case (SM_SUN4C | SM_4C_SS2): /* SparcStation2 Cache-Chip BUG! */
- case (SM_SUN4C | SM_4C_ELC): /* SparcStation ELC */
- case (SM_SUN4C | SM_4C_IPX): /* SparcStation IPX */
- return 32;
- default:
- printk("find_vac_linesize: Can't determine VAC linesize, bailing out...\n");
- halt();
- break;
- };
- };
- return -1;
-}
+ if (idprom->id_format != 0x01) {
+ prom_printf("IDPROM: Unknown format type!\n");
+ prom_halt();
+ }
-int
-find_vac_hwflushes(void)
-{
- register int len;
- int tmp1, tmp2;
+ if (idprom->id_cksum != calc_idprom_cksum(idprom)) {
+ prom_printf("IDPROM: Checksum failure (nvram=%x, calc=%x)!\n",
+ idprom->id_cksum, calc_idprom_cksum(idprom));
+ prom_halt();
+ }
- /* Sun 4/75 has typo in prom_node, it's a dash instead of an underscore
- * in the property name. :-(
- */
- len = prom_getproperty(prom_root_node, "vac_hwflush",
- (char *) &tmp1, sizeof(int));
- if(len != 4) tmp1=0;
-
- len = prom_getproperty(prom_root_node, "vac-hwflush",
- (char *) &tmp2, sizeof(int));
- if(len != 4) tmp2=0;
+ display_system_type(idprom->id_machtype);
- return (tmp1|tmp2);
+ printk("Ethernet address: %x:%x:%x:%x:%x:%x\n",
+ idprom->id_ethaddr[0], idprom->id_ethaddr[1],
+ idprom->id_ethaddr[2], idprom->id_ethaddr[3],
+ idprom->id_ethaddr[4], idprom->id_ethaddr[5]);
}
-
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov