idprom.c 3.3 KB

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