diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/mips/arc |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/mips/arc')
-rw-r--r-- | arch/mips/arc/Makefile | 10 | ||||
-rw-r--r-- | arch/mips/arc/arc_con.c | 50 | ||||
-rw-r--r-- | arch/mips/arc/cmdline.c | 108 | ||||
-rw-r--r-- | arch/mips/arc/console.c | 63 | ||||
-rw-r--r-- | arch/mips/arc/env.c | 27 | ||||
-rw-r--r-- | arch/mips/arc/file.c | 75 | ||||
-rw-r--r-- | arch/mips/arc/identify.c | 119 | ||||
-rw-r--r-- | arch/mips/arc/init.c | 48 | ||||
-rw-r--r-- | arch/mips/arc/memory.c | 170 | ||||
-rw-r--r-- | arch/mips/arc/misc.c | 108 | ||||
-rw-r--r-- | arch/mips/arc/promlib.c | 43 | ||||
-rw-r--r-- | arch/mips/arc/salone.c | 24 | ||||
-rw-r--r-- | arch/mips/arc/time.c | 25 | ||||
-rw-r--r-- | arch/mips/arc/tree.c | 127 |
14 files changed, 997 insertions, 0 deletions
diff --git a/arch/mips/arc/Makefile b/arch/mips/arc/Makefile new file mode 100644 index 000000000000..e8424932e1a3 --- /dev/null +++ b/arch/mips/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 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/arc/arc_con.c b/arch/mips/arc/arc_con.c new file mode 100644 index 000000000000..51785a6a7328 --- /dev/null +++ b/arch/mips/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 __init 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/arc/cmdline.c b/arch/mips/arc/cmdline.c new file mode 100644 index 000000000000..fd604ef28823 --- /dev/null +++ b/arch/mips/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/arc/console.c b/arch/mips/arc/console.c new file mode 100644 index 000000000000..6a9d144512c0 --- /dev/null +++ b/arch/mips/arc/console.c | |||
@@ -0,0 +1,63 @@ | |||
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 | } | ||
44 | |||
45 | void prom_printf(char *fmt, ...) | ||
46 | { | ||
47 | va_list args; | ||
48 | char ppbuf[1024]; | ||
49 | char *bptr; | ||
50 | |||
51 | va_start(args, fmt); | ||
52 | vsprintf(ppbuf, fmt, args); | ||
53 | |||
54 | bptr = ppbuf; | ||
55 | |||
56 | while (*bptr != 0) { | ||
57 | if (*bptr == '\n') | ||
58 | prom_putchar('\r'); | ||
59 | |||
60 | prom_putchar(*bptr++); | ||
61 | } | ||
62 | va_end(args); | ||
63 | } | ||
diff --git a/arch/mips/arc/env.c b/arch/mips/arc/env.c new file mode 100644 index 000000000000..e521a6e010aa --- /dev/null +++ b/arch/mips/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/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/arc/file.c b/arch/mips/arc/file.c new file mode 100644 index 000000000000..a43425b3c838 --- /dev/null +++ b/arch/mips/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/arc/types.h> | ||
14 | #include <asm/sgialib.h> | ||
15 | |||
16 | LONG __init | ||
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 __init | ||
24 | ArcOpen(CHAR *Path, enum linux_omode OpenMode, ULONG *FileID) | ||
25 | { | ||
26 | return ARC_CALL3(open, Path, OpenMode, FileID); | ||
27 | } | ||
28 | |||
29 | LONG __init | ||
30 | ArcClose(ULONG FileID) | ||
31 | { | ||
32 | return ARC_CALL1(close, FileID); | ||
33 | } | ||
34 | |||
35 | LONG __init | ||
36 | ArcRead(ULONG FileID, VOID *Buffer, ULONG N, ULONG *Count) | ||
37 | { | ||
38 | return ARC_CALL4(read, FileID, Buffer, N, Count); | ||
39 | } | ||
40 | |||
41 | LONG __init | ||
42 | ArcGetReadStatus(ULONG FileID) | ||
43 | { | ||
44 | return ARC_CALL1(get_rstatus, FileID); | ||
45 | } | ||
46 | |||
47 | LONG __init | ||
48 | ArcWrite(ULONG FileID, PVOID Buffer, ULONG N, PULONG Count) | ||
49 | { | ||
50 | return ARC_CALL4(write, FileID, Buffer, N, Count); | ||
51 | } | ||
52 | |||
53 | LONG __init | ||
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 __init | ||
60 | ArcMount(char *name, enum linux_mountops op) | ||
61 | { | ||
62 | return ARC_CALL2(mount, name, op); | ||
63 | } | ||
64 | |||
65 | LONG __init | ||
66 | ArcGetFileInformation(ULONG FileID, struct linux_finfo *Information) | ||
67 | { | ||
68 | return ARC_CALL2(get_finfo, FileID, Information); | ||
69 | } | ||
70 | |||
71 | LONG __init ArcSetFileInformation(ULONG FileID, ULONG AttributeFlags, | ||
72 | ULONG AttributeMask) | ||
73 | { | ||
74 | return ARC_CALL3(set_finfo, FileID, AttributeFlags, AttributeMask); | ||
75 | } | ||
diff --git a/arch/mips/arc/identify.c b/arch/mips/arc/identify.c new file mode 100644 index 000000000000..0dd7a345eb79 --- /dev/null +++ b/arch/mips/arc/identify.c | |||
@@ -0,0 +1,119 @@ | |||
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/config.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/types.h> | ||
18 | #include <linux/string.h> | ||
19 | |||
20 | #include <asm/sgialib.h> | ||
21 | #include <asm/bootinfo.h> | ||
22 | |||
23 | struct smatch { | ||
24 | char *arcname; | ||
25 | char *liname; | ||
26 | int group; | ||
27 | int type; | ||
28 | int flags; | ||
29 | }; | ||
30 | |||
31 | static struct smatch mach_table[] = { | ||
32 | { "SGI-IP22", | ||
33 | "SGI Indy", | ||
34 | MACH_GROUP_SGI, | ||
35 | MACH_SGI_IP22, | ||
36 | PROM_FLAG_ARCS | ||
37 | }, { "SGI-IP27", | ||
38 | "SGI Origin", | ||
39 | MACH_GROUP_SGI, | ||
40 | MACH_SGI_IP27, | ||
41 | PROM_FLAG_ARCS | ||
42 | }, { "SGI-IP28", | ||
43 | "SGI IP28", | ||
44 | MACH_GROUP_SGI, | ||
45 | MACH_SGI_IP28, | ||
46 | PROM_FLAG_ARCS | ||
47 | }, { "SGI-IP32", | ||
48 | "SGI O2", | ||
49 | MACH_GROUP_SGI, | ||
50 | MACH_SGI_IP32, | ||
51 | PROM_FLAG_ARCS | ||
52 | }, { "Microsoft-Jazz", | ||
53 | "Jazz MIPS_Magnum_4000", | ||
54 | MACH_GROUP_JAZZ, | ||
55 | MACH_MIPS_MAGNUM_4000, | ||
56 | 0 | ||
57 | }, { "PICA-61", | ||
58 | "Jazz Acer_PICA_61", | ||
59 | MACH_GROUP_JAZZ, | ||
60 | MACH_ACER_PICA_61, | ||
61 | 0 | ||
62 | }, { "RM200PCI", | ||
63 | "SNI RM200_PCI", | ||
64 | MACH_GROUP_SNI_RM, | ||
65 | MACH_SNI_RM200_PCI, | ||
66 | PROM_FLAG_DONT_FREE_TEMP | ||
67 | } | ||
68 | }; | ||
69 | |||
70 | int prom_flags; | ||
71 | |||
72 | static struct smatch * __init string_to_mach(const char *s) | ||
73 | { | ||
74 | int i; | ||
75 | |||
76 | for (i = 0; i < (sizeof(mach_table) / sizeof (mach_table[0])); i++) { | ||
77 | if (!strcmp(s, mach_table[i].arcname)) | ||
78 | return &mach_table[i]; | ||
79 | } | ||
80 | |||
81 | panic("Yeee, could not determine architecture type <%s>", s); | ||
82 | } | ||
83 | |||
84 | char *system_type; | ||
85 | |||
86 | const char *get_system_type(void) | ||
87 | { | ||
88 | return system_type; | ||
89 | } | ||
90 | |||
91 | void __init prom_identify_arch(void) | ||
92 | { | ||
93 | pcomponent *p; | ||
94 | struct smatch *mach; | ||
95 | const char *iname; | ||
96 | |||
97 | /* | ||
98 | * The root component tells us what machine architecture we have here. | ||
99 | */ | ||
100 | p = ArcGetChild(PROM_NULL_COMPONENT); | ||
101 | if (p == NULL) { | ||
102 | #ifdef CONFIG_SGI_IP27 | ||
103 | /* IP27 PROM misbehaves, seems to not implement ARC | ||
104 | GetChild(). So we just assume it's an IP27. */ | ||
105 | iname = "SGI-IP27"; | ||
106 | #else | ||
107 | iname = "Unknown"; | ||
108 | #endif | ||
109 | } else | ||
110 | iname = (char *) (long) p->iname; | ||
111 | |||
112 | printk("ARCH: %s\n", iname); | ||
113 | mach = string_to_mach(iname); | ||
114 | system_type = mach->liname; | ||
115 | |||
116 | mips_machgroup = mach->group; | ||
117 | mips_machtype = mach->type; | ||
118 | prom_flags = mach->flags; | ||
119 | } | ||
diff --git a/arch/mips/arc/init.c b/arch/mips/arc/init.c new file mode 100644 index 000000000000..76ab505ca693 --- /dev/null +++ b/arch/mips/arc/init.c | |||
@@ -0,0 +1,48 @@ | |||
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 | romvec = ROMVECTOR; | ||
27 | prom_argc = fw_arg0; | ||
28 | _prom_argv = (LONG *) fw_arg1; | ||
29 | _prom_envp = (LONG *) fw_arg2; | ||
30 | |||
31 | if (pb->magic != 0x53435241) { | ||
32 | prom_printf("Aieee, bad prom vector magic %08lx\n", pb->magic); | ||
33 | while(1) | ||
34 | ; | ||
35 | } | ||
36 | |||
37 | prom_init_cmdline(); | ||
38 | prom_identify_arch(); | ||
39 | printk(KERN_INFO "PROMLIB: ARC firmware Version %d Revision %d\n", | ||
40 | pb->ver, pb->rev); | ||
41 | prom_meminit(); | ||
42 | |||
43 | #ifdef DEBUG_PROM_INIT | ||
44 | prom_printf("Press a key to reboot\n"); | ||
45 | prom_getchar(); | ||
46 | ArcEnterInteractiveMode(); | ||
47 | #endif | ||
48 | } | ||
diff --git a/arch/mips/arc/memory.c b/arch/mips/arc/memory.c new file mode 100644 index 000000000000..958d2eb78862 --- /dev/null +++ b/arch/mips/arc/memory.c | |||
@@ -0,0 +1,170 @@ | |||
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 | prom_printf("ARCS MEMORY DESCRIPTOR dump:\n"); | ||
122 | p = ArcGetMemoryDescriptor(PROM_NULL_MDESC); | ||
123 | while(p) { | ||
124 | prom_printf("[%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 | unsigned long __init prom_free_prom_memory(void) | ||
145 | { | ||
146 | unsigned long freed = 0; | ||
147 | unsigned long addr; | ||
148 | int i; | ||
149 | |||
150 | if (prom_flags & PROM_FLAG_DONT_FREE_TEMP) | ||
151 | return 0; | ||
152 | |||
153 | for (i = 0; i < boot_mem_map.nr_map; i++) { | ||
154 | if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA) | ||
155 | continue; | ||
156 | |||
157 | addr = boot_mem_map.map[i].addr; | ||
158 | while (addr < boot_mem_map.map[i].addr | ||
159 | + boot_mem_map.map[i].size) { | ||
160 | ClearPageReserved(virt_to_page(__va(addr))); | ||
161 | set_page_count(virt_to_page(__va(addr)), 1); | ||
162 | free_page((unsigned long)__va(addr)); | ||
163 | addr += PAGE_SIZE; | ||
164 | freed += PAGE_SIZE; | ||
165 | } | ||
166 | } | ||
167 | printk(KERN_INFO "Freeing prom memory: %ldkb freed\n", freed >> 10); | ||
168 | |||
169 | return freed; | ||
170 | } | ||
diff --git a/arch/mips/arc/misc.c b/arch/mips/arc/misc.c new file mode 100644 index 000000000000..84867de22028 --- /dev/null +++ b/arch/mips/arc/misc.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 | * 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/config.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/kernel.h> | ||
15 | |||
16 | #include <asm/bcache.h> | ||
17 | |||
18 | #include <asm/arc/types.h> | ||
19 | #include <asm/sgialib.h> | ||
20 | #include <asm/bootinfo.h> | ||
21 | #include <asm/system.h> | ||
22 | |||
23 | extern void *sgiwd93_host; | ||
24 | extern void reset_wd33c93(void *instance); | ||
25 | |||
26 | VOID | ||
27 | ArcHalt(VOID) | ||
28 | { | ||
29 | bc_disable(); | ||
30 | local_irq_disable(); | ||
31 | #ifdef CONFIG_SCSI_SGIWD93 | ||
32 | reset_wd33c93(sgiwd93_host); | ||
33 | #endif | ||
34 | ARC_CALL0(halt); | ||
35 | never: goto never; | ||
36 | } | ||
37 | |||
38 | VOID | ||
39 | ArcPowerDown(VOID) | ||
40 | { | ||
41 | bc_disable(); | ||
42 | local_irq_disable(); | ||
43 | #ifdef CONFIG_SCSI_SGIWD93 | ||
44 | reset_wd33c93(sgiwd93_host); | ||
45 | #endif | ||
46 | ARC_CALL0(pdown); | ||
47 | never: goto never; | ||
48 | } | ||
49 | |||
50 | /* XXX is this a soft reset basically? XXX */ | ||
51 | VOID | ||
52 | ArcRestart(VOID) | ||
53 | { | ||
54 | bc_disable(); | ||
55 | local_irq_disable(); | ||
56 | #ifdef CONFIG_SCSI_SGIWD93 | ||
57 | reset_wd33c93(sgiwd93_host); | ||
58 | #endif | ||
59 | ARC_CALL0(restart); | ||
60 | never: goto never; | ||
61 | } | ||
62 | |||
63 | VOID | ||
64 | ArcReboot(VOID) | ||
65 | { | ||
66 | bc_disable(); | ||
67 | local_irq_disable(); | ||
68 | #ifdef CONFIG_SCSI_SGIWD93 | ||
69 | reset_wd33c93(sgiwd93_host); | ||
70 | #endif | ||
71 | ARC_CALL0(reboot); | ||
72 | never: goto never; | ||
73 | } | ||
74 | |||
75 | VOID | ||
76 | ArcEnterInteractiveMode(VOID) | ||
77 | { | ||
78 | bc_disable(); | ||
79 | local_irq_disable(); | ||
80 | #ifdef CONFIG_SCSI_SGIWD93 | ||
81 | reset_wd33c93(sgiwd93_host); | ||
82 | #endif | ||
83 | ARC_CALL0(imode); | ||
84 | never: goto never; | ||
85 | } | ||
86 | |||
87 | LONG | ||
88 | ArcSaveConfiguration(VOID) | ||
89 | { | ||
90 | return ARC_CALL0(cfg_save); | ||
91 | } | ||
92 | |||
93 | struct linux_sysid * | ||
94 | ArcGetSystemId(VOID) | ||
95 | { | ||
96 | return (struct linux_sysid *) ARC_CALL0(get_sysid); | ||
97 | } | ||
98 | |||
99 | VOID __init | ||
100 | ArcFlushAllCaches(VOID) | ||
101 | { | ||
102 | ARC_CALL0(cache_flush); | ||
103 | } | ||
104 | |||
105 | DISPLAY_STATUS * __init ArcGetDisplayStatus(ULONG FileID) | ||
106 | { | ||
107 | return (DISPLAY_STATUS *) ARC_CALL1(GetDisplayStatus, FileID); | ||
108 | } | ||
diff --git a/arch/mips/arc/promlib.c b/arch/mips/arc/promlib.c new file mode 100644 index 000000000000..c508c00dbb64 --- /dev/null +++ b/arch/mips/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/arc/salone.c b/arch/mips/arc/salone.c new file mode 100644 index 000000000000..e6afb64723d0 --- /dev/null +++ b/arch/mips/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/arc/time.c b/arch/mips/arc/time.c new file mode 100644 index 000000000000..299ff2c5c0b5 --- /dev/null +++ b/arch/mips/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/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/arc/tree.c b/arch/mips/arc/tree.c new file mode 100644 index 000000000000..2aedd4f52839 --- /dev/null +++ b/arch/mips/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/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 | prom_printf("[%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 | prom_printf("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 */ | ||