init.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * init.c: PROM library initialisation code.
  3. *
  4. * Copyright (C) 1998 Harald Koerfgen
  5. * Copyright (C) 2002, 2004 Maciej W. Rozycki
  6. */
  7. #include <linux/init.h>
  8. #include <linux/kernel.h>
  9. #include <linux/linkage.h>
  10. #include <linux/smp.h>
  11. #include <linux/string.h>
  12. #include <linux/types.h>
  13. #include <asm/bootinfo.h>
  14. #include <asm/cpu.h>
  15. #include <asm/cpu-type.h>
  16. #include <asm/processor.h>
  17. #include <asm/dec/prom.h>
  18. int (*__rex_bootinit)(void);
  19. int (*__rex_bootread)(void);
  20. int (*__rex_getbitmap)(memmap *);
  21. unsigned long *(*__rex_slot_address)(int);
  22. void *(*__rex_gettcinfo)(void);
  23. int (*__rex_getsysid)(void);
  24. void (*__rex_clear_cache)(void);
  25. int (*__prom_getchar)(void);
  26. char *(*__prom_getenv)(char *);
  27. int (*__prom_printf)(char *, ...);
  28. int (*__pmax_open)(char*, int);
  29. int (*__pmax_lseek)(int, long, int);
  30. int (*__pmax_read)(int, void *, int);
  31. int (*__pmax_close)(int);
  32. /*
  33. * Detect which PROM the DECSTATION has, and set the callback vectors
  34. * appropriately.
  35. */
  36. void __init which_prom(s32 magic, s32 *prom_vec)
  37. {
  38. /*
  39. * No sign of the REX PROM's magic number means we assume a non-REX
  40. * machine (i.e. we're on a DS2100/3100, DS5100 or DS5000/2xx)
  41. */
  42. if (prom_is_rex(magic)) {
  43. /*
  44. * Set up prom abstraction structure with REX entry points.
  45. */
  46. __rex_bootinit =
  47. (void *)(long)*(prom_vec + REX_PROM_BOOTINIT);
  48. __rex_bootread =
  49. (void *)(long)*(prom_vec + REX_PROM_BOOTREAD);
  50. __rex_getbitmap =
  51. (void *)(long)*(prom_vec + REX_PROM_GETBITMAP);
  52. __prom_getchar =
  53. (void *)(long)*(prom_vec + REX_PROM_GETCHAR);
  54. __prom_getenv =
  55. (void *)(long)*(prom_vec + REX_PROM_GETENV);
  56. __rex_getsysid =
  57. (void *)(long)*(prom_vec + REX_PROM_GETSYSID);
  58. __rex_gettcinfo =
  59. (void *)(long)*(prom_vec + REX_PROM_GETTCINFO);
  60. __prom_printf =
  61. (void *)(long)*(prom_vec + REX_PROM_PRINTF);
  62. __rex_slot_address =
  63. (void *)(long)*(prom_vec + REX_PROM_SLOTADDR);
  64. __rex_clear_cache =
  65. (void *)(long)*(prom_vec + REX_PROM_CLEARCACHE);
  66. } else {
  67. /*
  68. * Set up prom abstraction structure with non-REX entry points.
  69. */
  70. __prom_getchar = (void *)PMAX_PROM_GETCHAR;
  71. __prom_getenv = (void *)PMAX_PROM_GETENV;
  72. __prom_printf = (void *)PMAX_PROM_PRINTF;
  73. __pmax_open = (void *)PMAX_PROM_OPEN;
  74. __pmax_lseek = (void *)PMAX_PROM_LSEEK;
  75. __pmax_read = (void *)PMAX_PROM_READ;
  76. __pmax_close = (void *)PMAX_PROM_CLOSE;
  77. }
  78. }
  79. void __init prom_init(void)
  80. {
  81. extern void dec_machine_halt(void);
  82. static char cpu_msg[] __initdata =
  83. "Sorry, this kernel is compiled for a wrong CPU type!\n";
  84. s32 argc = fw_arg0;
  85. s32 *argv = (void *)fw_arg1;
  86. u32 magic = fw_arg2;
  87. s32 *prom_vec = (void *)fw_arg3;
  88. /*
  89. * Determine which PROM we have
  90. * (and therefore which machine we're on!)
  91. */
  92. which_prom(magic, prom_vec);
  93. if (prom_is_rex(magic))
  94. rex_clear_cache();
  95. /* Register the early console. */
  96. register_prom_console();
  97. /* Were we compiled with the right CPU option? */
  98. #if defined(CONFIG_CPU_R3000)
  99. if ((current_cpu_type() == CPU_R4000SC) ||
  100. (current_cpu_type() == CPU_R4400SC)) {
  101. static char r4k_msg[] __initdata =
  102. "Please recompile with \"CONFIG_CPU_R4x00 = y\".\n";
  103. printk(cpu_msg);
  104. printk(r4k_msg);
  105. dec_machine_halt();
  106. }
  107. #endif
  108. #if defined(CONFIG_CPU_R4X00)
  109. if ((current_cpu_type() == CPU_R3000) ||
  110. (current_cpu_type() == CPU_R3000A)) {
  111. static char r3k_msg[] __initdata =
  112. "Please recompile with \"CONFIG_CPU_R3000 = y\".\n";
  113. printk(cpu_msg);
  114. printk(r3k_msg);
  115. dec_machine_halt();
  116. }
  117. #endif
  118. prom_meminit(magic);
  119. prom_identify_arch(magic);
  120. prom_init_cmdline(argc, argv, magic);
  121. }