Linux Audio

Check our new training course

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