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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* devices.c: Initial scan of the prom device tree for important
  2.  *       Sparc device nodes which we need to find.
  3.  *
  4.  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  5.  */
  6. #include <linux/config.h>
  7. #include <linux/kernel.h>
  8. #include <linux/threads.h>
  9. #include <linux/string.h>
  10. #include <linux/init.h>
  11. #include <asm/page.h>
  12. #include <asm/oplib.h>
  13. #include <asm/smp.h>
  14. #include <asm/system.h>
  15. struct prom_cpuinfo linux_cpus[32];
  16. int linux_num_cpus = 0;
  17. extern void cpu_probe(void);
  18. extern void clock_stop_probe(void); /* tadpole.c */
  19. extern void sun4c_probe_memerr_reg(void);
  20. void __init
  21. device_scan(void)
  22. {
  23. char node_str[128];
  24. int thismid;
  25. prom_getstring(prom_root_node, "device_type", node_str, sizeof(node_str));
  26. prom_printf("Booting Linux...n");
  27. if(strcmp(node_str, "cpu") == 0) {
  28. linux_num_cpus++;
  29. } else {
  30. int scan;
  31. scan = prom_getchild(prom_root_node);
  32. /* One can look it up in PROM instead */
  33. while ((scan = prom_getsibling(scan)) != 0) {
  34. prom_getstring(scan, "device_type",
  35.        node_str, sizeof(node_str));
  36. if (strcmp(node_str, "cpu") == 0) {
  37. linux_cpus[linux_num_cpus].prom_node = scan;
  38. prom_getproperty(scan, "mid",
  39.  (char *) &thismid, sizeof(thismid));
  40. linux_cpus[linux_num_cpus].mid = thismid;
  41. printk("Found CPU %d <node=%08lx,mid=%d>n",
  42.        linux_num_cpus, (unsigned long) scan, thismid);
  43. linux_num_cpus++;
  44. }
  45. }
  46. if (linux_num_cpus == 0 && sparc_cpu_model == sun4d) {
  47. scan = prom_getchild(prom_root_node);
  48. for (scan = prom_searchsiblings(scan, "cpu-unit"); scan;
  49.      scan = prom_searchsiblings(prom_getsibling(scan), "cpu-unit")) {
  50. int node = prom_getchild(scan);
  51. prom_getstring(node, "device_type",
  52.        node_str, sizeof(node_str));
  53. if (strcmp(node_str, "cpu") == 0) {
  54. prom_getproperty(node, "cpu-id",
  55.  (char *) &thismid, sizeof(thismid));
  56. linux_cpus[linux_num_cpus].prom_node = node;
  57. linux_cpus[linux_num_cpus].mid = thismid;
  58. printk("Found CPU %d <node=%08lx,mid=%d>n", 
  59.        linux_num_cpus, (unsigned long) node, thismid);
  60. linux_num_cpus++;
  61. }
  62. }
  63. }
  64. if (linux_num_cpus == 0) {
  65. printk("No CPU nodes found, cannot continue.n");
  66. /* Probably a sun4e, Sun is trying to trick us ;-) */
  67. halt();
  68. }
  69. printk("Found %d CPU prom device tree node(s).n", linux_num_cpus);
  70. }
  71. cpu_probe();
  72. #ifdef CONFIG_SUN_AUXIO
  73. {
  74. extern void auxio_probe(void);
  75. extern void auxio_power_probe(void);
  76. auxio_probe();
  77. auxio_power_probe();
  78. }
  79. #endif
  80. clock_stop_probe();
  81. if (ARCH_SUN4C_SUN4)
  82. sun4c_probe_memerr_reg();
  83. return;
  84. }