init.c 3.5 KB

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