idprom.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 <asm/oplib.h>
  11. #include <asm/idprom.h>
  12. #include <asm/machines.h> /* Fun with Sun released architectures. */
  13. struct idprom *idprom;
  14. static struct idprom idprom_buffer;
  15. /* Here is the master table of Sun machines which use some implementation
  16. * of the Sparc CPU and have a meaningful IDPROM machtype value that we
  17. * know about. See asm-sparc/machines.h for empirical constants.
  18. */
  19. static struct Sun_Machine_Models Sun_Machines[NUM_SUN_MACHINES] = {
  20. /* First, Sun4's */
  21. { "Sun 4/100 Series", (SM_SUN4 | SM_4_110) },
  22. { "Sun 4/200 Series", (SM_SUN4 | SM_4_260) },
  23. { "Sun 4/300 Series", (SM_SUN4 | SM_4_330) },
  24. { "Sun 4/400 Series", (SM_SUN4 | SM_4_470) },
  25. /* Now, Sun4c's */
  26. { "Sun4c SparcStation 1", (SM_SUN4C | SM_4C_SS1) },
  27. { "Sun4c SparcStation IPC", (SM_SUN4C | SM_4C_IPC) },
  28. { "Sun4c SparcStation 1+", (SM_SUN4C | SM_4C_SS1PLUS) },
  29. { "Sun4c SparcStation SLC", (SM_SUN4C | SM_4C_SLC) },
  30. { "Sun4c SparcStation 2", (SM_SUN4C | SM_4C_SS2) },
  31. { "Sun4c SparcStation ELC", (SM_SUN4C | SM_4C_ELC) },
  32. { "Sun4c SparcStation IPX", (SM_SUN4C | SM_4C_IPX) },
  33. /* Finally, early Sun4m's */
  34. { "Sun4m SparcSystem600", (SM_SUN4M | SM_4M_SS60) },
  35. { "Sun4m SparcStation10/20", (SM_SUN4M | SM_4M_SS50) },
  36. { "Sun4m SparcStation5", (SM_SUN4M | SM_4M_SS40) },
  37. /* One entry for the OBP arch's which are sun4d, sun4e, and newer sun4m's */
  38. { "Sun4M OBP based system", (SM_SUN4M_OBP | 0x0) } };
  39. static void __init display_system_type(unsigned char machtype)
  40. {
  41. char sysname[128];
  42. register int i;
  43. for (i = 0; i < NUM_SUN_MACHINES; i++) {
  44. if(Sun_Machines[i].id_machtype == machtype) {
  45. if (machtype != (SM_SUN4M_OBP | 0x00) ||
  46. prom_getproperty(prom_root_node, "banner-name",
  47. sysname, sizeof(sysname)) <= 0)
  48. printk("TYPE: %s\n", Sun_Machines[i].name);
  49. else
  50. printk("TYPE: %s\n", sysname);
  51. return;
  52. }
  53. }
  54. prom_printf("IDPROM: Bogus id_machtype value, 0x%x\n", machtype);
  55. prom_halt();
  56. }
  57. /* Calculate the IDPROM checksum (xor of the data bytes). */
  58. static unsigned char __init calc_idprom_cksum(struct idprom *idprom)
  59. {
  60. unsigned char cksum, i, *ptr = (unsigned char *)idprom;
  61. for (i = cksum = 0; i <= 0x0E; i++)
  62. cksum ^= *ptr++;
  63. return cksum;
  64. }
  65. /* Create a local IDPROM copy, verify integrity, and display information. */
  66. void __init idprom_init(void)
  67. {
  68. prom_get_idprom((char *) &idprom_buffer, sizeof(idprom_buffer));
  69. idprom = &idprom_buffer;
  70. if (idprom->id_format != 0x01) {
  71. prom_printf("IDPROM: Unknown format type!\n");
  72. prom_halt();
  73. }
  74. if (idprom->id_cksum != calc_idprom_cksum(idprom)) {
  75. prom_printf("IDPROM: Checksum failure (nvram=%x, calc=%x)!\n",
  76. idprom->id_cksum, calc_idprom_cksum(idprom));
  77. prom_halt();
  78. }
  79. display_system_type(idprom->id_machtype);
  80. printk("Ethernet address: %x:%x:%x:%x:%x:%x\n",
  81. idprom->id_ethaddr[0], idprom->id_ethaddr[1],
  82. idprom->id_ethaddr[2], idprom->id_ethaddr[3],
  83. idprom->id_ethaddr[4], idprom->id_ethaddr[5]);
  84. }