ip22-system.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * ip22-system.c: Probe the system type using ARCS prom interface library.
  3.  *
  4.  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
  5.  */
  6. #include <linux/init.h>
  7. #include <linux/kernel.h>
  8. #include <linux/types.h>
  9. #include <linux/string.h>
  10. #include <asm/cpu.h>
  11. #include <asm/sgi/sgi.h>
  12. #include <asm/sgialib.h>
  13. enum sgi_mach sgimach;
  14. struct smatch {
  15. char *name;
  16. int type;
  17. };
  18. static struct smatch sgi_cputable[] = {
  19. { "MIPS-R2000", CPU_R2000 },
  20. { "MIPS-R3000", CPU_R3000 },
  21. { "MIPS-R3000A", CPU_R3000A },
  22. { "MIPS-R4000", CPU_R4000SC },
  23. { "MIPS-R4400", CPU_R4400SC },
  24. { "MIPS-R4600", CPU_R4600 },
  25. { "MIPS-R8000", CPU_R8000 },
  26. { "MIPS-R5000", CPU_R5000 },
  27. { "MIPS-R5000A", CPU_R5000A },
  28. { "MIPS-R10000", CPU_R10000 }
  29. };
  30. static int __init string_to_cpu(char *s)
  31. {
  32. ULONG cnt;
  33. char c;
  34. int i;
  35. for(i = 0; i < (sizeof(sgi_cputable) / sizeof(struct smatch)); i++) {
  36. if(!strcmp(s, sgi_cputable[i].name))
  37. return sgi_cputable[i].type;
  38. }
  39. prom_printf("nYeee, could not determine MIPS cpu type <%s>n", s);
  40. prom_printf("press a key to rebootn");
  41. ArcRead(0, &c, 1, &cnt);
  42. ArcEnterInteractiveMode();
  43. return 0;
  44. }
  45. /*
  46.  * We' call this early before loadmmu().  If we do the other way around
  47.  * the firmware will crash and burn.
  48.  */
  49. void __init sgi_sysinit(void)
  50. {
  51. pcomponent *p, *toplev, *cpup = 0;
  52. int cputype = -1;
  53. ULONG cnt;
  54. char c;
  55. /* The root component tells us what machine architecture we
  56.  * have here.
  57.  */
  58. p = ArcGetChild(PROM_NULL_COMPONENT);
  59. /* Now scan for cpu(s). */
  60. printk(KERN_INFO);
  61. toplev = p = ArcGetChild(p);
  62. while(p) {
  63. int ncpus = 0;
  64. if(p->type == Cpu) {
  65. if(++ncpus > 1) {
  66. prom_printf("nYeee, SGI MP not ready yetn");
  67. prom_printf("press a key to rebootn");
  68. ArcRead(0, &c, 1, &cnt);
  69. ArcEnterInteractiveMode();
  70. }
  71. printk("CPU: %s ", (char *)p->iname);
  72. cpup = p;
  73. cputype = string_to_cpu((char *)cpup->iname);
  74. }
  75. p = ArcGetPeer(p);
  76. }
  77. if (cputype == -1) {
  78. prom_printf("nYeee, could not find cpu ARCS componentn");
  79. prom_printf("press a key to rebootn");
  80. ArcRead(0, &c, 1, &cnt);
  81. ArcEnterInteractiveMode();
  82. }
  83. p = ArcGetChild(cpup);
  84. while(p) {
  85. switch(p->class) {
  86. case processor:
  87. switch(p->type) {
  88. case Fpu:
  89. printk("FPU<%s> ", (char *)p->iname);
  90. break;
  91. default:
  92. break;
  93. };
  94. break;
  95. case cache:
  96. switch(p->type) {
  97. case picache:
  98. printk("ICACHE ");
  99. break;
  100. case pdcache:
  101. printk("DCACHE ");
  102. break;
  103. case sccache:
  104. printk("SCACHE ");
  105. break;
  106. default:
  107. break;
  108. };
  109. break;
  110. default:
  111. break;
  112. };
  113. p = ArcGetPeer(p);
  114. }
  115. printk("n");
  116. }