2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
8 #include <linux/init.h>
11 #include <asm/bootinfo.h>
12 #include <asm/cacheflush.h>
13 #include <asm/traps.h>
14 #include <asm/mips-boards/generic.h>
15 #include <asm/mips-boards/prom.h>
17 extern void prom_init_early_console(char port
);
19 extern char except_vec_nmi
;
20 extern char except_vec_ejtag_debug
;
23 int *_prom_argv
, *_prom_envp
;
25 #define prom_envp(index) ((char *)(long)_prom_envp[(index)])
27 char *prom_getenv(char *envname
)
30 * Return a pointer to the given environment variable.
31 * In 64-bit mode: we're using 64-bit pointers, but all pointers
32 * in the PROM structures are only 32-bit, so we need some
33 * workarounds, if we are running in 64-bit mode.
39 while (prom_envp(index
)) {
40 if (strncmp(envname
, prom_envp(index
), i
) == 0)
41 return prom_envp(index
+1);
48 static void __init
mips_nmi_setup(void)
53 (void *)(CAC_BASE
+ 0xa80) :
54 (void *)(CAC_BASE
+ 0x380);
55 memcpy(base
, &except_vec_nmi
, 0x80);
56 flush_icache_range((unsigned long)base
, (unsigned long)base
+ 0x80);
59 static void __init
mips_ejtag_setup(void)
64 (void *)(CAC_BASE
+ 0xa00) :
65 (void *)(CAC_BASE
+ 0x300);
66 memcpy(base
, &except_vec_ejtag_debug
, 0x80);
67 flush_icache_range((unsigned long)base
, (unsigned long)base
+ 0x80);
70 void __init
prom_init(void)
73 _prom_argv
= (int *) fw_arg1
;
74 _prom_envp
= (int *) fw_arg2
;
76 board_nmi_handler_setup
= mips_nmi_setup
;
77 board_ejtag_handler_setup
= mips_ejtag_setup
;
80 #ifdef CONFIG_EARLY_PRINTK
81 if ((strstr(prom_getcmdline(), "console=ttyS0")) != NULL
)
82 prom_init_early_console(0);
83 else if ((strstr(prom_getcmdline(), "console=ttyS1")) != NULL
)
84 prom_init_early_console(1);
86 #ifdef CONFIG_SERIAL_8250_CONSOLE
87 if ((strstr(prom_getcmdline(), "console=")) == NULL
)
88 strcat(prom_getcmdline(), " console=ttyS0,38400n8r");
92 void prom_free_prom_memory(void)