diff options
| author | Aurelien Jarno <aurelien@aurel32.net> | 2007-09-05 02:59:34 -0400 |
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2007-10-11 18:46:06 -0400 |
| commit | 2f56cfdd812a17623483d3dfa3370a2e6282b245 (patch) | |
| tree | 624e2bfccf0b0ee02cd94343acdf5d3364cb002e /arch/mips/fw | |
| parent | df78b5c8faa72b3c04f82faab126de93af178348 (diff) | |
[MIPS] Move ARC code into arch/mips/fw/arc
Move the ARC code to arch/mips/fw/arc from arch/mips/arc.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/fw')
| -rw-r--r-- | arch/mips/fw/arc/Makefile | 10 | ||||
| -rw-r--r-- | arch/mips/fw/arc/arc_con.c | 50 | ||||
| -rw-r--r-- | arch/mips/fw/arc/cmdline.c | 108 | ||||
| -rw-r--r-- | arch/mips/fw/arc/env.c | 27 | ||||
| -rw-r--r-- | arch/mips/fw/arc/file.c | 75 | ||||
| -rw-r--r-- | arch/mips/fw/arc/identify.c | 123 | ||||
| -rw-r--r-- | arch/mips/fw/arc/init.c | 51 | ||||
| -rw-r--r-- | arch/mips/fw/arc/memory.c | 160 | ||||
| -rw-r--r-- | arch/mips/fw/arc/misc.c | 89 | ||||
| -rw-r--r-- | arch/mips/fw/arc/promlib.c | 43 | ||||
| -rw-r--r-- | arch/mips/fw/arc/salone.c | 24 | ||||
| -rw-r--r-- | arch/mips/fw/arc/time.c | 25 | ||||
| -rw-r--r-- | arch/mips/fw/arc/tree.c | 127 |
13 files changed, 912 insertions, 0 deletions
diff --git a/arch/mips/fw/arc/Makefile b/arch/mips/fw/arc/Makefile new file mode 100644 index 000000000000..4f349ec1ea2d --- /dev/null +++ b/arch/mips/fw/arc/Makefile | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | # | ||
| 2 | # Makefile for the ARC prom monitor library routines under Linux. | ||
| 3 | # | ||
| 4 | |||
| 5 | lib-y += cmdline.o env.o file.o identify.o init.o \ | ||
| 6 | misc.o salone.o time.o tree.o | ||
| 7 | |||
| 8 | lib-$(CONFIG_ARC_MEMORY) += memory.o | ||
| 9 | lib-$(CONFIG_ARC_CONSOLE) += arc_con.o | ||
| 10 | lib-$(CONFIG_ARC_PROMLIB) += promlib.o | ||
diff --git a/arch/mips/fw/arc/arc_con.c b/arch/mips/fw/arc/arc_con.c new file mode 100644 index 000000000000..bc32fe64f42a --- /dev/null +++ b/arch/mips/fw/arc/arc_con.c | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | /* | ||
| 2 | * Wrap-around code for a console using the | ||
| 3 | * ARC io-routines. | ||
| 4 | * | ||
| 5 | * Copyright (c) 1998 Harald Koerfgen | ||
| 6 | * Copyright (c) 2001 Ralf Baechle | ||
| 7 | * Copyright (c) 2002 Thiemo Seufer | ||
| 8 | */ | ||
| 9 | #include <linux/tty.h> | ||
| 10 | #include <linux/major.h> | ||
| 11 | #include <linux/init.h> | ||
| 12 | #include <linux/console.h> | ||
| 13 | #include <linux/fs.h> | ||
| 14 | #include <asm/sgialib.h> | ||
| 15 | |||
| 16 | static void prom_console_write(struct console *co, const char *s, | ||
| 17 | unsigned count) | ||
| 18 | { | ||
| 19 | /* Do each character */ | ||
| 20 | while (count--) { | ||
| 21 | if (*s == '\n') | ||
| 22 | prom_putchar('\r'); | ||
| 23 | prom_putchar(*s++); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | static int prom_console_setup(struct console *co, char *options) | ||
| 28 | { | ||
| 29 | return !(prom_flags & PROM_FLAG_USE_AS_CONSOLE); | ||
| 30 | } | ||
| 31 | |||
| 32 | static struct console arc_cons = { | ||
| 33 | .name = "arc", | ||
| 34 | .write = prom_console_write, | ||
| 35 | .setup = prom_console_setup, | ||
| 36 | .flags = CON_PRINTBUFFER, | ||
| 37 | .index = -1, | ||
| 38 | }; | ||
| 39 | |||
| 40 | /* | ||
| 41 | * Register console. | ||
| 42 | */ | ||
| 43 | |||
| 44 | static int __init arc_console_init(void) | ||
| 45 | { | ||
| 46 | register_console(&arc_cons); | ||
| 47 | |||
| 48 | return 0; | ||
| 49 | } | ||
| 50 | console_initcall(arc_console_init); | ||
diff --git a/arch/mips/fw/arc/cmdline.c b/arch/mips/fw/arc/cmdline.c new file mode 100644 index 000000000000..fd604ef28823 --- /dev/null +++ b/arch/mips/fw/arc/cmdline.c | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | /* | ||
| 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 | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * cmdline.c: Kernel command line creation using ARCS argc/argv. | ||
| 7 | * | ||
| 8 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | ||
| 9 | */ | ||
| 10 | #include <linux/init.h> | ||
| 11 | #include <linux/kernel.h> | ||
| 12 | #include <linux/string.h> | ||
| 13 | |||
| 14 | #include <asm/sgialib.h> | ||
| 15 | #include <asm/bootinfo.h> | ||
| 16 | |||
| 17 | #undef DEBUG_CMDLINE | ||
| 18 | |||
| 19 | char * __init prom_getcmdline(void) | ||
| 20 | { | ||
| 21 | return arcs_cmdline; | ||
| 22 | } | ||
| 23 | |||
| 24 | static char *ignored[] = { | ||
| 25 | "ConsoleIn=", | ||
| 26 | "ConsoleOut=", | ||
| 27 | "SystemPartition=", | ||
| 28 | "OSLoader=", | ||
| 29 | "OSLoadPartition=", | ||
| 30 | "OSLoadFilename=", | ||
| 31 | "OSLoadOptions=" | ||
| 32 | }; | ||
| 33 | |||
| 34 | static char *used_arc[][2] = { | ||
| 35 | { "OSLoadPartition=", "root=" }, | ||
| 36 | { "OSLoadOptions=", "" } | ||
| 37 | }; | ||
| 38 | |||
| 39 | static char * __init move_firmware_args(char* cp) | ||
| 40 | { | ||
| 41 | char *s; | ||
| 42 | int actr, i; | ||
| 43 | |||
| 44 | actr = 1; /* Always ignore argv[0] */ | ||
| 45 | |||
| 46 | while (actr < prom_argc) { | ||
| 47 | for(i = 0; i < ARRAY_SIZE(used_arc); i++) { | ||
| 48 | int len = strlen(used_arc[i][0]); | ||
| 49 | |||
| 50 | if (!strncmp(prom_argv(actr), used_arc[i][0], len)) { | ||
| 51 | /* Ok, we want it. First append the replacement... */ | ||
| 52 | strcat(cp, used_arc[i][1]); | ||
| 53 | cp += strlen(used_arc[i][1]); | ||
| 54 | /* ... and now the argument */ | ||
| 55 | s = strstr(prom_argv(actr), "="); | ||
| 56 | if (s) { | ||
| 57 | s++; | ||
| 58 | strcpy(cp, s); | ||
| 59 | cp += strlen(s); | ||
| 60 | } | ||
| 61 | *cp++ = ' '; | ||
| 62 | break; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | actr++; | ||
| 66 | } | ||
| 67 | |||
| 68 | return cp; | ||
| 69 | } | ||
| 70 | |||
| 71 | void __init prom_init_cmdline(void) | ||
| 72 | { | ||
| 73 | char *cp; | ||
| 74 | int actr, i; | ||
| 75 | |||
| 76 | actr = 1; /* Always ignore argv[0] */ | ||
| 77 | |||
| 78 | cp = arcs_cmdline; | ||
| 79 | /* | ||
| 80 | * Move ARC variables to the beginning to make sure they can be | ||
| 81 | * overridden by later arguments. | ||
| 82 | */ | ||
| 83 | cp = move_firmware_args(cp); | ||
| 84 | |||
| 85 | while (actr < prom_argc) { | ||
| 86 | for (i = 0; i < ARRAY_SIZE(ignored); i++) { | ||
| 87 | int len = strlen(ignored[i]); | ||
| 88 | |||
| 89 | if (!strncmp(prom_argv(actr), ignored[i], len)) | ||
| 90 | goto pic_cont; | ||
| 91 | } | ||
| 92 | /* Ok, we want it. */ | ||
| 93 | strcpy(cp, prom_argv(actr)); | ||
| 94 | cp += strlen(prom_argv(actr)); | ||
| 95 | *cp++ = ' '; | ||
| 96 | |||
| 97 | pic_cont: | ||
| 98 | actr++; | ||
| 99 | } | ||
| 100 | |||
| 101 | if (cp != arcs_cmdline) /* get rid of trailing space */ | ||
| 102 | --cp; | ||
| 103 | *cp = '\0'; | ||
| 104 | |||
| 105 | #ifdef DEBUG_CMDLINE | ||
| 106 | printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline); | ||
| 107 | #endif | ||
| 108 | } | ||
diff --git a/arch/mips/fw/arc/env.c b/arch/mips/fw/arc/env.c new file mode 100644 index 000000000000..6f5dd42b96e2 --- /dev/null +++ b/arch/mips/fw/arc/env.c | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /* | ||
| 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 | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * env.c: ARCS environment variable routines. | ||
| 7 | * | ||
| 8 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | ||
| 9 | */ | ||
| 10 | #include <linux/init.h> | ||
| 11 | #include <linux/kernel.h> | ||
| 12 | #include <linux/string.h> | ||
| 13 | |||
| 14 | #include <asm/fw/arc/types.h> | ||
| 15 | #include <asm/sgialib.h> | ||
| 16 | |||
| 17 | PCHAR __init | ||
| 18 | ArcGetEnvironmentVariable(CHAR *name) | ||
| 19 | { | ||
| 20 | return (CHAR *) ARC_CALL1(get_evar, name); | ||
| 21 | } | ||
| 22 | |||
| 23 | LONG __init | ||
| 24 | ArcSetEnvironmentVariable(PCHAR name, PCHAR value) | ||
| 25 | { | ||
| 26 | return ARC_CALL2(set_evar, name, value); | ||
| 27 | } | ||
diff --git a/arch/mips/fw/arc/file.c b/arch/mips/fw/arc/file.c new file mode 100644 index 000000000000..30335341b447 --- /dev/null +++ b/arch/mips/fw/arc/file.c | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | /* | ||
| 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 | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * ARC firmware interface. | ||
| 7 | * | ||
| 8 | * Copyright (C) 1994, 1995, 1996, 1999 Ralf Baechle | ||
| 9 | * Copyright (C) 1999 Silicon Graphics, Inc. | ||
| 10 | */ | ||
| 11 | #include <linux/init.h> | ||
| 12 | |||
| 13 | #include <asm/fw/arc/types.h> | ||
| 14 | #include <asm/sgialib.h> | ||
| 15 | |||
| 16 | LONG | ||
| 17 | ArcGetDirectoryEntry(ULONG FileID, struct linux_vdirent *Buffer, | ||
| 18 | ULONG N, ULONG *Count) | ||
| 19 | { | ||
| 20 | return ARC_CALL4(get_vdirent, FileID, Buffer, N, Count); | ||
| 21 | } | ||
| 22 | |||
| 23 | LONG | ||
| 24 | ArcOpen(CHAR *Path, enum linux_omode OpenMode, ULONG *FileID) | ||
| 25 | { | ||
| 26 | return ARC_CALL3(open, Path, OpenMode, FileID); | ||
| 27 | } | ||
| 28 | |||
| 29 | LONG | ||
| 30 | ArcClose(ULONG FileID) | ||
| 31 | { | ||
| 32 | return ARC_CALL1(close, FileID); | ||
| 33 | } | ||
| 34 | |||
| 35 | LONG | ||
| 36 | ArcRead(ULONG FileID, VOID *Buffer, ULONG N, ULONG *Count) | ||
| 37 | { | ||
| 38 | return ARC_CALL4(read, FileID, Buffer, N, Count); | ||
| 39 | } | ||
| 40 | |||
| 41 | LONG | ||
| 42 | ArcGetReadStatus(ULONG FileID) | ||
| 43 | { | ||
| 44 | return ARC_CALL1(get_rstatus, FileID); | ||
| 45 | } | ||
| 46 | |||
| 47 | LONG | ||
| 48 | ArcWrite(ULONG FileID, PVOID Buffer, ULONG N, PULONG Count) | ||
| 49 | { | ||
| 50 | return ARC_CALL4(write, FileID, Buffer, N, Count); | ||
| 51 | } | ||
| 52 | |||
| 53 | LONG | ||
| 54 | ArcSeek(ULONG FileID, struct linux_bigint *Position, enum linux_seekmode SeekMode) | ||
| 55 | { | ||
| 56 | return ARC_CALL3(seek, FileID, Position, SeekMode); | ||
| 57 | } | ||
| 58 | |||
| 59 | LONG | ||
| 60 | ArcMount(char *name, enum linux_mountops op) | ||
| 61 | { | ||
| 62 | return ARC_CALL2(mount, name, op); | ||
| 63 | } | ||
| 64 | |||
| 65 | LONG | ||
| 66 | ArcGetFileInformation(ULONG FileID, struct linux_finfo *Information) | ||
| 67 | { | ||
| 68 | return ARC_CALL2(get_finfo, FileID, Information); | ||
| 69 | } | ||
| 70 | |||
| 71 | LONG ArcSetFileInformation(ULONG FileID, ULONG AttributeFlags, | ||
| 72 | ULONG AttributeMask) | ||
| 73 | { | ||
| 74 | return ARC_CALL3(set_finfo, FileID, AttributeFlags, AttributeMask); | ||
| 75 | } | ||
diff --git a/arch/mips/fw/arc/identify.c b/arch/mips/fw/arc/identify.c new file mode 100644 index 000000000000..4b907369b0f9 --- /dev/null +++ b/arch/mips/fw/arc/identify.c | |||
| @@ -0,0 +1,123 @@ | |||
| 1 | /* | ||
| 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 | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * identify.c: identify machine by looking up system identifier | ||
| 7 | * | ||
| 8 | * Copyright (C) 1998 Thomas Bogendoerfer | ||
| 9 | * | ||
| 10 | * This code is based on arch/mips/sgi/kernel/system.c, which is | ||
| 11 | * | ||
| 12 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | ||
| 13 | */ | ||
| 14 | #include <linux/init.h> | ||
| 15 | #include <linux/kernel.h> | ||
| 16 | #include <linux/types.h> | ||
| 17 | #include <linux/string.h> | ||
| 18 | |||
| 19 | #include <asm/sgialib.h> | ||
| 20 | #include <asm/bootinfo.h> | ||
| 21 | |||
| 22 | struct smatch { | ||
| 23 | char *arcname; | ||
| 24 | char *liname; | ||
| 25 | int group; | ||
| 26 | int type; | ||
| 27 | int flags; | ||
| 28 | }; | ||
| 29 | |||
| 30 | static struct smatch mach_table[] = { | ||
| 31 | { "SGI-IP22", | ||
| 32 | "SGI Indy", | ||
| 33 | MACH_GROUP_SGI, | ||
| 34 | MACH_SGI_IP22, | ||
| 35 | PROM_FLAG_ARCS | ||
| 36 | }, { "SGI-IP27", | ||
| 37 | "SGI Origin", | ||
| 38 | MACH_GROUP_SGI, | ||
| 39 | MACH_SGI_IP27, | ||
| 40 | PROM_FLAG_ARCS | ||
| 41 | }, { "SGI-IP28", | ||
| 42 | "SGI IP28", | ||
| 43 | MACH_GROUP_SGI, | ||
| 44 | MACH_SGI_IP28, | ||
| 45 | PROM_FLAG_ARCS | ||
| 46 | }, { "SGI-IP30", | ||
| 47 | "SGI Octane", | ||
| 48 | MACH_GROUP_SGI, | ||
| 49 | MACH_SGI_IP30, | ||
| 50 | PROM_FLAG_ARCS | ||
| 51 | }, { "SGI-IP32", | ||
| 52 | "SGI O2", | ||
| 53 | MACH_GROUP_SGI, | ||
| 54 | MACH_SGI_IP32, | ||
| 55 | PROM_FLAG_ARCS | ||
| 56 | }, { "Microsoft-Jazz", | ||
| 57 | "Jazz MIPS_Magnum_4000", | ||
| 58 | MACH_GROUP_JAZZ, | ||
| 59 | MACH_MIPS_MAGNUM_4000, | ||
| 60 | 0 | ||
| 61 | }, { "PICA-61", | ||
| 62 | "Jazz Acer_PICA_61", | ||
| 63 | MACH_GROUP_JAZZ, | ||
| 64 | MACH_ACER_PICA_61, | ||
| 65 | 0 | ||
| 66 | }, { "RM200PCI", | ||
| 67 | "SNI RM200_PCI", | ||
| 68 | MACH_GROUP_SNI_RM, | ||
| 69 | MACH_SNI_RM200_PCI, | ||
| 70 | PROM_FLAG_DONT_FREE_TEMP | ||
| 71 | } | ||
| 72 | }; | ||
| 73 | |||
| 74 | int prom_flags; | ||
| 75 | |||
| 76 | static struct smatch * __init string_to_mach(const char *s) | ||
| 77 | { | ||
| 78 | int i; | ||
| 79 | |||
| 80 | for (i = 0; i < ARRAY_SIZE(mach_table); i++) { | ||
| 81 | if (!strcmp(s, mach_table[i].arcname)) | ||
| 82 | return &mach_table[i]; | ||
| 83 | } | ||
| 84 | |||
| 85 | panic("Yeee, could not determine architecture type <%s>", s); | ||
| 86 | } | ||
| 87 | |||
| 88 | char *system_type; | ||
| 89 | |||
| 90 | const char *get_system_type(void) | ||
| 91 | { | ||
| 92 | return system_type; | ||
| 93 | } | ||
| 94 | |||
| 95 | void __init prom_identify_arch(void) | ||
| 96 | { | ||
| 97 | pcomponent *p; | ||
| 98 | struct smatch *mach; | ||
| 99 | const char *iname; | ||
| 100 | |||
| 101 | /* | ||
| 102 | * The root component tells us what machine architecture we have here. | ||
| 103 | */ | ||
| 104 | p = ArcGetChild(PROM_NULL_COMPONENT); | ||
| 105 | if (p == NULL) { | ||
| 106 | #ifdef CONFIG_SGI_IP27 | ||
| 107 | /* IP27 PROM misbehaves, seems to not implement ARC | ||
| 108 | GetChild(). So we just assume it's an IP27. */ | ||
| 109 | iname = "SGI-IP27"; | ||
| 110 | #else | ||
| 111 | iname = "Unknown"; | ||
| 112 | #endif | ||
| 113 | } else | ||
| 114 | iname = (char *) (long) p->iname; | ||
| 115 | |||
| 116 | printk("ARCH: %s\n", iname); | ||
| 117 | mach = string_to_mach(iname); | ||
| 118 | system_type = mach->liname; | ||
| 119 | |||
| 120 | mips_machgroup = mach->group; | ||
| 121 | mips_machtype = mach->type; | ||
| 122 | prom_flags = mach->flags; | ||
| 123 | } | ||
diff --git a/arch/mips/fw/arc/init.c b/arch/mips/fw/arc/init.c new file mode 100644 index 000000000000..e2f75b13312f --- /dev/null +++ b/arch/mips/fw/arc/init.c | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | /* | ||
| 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 | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * PROM library initialisation code. | ||
| 7 | * | ||
| 8 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | ||
| 9 | */ | ||
| 10 | #include <linux/init.h> | ||
| 11 | #include <linux/kernel.h> | ||
| 12 | |||
| 13 | #include <asm/bootinfo.h> | ||
| 14 | #include <asm/sgialib.h> | ||
| 15 | |||
| 16 | #undef DEBUG_PROM_INIT | ||
| 17 | |||
| 18 | /* Master romvec interface. */ | ||
| 19 | struct linux_romvec *romvec; | ||
| 20 | int prom_argc; | ||
| 21 | LONG *_prom_argv, *_prom_envp; | ||
| 22 | |||
| 23 | void __init prom_init(void) | ||
| 24 | { | ||
| 25 | PSYSTEM_PARAMETER_BLOCK pb = PROMBLOCK; | ||
| 26 | |||
| 27 | romvec = ROMVECTOR; | ||
| 28 | |||
| 29 | prom_argc = fw_arg0; | ||
| 30 | _prom_argv = (LONG *) fw_arg1; | ||
| 31 | _prom_envp = (LONG *) fw_arg2; | ||
| 32 | |||
| 33 | if (pb->magic != 0x53435241) { | ||
| 34 | printk(KERN_CRIT "Aieee, bad prom vector magic %08lx\n", | ||
| 35 | (unsigned long) pb->magic); | ||
| 36 | while(1) | ||
| 37 | ; | ||
| 38 | } | ||
| 39 | |||
| 40 | prom_init_cmdline(); | ||
| 41 | prom_identify_arch(); | ||
| 42 | printk(KERN_INFO "PROMLIB: ARC firmware Version %d Revision %d\n", | ||
| 43 | pb->ver, pb->rev); | ||
| 44 | prom_meminit(); | ||
| 45 | |||
| 46 | #ifdef DEBUG_PROM_INIT | ||
| 47 | pr_info("Press a key to reboot\n"); | ||
| 48 | ArcRead(0, &c, 1, &cnt); | ||
| 49 | ArcEnterInteractiveMode(); | ||
| 50 | #endif | ||
| 51 | } | ||
diff --git a/arch/mips/fw/arc/memory.c b/arch/mips/fw/arc/memory.c new file mode 100644 index 000000000000..83d15791ef6a --- /dev/null +++ b/arch/mips/fw/arc/memory.c | |||
| @@ -0,0 +1,160 @@ | |||
| 1 | /* | ||
| 2 | * memory.c: PROM library functions for acquiring/using memory descriptors | ||
| 3 | * given to us from the ARCS firmware. | ||
| 4 | * | ||
| 5 | * Copyright (C) 1996 by David S. Miller | ||
| 6 | * Copyright (C) 1999, 2000, 2001 by Ralf Baechle | ||
| 7 | * Copyright (C) 1999, 2000 by Silicon Graphics, Inc. | ||
| 8 | * | ||
| 9 | * PROM library functions for acquiring/using memory descriptors given to us | ||
| 10 | * from the ARCS firmware. This is only used when CONFIG_ARC_MEMORY is set | ||
| 11 | * because on some machines like SGI IP27 the ARC memory configuration data | ||
| 12 | * completly bogus and alternate easier to use mechanisms are available. | ||
| 13 | */ | ||
| 14 | #include <linux/init.h> | ||
| 15 | #include <linux/kernel.h> | ||
| 16 | #include <linux/types.h> | ||
| 17 | #include <linux/sched.h> | ||
| 18 | #include <linux/mm.h> | ||
| 19 | #include <linux/bootmem.h> | ||
| 20 | #include <linux/swap.h> | ||
| 21 | |||
| 22 | #include <asm/sgialib.h> | ||
| 23 | #include <asm/page.h> | ||
| 24 | #include <asm/pgtable.h> | ||
| 25 | #include <asm/bootinfo.h> | ||
| 26 | |||
| 27 | #undef DEBUG | ||
| 28 | |||
| 29 | /* | ||
| 30 | * For ARC firmware memory functions the unit of meassuring memory is always | ||
| 31 | * a 4k page of memory | ||
| 32 | */ | ||
| 33 | #define ARC_PAGE_SHIFT 12 | ||
| 34 | |||
| 35 | struct linux_mdesc * __init ArcGetMemoryDescriptor(struct linux_mdesc *Current) | ||
| 36 | { | ||
| 37 | return (struct linux_mdesc *) ARC_CALL1(get_mdesc, Current); | ||
| 38 | } | ||
| 39 | |||
| 40 | #ifdef DEBUG /* convenient for debugging */ | ||
| 41 | static char *arcs_mtypes[8] = { | ||
| 42 | "Exception Block", | ||
| 43 | "ARCS Romvec Page", | ||
| 44 | "Free/Contig RAM", | ||
| 45 | "Generic Free RAM", | ||
| 46 | "Bad Memory", | ||
| 47 | "Standalone Program Pages", | ||
| 48 | "ARCS Temp Storage Area", | ||
| 49 | "ARCS Permanent Storage Area" | ||
| 50 | }; | ||
| 51 | |||
| 52 | static char *arc_mtypes[8] = { | ||
| 53 | "Exception Block", | ||
| 54 | "SystemParameterBlock", | ||
| 55 | "FreeMemory", | ||
| 56 | "Bad Memory", | ||
| 57 | "LoadedProgram", | ||
| 58 | "FirmwareTemporary", | ||
| 59 | "FirmwarePermanent", | ||
| 60 | "FreeContiguous" | ||
| 61 | }; | ||
| 62 | #define mtypes(a) (prom_flags & PROM_FLAG_ARCS) ? arcs_mtypes[a.arcs] \ | ||
| 63 | : arc_mtypes[a.arc] | ||
| 64 | #endif | ||
| 65 | |||
| 66 | static inline int memtype_classify_arcs (union linux_memtypes type) | ||
| 67 | { | ||
| 68 | switch (type.arcs) { | ||
| 69 | case arcs_fcontig: | ||
| 70 | case arcs_free: | ||
| 71 | return BOOT_MEM_RAM; | ||
| 72 | case arcs_atmp: | ||
| 73 | return BOOT_MEM_ROM_DATA; | ||
| 74 | case arcs_eblock: | ||
| 75 | case arcs_rvpage: | ||
| 76 | case arcs_bmem: | ||
| 77 | case arcs_prog: | ||
| 78 | case arcs_aperm: | ||
| 79 | return BOOT_MEM_RESERVED; | ||
| 80 | default: | ||
| 81 | BUG(); | ||
| 82 | } | ||
| 83 | while(1); /* Nuke warning. */ | ||
| 84 | } | ||
| 85 | |||
| 86 | static inline int memtype_classify_arc (union linux_memtypes type) | ||
| 87 | { | ||
| 88 | switch (type.arc) { | ||
| 89 | case arc_free: | ||
| 90 | case arc_fcontig: | ||
| 91 | return BOOT_MEM_RAM; | ||
| 92 | case arc_atmp: | ||
| 93 | return BOOT_MEM_ROM_DATA; | ||
| 94 | case arc_eblock: | ||
| 95 | case arc_rvpage: | ||
| 96 | case arc_bmem: | ||
| 97 | case arc_prog: | ||
| 98 | case arc_aperm: | ||
| 99 | return BOOT_MEM_RESERVED; | ||
| 100 | default: | ||
| 101 | BUG(); | ||
| 102 | } | ||
| 103 | while(1); /* Nuke warning. */ | ||
| 104 | } | ||
| 105 | |||
| 106 | static int __init prom_memtype_classify (union linux_memtypes type) | ||
| 107 | { | ||
| 108 | if (prom_flags & PROM_FLAG_ARCS) /* SGI is ``different'' ... */ | ||
| 109 | return memtype_classify_arcs(type); | ||
| 110 | |||
| 111 | return memtype_classify_arc(type); | ||
| 112 | } | ||
| 113 | |||
| 114 | void __init prom_meminit(void) | ||
| 115 | { | ||
| 116 | struct linux_mdesc *p; | ||
| 117 | |||
| 118 | #ifdef DEBUG | ||
| 119 | int i = 0; | ||
| 120 | |||
| 121 | printk("ARCS MEMORY DESCRIPTOR dump:\n"); | ||
| 122 | p = ArcGetMemoryDescriptor(PROM_NULL_MDESC); | ||
| 123 | while(p) { | ||
| 124 | printk("[%d,%p]: base<%08lx> pages<%08lx> type<%s>\n", | ||
| 125 | i, p, p->base, p->pages, mtypes(p->type)); | ||
| 126 | p = ArcGetMemoryDescriptor(p); | ||
| 127 | i++; | ||
| 128 | } | ||
| 129 | #endif | ||
| 130 | |||
| 131 | p = PROM_NULL_MDESC; | ||
| 132 | while ((p = ArcGetMemoryDescriptor(p))) { | ||
| 133 | unsigned long base, size; | ||
| 134 | long type; | ||
| 135 | |||
| 136 | base = p->base << ARC_PAGE_SHIFT; | ||
| 137 | size = p->pages << ARC_PAGE_SHIFT; | ||
| 138 | type = prom_memtype_classify(p->type); | ||
| 139 | |||
| 140 | add_memory_region(base, size, type); | ||
| 141 | } | ||
| 142 | } | ||
| 143 | |||
| 144 | void __init prom_free_prom_memory(void) | ||
| 145 | { | ||
| 146 | unsigned long addr; | ||
| 147 | int i; | ||
| 148 | |||
| 149 | if (prom_flags & PROM_FLAG_DONT_FREE_TEMP) | ||
| 150 | return; | ||
| 151 | |||
| 152 | for (i = 0; i < boot_mem_map.nr_map; i++) { | ||
| 153 | if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA) | ||
| 154 | continue; | ||
| 155 | |||
| 156 | addr = boot_mem_map.map[i].addr; | ||
| 157 | free_init_pages("prom memory", | ||
| 158 | addr, addr + boot_mem_map.map[i].size); | ||
| 159 | } | ||
| 160 | } | ||
diff --git a/arch/mips/fw/arc/misc.c b/arch/mips/fw/arc/misc.c new file mode 100644 index 000000000000..e527c5fd5a32 --- /dev/null +++ b/arch/mips/fw/arc/misc.c | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | /* | ||
| 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 | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * Miscellaneous ARCS PROM routines. | ||
| 7 | * | ||
| 8 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | ||
| 9 | * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org) | ||
| 10 | * Copyright (C) 1999 Silicon Graphics, Inc. | ||
| 11 | */ | ||
| 12 | #include <linux/init.h> | ||
| 13 | #include <linux/kernel.h> | ||
| 14 | |||
| 15 | #include <asm/bcache.h> | ||
| 16 | |||
| 17 | #include <asm/fw/arc/types.h> | ||
| 18 | #include <asm/sgialib.h> | ||
| 19 | #include <asm/bootinfo.h> | ||
| 20 | #include <asm/system.h> | ||
| 21 | |||
| 22 | VOID | ||
| 23 | ArcHalt(VOID) | ||
| 24 | { | ||
| 25 | bc_disable(); | ||
| 26 | local_irq_disable(); | ||
| 27 | ARC_CALL0(halt); | ||
| 28 | never: goto never; | ||
| 29 | } | ||
| 30 | |||
| 31 | VOID | ||
| 32 | ArcPowerDown(VOID) | ||
| 33 | { | ||
| 34 | bc_disable(); | ||
| 35 | local_irq_disable(); | ||
| 36 | ARC_CALL0(pdown); | ||
| 37 | never: goto never; | ||
| 38 | } | ||
| 39 | |||
| 40 | /* XXX is this a soft reset basically? XXX */ | ||
| 41 | VOID | ||
| 42 | ArcRestart(VOID) | ||
| 43 | { | ||
| 44 | bc_disable(); | ||
| 45 | local_irq_disable(); | ||
| 46 | ARC_CALL0(restart); | ||
| 47 | never: goto never; | ||
| 48 | } | ||
| 49 | |||
| 50 | VOID | ||
| 51 | ArcReboot(VOID) | ||
| 52 | { | ||
| 53 | bc_disable(); | ||
| 54 | local_irq_disable(); | ||
| 55 | ARC_CALL0(reboot); | ||
| 56 | never: goto never; | ||
| 57 | } | ||
| 58 | |||
| 59 | VOID | ||
| 60 | ArcEnterInteractiveMode(VOID) | ||
| 61 | { | ||
| 62 | bc_disable(); | ||
| 63 | local_irq_disable(); | ||
| 64 | ARC_CALL0(imode); | ||
| 65 | never: goto never; | ||
| 66 | } | ||
| 67 | |||
| 68 | LONG | ||
| 69 | ArcSaveConfiguration(VOID) | ||
| 70 | { | ||
| 71 | return ARC_CALL0(cfg_save); | ||
| 72 | } | ||
| 73 | |||
| 74 | struct linux_sysid * | ||
| 75 | ArcGetSystemId(VOID) | ||
| 76 | { | ||
| 77 | return (struct linux_sysid *) ARC_CALL0(get_sysid); | ||
| 78 | } | ||
| 79 | |||
| 80 | VOID __init | ||
| 81 | ArcFlushAllCaches(VOID) | ||
| 82 | { | ||
| 83 | ARC_CALL0(cache_flush); | ||
| 84 | } | ||
| 85 | |||
| 86 | DISPLAY_STATUS * __init ArcGetDisplayStatus(ULONG FileID) | ||
| 87 | { | ||
| 88 | return (DISPLAY_STATUS *) ARC_CALL1(GetDisplayStatus, FileID); | ||
| 89 | } | ||
diff --git a/arch/mips/fw/arc/promlib.c b/arch/mips/fw/arc/promlib.c new file mode 100644 index 000000000000..c508c00dbb64 --- /dev/null +++ b/arch/mips/fw/arc/promlib.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* | ||
| 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 | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * Copyright (C) 1996 David S. Miller (dm@sgi.com) | ||
| 7 | * Compability with board caches, Ulf Carlsson | ||
| 8 | */ | ||
| 9 | #include <linux/kernel.h> | ||
| 10 | #include <asm/sgialib.h> | ||
| 11 | #include <asm/bcache.h> | ||
| 12 | |||
| 13 | /* | ||
| 14 | * IP22 boardcache is not compatible with board caches. Thus we disable it | ||
| 15 | * during romvec action. Since r4xx0.c is always compiled and linked with your | ||
| 16 | * kernel, this shouldn't cause any harm regardless what MIPS processor you | ||
| 17 | * have. | ||
| 18 | * | ||
| 19 | * The ARC write and read functions seem to interfere with the serial lines | ||
| 20 | * in some way. You should be careful with them. | ||
| 21 | */ | ||
| 22 | |||
| 23 | void prom_putchar(char c) | ||
| 24 | { | ||
| 25 | ULONG cnt; | ||
| 26 | CHAR it = c; | ||
| 27 | |||
| 28 | bc_disable(); | ||
| 29 | ArcWrite(1, &it, 1, &cnt); | ||
| 30 | bc_enable(); | ||
| 31 | } | ||
| 32 | |||
| 33 | char prom_getchar(void) | ||
| 34 | { | ||
| 35 | ULONG cnt; | ||
| 36 | CHAR c; | ||
| 37 | |||
| 38 | bc_disable(); | ||
| 39 | ArcRead(0, &c, 1, &cnt); | ||
| 40 | bc_enable(); | ||
| 41 | |||
| 42 | return c; | ||
| 43 | } | ||
diff --git a/arch/mips/fw/arc/salone.c b/arch/mips/fw/arc/salone.c new file mode 100644 index 000000000000..e6afb64723d0 --- /dev/null +++ b/arch/mips/fw/arc/salone.c | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | /* | ||
| 2 | * Routines to load into memory and execute stand-along program images using | ||
| 3 | * ARCS PROM firmware. | ||
| 4 | * | ||
| 5 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | ||
| 6 | */ | ||
| 7 | #include <linux/init.h> | ||
| 8 | #include <asm/sgialib.h> | ||
| 9 | |||
| 10 | LONG __init ArcLoad(CHAR *Path, ULONG TopAddr, ULONG *ExecAddr, ULONG *LowAddr) | ||
| 11 | { | ||
| 12 | return ARC_CALL4(load, Path, TopAddr, ExecAddr, LowAddr); | ||
| 13 | } | ||
| 14 | |||
| 15 | LONG __init ArcInvoke(ULONG ExecAddr, ULONG StackAddr, ULONG Argc, CHAR *Argv[], | ||
| 16 | CHAR *Envp[]) | ||
| 17 | { | ||
| 18 | return ARC_CALL5(invoke, ExecAddr, StackAddr, Argc, Argv, Envp); | ||
| 19 | } | ||
| 20 | |||
| 21 | LONG __init ArcExecute(CHAR *Path, LONG Argc, CHAR *Argv[], CHAR *Envp[]) | ||
| 22 | { | ||
| 23 | return ARC_CALL4(exec, Path, Argc, Argv, Envp); | ||
| 24 | } | ||
diff --git a/arch/mips/fw/arc/time.c b/arch/mips/fw/arc/time.c new file mode 100644 index 000000000000..42138c837d48 --- /dev/null +++ b/arch/mips/fw/arc/time.c | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | /* | ||
| 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 | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * Extracting time information from ARCS prom. | ||
| 7 | * | ||
| 8 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | ||
| 9 | */ | ||
| 10 | #include <linux/init.h> | ||
| 11 | |||
| 12 | #include <asm/fw/arc/types.h> | ||
| 13 | #include <asm/sgialib.h> | ||
| 14 | |||
| 15 | struct linux_tinfo * __init | ||
| 16 | ArcGetTime(VOID) | ||
| 17 | { | ||
| 18 | return (struct linux_tinfo *) ARC_CALL0(get_tinfo); | ||
| 19 | } | ||
| 20 | |||
| 21 | ULONG __init | ||
| 22 | ArcGetRelativeTime(VOID) | ||
| 23 | { | ||
| 24 | return ARC_CALL0(get_rtime); | ||
| 25 | } | ||
diff --git a/arch/mips/fw/arc/tree.c b/arch/mips/fw/arc/tree.c new file mode 100644 index 000000000000..d68e5a59c1f6 --- /dev/null +++ b/arch/mips/fw/arc/tree.c | |||
| @@ -0,0 +1,127 @@ | |||
| 1 | /* | ||
| 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 | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * PROM component device tree code. | ||
| 7 | * | ||
| 8 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | ||
| 9 | * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org) | ||
| 10 | * Copyright (C) 1999 Silicon Graphics, Inc. | ||
| 11 | */ | ||
| 12 | #include <linux/init.h> | ||
| 13 | #include <asm/fw/arc/types.h> | ||
| 14 | #include <asm/sgialib.h> | ||
| 15 | |||
| 16 | #undef DEBUG_PROM_TREE | ||
| 17 | |||
| 18 | pcomponent * __init | ||
| 19 | ArcGetPeer(pcomponent *Current) | ||
| 20 | { | ||
| 21 | if (Current == PROM_NULL_COMPONENT) | ||
| 22 | return PROM_NULL_COMPONENT; | ||
| 23 | |||
| 24 | return (pcomponent *) ARC_CALL1(next_component, Current); | ||
| 25 | } | ||
| 26 | |||
| 27 | pcomponent * __init | ||
| 28 | ArcGetChild(pcomponent *Current) | ||
| 29 | { | ||
| 30 | return (pcomponent *) ARC_CALL1(child_component, Current); | ||
| 31 | } | ||
| 32 | |||
| 33 | pcomponent * __init | ||
| 34 | ArcGetParent(pcomponent *Current) | ||
| 35 | { | ||
| 36 | if (Current == PROM_NULL_COMPONENT) | ||
| 37 | return PROM_NULL_COMPONENT; | ||
| 38 | |||
| 39 | return (pcomponent *) ARC_CALL1(parent_component, Current); | ||
| 40 | } | ||
| 41 | |||
| 42 | LONG __init | ||
| 43 | ArcGetConfigurationData(VOID *Buffer, pcomponent *Current) | ||
| 44 | { | ||
| 45 | return ARC_CALL2(component_data, Buffer, Current); | ||
| 46 | } | ||
| 47 | |||
| 48 | pcomponent * __init | ||
| 49 | ArcAddChild(pcomponent *Current, pcomponent *Template, VOID *ConfigurationData) | ||
| 50 | { | ||
| 51 | return (pcomponent *) | ||
| 52 | ARC_CALL3(child_add, Current, Template, ConfigurationData); | ||
| 53 | } | ||
| 54 | |||
| 55 | LONG __init | ||
| 56 | ArcDeleteComponent(pcomponent *ComponentToDelete) | ||
| 57 | { | ||
| 58 | return ARC_CALL1(comp_del, ComponentToDelete); | ||
| 59 | } | ||
| 60 | |||
| 61 | pcomponent * __init | ||
| 62 | ArcGetComponent(CHAR *Path) | ||
| 63 | { | ||
| 64 | return (pcomponent *)ARC_CALL1(component_by_path, Path); | ||
| 65 | } | ||
| 66 | |||
| 67 | #ifdef DEBUG_PROM_TREE | ||
| 68 | |||
| 69 | static char *classes[] = { | ||
| 70 | "system", "processor", "cache", "adapter", "controller", "peripheral", | ||
| 71 | "memory" | ||
| 72 | }; | ||
| 73 | |||
| 74 | static char *types[] = { | ||
| 75 | "arc", "cpu", "fpu", "picache", "pdcache", "sicache", "sdcache", | ||
| 76 | "sccache", "memdev", "eisa adapter", "tc adapter", "scsi adapter", | ||
| 77 | "dti adapter", "multi-func adapter", "disk controller", | ||
| 78 | "tp controller", "cdrom controller", "worm controller", | ||
| 79 | "serial controller", "net controller", "display controller", | ||
| 80 | "parallel controller", "pointer controller", "keyboard controller", | ||
| 81 | "audio controller", "misc controller", "disk peripheral", | ||
| 82 | "floppy peripheral", "tp peripheral", "modem peripheral", | ||
| 83 | "monitor peripheral", "printer peripheral", "pointer peripheral", | ||
| 84 | "keyboard peripheral", "terminal peripheral", "line peripheral", | ||
| 85 | "net peripheral", "misc peripheral", "anonymous" | ||
| 86 | }; | ||
| 87 | |||
| 88 | static char *iflags[] = { | ||
| 89 | "bogus", "read only", "removable", "console in", "console out", | ||
| 90 | "input", "output" | ||
| 91 | }; | ||
| 92 | |||
| 93 | static void __init | ||
| 94 | dump_component(pcomponent *p) | ||
| 95 | { | ||
| 96 | printk("[%p]:class<%s>type<%s>flags<%s>ver<%d>rev<%d>", | ||
| 97 | p, classes[p->class], types[p->type], | ||
| 98 | iflags[p->iflags], p->vers, p->rev); | ||
| 99 | printk("key<%08lx>\n\tamask<%08lx>cdsize<%d>ilen<%d>iname<%s>\n", | ||
| 100 | p->key, p->amask, (int)p->cdsize, (int)p->ilen, p->iname); | ||
| 101 | } | ||
| 102 | |||
| 103 | static void __init | ||
| 104 | traverse(pcomponent *p, int op) | ||
| 105 | { | ||
| 106 | dump_component(p); | ||
| 107 | if(ArcGetChild(p)) | ||
| 108 | traverse(ArcGetChild(p), 1); | ||
| 109 | if(ArcGetPeer(p) && op) | ||
| 110 | traverse(ArcGetPeer(p), 1); | ||
| 111 | } | ||
| 112 | |||
| 113 | void __init | ||
| 114 | prom_testtree(void) | ||
| 115 | { | ||
| 116 | pcomponent *p; | ||
| 117 | |||
| 118 | p = ArcGetChild(PROM_NULL_COMPONENT); | ||
| 119 | dump_component(p); | ||
| 120 | p = ArcGetChild(p); | ||
| 121 | while(p) { | ||
| 122 | dump_component(p); | ||
| 123 | p = ArcGetPeer(p); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | #endif /* DEBUG_PROM_TREE */ | ||
