init.c 3.5 KB

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