0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/kernel.h>
0013 #include <linux/init.h>
0014 #include <linux/memblock.h>
0015 #include <linux/string.h>
0016 #include <linux/console.h>
0017
0018 #include <asm/addrspace.h>
0019 #include <asm/sni.h>
0020 #include <asm/mipsprom.h>
0021 #include <asm/mipsregs.h>
0022 #include <asm/bootinfo.h>
0023 #include <asm/setup.h>
0024
0025
0026
0027
0028
0029
0030
0031
0032 #define PROM_GET_MEMCONF 58
0033 #define PROM_GET_HWCONF 61
0034
0035 #define PROM_VEC (u64 *)CKSEG1ADDR(0x1fc00000)
0036 #define PROM_ENTRY(x) (PROM_VEC + (x))
0037
0038 #define ___prom_putchar ((int *(*)(int))PROM_ENTRY(PROM_PUTCHAR))
0039 #define ___prom_getenv ((char *(*)(char *))PROM_ENTRY(PROM_GETENV))
0040 #define ___prom_get_memconf ((void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF))
0041 #define ___prom_get_hwconf ((u32 (*)(void))PROM_ENTRY(PROM_GET_HWCONF))
0042
0043 #ifdef CONFIG_64BIT
0044
0045
0046 static u64 o32_stk[4096];
0047 #define O32_STK (&o32_stk[ARRAY_SIZE(o32_stk)])
0048
0049 #define __PROM_O32(fun, arg) fun arg __asm__(#fun); \
0050 __asm__(#fun " = call_o32")
0051
0052 int __PROM_O32(__prom_putchar, (int *(*)(int), void *, int));
0053 char *__PROM_O32(__prom_getenv, (char *(*)(char *), void *, char *));
0054 void __PROM_O32(__prom_get_memconf, (void (*)(void *), void *, void *));
0055 u32 __PROM_O32(__prom_get_hwconf, (u32 (*)(void), void *));
0056
0057 #define _prom_putchar(x) __prom_putchar(___prom_putchar, O32_STK, x)
0058 #define _prom_getenv(x) __prom_getenv(___prom_getenv, O32_STK, x)
0059 #define _prom_get_memconf(x) __prom_get_memconf(___prom_get_memconf, O32_STK, x)
0060 #define _prom_get_hwconf() __prom_get_hwconf(___prom_get_hwconf, O32_STK)
0061
0062 #else
0063 #define _prom_putchar(x) ___prom_putchar(x)
0064 #define _prom_getenv(x) ___prom_getenv(x)
0065 #define _prom_get_memconf(x) ___prom_get_memconf(x)
0066 #define _prom_get_hwconf(x) ___prom_get_hwconf(x)
0067 #endif
0068
0069 void prom_putchar(char c)
0070 {
0071 _prom_putchar(c);
0072 }
0073
0074
0075 char *prom_getenv(char *s)
0076 {
0077 return _prom_getenv(s);
0078 }
0079
0080 void *prom_get_hwconf(void)
0081 {
0082 u32 hwconf = _prom_get_hwconf();
0083
0084 if (hwconf == 0xffffffff)
0085 return NULL;
0086
0087 return (void *)CKSEG1ADDR(hwconf);
0088 }
0089
0090
0091
0092
0093
0094 char *system_type = "Unknown";
0095 const char *get_system_type(void)
0096 {
0097 return system_type;
0098 }
0099
0100 static void __init sni_mem_init(void)
0101 {
0102 int i, memsize;
0103 struct membank {
0104 u32 size;
0105 u32 base;
0106 u32 size2;
0107 u32 pad1;
0108 u32 pad2;
0109 } memconf[8];
0110 int brd_type = *(unsigned char *)SNI_IDPROM_BRDTYPE;
0111
0112
0113
0114 memsize = *((unsigned char *) SNI_IDPROM_MEMSIZE) * 16;
0115
0116 pr_debug("IDProm memsize: %u MByte\n", memsize);
0117
0118
0119 _prom_get_memconf(&memconf);
0120
0121 pr_debug("prom_get_mem_conf memory configuration:\n");
0122 for (i = 0; i < 8 && memconf[i].size; i++) {
0123 if (brd_type == SNI_BRD_PCI_TOWER ||
0124 brd_type == SNI_BRD_PCI_TOWER_CPLUS) {
0125 if (memconf[i].base >= 0x20000000 &&
0126 memconf[i].base < 0x30000000)
0127 memconf[i].base -= 0x20000000;
0128 }
0129 pr_debug("Bank%d: %08x @ %08x\n", i,
0130 memconf[i].size, memconf[i].base);
0131 memblock_add(memconf[i].base, memconf[i].size);
0132 }
0133 }
0134
0135 void __init prom_init(void)
0136 {
0137 int argc = fw_arg0;
0138 u32 *argv = (u32 *)CKSEG0ADDR(fw_arg1);
0139 int i;
0140
0141 sni_mem_init();
0142
0143
0144 for (i = 1; i < argc; i++) {
0145 strcat(arcs_cmdline, (char *)CKSEG0ADDR(argv[i]));
0146 if (i < (argc - 1))
0147 strcat(arcs_cmdline, " ");
0148 }
0149 }