idprom.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * idprom.c: Routines to load the idprom into kernel addresses and
  3. * interpret the data contained within.
  4. *
  5. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/types.h>
  9. #include <linux/init.h>
  10. #include <linux/export.h>
  11. #include <asm/oplib.h>
  12. #include <asm/idprom.h>
  13. struct idprom *idprom;
  14. EXPORT_SYMBOL(idprom);
  15. static struct idprom idprom_buffer;
  16. #ifdef CONFIG_SPARC32
  17. #include <asm/machines.h> /* Fun with Sun released architectures. */
  18. /* Here is the master table of Sun machines which use some implementation
  19. * of the Sparc CPU and have a meaningful IDPROM machtype value that we
  20. * know about. See asm-sparc/machines.h for empirical constants.
  21. */
  22. static struct Sun_Machine_Models Sun_Machines[] = {
  23. /* First, Leon */
  24. { .name = "Leon3 System-on-a-Chip", .id_machtype = (M_LEON | M_LEON3_SOC) },
  25. /* Finally, early Sun4m's */
  26. { .name = "Sun4m SparcSystem600", .id_machtype = (SM_SUN4M | SM_4M_SS60) },
  27. { .name = "Sun4m SparcStation10/20", .id_machtype = (SM_SUN4M | SM_4M_SS50) },
  28. { .name = "Sun4m SparcStation5", .id_machtype = (SM_SUN4M | SM_4M_SS40) },
  29. /* One entry for the OBP arch's which are sun4d, sun4e, and newer sun4m's */
  30. { .name = "Sun4M OBP based system", .id_machtype = (SM_SUN4M_OBP | 0x0) } };
  31. static void __init display_system_type(unsigned char machtype)
  32. {
  33. char sysname[128];
  34. register int i;
  35. for (i = 0; i < ARRAY_SIZE(Sun_Machines); i++) {
  36. if (Sun_Machines[i].id_machtype == machtype) {
  37. if (machtype != (SM_SUN4M_OBP | 0x00) ||
  38. prom_getproperty(prom_root_node, "banner-name",
  39. sysname, sizeof(sysname)) <= 0)
  40. printk(KERN_WARNING "TYPE: %s\n",
  41. Sun_Machines[i].name);
  42. else
  43. printk(KERN_WARNING "TYPE: %s\n", sysname);
  44. return;
  45. }
  46. }
  47. prom_printf("IDPROM: Warning, bogus id_machtype value, 0x%x\n", machtype);
  48. }
  49. #else
  50. static void __init display_system_type(unsigned char machtype)
  51. {
  52. }
  53. #endif
  54. /* Calculate the IDPROM checksum (xor of the data bytes). */
  55. static unsigned char __init calc_idprom_cksum(struct idprom *idprom)
  56. {
  57. unsigned char cksum, i, *ptr = (unsigned char *)idprom;
  58. for (i = cksum = 0; i <= 0x0E; i++)
  59. cksum ^= *ptr++;
  60. return cksum;
  61. }
  62. /* Create a local IDPROM copy, verify integrity, and display information. */
  63. void __init idprom_init(void)
  64. {
  65. prom_get_idprom((char *) &idprom_buffer, sizeof(idprom_buffer));
  66. idprom = &idprom_buffer;
  67. if (idprom->id_format != 0x01)
  68. prom_printf("IDPROM: Warning, unknown format type!\n");
  69. if (idprom->id_cksum != calc_idprom_cksum(idprom))
  70. prom_printf("IDPROM: Warning, checksum failure (nvram=%x, calc=%x)!\n",
  71. idprom->id_cksum, calc_idprom_cksum(idprom));
  72. display_system_type(idprom->id_machtype);
  73. printk(KERN_WARNING "Ethernet address: %pM\n", idprom->id_ethaddr);
  74. }