aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/fw
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/fw')
-rw-r--r--arch/mips/fw/arc/Makefile10
-rw-r--r--arch/mips/fw/arc/arc_con.c50
-rw-r--r--arch/mips/fw/arc/cmdline.c108
-rw-r--r--arch/mips/fw/arc/env.c27
-rw-r--r--arch/mips/fw/arc/file.c75
-rw-r--r--arch/mips/fw/arc/identify.c121
-rw-r--r--arch/mips/fw/arc/init.c51
-rw-r--r--arch/mips/fw/arc/memory.c160
-rw-r--r--arch/mips/fw/arc/misc.c89
-rw-r--r--arch/mips/fw/arc/promlib.c43
-rw-r--r--arch/mips/fw/arc/salone.c24
-rw-r--r--arch/mips/fw/arc/time.c25
-rw-r--r--arch/mips/fw/arc/tree.c127
-rw-r--r--arch/mips/fw/cfe/Makefile5
-rw-r--r--arch/mips/fw/cfe/cfe_api.c502
-rw-r--r--arch/mips/fw/cfe/cfe_api_int.h152
16 files changed, 1569 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
5lib-y += cmdline.o env.o file.o identify.o init.o \
6 misc.o salone.o time.o tree.o
7
8lib-$(CONFIG_ARC_MEMORY) += memory.o
9lib-$(CONFIG_ARC_CONSOLE) += arc_con.o
10lib-$(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
16static 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
27static int prom_console_setup(struct console *co, char *options)
28{
29 return !(prom_flags & PROM_FLAG_USE_AS_CONSOLE);
30}
31
32static 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
44static int __init arc_console_init(void)
45{
46 register_console(&arc_cons);
47
48 return 0;
49}
50console_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
19char * __init prom_getcmdline(void)
20{
21 return arcs_cmdline;
22}
23
24static char *ignored[] = {
25 "ConsoleIn=",
26 "ConsoleOut=",
27 "SystemPartition=",
28 "OSLoader=",
29 "OSLoadPartition=",
30 "OSLoadFilename=",
31 "OSLoadOptions="
32};
33
34static char *used_arc[][2] = {
35 { "OSLoadPartition=", "root=" },
36 { "OSLoadOptions=", "" }
37};
38
39static 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
71void __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
17PCHAR __init
18ArcGetEnvironmentVariable(CHAR *name)
19{
20 return (CHAR *) ARC_CALL1(get_evar, name);
21}
22
23LONG __init
24ArcSetEnvironmentVariable(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
16LONG
17ArcGetDirectoryEntry(ULONG FileID, struct linux_vdirent *Buffer,
18 ULONG N, ULONG *Count)
19{
20 return ARC_CALL4(get_vdirent, FileID, Buffer, N, Count);
21}
22
23LONG
24ArcOpen(CHAR *Path, enum linux_omode OpenMode, ULONG *FileID)
25{
26 return ARC_CALL3(open, Path, OpenMode, FileID);
27}
28
29LONG
30ArcClose(ULONG FileID)
31{
32 return ARC_CALL1(close, FileID);
33}
34
35LONG
36ArcRead(ULONG FileID, VOID *Buffer, ULONG N, ULONG *Count)
37{
38 return ARC_CALL4(read, FileID, Buffer, N, Count);
39}
40
41LONG
42ArcGetReadStatus(ULONG FileID)
43{
44 return ARC_CALL1(get_rstatus, FileID);
45}
46
47LONG
48ArcWrite(ULONG FileID, PVOID Buffer, ULONG N, PULONG Count)
49{
50 return ARC_CALL4(write, FileID, Buffer, N, Count);
51}
52
53LONG
54ArcSeek(ULONG FileID, struct linux_bigint *Position, enum linux_seekmode SeekMode)
55{
56 return ARC_CALL3(seek, FileID, Position, SeekMode);
57}
58
59LONG
60ArcMount(char *name, enum linux_mountops op)
61{
62 return ARC_CALL2(mount, name, op);
63}
64
65LONG
66ArcGetFileInformation(ULONG FileID, struct linux_finfo *Information)
67{
68 return ARC_CALL2(get_finfo, FileID, Information);
69}
70
71LONG 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..28dfd2e2989a
--- /dev/null
+++ b/arch/mips/fw/arc/identify.c
@@ -0,0 +1,121 @@
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
22struct smatch {
23 char *arcname;
24 char *liname;
25 int type;
26 int flags;
27};
28
29static struct smatch mach_table[] = {
30 {
31 .arcname = "SGI-IP22",
32 .liname = "SGI Indy",
33 .type = MACH_SGI_IP22,
34 .flags = PROM_FLAG_ARCS,
35 }, {
36 .arcname = "SGI-IP27",
37 .liname = "SGI Origin",
38 .type = MACH_SGI_IP27,
39 .flags = PROM_FLAG_ARCS,
40 }, {
41 .arcname = "SGI-IP28",
42 .liname = "SGI IP28",
43 .type = MACH_SGI_IP28,
44 .flags = PROM_FLAG_ARCS,
45 }, {
46 .arcname = "SGI-IP30",
47 .liname = "SGI Octane",
48 .type = MACH_SGI_IP30,
49 .flags = PROM_FLAG_ARCS,
50 }, {
51 .arcname = "SGI-IP32",
52 .liname = "SGI O2",
53 .type = MACH_SGI_IP32,
54 .flags = PROM_FLAG_ARCS,
55 }, {
56 .arcname = "Microsoft-Jazz",
57 .liname = "Jazz MIPS_Magnum_4000",
58 .type = MACH_MIPS_MAGNUM_4000,
59 .flags = 0,
60 }, {
61 .arcname = "PICA-61",
62 .liname = "Jazz Acer_PICA_61",
63 .type = MACH_ACER_PICA_61,
64 .flags = 0,
65 }, {
66 .arcname = "RM200PCI",
67 .liname = "SNI RM200_PCI",
68 .type = MACH_SNI_RM200_PCI,
69 .flags = PROM_FLAG_DONT_FREE_TEMP,
70 }
71};
72
73int prom_flags;
74
75static struct smatch * __init string_to_mach(const char *s)
76{
77 int i;
78
79 for (i = 0; i < ARRAY_SIZE(mach_table); i++) {
80 if (!strcmp(s, mach_table[i].arcname))
81 return &mach_table[i];
82 }
83
84 panic("Yeee, could not determine architecture type <%s>", s);
85}
86
87char *system_type;
88
89const char *get_system_type(void)
90{
91 return system_type;
92}
93
94void __init prom_identify_arch(void)
95{
96 pcomponent *p;
97 struct smatch *mach;
98 const char *iname;
99
100 /*
101 * The root component tells us what machine architecture we have here.
102 */
103 p = ArcGetChild(PROM_NULL_COMPONENT);
104 if (p == NULL) {
105#ifdef CONFIG_SGI_IP27
106 /* IP27 PROM misbehaves, seems to not implement ARC
107 GetChild(). So we just assume it's an IP27. */
108 iname = "SGI-IP27";
109#else
110 iname = "Unknown";
111#endif
112 } else
113 iname = (char *) (long) p->iname;
114
115 printk("ARCH: %s\n", iname);
116 mach = string_to_mach(iname);
117 system_type = mach->liname;
118
119 mips_machtype = mach->type;
120 prom_flags = mach->flags;
121}
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. */
19struct linux_romvec *romvec;
20int prom_argc;
21LONG *_prom_argv, *_prom_envp;
22
23void __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..8b8eea2b6cf6
--- /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
35struct 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 */
41static 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
52static 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
66static 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
86static 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
106static 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
114void __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
144void __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
22VOID
23ArcHalt(VOID)
24{
25 bc_disable();
26 local_irq_disable();
27 ARC_CALL0(halt);
28never: goto never;
29}
30
31VOID
32ArcPowerDown(VOID)
33{
34 bc_disable();
35 local_irq_disable();
36 ARC_CALL0(pdown);
37never: goto never;
38}
39
40/* XXX is this a soft reset basically? XXX */
41VOID
42ArcRestart(VOID)
43{
44 bc_disable();
45 local_irq_disable();
46 ARC_CALL0(restart);
47never: goto never;
48}
49
50VOID
51ArcReboot(VOID)
52{
53 bc_disable();
54 local_irq_disable();
55 ARC_CALL0(reboot);
56never: goto never;
57}
58
59VOID
60ArcEnterInteractiveMode(VOID)
61{
62 bc_disable();
63 local_irq_disable();
64 ARC_CALL0(imode);
65never: goto never;
66}
67
68LONG
69ArcSaveConfiguration(VOID)
70{
71 return ARC_CALL0(cfg_save);
72}
73
74struct linux_sysid *
75ArcGetSystemId(VOID)
76{
77 return (struct linux_sysid *) ARC_CALL0(get_sysid);
78}
79
80VOID __init
81ArcFlushAllCaches(VOID)
82{
83 ARC_CALL0(cache_flush);
84}
85
86DISPLAY_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
23void 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
33char 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
10LONG __init ArcLoad(CHAR *Path, ULONG TopAddr, ULONG *ExecAddr, ULONG *LowAddr)
11{
12 return ARC_CALL4(load, Path, TopAddr, ExecAddr, LowAddr);
13}
14
15LONG __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
21LONG __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
15struct linux_tinfo * __init
16ArcGetTime(VOID)
17{
18 return (struct linux_tinfo *) ARC_CALL0(get_tinfo);
19}
20
21ULONG __init
22ArcGetRelativeTime(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
18pcomponent * __init
19ArcGetPeer(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
27pcomponent * __init
28ArcGetChild(pcomponent *Current)
29{
30 return (pcomponent *) ARC_CALL1(child_component, Current);
31}
32
33pcomponent * __init
34ArcGetParent(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
42LONG __init
43ArcGetConfigurationData(VOID *Buffer, pcomponent *Current)
44{
45 return ARC_CALL2(component_data, Buffer, Current);
46}
47
48pcomponent * __init
49ArcAddChild(pcomponent *Current, pcomponent *Template, VOID *ConfigurationData)
50{
51 return (pcomponent *)
52 ARC_CALL3(child_add, Current, Template, ConfigurationData);
53}
54
55LONG __init
56ArcDeleteComponent(pcomponent *ComponentToDelete)
57{
58 return ARC_CALL1(comp_del, ComponentToDelete);
59}
60
61pcomponent * __init
62ArcGetComponent(CHAR *Path)
63{
64 return (pcomponent *)ARC_CALL1(component_by_path, Path);
65}
66
67#ifdef DEBUG_PROM_TREE
68
69static char *classes[] = {
70 "system", "processor", "cache", "adapter", "controller", "peripheral",
71 "memory"
72};
73
74static 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
88static char *iflags[] = {
89 "bogus", "read only", "removable", "console in", "console out",
90 "input", "output"
91};
92
93static void __init
94dump_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
103static void __init
104traverse(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
113void __init
114prom_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 */
diff --git a/arch/mips/fw/cfe/Makefile b/arch/mips/fw/cfe/Makefile
new file mode 100644
index 000000000000..8f20044c0adf
--- /dev/null
+++ b/arch/mips/fw/cfe/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the Broadcom Common Firmware Environment support
3#
4
5lib-y += cfe_api.o
diff --git a/arch/mips/fw/cfe/cfe_api.c b/arch/mips/fw/cfe/cfe_api.c
new file mode 100644
index 000000000000..a9f69e4e40ac
--- /dev/null
+++ b/arch/mips/fw/cfe/cfe_api.c
@@ -0,0 +1,502 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19/* *********************************************************************
20 *
21 * Broadcom Common Firmware Environment (CFE)
22 *
23 * Device Function stubs File: cfe_api.c
24 *
25 * This module contains device function stubs (small routines to
26 * call the standard "iocb" interface entry point to CFE).
27 * There should be one routine here per iocb function call.
28 *
29 * Authors: Mitch Lichtenberg, Chris Demetriou
30 *
31 ********************************************************************* */
32
33#include <asm/fw/cfe/cfe_api.h>
34#include "cfe_api_int.h"
35
36/* Cast from a native pointer to a cfe_xptr_t and back. */
37#define XPTR_FROM_NATIVE(n) ((cfe_xptr_t) (intptr_t) (n))
38#define NATIVE_FROM_XPTR(x) ((void *) (intptr_t) (x))
39
40#ifdef CFE_API_IMPL_NAMESPACE
41#define cfe_iocb_dispatch(a) __cfe_iocb_dispatch(a)
42#endif
43int cfe_iocb_dispatch(cfe_xiocb_t * xiocb);
44
45#if defined(CFE_API_common) || defined(CFE_API_ALL)
46/*
47 * Declare the dispatch function with args of "intptr_t".
48 * This makes sure whatever model we're compiling in
49 * puts the pointers in a single register. For example,
50 * combining -mlong64 and -mips1 or -mips2 would lead to
51 * trouble, since the handle and IOCB pointer will be
52 * passed in two registers each, and CFE expects one.
53 */
54
55static int (*cfe_dispfunc) (intptr_t handle, intptr_t xiocb) = 0;
56static cfe_xuint_t cfe_handle = 0;
57
58int cfe_init(cfe_xuint_t handle, cfe_xuint_t ept)
59{
60 cfe_dispfunc = NATIVE_FROM_XPTR(ept);
61 cfe_handle = handle;
62 return 0;
63}
64
65int cfe_iocb_dispatch(cfe_xiocb_t * xiocb)
66{
67 if (!cfe_dispfunc)
68 return -1;
69 return (*cfe_dispfunc) ((intptr_t) cfe_handle, (intptr_t) xiocb);
70}
71#endif /* CFE_API_common || CFE_API_ALL */
72
73#if defined(CFE_API_close) || defined(CFE_API_ALL)
74int cfe_close(int handle)
75{
76 cfe_xiocb_t xiocb;
77
78 xiocb.xiocb_fcode = CFE_CMD_DEV_CLOSE;
79 xiocb.xiocb_status = 0;
80 xiocb.xiocb_handle = handle;
81 xiocb.xiocb_flags = 0;
82 xiocb.xiocb_psize = 0;
83
84 cfe_iocb_dispatch(&xiocb);
85
86 return xiocb.xiocb_status;
87
88}
89#endif /* CFE_API_close || CFE_API_ALL */
90
91#if defined(CFE_API_cpu_start) || defined(CFE_API_ALL)
92int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1)
93{
94 cfe_xiocb_t xiocb;
95
96 xiocb.xiocb_fcode = CFE_CMD_FW_CPUCTL;
97 xiocb.xiocb_status = 0;
98 xiocb.xiocb_handle = 0;
99 xiocb.xiocb_flags = 0;
100 xiocb.xiocb_psize = sizeof(xiocb_cpuctl_t);
101 xiocb.plist.xiocb_cpuctl.cpu_number = cpu;
102 xiocb.plist.xiocb_cpuctl.cpu_command = CFE_CPU_CMD_START;
103 xiocb.plist.xiocb_cpuctl.gp_val = gp;
104 xiocb.plist.xiocb_cpuctl.sp_val = sp;
105 xiocb.plist.xiocb_cpuctl.a1_val = a1;
106 xiocb.plist.xiocb_cpuctl.start_addr = (long) fn;
107
108 cfe_iocb_dispatch(&xiocb);
109
110 return xiocb.xiocb_status;
111}
112#endif /* CFE_API_cpu_start || CFE_API_ALL */
113
114#if defined(CFE_API_cpu_stop) || defined(CFE_API_ALL)
115int cfe_cpu_stop(int cpu)
116{
117 cfe_xiocb_t xiocb;
118
119 xiocb.xiocb_fcode = CFE_CMD_FW_CPUCTL;
120 xiocb.xiocb_status = 0;
121 xiocb.xiocb_handle = 0;
122 xiocb.xiocb_flags = 0;
123 xiocb.xiocb_psize = sizeof(xiocb_cpuctl_t);
124 xiocb.plist.xiocb_cpuctl.cpu_number = cpu;
125 xiocb.plist.xiocb_cpuctl.cpu_command = CFE_CPU_CMD_STOP;
126
127 cfe_iocb_dispatch(&xiocb);
128
129 return xiocb.xiocb_status;
130}
131#endif /* CFE_API_cpu_stop || CFE_API_ALL */
132
133#if defined(CFE_API_enumenv) || defined(CFE_API_ALL)
134int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen)
135{
136 cfe_xiocb_t xiocb;
137
138 xiocb.xiocb_fcode = CFE_CMD_ENV_SET;
139 xiocb.xiocb_status = 0;
140 xiocb.xiocb_handle = 0;
141 xiocb.xiocb_flags = 0;
142 xiocb.xiocb_psize = sizeof(xiocb_envbuf_t);
143 xiocb.plist.xiocb_envbuf.enum_idx = idx;
144 xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name);
145 xiocb.plist.xiocb_envbuf.name_length = namelen;
146 xiocb.plist.xiocb_envbuf.val_ptr = XPTR_FROM_NATIVE(val);
147 xiocb.plist.xiocb_envbuf.val_length = vallen;
148
149 cfe_iocb_dispatch(&xiocb);
150
151 return xiocb.xiocb_status;
152}
153#endif /* CFE_API_enumenv || CFE_API_ALL */
154
155#if defined(CFE_API_enummem) || defined(CFE_API_ALL)
156int
157cfe_enummem(int idx, int flags, cfe_xuint_t * start, cfe_xuint_t * length,
158 cfe_xuint_t * type)
159{
160 cfe_xiocb_t xiocb;
161
162 xiocb.xiocb_fcode = CFE_CMD_FW_MEMENUM;
163 xiocb.xiocb_status = 0;
164 xiocb.xiocb_handle = 0;
165 xiocb.xiocb_flags = flags;
166 xiocb.xiocb_psize = sizeof(xiocb_meminfo_t);
167 xiocb.plist.xiocb_meminfo.mi_idx = idx;
168
169 cfe_iocb_dispatch(&xiocb);
170
171 if (xiocb.xiocb_status < 0)
172 return xiocb.xiocb_status;
173
174 *start = xiocb.plist.xiocb_meminfo.mi_addr;
175 *length = xiocb.plist.xiocb_meminfo.mi_size;
176 *type = xiocb.plist.xiocb_meminfo.mi_type;
177
178 return 0;
179}
180#endif /* CFE_API_enummem || CFE_API_ALL */
181
182#if defined(CFE_API_exit) || defined(CFE_API_ALL)
183int cfe_exit(int warm, int status)
184{
185 cfe_xiocb_t xiocb;
186
187 xiocb.xiocb_fcode = CFE_CMD_FW_RESTART;
188 xiocb.xiocb_status = 0;
189 xiocb.xiocb_handle = 0;
190 xiocb.xiocb_flags = warm ? CFE_FLG_WARMSTART : 0;
191 xiocb.xiocb_psize = sizeof(xiocb_exitstat_t);
192 xiocb.plist.xiocb_exitstat.status = status;
193
194 cfe_iocb_dispatch(&xiocb);
195
196 return xiocb.xiocb_status;
197}
198#endif /* CFE_API_exit || CFE_API_ALL */
199
200#if defined(CFE_API_flushcache) || defined(CFE_API_ALL)
201int cfe_flushcache(int flg)
202{
203 cfe_xiocb_t xiocb;
204
205 xiocb.xiocb_fcode = CFE_CMD_FW_FLUSHCACHE;
206 xiocb.xiocb_status = 0;
207 xiocb.xiocb_handle = 0;
208 xiocb.xiocb_flags = flg;
209 xiocb.xiocb_psize = 0;
210
211 cfe_iocb_dispatch(&xiocb);
212
213 return xiocb.xiocb_status;
214}
215#endif /* CFE_API_flushcache || CFE_API_ALL */
216
217#if defined(CFE_API_getdevinfo) || defined(CFE_API_ALL)
218int cfe_getdevinfo(char *name)
219{
220 cfe_xiocb_t xiocb;
221
222 xiocb.xiocb_fcode = CFE_CMD_DEV_GETINFO;
223 xiocb.xiocb_status = 0;
224 xiocb.xiocb_handle = 0;
225 xiocb.xiocb_flags = 0;
226 xiocb.xiocb_psize = sizeof(xiocb_buffer_t);
227 xiocb.plist.xiocb_buffer.buf_offset = 0;
228 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(name);
229 xiocb.plist.xiocb_buffer.buf_length = cfe_strlen(name);
230
231 cfe_iocb_dispatch(&xiocb);
232
233 if (xiocb.xiocb_status < 0)
234 return xiocb.xiocb_status;
235 return xiocb.plist.xiocb_buffer.buf_devflags;
236}
237#endif /* CFE_API_getdevinfo || CFE_API_ALL */
238
239#if defined(CFE_API_getenv) || defined(CFE_API_ALL)
240int cfe_getenv(char *name, char *dest, int destlen)
241{
242 cfe_xiocb_t xiocb;
243
244 *dest = 0;
245
246 xiocb.xiocb_fcode = CFE_CMD_ENV_GET;
247 xiocb.xiocb_status = 0;
248 xiocb.xiocb_handle = 0;
249 xiocb.xiocb_flags = 0;
250 xiocb.xiocb_psize = sizeof(xiocb_envbuf_t);
251 xiocb.plist.xiocb_envbuf.enum_idx = 0;
252 xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name);
253 xiocb.plist.xiocb_envbuf.name_length = cfe_strlen(name);
254 xiocb.plist.xiocb_envbuf.val_ptr = XPTR_FROM_NATIVE(dest);
255 xiocb.plist.xiocb_envbuf.val_length = destlen;
256
257 cfe_iocb_dispatch(&xiocb);
258
259 return xiocb.xiocb_status;
260}
261#endif /* CFE_API_getenv || CFE_API_ALL */
262
263#if defined(CFE_API_getfwinfo) || defined(CFE_API_ALL)
264int cfe_getfwinfo(cfe_fwinfo_t * info)
265{
266 cfe_xiocb_t xiocb;
267
268 xiocb.xiocb_fcode = CFE_CMD_FW_GETINFO;
269 xiocb.xiocb_status = 0;
270 xiocb.xiocb_handle = 0;
271 xiocb.xiocb_flags = 0;
272 xiocb.xiocb_psize = sizeof(xiocb_fwinfo_t);
273
274 cfe_iocb_dispatch(&xiocb);
275
276 if (xiocb.xiocb_status < 0)
277 return xiocb.xiocb_status;
278
279 info->fwi_version = xiocb.plist.xiocb_fwinfo.fwi_version;
280 info->fwi_totalmem = xiocb.plist.xiocb_fwinfo.fwi_totalmem;
281 info->fwi_flags = xiocb.plist.xiocb_fwinfo.fwi_flags;
282 info->fwi_boardid = xiocb.plist.xiocb_fwinfo.fwi_boardid;
283 info->fwi_bootarea_va = xiocb.plist.xiocb_fwinfo.fwi_bootarea_va;
284 info->fwi_bootarea_pa = xiocb.plist.xiocb_fwinfo.fwi_bootarea_pa;
285 info->fwi_bootarea_size =
286 xiocb.plist.xiocb_fwinfo.fwi_bootarea_size;
287#if 0
288 info->fwi_reserved1 = xiocb.plist.xiocb_fwinfo.fwi_reserved1;
289 info->fwi_reserved2 = xiocb.plist.xiocb_fwinfo.fwi_reserved2;
290 info->fwi_reserved3 = xiocb.plist.xiocb_fwinfo.fwi_reserved3;
291#endif
292
293 return 0;
294}
295#endif /* CFE_API_getfwinfo || CFE_API_ALL */
296
297#if defined(CFE_API_getstdhandle) || defined(CFE_API_ALL)
298int cfe_getstdhandle(int flg)
299{
300 cfe_xiocb_t xiocb;
301
302 xiocb.xiocb_fcode = CFE_CMD_DEV_GETHANDLE;
303 xiocb.xiocb_status = 0;
304 xiocb.xiocb_handle = 0;
305 xiocb.xiocb_flags = flg;
306 xiocb.xiocb_psize = 0;
307
308 cfe_iocb_dispatch(&xiocb);
309
310 if (xiocb.xiocb_status < 0)
311 return xiocb.xiocb_status;
312 return xiocb.xiocb_handle;
313}
314#endif /* CFE_API_getstdhandle || CFE_API_ALL */
315
316#if defined(CFE_API_getticks) || defined(CFE_API_ALL)
317int64_t
318#ifdef CFE_API_IMPL_NAMESPACE
319__cfe_getticks(void)
320#else
321cfe_getticks(void)
322#endif
323{
324 cfe_xiocb_t xiocb;
325
326 xiocb.xiocb_fcode = CFE_CMD_FW_GETTIME;
327 xiocb.xiocb_status = 0;
328 xiocb.xiocb_handle = 0;
329 xiocb.xiocb_flags = 0;
330 xiocb.xiocb_psize = sizeof(xiocb_time_t);
331 xiocb.plist.xiocb_time.ticks = 0;
332
333 cfe_iocb_dispatch(&xiocb);
334
335 return xiocb.plist.xiocb_time.ticks;
336
337}
338#endif /* CFE_API_getticks || CFE_API_ALL */
339
340#if defined(CFE_API_inpstat) || defined(CFE_API_ALL)
341int cfe_inpstat(int handle)
342{
343 cfe_xiocb_t xiocb;
344
345 xiocb.xiocb_fcode = CFE_CMD_DEV_INPSTAT;
346 xiocb.xiocb_status = 0;
347 xiocb.xiocb_handle = handle;
348 xiocb.xiocb_flags = 0;
349 xiocb.xiocb_psize = sizeof(xiocb_inpstat_t);
350 xiocb.plist.xiocb_inpstat.inp_status = 0;
351
352 cfe_iocb_dispatch(&xiocb);
353
354 if (xiocb.xiocb_status < 0)
355 return xiocb.xiocb_status;
356 return xiocb.plist.xiocb_inpstat.inp_status;
357}
358#endif /* CFE_API_inpstat || CFE_API_ALL */
359
360#if defined(CFE_API_ioctl) || defined(CFE_API_ALL)
361int
362cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,
363 int length, int *retlen, cfe_xuint_t offset)
364{
365 cfe_xiocb_t xiocb;
366
367 xiocb.xiocb_fcode = CFE_CMD_DEV_IOCTL;
368 xiocb.xiocb_status = 0;
369 xiocb.xiocb_handle = handle;
370 xiocb.xiocb_flags = 0;
371 xiocb.xiocb_psize = sizeof(xiocb_buffer_t);
372 xiocb.plist.xiocb_buffer.buf_offset = offset;
373 xiocb.plist.xiocb_buffer.buf_ioctlcmd = ioctlnum;
374 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer);
375 xiocb.plist.xiocb_buffer.buf_length = length;
376
377 cfe_iocb_dispatch(&xiocb);
378
379 if (retlen)
380 *retlen = xiocb.plist.xiocb_buffer.buf_retlen;
381 return xiocb.xiocb_status;
382}
383#endif /* CFE_API_ioctl || CFE_API_ALL */
384
385#if defined(CFE_API_open) || defined(CFE_API_ALL)
386int cfe_open(char *name)
387{
388 cfe_xiocb_t xiocb;
389
390 xiocb.xiocb_fcode = CFE_CMD_DEV_OPEN;
391 xiocb.xiocb_status = 0;
392 xiocb.xiocb_handle = 0;
393 xiocb.xiocb_flags = 0;
394 xiocb.xiocb_psize = sizeof(xiocb_buffer_t);
395 xiocb.plist.xiocb_buffer.buf_offset = 0;
396 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(name);
397 xiocb.plist.xiocb_buffer.buf_length = cfe_strlen(name);
398
399 cfe_iocb_dispatch(&xiocb);
400
401 if (xiocb.xiocb_status < 0)
402 return xiocb.xiocb_status;
403 return xiocb.xiocb_handle;
404}
405#endif /* CFE_API_open || CFE_API_ALL */
406
407#if defined(CFE_API_read) || defined(CFE_API_ALL)
408int cfe_read(int handle, unsigned char *buffer, int length)
409{
410 return cfe_readblk(handle, 0, buffer, length);
411}
412#endif /* CFE_API_read || CFE_API_ALL */
413
414#if defined(CFE_API_readblk) || defined(CFE_API_ALL)
415int
416cfe_readblk(int handle, cfe_xint_t offset, unsigned char *buffer,
417 int length)
418{
419 cfe_xiocb_t xiocb;
420
421 xiocb.xiocb_fcode = CFE_CMD_DEV_READ;
422 xiocb.xiocb_status = 0;
423 xiocb.xiocb_handle = handle;
424 xiocb.xiocb_flags = 0;
425 xiocb.xiocb_psize = sizeof(xiocb_buffer_t);
426 xiocb.plist.xiocb_buffer.buf_offset = offset;
427 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer);
428 xiocb.plist.xiocb_buffer.buf_length = length;
429
430 cfe_iocb_dispatch(&xiocb);
431
432 if (xiocb.xiocb_status < 0)
433 return xiocb.xiocb_status;
434 return xiocb.plist.xiocb_buffer.buf_retlen;
435}
436#endif /* CFE_API_readblk || CFE_API_ALL */
437
438#if defined(CFE_API_setenv) || defined(CFE_API_ALL)
439int cfe_setenv(char *name, char *val)
440{
441 cfe_xiocb_t xiocb;
442
443 xiocb.xiocb_fcode = CFE_CMD_ENV_SET;
444 xiocb.xiocb_status = 0;
445 xiocb.xiocb_handle = 0;
446 xiocb.xiocb_flags = 0;
447 xiocb.xiocb_psize = sizeof(xiocb_envbuf_t);
448 xiocb.plist.xiocb_envbuf.enum_idx = 0;
449 xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name);
450 xiocb.plist.xiocb_envbuf.name_length = cfe_strlen(name);
451 xiocb.plist.xiocb_envbuf.val_ptr = XPTR_FROM_NATIVE(val);
452 xiocb.plist.xiocb_envbuf.val_length = cfe_strlen(val);
453
454 cfe_iocb_dispatch(&xiocb);
455
456 return xiocb.xiocb_status;
457}
458#endif /* CFE_API_setenv || CFE_API_ALL */
459
460#if (defined(CFE_API_strlen) || defined(CFE_API_ALL)) \
461 && !defined(CFE_API_STRLEN_CUSTOM)
462int cfe_strlen(char *name)
463{
464 int count = 0;
465
466 while (*name++)
467 count++;
468
469 return count;
470}
471#endif /* CFE_API_strlen || CFE_API_ALL */
472
473#if defined(CFE_API_write) || defined(CFE_API_ALL)
474int cfe_write(int handle, unsigned char *buffer, int length)
475{
476 return cfe_writeblk(handle, 0, buffer, length);
477}
478#endif /* CFE_API_write || CFE_API_ALL */
479
480#if defined(CFE_API_writeblk) || defined(CFE_API_ALL)
481int
482cfe_writeblk(int handle, cfe_xint_t offset, unsigned char *buffer,
483 int length)
484{
485 cfe_xiocb_t xiocb;
486
487 xiocb.xiocb_fcode = CFE_CMD_DEV_WRITE;
488 xiocb.xiocb_status = 0;
489 xiocb.xiocb_handle = handle;
490 xiocb.xiocb_flags = 0;
491 xiocb.xiocb_psize = sizeof(xiocb_buffer_t);
492 xiocb.plist.xiocb_buffer.buf_offset = offset;
493 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer);
494 xiocb.plist.xiocb_buffer.buf_length = length;
495
496 cfe_iocb_dispatch(&xiocb);
497
498 if (xiocb.xiocb_status < 0)
499 return xiocb.xiocb_status;
500 return xiocb.plist.xiocb_buffer.buf_retlen;
501}
502#endif /* CFE_API_writeblk || CFE_API_ALL */
diff --git a/arch/mips/fw/cfe/cfe_api_int.h b/arch/mips/fw/cfe/cfe_api_int.h
new file mode 100644
index 000000000000..f7e5a64b55f3
--- /dev/null
+++ b/arch/mips/fw/cfe/cfe_api_int.h
@@ -0,0 +1,152 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19/* *********************************************************************
20 *
21 * Broadcom Common Firmware Environment (CFE)
22 *
23 * Device function prototypes File: cfe_api_int.h
24 *
25 * This header defines all internal types and macros for the
26 * library. This is stuff that's not exported to an app
27 * using the library.
28 *
29 * Authors: Mitch Lichtenberg, Chris Demetriou
30 *
31 ********************************************************************* */
32
33#ifndef CFE_API_INT_H
34#define CFE_API_INT_H
35
36/* *********************************************************************
37 * Constants
38 ********************************************************************* */
39
40#define CFE_CMD_FW_GETINFO 0
41#define CFE_CMD_FW_RESTART 1
42#define CFE_CMD_FW_BOOT 2
43#define CFE_CMD_FW_CPUCTL 3
44#define CFE_CMD_FW_GETTIME 4
45#define CFE_CMD_FW_MEMENUM 5
46#define CFE_CMD_FW_FLUSHCACHE 6
47
48#define CFE_CMD_DEV_GETHANDLE 9
49#define CFE_CMD_DEV_ENUM 10
50#define CFE_CMD_DEV_OPEN 11
51#define CFE_CMD_DEV_INPSTAT 12
52#define CFE_CMD_DEV_READ 13
53#define CFE_CMD_DEV_WRITE 14
54#define CFE_CMD_DEV_IOCTL 15
55#define CFE_CMD_DEV_CLOSE 16
56#define CFE_CMD_DEV_GETINFO 17
57
58#define CFE_CMD_ENV_ENUM 20
59#define CFE_CMD_ENV_GET 22
60#define CFE_CMD_ENV_SET 23
61#define CFE_CMD_ENV_DEL 24
62
63#define CFE_CMD_MAX 32
64
65#define CFE_CMD_VENDOR_USE 0x8000 /* codes above this are for customer use */
66
67/* *********************************************************************
68 * Structures
69 ********************************************************************* */
70
71typedef uint64_t cfe_xuint_t;
72typedef int64_t cfe_xint_t;
73typedef int64_t cfe_xptr_t;
74
75typedef struct xiocb_buffer_s {
76 cfe_xuint_t buf_offset; /* offset on device (bytes) */
77 cfe_xptr_t buf_ptr; /* pointer to a buffer */
78 cfe_xuint_t buf_length; /* length of this buffer */
79 cfe_xuint_t buf_retlen; /* returned length (for read ops) */
80 cfe_xuint_t buf_ioctlcmd; /* IOCTL command (used only for IOCTLs) */
81} xiocb_buffer_t;
82
83#define buf_devflags buf_ioctlcmd /* returned device info flags */
84
85typedef struct xiocb_inpstat_s {
86 cfe_xuint_t inp_status; /* 1 means input available */
87} xiocb_inpstat_t;
88
89typedef struct xiocb_envbuf_s {
90 cfe_xint_t enum_idx; /* 0-based enumeration index */
91 cfe_xptr_t name_ptr; /* name string buffer */
92 cfe_xint_t name_length; /* size of name buffer */
93 cfe_xptr_t val_ptr; /* value string buffer */
94 cfe_xint_t val_length; /* size of value string buffer */
95} xiocb_envbuf_t;
96
97typedef struct xiocb_cpuctl_s {
98 cfe_xuint_t cpu_number; /* cpu number to control */
99 cfe_xuint_t cpu_command; /* command to issue to CPU */
100 cfe_xuint_t start_addr; /* CPU start address */
101 cfe_xuint_t gp_val; /* starting GP value */
102 cfe_xuint_t sp_val; /* starting SP value */
103 cfe_xuint_t a1_val; /* starting A1 value */
104} xiocb_cpuctl_t;
105
106typedef struct xiocb_time_s {
107 cfe_xint_t ticks; /* current time in ticks */
108} xiocb_time_t;
109
110typedef struct xiocb_exitstat_s {
111 cfe_xint_t status;
112} xiocb_exitstat_t;
113
114typedef struct xiocb_meminfo_s {
115 cfe_xint_t mi_idx; /* 0-based enumeration index */
116 cfe_xint_t mi_type; /* type of memory block */
117 cfe_xuint_t mi_addr; /* physical start address */
118 cfe_xuint_t mi_size; /* block size */
119} xiocb_meminfo_t;
120
121typedef struct xiocb_fwinfo_s {
122 cfe_xint_t fwi_version; /* major, minor, eco version */
123 cfe_xint_t fwi_totalmem; /* total installed mem */
124 cfe_xint_t fwi_flags; /* various flags */
125 cfe_xint_t fwi_boardid; /* board ID */
126 cfe_xint_t fwi_bootarea_va; /* VA of boot area */
127 cfe_xint_t fwi_bootarea_pa; /* PA of boot area */
128 cfe_xint_t fwi_bootarea_size; /* size of boot area */
129 cfe_xint_t fwi_reserved1;
130 cfe_xint_t fwi_reserved2;
131 cfe_xint_t fwi_reserved3;
132} xiocb_fwinfo_t;
133
134typedef struct cfe_xiocb_s {
135 cfe_xuint_t xiocb_fcode; /* IOCB function code */
136 cfe_xint_t xiocb_status; /* return status */
137 cfe_xint_t xiocb_handle; /* file/device handle */
138 cfe_xuint_t xiocb_flags; /* flags for this IOCB */
139 cfe_xuint_t xiocb_psize; /* size of parameter list */
140 union {
141 xiocb_buffer_t xiocb_buffer; /* buffer parameters */
142 xiocb_inpstat_t xiocb_inpstat; /* input status parameters */
143 xiocb_envbuf_t xiocb_envbuf; /* environment function parameters */
144 xiocb_cpuctl_t xiocb_cpuctl; /* CPU control parameters */
145 xiocb_time_t xiocb_time; /* timer parameters */
146 xiocb_meminfo_t xiocb_meminfo; /* memory arena info parameters */
147 xiocb_fwinfo_t xiocb_fwinfo; /* firmware information */
148 xiocb_exitstat_t xiocb_exitstat; /* Exit Status */
149 } plist;
150} cfe_xiocb_t;
151
152#endif /* CFE_API_INT_H */