init.c 3.4 KB

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