idprom.c 3.3 KB

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