summaryrefslogtreecommitdiffstats
path: root/cfe/cfe/include
diff options
context:
space:
mode:
authorroot <root@lamia.panaceas.james.local>2015-12-19 13:13:57 +0000
committerroot <root@lamia.panaceas.james.local>2015-12-19 14:18:03 +0000
commit1a2238d1bddc823df06f67312d96ccf9de2893cc (patch)
treec58a3944d674a667f133ea5a730f5037e57d3d2e /cfe/cfe/include
downloadbootloader-1a2238d1bddc823df06f67312d96ccf9de2893cc.tar.gz
bootloader-1a2238d1bddc823df06f67312d96ccf9de2893cc.tar.bz2
bootloader-1a2238d1bddc823df06f67312d96ccf9de2893cc.zip
CFE from danitool [without hostTools dir]: https://mega.nz/#!mwZyFK7a!CPT3BKC8dEw29kubtdYxhB91G9vIIismTkgzQ3iUy3k
Diffstat (limited to 'cfe/cfe/include')
-rwxr-xr-xcfe/cfe/include/cfe.h101
-rw-r--r--cfe/cfe/include/cfe_autoboot.h71
-rw-r--r--cfe/cfe/include/cfe_boot.h58
-rw-r--r--cfe/cfe/include/cfe_bootblock.h129
-rwxr-xr-xcfe/cfe/include/cfe_console.h92
-rw-r--r--cfe/cfe/include/cfe_devfuncs.h76
-rw-r--r--cfe/cfe/include/cfe_device.h118
-rw-r--r--cfe/cfe/include/cfe_error.h110
-rw-r--r--cfe/cfe/include/cfe_fileops.h109
-rw-r--r--cfe/cfe/include/cfe_flashimage.h64
-rw-r--r--cfe/cfe/include/cfe_iocb.h211
-rw-r--r--cfe/cfe/include/cfe_ioctl.h167
-rw-r--r--cfe/cfe/include/cfe_irq.h103
-rw-r--r--cfe/cfe/include/cfe_loader.h86
-rw-r--r--cfe/cfe/include/cfe_mem.h79
-rw-r--r--cfe/cfe/include/cfe_timer.h74
-rw-r--r--cfe/cfe/include/cfe_xiocb.h202
-rw-r--r--cfe/cfe/include/dev_flash.h168
-rw-r--r--cfe/cfe/include/dev_ide.h90
-rw-r--r--cfe/cfe/include/dev_ide_common.h204
-rw-r--r--cfe/cfe/include/dev_newflash.h344
-rw-r--r--cfe/cfe/include/elf.h194
-rw-r--r--cfe/cfe/include/env_subr.h117
-rwxr-xr-xcfe/cfe/include/foxconnCfg.h9
-rw-r--r--cfe/cfe/include/lib_arena.h76
-rw-r--r--cfe/cfe/include/lib_malloc.h78
-rwxr-xr-xcfe/cfe/include/lib_printf.h69
-rw-r--r--cfe/cfe/include/lib_queue.h85
-rw-r--r--cfe/cfe/include/lib_string.h117
-rw-r--r--cfe/cfe/include/lib_types.h120
-rw-r--r--cfe/cfe/include/socregs.h63
-rwxr-xr-xcfe/cfe/include/tftpd.h26
-rw-r--r--cfe/cfe/include/ui_command.h140
33 files changed, 3750 insertions, 0 deletions
diff --git a/cfe/cfe/include/cfe.h b/cfe/cfe/include/cfe.h
new file mode 100755
index 0000000..013fb13
--- /dev/null
+++ b/cfe/cfe/include/cfe.h
@@ -0,0 +1,101 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * CFE version # and prototypes File: cfe.h
+ *
+ * CFE's version # temporarily lives here.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+/* *********************************************************************
+ * Version number
+ ********************************************************************* */
+
+#define CFE_VER_MAJOR CFE_VER_MAJ
+#define CFE_VER_MINOR CFE_VER_MIN
+#define CFE_VER_BUILD CFE_VER_ECO
+
+/* Numbers must not exceed 255 */
+#define BCM63XX_MAJOR 106
+#define BCM63XX_MINOR 24
+
+/* *********************************************************************
+ * Some runtime startup parameters
+ ********************************************************************* */
+#if !defined(__ASSEMBLER__)
+extern unsigned cfe_startflags;
+#endif
+
+#define CFE_INIT_USER 0x0000FFFF /* these are BSP-specific flags */
+#define CFE_INIT_SAFE 0x00010000 /* "Safe mode" */
+#define CFE_INIT_PCI 0x00020000 /* Initialize PCI */
+#define CFE_LDT_SLAVE 0x00040000 /* Select LDT slave mode */
+
+/* *********************************************************************
+ * Other constants
+ ********************************************************************* */
+
+#define CFE_MAX_HANDLE 64 /* max file handles */
+
+#if !defined(__ASSEMBLER__)
+
+/* *********************************************************************
+ * prototypes
+ ********************************************************************* */
+
+void board_console_init(void);
+void board_device_init(void);
+void board_final_init(void);
+void board_device_reset(void);
+#define CFE_BUFFER_CONSOLE "buffer"
+int cfe_set_console(char *);
+int cfe_set_envdevice(char *);
+void cfe_restart(void);
+void cfe_command_loop(void);
+void cfe_leds(unsigned int val);
+void cfe_ledstr(const char *str);
+void cfe_launch(unsigned long ept);
+void cfe_start(unsigned long ept);
+void cfe_warmstart(unsigned long long);
+#define SETLEDS(x) cfe_ledstr(x)
+const char *cfe_errortext(int err);
+
+#endif
diff --git a/cfe/cfe/include/cfe_autoboot.h b/cfe/cfe/include/cfe_autoboot.h
new file mode 100644
index 0000000..603803b
--- /dev/null
+++ b/cfe/cfe/include/cfe_autoboot.h
@@ -0,0 +1,71 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Automatic OS bootstrap File: cfe_autoboot.h
+ *
+ * This module handles OS bootstrap stuff. We use this version
+ * to do "automatic" booting; walking down a list of possible boot
+ * options, trying them until something good happens.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+#define CFE_AUTOBOOT_END 0
+#define CFE_AUTOBOOT_NETWORK 1
+#define CFE_AUTOBOOT_DISK 2
+#define CFE_AUTOBOOT_RAW 3
+
+typedef struct cfe_autoboot_method_s {
+ queue_t ab_qblock;
+ int ab_type;
+ int ab_flags;
+ char *ab_dev;
+ char *ab_loader;
+ char *ab_filesys;
+ char *ab_file;
+} cfe_autoboot_method_t;
+
+#define CFE_AUTOFLG_POLLCONSOLE 1 /* boot can be interrupted */
+#define CFE_AUTOFLG_TRYFOREVER 2 /* keep trying forever */
+
+int cfe_autoboot(char *dev,int flags);
+int cfe_add_autoboot(int type,int flags,char *dev,char *loader,char *filesys,char *file);
+
+
diff --git a/cfe/cfe/include/cfe_boot.h b/cfe/cfe/include/cfe_boot.h
new file mode 100644
index 0000000..93c3c6d
--- /dev/null
+++ b/cfe/cfe/include/cfe_boot.h
@@ -0,0 +1,58 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Bootstrap prototypes File: cfe_boot.h
+ *
+ * Prototypes for main bootstrap routines
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+#define BOOT_START_ADDRESS 0x20000000 /* VA of boot area */
+#define BOOT_AREA_SIZE (256*1024) /* 256K */
+
+
+
+
diff --git a/cfe/cfe/include/cfe_bootblock.h b/cfe/cfe/include/cfe_bootblock.h
new file mode 100644
index 0000000..c3a93f0
--- /dev/null
+++ b/cfe/cfe/include/cfe_bootblock.h
@@ -0,0 +1,129 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Boot Block File: cfe_bootblock.h
+ *
+ * The structure of the boot block used on block-style devices
+ * like disks and CDROMs
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+/*
+ * CFE boot block, modeled loosely on Alpha.
+ *
+ * It consists of:
+ *
+ * BSD disk label
+ * <blank space>
+ * Boot block info (5 u_int_64s)
+ *
+ * The boot block portion looks like:
+ *
+ *
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | BOOT_MAGIC_NUMBER |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Flags | Reserved | Vers | Header Checksum |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Secondary Loader Location (bytes) |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Loader Checksum | Size of loader (bytes) |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Reserved | Architecture Information |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ *
+ * Boot block fields should always be read as 64-bit numbers.
+ *
+ */
+
+
+struct boot_block {
+ uint64_t bb_data[64]; /* data (disklabel, also as below) */
+};
+#define bb_magic bb_data[59] /* magic number */
+#define bb_hdrinfo bb_data[60] /* header checksum, ver, flags */
+#define bb_secstart bb_data[61] /* secondary start (bytes) */
+#define bb_secsize bb_data[62] /* secondary size (bytes) */
+#define bb_archinfo bb_data[63] /* architecture info */
+
+#define BOOT_BLOCK_OFFSET 0 /* offset of boot block. */
+#define BOOT_BLOCK_BLOCKSIZE 512 /* block size for sec. size/start,
+ * and for boot block itself
+ */
+#define BOOT_BLOCK_SIZE 40 /* 5 64-bit words */
+
+/*
+ * This is the highest block number that we look at when
+ * searching for a valid boot block
+ */
+#define BOOT_BLOCK_MAXLOC 16
+
+/*
+ * Fields within the boot block
+ */
+#define _U64(x) ((uint64_t) x)
+#define BOOT_MAGIC_NUMBER _U64(0x43465631424f4f54)
+#define BOOT_HDR_CHECKSUM_MASK _U64(0x00000000FFFFFFFF)
+#define BOOT_HDR_VER_MASK _U64(0x000000FF00000000)
+#define BOOT_HDR_VER_SHIFT 32
+#define BOOT_HDR_FLAGS_MASK _U64(0xFF00000000000000)
+#define BOOT_SECSIZE_MASK _U64(0x00000000FFFFFFFF)
+#define BOOT_DATA_CHECKSUM_MASK _U64(0xFFFFFFFF00000000)
+#define BOOT_DATA_CHECKSUM_SHIFT 32
+#define BOOT_ARCHINFO_MASK _U64(0x00000000FFFFFFFF)
+
+#define BOOT_HDR_VERSION 1
+
+#define CHECKSUM_BOOT_DATA(data,len,cksum) \
+ do { \
+ uint32_t *_ptr = (uint32_t *) (data); \
+ uint32_t _cksum; \
+ int _i; \
+ \
+ _cksum = 0; \
+ for (_i = 0; \
+ _i < ((len) / sizeof (uint32_t)); \
+ _i++) \
+ _cksum += _ptr[_i]; \
+ *(cksum) = _cksum; \
+ } while (0)
+
+
diff --git a/cfe/cfe/include/cfe_console.h b/cfe/cfe/include/cfe_console.h
new file mode 100755
index 0000000..7ee1056
--- /dev/null
+++ b/cfe/cfe/include/cfe_console.h
@@ -0,0 +1,92 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Console prototypes File: cfe_console.c
+ *
+ * Prototypes for routines dealing with the console.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+#define VKEY(x) (0x100|(x))
+#define VKEY_UP VKEY(1)
+#define VKEY_DOWN VKEY(2)
+#define VKEY_LEFT VKEY(3)
+#define VKEY_RIGHT VKEY(4)
+#define VKEY_PGUP VKEY(5)
+#define VKEY_PGDN VKEY(6)
+#define VKEY_HOME VKEY(7)
+#define VKEY_END VKEY(8)
+#define VKEY_F1 VKEY(0x10)
+#define VKEY_F2 VKEY(0x11)
+#define VKEY_F3 VKEY(0x12)
+#define VKEY_F4 VKEY(0x13)
+#define VKEY_F5 VKEY(0x14)
+#define VKEY_F6 VKEY(0x15)
+#define VKEY_F7 VKEY(0x16)
+#define VKEY_F8 VKEY(0x17)
+#define VKEY_F9 VKEY(0x18)
+#define VKEY_F10 VKEY(0x19)
+#define VKEY_F11 VKEY(0x1A)
+#define VKEY_F12 VKEY(0x1B)
+#define VKEY_ESC 27
+
+
+/* *********************************************************************
+ * Prototypes
+ ********************************************************************* */
+
+int console_open(char *name);
+int console_close(void);
+int console_read(char *buffer,int length);
+int console_write(char *buffer,int length);
+int console_status(void);
+int console_readkey(void);
+int console_readline(char *prompt,char *str,int len);
+int console_readline_noedit(char *prompt,char *str,int len);
+int console_readline(char *prompt,char *str,int len);
+extern char *console_name;
+extern int console_handle;
+void console_log(const char *tmplt,...);
+
+
diff --git a/cfe/cfe/include/cfe_devfuncs.h b/cfe/cfe/include/cfe_devfuncs.h
new file mode 100644
index 0000000..207c4a6
--- /dev/null
+++ b/cfe/cfe/include/cfe_devfuncs.h
@@ -0,0 +1,76 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Device function prototypes File: cfe_devfuncs.h
+ *
+ * This module contains prototypes for cfe_devfuncs.c, a set
+ * of wrapper routines to the IOCB interface. This file,
+ * along with cfe_devfuncs.c, can be incorporated into programs
+ * that need to call CFE.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+#define CFE_EPTSEAL 0x43464531
+#if (CFG_BIENDIAN) && defined(__MIPSEB)
+#define CFE_EPTSEAL_REV 0x31454643
+#endif
+
+#define CFE_APISEAL 0xBFC004E0
+#define CFE_APIENTRY 0xBFC00500
+
+
+
+#ifndef __ASSEMBLER__
+int cfe_open(char *name);
+int cfe_close(int handle);
+int cfe_readblk(int handle,cfe_offset_t offset,unsigned char *buffer,int length);
+int cfe_read(int handle,unsigned char *buffer,int length);
+int cfe_writeblk(int handle,cfe_offset_t offset,unsigned char *buffer,int length);
+int cfe_write(int handle,unsigned char *buffer,int length);
+int cfe_ioctl(int handle,unsigned int ioctlnum,unsigned char *buffer,int length,int *retlen,
+ cfe_offset_t offset);
+int cfe_inpstat(int handle);
+int cfe_getenv(char *name,char *dest,int destlen);
+long long cfe_getticks(void);
+int cfe_exit(int warm,int code);
+int cfe_flushcache(int flg);
+int cfe_getdevinfo(char *name);
+int cfe_flushcache(int);
+#endif
diff --git a/cfe/cfe/include/cfe_device.h b/cfe/cfe/include/cfe_device.h
new file mode 100644
index 0000000..f90b167
--- /dev/null
+++ b/cfe/cfe/include/cfe_device.h
@@ -0,0 +1,118 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Device manager definitions File: cfe_device.h
+ *
+ * Structures, constants, etc. for the device manager, which keeps
+ * track of installed devices in CFE.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+#ifndef _CFE_DEVICE_H
+#define _CFE_DEVICE_H
+
+#include "lib_queue.h"
+
+typedef struct cfe_devdisp_s cfe_devdisp_t;
+
+
+/*
+ * The Device structure defines a particular instance of a device.
+ * They are generated as a result of calling the cfe_attach call.
+ */
+
+typedef struct cfe_device_s {
+ queue_t dev_next;
+ char *dev_fullname;
+ void *dev_softc;
+ int dev_class;
+ const cfe_devdisp_t *dev_dispatch;
+ int dev_opencount;
+ char *dev_description;
+} cfe_device_t;
+
+/*
+ * This is what gets returned from the OPEN call
+ */
+typedef struct cfe_devctx_s {
+ cfe_device_t *dev_dev;
+ void *dev_softc;
+ void *dev_openinfo;
+} cfe_devctx_t;
+
+
+/*
+ * This defines a given device class. Even though there are
+ * three identical MACs, there is only one of these.
+ */
+
+struct cfe_devdisp_s {
+ int (*dev_open)(cfe_devctx_t *ctx);
+ int (*dev_read)(cfe_devctx_t *ctx,iocb_buffer_t *buffer);
+ int (*dev_inpstat)(cfe_devctx_t *ctx,iocb_inpstat_t *inpstat);
+ int (*dev_write)(cfe_devctx_t *ctx,iocb_buffer_t *buffer);
+ int (*dev_ioctl)(cfe_devctx_t *ctx,iocb_buffer_t *buffer);
+ int (*dev_close)(cfe_devctx_t *ctx);
+ void (*dev_poll)(cfe_devctx_t *ctx,int64_t ticks);
+ void (*dev_reset)(void *softc); /* called when device is closed, so no devctx_t */
+};
+
+
+
+typedef struct cfe_driver_s {
+ char *drv_description; /* Description of device for SHOW commands */
+ char *drv_bootname; /* Device's name prefix for open() */
+ int drv_class;
+ const cfe_devdisp_t *drv_dispatch;
+ void (*drv_probe)(struct cfe_driver_s *drv,
+ unsigned long probe_a, unsigned long probe_b,
+ void *probe_ptr);
+} cfe_driver_t;
+
+char *cfe_device_name(cfe_devctx_t *ctx);
+void cfe_attach(cfe_driver_t *devname,void *softc,char *bootinfo,char *description);
+int cfe_attach_idx(cfe_driver_t *drv,int idx,void *softc,char *bootinfo,char *description);
+cfe_device_t *cfe_finddev(char *name);
+void cfe_attach_init(void);
+#define cfe_add_device(devdescr,a,b,ptr) (devdescr)->drv_probe(devdescr,a,b,ptr)
+void cfe_device_reset(void);
+
+#endif
diff --git a/cfe/cfe/include/cfe_error.h b/cfe/cfe/include/cfe_error.h
new file mode 100644
index 0000000..9c564e1
--- /dev/null
+++ b/cfe/cfe/include/cfe_error.h
@@ -0,0 +1,110 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Error codes File: cfe_error.h
+ *
+ * CFE's global error code list is here.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+
+
+#define CFE_OK 0
+#define CFE_ERR -1 /* generic error */
+#define CFE_ERR_INV_COMMAND -2
+#define CFE_ERR_EOF -3
+#define CFE_ERR_IOERR -4
+#define CFE_ERR_NOMEM -5
+#define CFE_ERR_DEVNOTFOUND -6
+#define CFE_ERR_DEVOPEN -7
+#define CFE_ERR_INV_PARAM -8
+#define CFE_ERR_ENVNOTFOUND -9
+#define CFE_ERR_ENVREADONLY -10
+
+#define CFE_ERR_NOTELF -11
+#define CFE_ERR_NOT32BIT -12
+#define CFE_ERR_WRONGENDIAN -13
+#define CFE_ERR_BADELFVERS -14
+#define CFE_ERR_NOTMIPS -15
+#define CFE_ERR_BADELFFMT -16
+#define CFE_ERR_BADADDR -17
+
+#define CFE_ERR_FILENOTFOUND -18
+#define CFE_ERR_UNSUPPORTED -19
+
+#define CFE_ERR_HOSTUNKNOWN -20
+
+#define CFE_ERR_TIMEOUT -21
+
+#define CFE_ERR_PROTOCOLERR -22
+
+#define CFE_ERR_NETDOWN -23
+#define CFE_ERR_NONAMESERVER -24
+
+#define CFE_ERR_NOHANDLES -25
+#define CFE_ERR_ALREADYBOUND -26
+
+#define CFE_ERR_CANNOTSET -27
+#define CFE_ERR_NOMORE -28
+#define CFE_ERR_BADFILESYS -29
+#define CFE_ERR_FSNOTAVAIL -30
+
+#define CFE_ERR_INVBOOTBLOCK -31
+#define CFE_ERR_WRONGDEVTYPE -32
+#define CFE_ERR_BBCHECKSUM -33
+#define CFE_ERR_BOOTPROGCHKSUM -34
+
+#define CFE_ERR_LDRNOTAVAIL -35
+
+#define CFE_ERR_NOTREADY -36
+
+#define CFE_ERR_GETMEM -37
+#define CFE_ERR_SETMEM -38
+
+#define CFE_ERR_NOTCONN -39
+#define CFE_ERR_ADDRINUSE -40
+
+/* Foxconn add start by Cliff Wang, 03/23/2010 */
+#define CFE_ERR_INTR -41
+#define CFE_ERR_BADIMAGE -42
+/* Foxconn add end by Cliff Wang, 03/23/2010 */
+
+
diff --git a/cfe/cfe/include/cfe_fileops.h b/cfe/cfe/include/cfe_fileops.h
new file mode 100644
index 0000000..f119037
--- /dev/null
+++ b/cfe/cfe/include/cfe_fileops.h
@@ -0,0 +1,109 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Filesystem dispatch defs File: cfe_fileops.h
+ *
+ * CFE supports multiple access methods to files on boot
+ * media. This module contains the dispatch table structures
+ * for "file systems".
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+#define FILE_SEEK_BEGINNING 0
+#define FILE_SEEK_CURRENT 1
+
+#define FILE_MODE_READ 1
+#define FILE_MODE_WRITE 2
+
+/* These flags should not conflict with the loader arg flags (see cfe_loadargs_t) */
+#define FSYS_TYPE_NETWORK 0x40000000
+
+/* *********************************************************************
+ * Macros
+ ********************************************************************* */
+
+#define BDINIT(ops,fsctx,name) (ops)->init((fsctx),(name))
+#define BDOPEN(ops,ref,fsctx,name) (ops)->open((ref),(fsctx),(name),FILE_MODE_READ)
+#define BDOPEN2(ops,ref,fsctx,name,mode) (ops)->open((ref),(fsctx),(name),(mode))
+#define BDOPEN_WR(ops,ref,fsctx,name) (ops)->open((ref),(fsctx),(name),FILE_MODE_WRITE)
+#define BDREAD(ops,ref,buf,len) (ops)->read((ref),(buf),(len))
+#define BDWRITE(ops,ref,buf,len) (ops)->write((ref),(buf),(len))
+#define BDCLOSE(ops,ref) (ops)->close((ref))
+#define BDUNINIT(ops,ref) (ops)->uninit((ref))
+#define BDSEEK(ops,ref,offset,how) (ops)->seek((ref),(offset),(how))
+
+/* *********************************************************************
+ * Structures
+ ********************************************************************* */
+
+typedef struct fileio_dispatch_s {
+ const char *method;
+ unsigned int loadflags;
+ int (*init)(void **fsctx,void *device);
+ int (*open)(void **ref,void *fsctx,char *filename,int mode);
+ int (*read)(void *ref,uint8_t *buf,int len);
+ int (*write)(void *ref,uint8_t *buf,int len);
+ int (*seek)(void *ref,int offset,int how);
+ void (*close)(void *ref);
+ void (*uninit)(void *devctx);
+} fileio_dispatch_t;
+
+typedef struct fileio_ctx_s {
+ const fileio_dispatch_t *ops;
+ void *fsctx;
+} fileio_ctx_t;
+
+const fileio_dispatch_t *cfe_findfilesys(const char *name);
+
+int fs_init(char *fsname,fileio_ctx_t **fsctx,void *device);
+int fs_uninit(fileio_ctx_t *);
+int fs_open(fileio_ctx_t *,void **ref,char *filename,int mode);
+int fs_close(fileio_ctx_t *,void *ref);
+int fs_read(fileio_ctx_t *,void *ref,uint8_t *buffer,int len);
+int fs_write(fileio_ctx_t *,void *ref,uint8_t *buffer,int len);
+int fs_seek(fileio_ctx_t *,void *ref,int offset,int how);
+int fs_hook(fileio_ctx_t *fsctx,char *fsname);
+
+
diff --git a/cfe/cfe/include/cfe_flashimage.h b/cfe/cfe/include/cfe_flashimage.h
new file mode 100644
index 0000000..4e4647c
--- /dev/null
+++ b/cfe/cfe/include/cfe_flashimage.h
@@ -0,0 +1,64 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Flash Image defs File: cfe_flashimage.h
+ *
+ * This file contains stuff that describes the image header on
+ * the front of our flash images.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+typedef struct cfe_flashimage_s {
+ uint8_t seal[4]; /* CFE1 */
+ uint8_t flags[4]; /* Various flags, always big-endian */
+ uint8_t size[4]; /* Image size, in bytes, always big-endian */
+ uint8_t crc[4]; /* CRC-32, always big-endian */
+ uint8_t boardname[32]; /* Board name */
+ uint8_t majver,minver,ecover,miscver; /* Firmware version */
+ uint8_t reserved[12]; /* not used just yet */
+} cfe_flashimage_t; /* should be 64 bytes */
+
+
+#define CFE_IMAGE_SEAL "CFE1"
+#define CFE_IMAGE_EB 0x00000001
+#define CFE_IMAGE_EL 0x00000002
+#define CFE_IMAGE_MLONG64 0x00000004
+
diff --git a/cfe/cfe/include/cfe_iocb.h b/cfe/cfe/include/cfe_iocb.h
new file mode 100644
index 0000000..bc62078
--- /dev/null
+++ b/cfe/cfe/include/cfe_iocb.h
@@ -0,0 +1,211 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * IOCB definitions File: cfe_iocb.h
+ *
+ * This module describes CFE's IOCB structure, the main
+ * data structure used to communicate API requests with CFE.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+#ifndef _CFE_IOCB_H
+#define _CFE_IOCB_H
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+#define CFE_CMD_FW_GETINFO 0
+#define CFE_CMD_FW_RESTART 1
+#define CFE_CMD_FW_BOOT 2
+#define CFE_CMD_FW_CPUCTL 3
+#define CFE_CMD_FW_GETTIME 4
+#define CFE_CMD_FW_MEMENUM 5
+#define CFE_CMD_FW_FLUSHCACHE 6
+
+#define CFE_CMD_DEV_GETHANDLE 9
+#define CFE_CMD_DEV_ENUM 10
+#define CFE_CMD_DEV_OPEN 11
+#define CFE_CMD_DEV_INPSTAT 12
+#define CFE_CMD_DEV_READ 13
+#define CFE_CMD_DEV_WRITE 14
+#define CFE_CMD_DEV_IOCTL 15
+#define CFE_CMD_DEV_CLOSE 16
+#define CFE_CMD_DEV_GETINFO 17
+
+#define CFE_CMD_ENV_ENUM 20
+#define CFE_CMD_ENV_GET 22
+#define CFE_CMD_ENV_SET 23
+#define CFE_CMD_ENV_DEL 24
+
+#define CFE_CMD_MAX 32
+
+#define CFE_CMD_VENDOR_USE 0x8000 /* codes above this are for customer use */
+
+#define CFE_MI_RESERVED 0 /* memory is reserved, do not use */
+#define CFE_MI_AVAILABLE 1 /* memory is available */
+
+#define CFE_FLG_WARMSTART 0x00000001
+#define CFE_FLG_FULL_ARENA 0x00000001
+#define CFE_FLG_ENV_PERMANENT 0x00000001
+
+#define CFE_CPU_CMD_START 1
+#define CFE_CPU_CMD_STOP 0
+
+#define CFE_STDHANDLE_CONSOLE 0
+
+#define CFE_DEV_NETWORK 1
+#define CFE_DEV_DISK 2
+#define CFE_DEV_FLASH 3
+#define CFE_DEV_SERIAL 4
+#define CFE_DEV_CPU 5
+#define CFE_DEV_NVRAM 6
+#define CFE_DEV_CLOCK 7
+#define CFE_DEV_OTHER 8
+#define CFE_DEV_MASK 0x0F
+
+#define CFE_CACHE_FLUSH_D 1
+#define CFE_CACHE_INVAL_I 2
+#define CFE_CACHE_INVAL_D 4
+#define CFE_CACHE_INVAL_L2 8
+#define CFE_CACHE_FLUSH_L2 16
+#define CFE_CACHE_INVAL_RANGE 32
+#define CFE_CACHE_FLUSH_RANGE 64
+
+/* *********************************************************************
+ * Structures
+ ********************************************************************* */
+
+#define unsigned signed /* Kludge to get unsigned size-shaped type. */
+typedef __SIZE_TYPE__ cfe_int_t;
+#undef unsigned
+typedef __SIZE_TYPE__ cfe_uint_t;
+typedef unsigned long long cfe_offset_t;
+typedef long long cfe_int64_t;
+typedef unsigned char *cfe_ptr_t;
+
+typedef struct iocb_buffer_s {
+ cfe_offset_t buf_offset; /* offset on device (bytes) */
+ cfe_ptr_t buf_ptr; /* pointer to a buffer */
+ cfe_uint_t buf_length; /* length of this buffer */
+ cfe_uint_t buf_retlen; /* returned length (for read ops) */
+ cfe_uint_t buf_ioctlcmd; /* IOCTL command (used only for IOCTLs) */
+} iocb_buffer_t;
+
+#define buf_devflags buf_ioctlcmd /* returned device info flags */
+
+typedef struct iocb_inpstat_s {
+ cfe_uint_t inp_status; /* 1 means input available */
+} iocb_inpstat_t;
+
+typedef struct iocb_envbuf_s {
+ int enum_idx; /* 0-based enumeration index */
+ cfe_ptr_t name_ptr; /* name string buffer */
+ cfe_int_t name_length; /* size of name buffer */
+ cfe_ptr_t val_ptr; /* value string buffer */
+ cfe_int_t val_length; /* size of value string buffer */
+} iocb_envbuf_t;
+
+typedef struct iocb_cpuctl_s {
+ cfe_uint_t cpu_number; /* cpu number to control */
+ cfe_uint_t cpu_command; /* command to issue to CPU */
+ cfe_uint_t start_addr; /* CPU start address */
+ cfe_uint_t gp_val; /* starting GP value */
+ cfe_uint_t sp_val; /* starting SP value */
+ cfe_uint_t a1_val; /* starting A1 value */
+} iocb_cpuctl_t;
+
+typedef struct iocb_time_s {
+ long long ticks; /* current time in ticks */
+} iocb_time_t;
+
+typedef struct iocb_exitstat_s {
+ cfe_int_t status;
+} iocb_exitstat_t;
+
+typedef struct iocb_meminfo_s {
+ cfe_int_t mi_idx; /* 0-based enumeration index */
+ cfe_int_t mi_type; /* type of memory block */
+ cfe_int64_t mi_addr; /* physical start address */
+ cfe_int64_t mi_size; /* block size */
+} iocb_meminfo_t;
+
+#define CFE_FWI_64BIT 0x00000001
+#define CFE_FWI_32BIT 0x00000002
+#define CFE_FWI_RELOC 0x00000004
+#define CFE_FWI_UNCACHED 0x00000008
+#define CFE_FWI_MULTICPU 0x00000010
+#define CFE_FWI_FUNCSIM 0x00000020
+#define CFE_FWI_RTLSIM 0x00000040
+
+typedef struct iocb_fwinfo_s {
+ cfe_int64_t fwi_version; /* major, minor, eco version */
+ cfe_int64_t fwi_totalmem; /* total installed mem */
+ cfe_int64_t fwi_flags; /* various flags */
+ cfe_int64_t fwi_boardid; /* board ID */
+ cfe_int64_t fwi_bootarea_va; /* VA of boot area */
+ cfe_int64_t fwi_bootarea_pa; /* PA of boot area */
+ cfe_int64_t fwi_bootarea_size; /* size of boot area */
+ cfe_int64_t fwi_reserved1;
+ cfe_int64_t fwi_reserved2;
+ cfe_int64_t fwi_reserved3;
+} iocb_fwinfo_t;
+
+
+typedef struct cfe_iocb_s {
+ cfe_uint_t iocb_fcode; /* IOCB function code */
+ cfe_int_t iocb_status; /* return status */
+ cfe_int_t iocb_handle; /* file/device handle */
+ cfe_uint_t iocb_flags; /* flags for this IOCB */
+ cfe_uint_t iocb_psize; /* size of parameter list */
+ union {
+ iocb_buffer_t iocb_buffer; /* buffer parameters */
+ iocb_inpstat_t iocb_inpstat; /* input status parameters */
+ iocb_envbuf_t iocb_envbuf; /* environment function parameters */
+ iocb_cpuctl_t iocb_cpuctl; /* CPU control parameters */
+ iocb_time_t iocb_time; /* timer parameters */
+ iocb_meminfo_t iocb_meminfo; /* memory arena info parameters */
+ iocb_fwinfo_t iocb_fwinfo; /* firmware information */
+ iocb_exitstat_t iocb_exitstat; /* Exit Status */
+ } plist;
+} cfe_iocb_t;
+
+
+#endif
diff --git a/cfe/cfe/include/cfe_ioctl.h b/cfe/cfe/include/cfe_ioctl.h
new file mode 100644
index 0000000..1a389f8
--- /dev/null
+++ b/cfe/cfe/include/cfe_ioctl.h
@@ -0,0 +1,167 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * IOCTL definitions File: cfe_ioctl.h
+ *
+ * IOCTL function numbers and I/O data structures.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+/* *********************************************************************
+ * NVFAM and FLASH stuff
+ ********************************************************************* */
+
+#define IOCTL_NVRAM_GETINFO 1 /* return nvram_info_t */
+#define IOCTL_NVRAM_ERASE 2 /* erase sector containing nvram_info_t area */
+#define IOCTL_FLASH_ERASE_SECTOR 3 /* erase an arbitrary sector */
+#define IOCTL_FLASH_ERASE_ALL 4 /* Erase the entire flash */
+#define IOCTL_FLASH_WRITE_ALL 5 /* write entire flash */
+#define IOCTL_FLASH_GETINFO 6 /* get flash device info */
+#define IOCTL_FLASH_GETSECTORS 7 /* get sector information */
+#define IOCTL_FLASH_ERASE_RANGE 8 /* erase range of bytes */
+#define IOCTL_NVRAM_UNLOCK 9 /* allow r/w beyond logical end of device */
+#define IOCTL_FLASH_PROTECT_RANGE 10 /* Protect a group of sectors */
+#define IOCTL_FLASH_UNPROTECT_RANGE 11 /* unprotect a group of sectors */
+#define IOCTL_FLASH_DATA_WIDTH_MODE 12 /* switch flash and gen bus to support 8 or 16-bit mode I/Os */
+#define IOCTL_FLASH_BURST_MODE 13 /* configure gen bus for burst mode */
+
+typedef struct flash_range_s {
+ unsigned int range_base;
+ unsigned int range_length;
+} flash_range_t;
+
+typedef struct flash_info_s {
+ unsigned long long flash_base; /* flash physical base address */
+ unsigned int flash_size; /* available device size in bytes */
+ unsigned int flash_type; /* type, from FLASH_TYPE below */
+ unsigned int flash_flags; /* Various flags (FLASH_FLAG_xxx) */
+} flash_info_t;
+
+typedef struct flash_sector_s {
+ int flash_sector_idx;
+ int flash_sector_status;
+ unsigned int flash_sector_offset;
+ unsigned int flash_sector_size;
+} flash_sector_t;
+
+#define FLASH_SECTOR_OK 0
+#define FLASH_SECTOR_INVALID -1
+
+#define FLASH_TYPE_UNKNOWN 0 /* not sure what kind of flash */
+#define FLASH_TYPE_SRAM 1 /* not flash: it's SRAM */
+#define FLASH_TYPE_ROM 2 /* not flash: it's ROM */
+#define FLASH_TYPE_FLASH 3 /* it's flash memory of some sort */
+
+#define FLASH_FLAG_NOERASE 1 /* Byte-range writes supported,
+ Erasing is not necessary */
+
+typedef struct nvram_info_s {
+ int nvram_offset; /* offset of environment area */
+ int nvram_size; /* size of environment area */
+ int nvram_eraseflg; /* true if we need to erase first */
+} nvram_info_t;
+
+/* *********************************************************************
+ * Ethernet stuff
+ ********************************************************************* */
+
+#define IOCTL_ETHER_GETHWADDR 1 /* Get hardware address (6bytes) */
+#define IOCTL_ETHER_SETHWADDR 2 /* Set hardware address (6bytes) */
+#define IOCTL_ETHER_GETSPEED 3 /* Get Speed and Media (int) */
+#define IOCTL_ETHER_SETSPEED 4 /* Set Speed and Media (int) */
+#define IOCTL_ETHER_GETLINK 5 /* get link status (int) */
+#define IOCTL_ETHER_GETLOOPBACK 7 /* get loopback state */
+#define IOCTL_ETHER_SETLOOPBACK 8 /* set loopback state */
+#define IOCTL_ETHER_SETPACKETFIFO 9 /* set packet fifo mode (int) */
+#define IOCTL_ETHER_SETSTROBESIG 10 /* set strobe signal (int) */
+
+#define ETHER_LOOPBACK_OFF 0 /* no loopback */
+#define ETHER_LOOPBACK_INT 1 /* Internal loopback */
+#define ETHER_LOOPBACK_EXT 2 /* External loopback (through PHY) */
+
+#define ETHER_SPEED_AUTO 0 /* Auto detect */
+#define ETHER_SPEED_UNKNOWN 0 /* Speed not known (on link status) */
+#define ETHER_SPEED_10HDX 1 /* 10MB hdx and fdx */
+#define ETHER_SPEED_10FDX 2
+#define ETHER_SPEED_100HDX 3 /* 100MB hdx and fdx */
+#define ETHER_SPEED_100FDX 4
+#define ETHER_SPEED_1000HDX 5 /* 1000MB hdx and fdx */
+#define ETHER_SPEED_1000FDX 6
+
+#define ETHER_FIFO_8 0 /* 8-bit packet fifo mode */
+#define ETHER_FIFO_16 1 /* 16-bit packet fifo mode */
+#define ETHER_ETHER 2 /* Standard ethernet mode */
+
+#define ETHER_STROBE_GMII 0 /* GMII style strobe signal */
+#define ETHER_STROBE_ENCODED 1 /* Encoded */
+#define ETHER_STROBE_SOP 2 /* SOP flagged. Only in 8-bit mode*/
+#define ETHER_STROBE_EOP 3 /* EOP flagged. Only in 8-bit mode*/
+
+/* *********************************************************************
+ * Serial Ports
+ ********************************************************************* */
+
+#define IOCTL_SERIAL_SETSPEED 1 /* get baud rate (int) */
+#define IOCTL_SERIAL_GETSPEED 2 /* set baud rate (int) */
+#define IOCTL_SERIAL_SETFLOW 3 /* Set Flow Control */
+#define IOCTL_SERIAL_GETFLOW 4 /* Get Flow Control */
+
+#define SERIAL_FLOW_NONE 0 /* no flow control */
+#define SERIAL_FLOW_SOFTWARE 1 /* software flow control (not impl) */
+#define SERIAL_FLOW_HARDWARE 2 /* hardware flow control */
+
+/* *********************************************************************
+ * Block device stuff
+ ********************************************************************* */
+
+#define IOCTL_BLOCK_GETBLOCKSIZE 1 /* get block size (int) */
+#define IOCTL_BLOCK_GETTOTALBLOCKS 2 /* get total bocks (long long) */
+#define IOCTL_BLOCK_GETDEVTYPE 3 /* get device type (struct) */
+
+typedef struct blockdev_info_s {
+ unsigned long long blkdev_totalblocks;
+ unsigned int blkdev_blocksize;
+ unsigned int blkdev_devtype;
+} blockdev_info_t;
+
+#define BLOCK_DEVTYPE_DISK 0
+#define BLOCK_DEVTYPE_CDROM 1
+
diff --git a/cfe/cfe/include/cfe_irq.h b/cfe/cfe/include/cfe_irq.h
new file mode 100644
index 0000000..7605b5e
--- /dev/null
+++ b/cfe/cfe/include/cfe_irq.h
@@ -0,0 +1,103 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * IRQ related definitions File: cfe_irq.h
+ *
+ * This module describes CFE's interface for dispatching
+ * to driver-supplied service routines. Dispatch can be based
+ * either on asynchronous interrupt events or on synchrnous
+ * polling of the interrupt status registers from the idle loop.
+ *
+ * The interface attempts to accomodate the concept of interrupt
+ * mapping as is common on high-integration parts with standard
+ * cores. The details are motivated by the bcm1250/MIPS
+ * architecture, where the mapping abstraction is somewhat violated
+ * by CP0 interrupts that do not go through the mapper.
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+#define NR_IRQS 64
+
+#define CFE_IRQ_FLAGS_SHARED 0x1
+
+/* *********************************************************************
+ * Structures
+ ********************************************************************* */
+
+/* *********************************************************************
+ * Functions
+ ********************************************************************* */
+
+void cfe_irq_init(void);
+
+
+/* Functions that use interrupt mapping, i.e., the irq argument is the
+ interrupt number at the input to the mapper. */
+
+void cfe_mask_irq(int cpu, unsigned int irq);
+void cfe_unmask_irq(int cpu, unsigned int irq);
+
+void cfe_enable_irq(unsigned int irq);
+void cfe_disable_irq(unsigned int irq);
+
+int cfe_request_irq(unsigned int irq,
+ void (*handler)(void *), void *arg,
+ unsigned long irqflags, int device);
+void cfe_free_irq(unsigned int irq, int device);
+
+/* pseudo-interrupts, by polling request lines and invoking handlers */
+
+void cfe_irq_poll(void *);
+
+
+/* Functions that bypass interrupt mapping, i.e., the ip argument
+ is the interrupt number at the output of the mapper and/or the
+ input to the CPU. */
+
+typedef void (* ip_handler_t)(int ip);
+
+void cfe_irq_setvector(int ip, ip_handler_t handler);
+
+/* enable/disable interrupts at the CPU level. */
+
+void cfe_irq_enable(int mask);
+int cfe_irq_disable(void);
diff --git a/cfe/cfe/include/cfe_loader.h b/cfe/cfe/include/cfe_loader.h
new file mode 100644
index 0000000..9ed0c13
--- /dev/null
+++ b/cfe/cfe/include/cfe_loader.h
@@ -0,0 +1,86 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Loader API File: cfe_loader.h
+ *
+ * This is the main API for the program loader.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+#ifndef _CFE_LOADER_H_
+#define _CFE_LOADER_H_
+
+#define LOADFLG_NOISY 0x0001 /* print out noisy info */
+#define LOADFLG_EXECUTE 0x0002 /* execute loaded program */
+#define LOADFLG_SPECADDR 0x0004 /* Use a specific size & addr */
+#define LOADFLG_NOBB 0x0008 /* don't look for a boot block */
+#define LOADFLG_NOCLOSE 0x0010 /* don't close network */
+#define LOADFLG_COMPRESSED 0x0020 /* file is compressed */
+#define LOADFLG_BATCH 0x0040 /* batch file */
+
+typedef struct cfe_loadargs_s {
+ char *la_filename; /* name of file on I/O device */
+ char *la_filesys; /* file system name */
+ char *la_device; /* device name (ide0, etc.) */
+ char *la_options; /* args to pass to loaded prog */
+ char *la_loader; /* binary file loader to use */
+ unsigned int la_flags; /* various flags */
+ long la_address; /* used by SPECADDR only */
+ unsigned long la_maxsize; /* used by SPECADDR only */
+ long la_entrypt; /* returned entry point */
+} cfe_loadargs_t;
+
+
+typedef struct cfe_loader_s {
+ char *name; /* name of loader */
+ int (*loader)(cfe_loadargs_t *); /* access function */
+ int flags; /* flags */
+} cfe_loader_t;
+
+#define LDRLOAD(ldr,arg) (*((ldr)->loader))(arg)
+
+int cfe_load_program(char *name,cfe_loadargs_t *la);
+const cfe_loader_t *cfe_findloader(char *name);
+void splitpath(char *path,char **devname,char **filename);
+void cfe_go(cfe_loadargs_t *la);
+int cfe_boot(char *ldrname,cfe_loadargs_t *la);
+int cfe_savedata(char *fsname,char *devname,char *filename,uint8_t *start,uint8_t *end);
+
+#endif /* _CFE_LOADER_H_ */
diff --git a/cfe/cfe/include/cfe_mem.h b/cfe/cfe/include/cfe_mem.h
new file mode 100644
index 0000000..83c3be2
--- /dev/null
+++ b/cfe/cfe/include/cfe_mem.h
@@ -0,0 +1,79 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Memory manager definitions File: cfe_mem.h
+ *
+ * Function prototypes and contants for the memory manager
+ * (used to manage the physical memory arena)
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+#define MEMTYPE_EMPTY 0
+#define MEMTYPE_DRAM_AVAILABLE 1 /* must match value in cfe_iocb.h */
+#define MEMTYPE_DRAM_NOTINSTALLED 2
+#define MEMTYPE_DRAM_USEDBYFIRMWARE 3
+#define MEMTYPE_BOOTROM 4
+#define MEMTYPE_IOREGISTERS 5
+#define MEMTYPE_RESERVED 6
+#define MEMTYPE_L2CACHE 7
+#define MEMTYPE_LDT_PCI 8
+#define MEMTYPE_DRAM_BOOTPROGRAM 9
+
+/* *********************************************************************
+ * External data
+ ********************************************************************* */
+
+extern unsigned int mem_bootarea_start;
+extern unsigned int mem_bootarea_size;
+
+/* *********************************************************************
+ * Prototypes
+ ********************************************************************* */
+
+void cfe_arena_init(void);
+int cfe_arena_loadcheck(uintptr_t start,unsigned int size);
+int cfe_arena_enum(int idx,int *type,uint64_t *start,uint64_t *size,int allrecs);
+void cfe_pagetable_init(void);
+
diff --git a/cfe/cfe/include/cfe_timer.h b/cfe/cfe/include/cfe_timer.h
new file mode 100644
index 0000000..8c6a26f
--- /dev/null
+++ b/cfe/cfe/include/cfe_timer.h
@@ -0,0 +1,74 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Timer defs and prototypes File: cfe_timer.h
+ *
+ * Definitions, prototypes, and macros related to the timer.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+#ifndef _CFE_TIMER_T
+#define _CFE_TIMER_T
+
+void cfe_bg_init(void);
+void cfe_bg_add(void (*func)(void *),void *arg);
+void cfe_bg_remove(void (*func)(void *));
+
+void background(void);
+
+#define POLL() background()
+
+typedef int64_t cfe_timer_t;
+
+void cfe_timer_init(void);
+extern volatile int64_t cfe_ticks;
+extern int cfe_cpu_speed;
+
+void cfe_sleep(int ticks);
+void cfe_usleep(int usec);
+
+#define CFE_HZ 10 /* ticks per second */
+
+#define TIMER_SET(x,v) x = cfe_ticks + (v)
+#define TIMER_EXPIRED(x) ((x) && (cfe_ticks > (x)))
+#define TIMER_CLEAR(x) x = 0
+#define TIMER_RUNNING(x) ((x) != 0)
+
+#endif
diff --git a/cfe/cfe/include/cfe_xiocb.h b/cfe/cfe/include/cfe_xiocb.h
new file mode 100644
index 0000000..75a336a
--- /dev/null
+++ b/cfe/cfe/include/cfe_xiocb.h
@@ -0,0 +1,202 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * IOCB definitions File: cfe_iocb.h
+ *
+ * This module describes CFE's IOCB structure, the main
+ * data structure used to communicate API requests with CFE.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+#ifndef _CFE_XIOCB_H
+#define _CFE_XIOCB_H
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+#define CFE_CMD_FW_GETINFO 0
+#define CFE_CMD_FW_RESTART 1
+#define CFE_CMD_FW_BOOT 2
+#define CFE_CMD_FW_CPUCTL 3
+#define CFE_CMD_FW_GETTIME 4
+#define CFE_CMD_FW_MEMENUM 5
+#define CFE_CMD_FW_FLUSHCACHE 6
+
+#define CFE_CMD_DEV_GETHANDLE 9
+#define CFE_CMD_DEV_ENUM 10
+#define CFE_CMD_DEV_OPEN 11
+#define CFE_CMD_DEV_INPSTAT 12
+#define CFE_CMD_DEV_READ 13
+#define CFE_CMD_DEV_WRITE 14
+#define CFE_CMD_DEV_IOCTL 15
+#define CFE_CMD_DEV_CLOSE 16
+#define CFE_CMD_DEV_GETINFO 17
+
+#define CFE_CMD_ENV_ENUM 20
+#define CFE_CMD_ENV_GET 22
+#define CFE_CMD_ENV_SET 23
+#define CFE_CMD_ENV_DEL 24
+
+#define CFE_CMD_MAX 32
+
+#define CFE_CMD_VENDOR_USE 0x8000 /* codes above this are for customer use */
+
+#define CFE_MI_RESERVED 0 /* memory is reserved, do not use */
+#define CFE_MI_AVAILABLE 1 /* memory is available */
+
+#define CFE_FLG_WARMSTART 0x00000001
+#define CFE_FLG_FULL_ARENA 0x00000001
+#define CFE_FLG_ENV_PERMANENT 0x00000001
+
+#define CFE_CPU_CMD_START 1
+#define CFE_CPU_CMD_STOP 0
+
+#define CFE_STDHANDLE_CONSOLE 0
+
+#define CFE_DEV_NETWORK 1
+#define CFE_DEV_DISK 2
+#define CFE_DEV_FLASH 3
+#define CFE_DEV_SERIAL 4
+#define CFE_DEV_CPU 5
+#define CFE_DEV_NVRAM 6
+#define CFE_DEV_CLOCK 7
+#define CFE_DEV_OTHER 8
+#define CFE_DEV_MASK 0x0F
+
+#define CFE_CACHE_FLUSH_D 1
+#define CFE_CACHE_INVAL_I 2
+#define CFE_CACHE_INVAL_D 4
+#define CFE_CACHE_INVAL_L2 8
+
+/* *********************************************************************
+ * Structures
+ ********************************************************************* */
+
+typedef unsigned long long cfe_xuint_t;
+typedef long long cfe_xint_t;
+typedef long long cfe_xptr_t;
+
+typedef struct xiocb_buffer_s {
+ cfe_xuint_t buf_offset; /* offset on device (bytes) */
+ cfe_xptr_t buf_ptr; /* pointer to a buffer */
+ cfe_xuint_t buf_length; /* length of this buffer */
+ cfe_xuint_t buf_retlen; /* returned length (for read ops) */
+ cfe_xuint_t buf_ioctlcmd; /* IOCTL command (used only for IOCTLs) */
+} xiocb_buffer_t;
+
+#define buf_devflags buf_ioctlcmd /* returned device info flags */
+
+typedef struct xiocb_inpstat_s {
+ cfe_xuint_t inp_status; /* 1 means input available */
+} xiocb_inpstat_t;
+
+typedef struct xiocb_envbuf_s {
+ cfe_xint_t enum_idx; /* 0-based enumeration index */
+ cfe_xptr_t name_ptr; /* name string buffer */
+ cfe_xint_t name_length; /* size of name buffer */
+ cfe_xptr_t val_ptr; /* value string buffer */
+ cfe_xint_t val_length; /* size of value string buffer */
+} xiocb_envbuf_t;
+
+typedef struct xiocb_cpuctl_s {
+ cfe_xuint_t cpu_number; /* cpu number to control */
+ cfe_xuint_t cpu_command; /* command to issue to CPU */
+ cfe_xuint_t start_addr; /* CPU start address */
+ cfe_xuint_t gp_val; /* starting GP value */
+ cfe_xuint_t sp_val; /* starting SP value */
+ cfe_xuint_t a1_val; /* starting A1 value */
+} xiocb_cpuctl_t;
+
+typedef struct xiocb_time_s {
+ cfe_xint_t ticks; /* current time in ticks */
+} xiocb_time_t;
+
+typedef struct xiocb_exitstat_s {
+ cfe_xint_t status;
+} xiocb_exitstat_t;
+
+typedef struct xiocb_meminfo_s {
+ cfe_xint_t mi_idx; /* 0-based enumeration index */
+ cfe_xint_t mi_type; /* type of memory block */
+ cfe_xuint_t mi_addr; /* physical start address */
+ cfe_xuint_t mi_size; /* block size */
+} xiocb_meminfo_t;
+
+#define CFE_FWI_64BIT 0x00000001
+#define CFE_FWI_32BIT 0x00000002
+#define CFE_FWI_RELOC 0x00000004
+#define CFE_FWI_UNCACHED 0x00000008
+#define CFE_FWI_MULTICPU 0x00000010
+#define CFE_FWI_FUNCSIM 0x00000020
+#define CFE_FWI_RTLSIM 0x00000040
+
+typedef struct xiocb_fwinfo_s {
+ cfe_xint_t fwi_version; /* major, minor, eco version */
+ cfe_xint_t fwi_totalmem; /* total installed mem */
+ cfe_xint_t fwi_flags; /* various flags */
+ cfe_xint_t fwi_boardid; /* board ID */
+ cfe_xint_t fwi_bootarea_va; /* VA of boot area */
+ cfe_xint_t fwi_bootarea_pa; /* PA of boot area */
+ cfe_xint_t fwi_bootarea_size; /* size of boot area */
+ cfe_xint_t fwi_reserved1;
+ cfe_xint_t fwi_reserved2;
+ cfe_xint_t fwi_reserved3;
+} xiocb_fwinfo_t;
+
+typedef struct cfe_xiocb_s {
+ cfe_xuint_t xiocb_fcode; /* IOCB function code */
+ cfe_xint_t xiocb_status; /* return status */
+ cfe_xint_t xiocb_handle; /* file/device handle */
+ cfe_xuint_t xiocb_flags; /* flags for this IOCB */
+ cfe_xuint_t xiocb_psize; /* size of parameter list */
+ union {
+ xiocb_buffer_t xiocb_buffer; /* buffer parameters */
+ xiocb_inpstat_t xiocb_inpstat; /* input status parameters */
+ xiocb_envbuf_t xiocb_envbuf; /* environment function parameters */
+ xiocb_cpuctl_t xiocb_cpuctl; /* CPU control parameters */
+ xiocb_time_t xiocb_time; /* timer parameters */
+ xiocb_meminfo_t xiocb_meminfo; /* memory arena info parameters */
+ xiocb_fwinfo_t xiocb_fwinfo; /* firmware information */
+ xiocb_exitstat_t xiocb_exitstat; /* Exit Status */
+ } plist;
+} cfe_xiocb_t;
+
+#endif
diff --git a/cfe/cfe/include/dev_flash.h b/cfe/cfe/include/dev_flash.h
new file mode 100644
index 0000000..8cbce48
--- /dev/null
+++ b/cfe/cfe/include/dev_flash.h
@@ -0,0 +1,168 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Flash memory definitions File: dev_flash.h
+ *
+ * Stuff we use when manipulating flash memory devices.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+/*
+ * AMD Flash commands and magic offsets
+ */
+
+#define AMD_FLASH_MAGIC_ADDR_1 0x555 /* AAA for 16-bit devices in 8-bit mode */
+#define AMD_FLASH_MAGIC_ADDR_2 0x2AA /* 554 for 16-bit devices in 8-bit mode */
+
+#define AMD_FLASH_RESET 0xF0
+#define AMD_FLASH_MAGIC_1 0xAA
+#define AMD_FLASH_MAGIC_2 0x55
+#define AMD_FLASH_AUTOSEL 0x90
+#define AMD_FLASH_PROGRAM 0xA0
+#define AMD_FLASH_UNLOCK_BYPASS 0x20
+#define AMD_FLASH_ERASE_3 0x80
+#define AMD_FLASH_ERASE_4 0xAA
+#define AMD_FLASH_ERASE_5 0x55
+#define AMD_FLASH_ERASE_ALL_6 0x10
+#define AMD_FLASH_ERASE_SEC_6 0x30
+
+/*
+ * INTEL Flash commands and magic offsets
+ */
+
+#define INTEL_FLASH_READ_MODE 0xFF
+#define INTEL_FLASH_ERASE_BLOCK 0x20
+#define INTEL_FLASH_ERASE_CONFIRM 0xD0
+#define INTEL_FLASH_PROGRAM 0x40
+
+/* INTEL Flash commands for 16-bit mode */
+#define INTEL_FLASH_16BIT_READ_MODE 0xFF00
+#define INTEL_FLASH_16BIT_ERASE_BLOCK 0x2000
+#define INTEL_FLASH_16BIT_ERASE_CONFIRM 0xD000
+#define INTEL_FLASH_16BIT_PROGRAM 0x4000
+#define INTEL_FLASH_8BIT 0
+#define INTEL_FLASH_16BIT 1
+
+
+/*
+ * Common Flash Interface (CFI) commands and offsets
+ */
+
+#define FLASH_CFI_QUERY_ADDR 0x55
+#define FLASH_CFI_QUERY_MODE 0x98
+#define FLASH_CFI_QUERY_EXIT 0xFF
+
+#define FLASH_CFI_MANUFACTURER 0x00
+#define FLASH_CFI_DEVICE 0x01
+#define FLASH_CFI_SIGNATURE 0x10
+#define FLASH_CFI_QUERY_STRING 0x10
+#define FLASH_CFI_COMMAND_SET 0x13
+#define FLASH_CFI_DEVICE_SIZE 0x27
+#define FLASH_CFI_DEVICE_INTERFACE 0x28
+#define FLASH_CFI_REGION_COUNT 0x2C
+#define FLASH_CFI_REGION_TABLE 0x2D
+
+#define FLASH_CFI_CMDSET_INTEL_ECS 0x0001 /* Intel extended */
+#define FLASH_CFI_CMDSET_AMD_STD 0x0002 /* AMD Standard */
+#define FLASH_CFI_CMDSET_INTEL_STD 0x0003 /* Intel Standard */
+#define FLASH_CFI_CMDSET_AMD_ECS 0x0004 /* AMD Extended */
+
+#define FLASH_CFI_DEVIF_X8 0x0000 /* 8-bit asynchronous */
+#define FLASH_CFI_DEVIF_X16 0x0001 /* 16-bit asynchronous */
+#define FLASH_CFI_DEVIF_X8X16 0x0002 /* 8 or 16-bit with BYTE# pin */
+#define FLASH_CFI_DEVIF_X32 0x0003 /* 32-bit asynchronous */
+
+/*
+ * JEDEC offsets
+ */
+
+#define FLASH_JEDEC_OFFSET_MFR 0
+#define FLASH_JEDEC_OFFSET_DEV 1
+
+/* Vendor-specific flash identifiers */
+
+#define FLASH_MFR_HYUNDAI 0xAD
+
+/* *********************************************************************
+ * Macros for defining custom sector tables
+ ********************************************************************* */
+
+#define FLASH_SECTOR_RANGE(nblks,size) (((nblks)-1) << 16) + ((size)/256)
+#define FLASH_SECTOR_NBLKS(x) (((x) >> 16)+1)
+#define FLASH_SECTOR_SIZE(x) (((x) & 0xFFFF)*256)
+#define FLASH_MAXSECTORS 8
+
+
+/* *********************************************************************
+ * Structures
+ ********************************************************************* */
+
+/*
+ * This structure is passed in the "probe_ptr" field of the
+ * flash's probe routines and can be used for advanced
+ * configuration. If you pass this structure, probe_a and
+ * probe_b will be ignored by the driver
+ *
+ * flash_prog_phys is the base address you use for flash commands -
+ * you can put 0 here if it's the same as flash_phys. some boards,
+ * like the Algor P5064, have a different PA region used for doing
+ * byte accesses to the flash. In this case the special
+ * "flash_prog_phys" field is used for that.
+ */
+
+
+#define FLASH_FLG_NVRAM 0x00000001 /* Reserve space for NVRAM */
+#define FLASH_FLG_AUTOSIZE 0x00000002 /* resize to actual device size */
+#define FLASH_FLG_16BIT 0x00000004 /* it's a 16-bit ROM in 16-bit mode */
+#define FLASH_FLG_MANUAL 0x00000008 /* Not CFI, manual sectoring */
+#define FLASH_FLG_WIDE 0x00000010 /* must shift control addresses left one bit */
+
+#ifndef __ASSEMBLER__
+typedef struct flash_probe_t {
+ long flash_phys;
+ long flash_prog_phys; /* base address for programming, if different */
+ int flash_size; /* total flash size */
+ int flash_flags;
+ /* The following are used when manually sectoring */
+ int flash_cmdset;
+ int flash_nsectors; /* number of ranges */
+ int flash_sectors[FLASH_MAXSECTORS];
+} flash_probe_t;
+#endif
diff --git a/cfe/cfe/include/dev_ide.h b/cfe/cfe/include/dev_ide.h
new file mode 100644
index 0000000..96d3e18
--- /dev/null
+++ b/cfe/cfe/include/dev_ide.h
@@ -0,0 +1,90 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * IDE disk driver File: dev_ide.h
+ *
+ * Probe constants for the IDE disk device. Various flags
+ * can be passed to the probe routine to configure various
+ * things. This is where they are defined.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+/*
+ * Use the macros below to set the type of the master and slave devices
+ * on the IDE bus. If you want automatic probing, then you need
+ * to specify that IDE_DEV_TYPE_AUTO as the device type.
+ */
+
+
+/*
+ * XXX: If you have more than one PCI IDE controller
+ * installed, this will be applied to all installed
+ * controllers. Clearly not right, we'll need to add
+ * a field here for a controller index.
+ */
+
+
+#define IDE_PROBE_TYPE_MASK 0x0F
+#define IDE_PROBE_MASTER_SHIFT 0
+#define IDE_PROBE_SLAVE_SHIFT 4
+
+#define IDE_PROBE_MASTER_TYPE(x) ((x) << IDE_PROBE_MASTER_SHIFT)
+#define IDE_PROBE_SLAVE_TYPE(x) ((x) << IDE_PROBE_SLAVE_SHIFT)
+
+#define IDE_PROBE_GET_TYPE(pb,unit) (((pb) >> (unit*4)) & IDE_PROBE_TYPE_MASK)
+
+/*
+ * Device types.
+ */
+
+#define IDE_DEVTYPE_NOPROBE 0 /* none */
+#define IDE_DEVTYPE_AUTO 0x0F /* automatically probe */
+
+#define IDE_DEVTYPE_DISK 1 /* hard drives */
+#define IDE_DEVTYPE_CDROM 2 /* CD-ROMs */
+#define IDE_DEVTYPE_ATAPIDISK 3 /* ZIP disks, etc. */
+
+
+
diff --git a/cfe/cfe/include/dev_ide_common.h b/cfe/cfe/include/dev_ide_common.h
new file mode 100644
index 0000000..736fd99
--- /dev/null
+++ b/cfe/cfe/include/dev_ide_common.h
@@ -0,0 +1,204 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Generic IDE disk driver File: dev_ide_common.c
+ *
+ * This file contains common constants and structures for IDE
+ * disks and CFE drivers for them.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+#define IDE_REG_DATA 0x0
+#define IDE_REG_ERROR 0x1
+#define IDE_REG_PRECOMP 0x1
+#define IDE_REG_SECCNT 0x2
+#define IDE_REG_IR 0x2 /* ATAPI */
+#define IDE_REG_SECNUM 0x3
+#define IDE_REG_BCLSB 0x4 /* ATAPI */
+#define IDE_REG_BCMSB 0x5 /* ATAPI */
+#define IDE_REG_CYLLSB 0x4
+#define IDE_REG_CYLMSB 0x5
+#define IDE_REG_DRVHD 0x6
+#define IDE_REG_STATUS 0x7
+#define IDE_REG_COMMAND 0x7
+#define IDE_REG_ALTSTAT 0x6 /* Note: ALTSTAT is really 0x3F6, what do we do? */
+#define IDE_REG_DIGOUT 0x6
+
+#define IDE_IR_CD 0x01 /* 1 = command, 0 = data */
+#define IDE_IR_IO 0x02 /* 1 = from device, 0 = to device */
+#define IDE_IR_REL 0x04
+
+#define IDE_ERR_BBK 0x80 /* sector marked bad by host */
+#define IDE_ERR_UNC 0x40 /* uncorrectable error */
+#define IDE_ERR_MC 0x20 /* medium changed */
+#define IDE_ERR_NID 0x10 /* no ID mark found */
+#define IDE_ERR_MCR 0x08 /* medium change required */
+#define IDE_ERR_ABT 0x04 /* command aborted */
+#define IDE_ERR_NT0 0x02 /* track 0 not found */
+#define IDE_ERR_NDM 0x01 /* address mark not found */
+
+#define IDE_DRV_SLAVE 0x10
+#define IDE_DRV_LBA 0x40
+#define IDE_DRV_MBO 0xA0
+#define IDE_DRV_HDMASK 0x0F
+
+#define IDE_STS_BSY 0x80 /* drive is busy */
+#define IDE_STS_RDY 0x40 /* drive is ready */
+#define IDE_STS_WFT 0x20 /* write fault */
+#define IDE_STS_SKC 0x10 /* seek complete */
+#define IDE_STS_DRQ 0x08 /* data can be transferred */
+#define IDE_STS_CORR 0x04 /* correctable data error */
+#define IDE_STS_IDX 0x02 /* index mark just passed */
+#define IDE_STS_ERR 0x01 /* Error register contains info */
+
+#define IDE_CMD_RECAL 0x10
+#define IDE_CMD_READ 0x20
+#define IDE_CMD_READRETRY 0x21
+#define IDE_CMD_WRITE 0x30
+#define IDE_CMD_READVERIFY 0x40
+#define IDE_CMD_DIAGNOSTIC 0x90
+#define IDE_CMD_INITPARAMS 0x91
+#define IDE_CMD_SETMULTIPLE 0xC6
+#define IDE_CMD_POWER_MODE 0xE5
+#define IDE_CMD_DRIVE_INFO 0xEC
+
+#define IDE_CMD_ATAPI_SOFTRESET 0x08
+#define IDE_CMD_ATAPI_PACKET 0xA0
+#define IDE_CMD_ATAPI_IDENTIFY 0xA1
+#define IDE_CMD_ATAPI_SERVICE 0xA2
+
+#define IDE_DOR_SRST 0x04
+#define IDE_DOR_IEN 0x02
+
+#define DISK_SECTORSIZE 512
+#define CDROM_SECTORSIZE 2048
+#define MAX_SECTORSIZE 2048
+
+#define ATAPI_SENSE_MASK 0xF0
+#define ATAPI_SENSE_NONE 0x00
+#define ATAPI_SENSE_RECOVERED 0x10
+#define ATAPI_SENSE_NOTREADY 0x20
+#define ATAPI_SENSE_MEDIUMERROR 0x30
+#define ATAPI_SENSE_HWERROR 0x40
+#define ATAPI_SENSE_ILLREQUEST 0x50
+#define ATAPI_SENSE_ATTENTION 0x60
+#define ATAPI_SENSE_PROTECT 0x70
+#define ATAPI_SENSE_BLANKCHECK 0x80
+#define ATAPI_SENSE_VSPECIFIC 0x90
+#define ATAPI_SENSE_COPYABORT 0xA0
+#define ATAPI_SENSE_CMDABORT 0xB0
+#define ATAPI_SENSE_EQUAL 0xC0
+#define ATAPI_SENSE_VOLOVERFLOW 0xD0
+#define ATAPI_SENSE_MISCOMPARE 0xE0
+#define ATAPI_SENSE_RESERVED 0xF0
+
+#define ATAPI_SIG_LSB 0x14
+#define ATAPI_SIG_MSB 0xEB
+
+#define CDB_CMD_READ 0x28
+#define CDB_CMD_WRITE 0x2A
+#define CDB_CMD_REQSENSE 0x03
+
+
+/* *********************************************************************
+ * Structures
+ ********************************************************************* */
+
+typedef struct idecommon_dispatch_s idecommon_dispatch_t;
+
+struct idecommon_dispatch_s {
+ void *ref;
+ uint32_t baseaddr;
+ uint8_t (*inb)(idecommon_dispatch_t *disp,uint32_t reg);
+ uint16_t (*inw)(idecommon_dispatch_t *disp,uint32_t reg);
+ void (*ins)(idecommon_dispatch_t *disp,uint32_t reg,uint8_t *buf,int len);
+
+ void (*outb)(idecommon_dispatch_t *disp,uint32_t reg,uint8_t val);
+ void (*outw)(idecommon_dispatch_t *disp,uint32_t reg,uint16_t val);
+ void (*outs)(idecommon_dispatch_t *disp,uint32_t reg,uint8_t *buf,int len);
+};
+
+#define IDEDISP_WRITEREG8(ide,reg,val) (*((ide)->outb))(ide,reg,val)
+#define IDEDISP_WRITEREG16(ide,reg,val) (*((ide)->outw))(ide,reg,val)
+#define IDEDISP_WRITEBUF(ide,reg,buf,len) (*((ide)->outs))(ide,reg,buf,len)
+#define IDEDISP_READREG8(ide,reg) (*((ide)->inb))(ide,reg)
+#define IDEDISP_READREG16(ide,reg) (*((ide)->inw))(ide,reg)
+#define IDEDISP_READBUF(ide,reg,buf,len) (*((ide)->ins))(ide,reg,buf,len)
+
+typedef struct idecommon_s idecommon_t;
+
+struct idecommon_s {
+ idecommon_dispatch_t *idecommon_dispatch;
+ unsigned long idecommon_addr; /* physical address */
+ int idecommon_unit; /* 0 or 1 master/slave */
+ int idecommon_sectorsize; /* size of each sector */
+ long long idecommon_ttlsect; /* total sectors */
+ int idecommon_atapi; /* 1 if ATAPI device */
+ int idecommon_devtype; /* device type */
+ uint64_t idecommon_deferprobe; /* Defer probe to open */
+ uint32_t idecommon_flags; /* flags for underlying driver */
+ int (*idecommon_readfunc)(idecommon_t *ide,uint64_t lba,int numsec,uint8_t *buffer);
+ int (*idecommon_writefunc)(idecommon_t *ide,uint64_t lba,int numsec,uint8_t *buffer);
+
+ uint32_t timer;
+};
+
+
+
+/* *********************************************************************
+ * Prototypes
+ ********************************************************************* */
+
+extern void idecommon_init(idecommon_t *ide,int devtype);
+extern int idecommon_open(cfe_devctx_t *ctx);
+extern int idecommon_read(cfe_devctx_t *ctx,iocb_buffer_t *buffer);
+extern int idecommon_inpstat(cfe_devctx_t *ctx,iocb_inpstat_t *inpstat);
+extern int idecommon_write(cfe_devctx_t *ctx,iocb_buffer_t *buffer);
+extern int idecommon_ioctl(cfe_devctx_t *ctx,iocb_buffer_t *buffer);
+extern int idecommon_identify(idecommon_t *ide,unsigned char *buffer);
+extern int idecommon_close(cfe_devctx_t *ctx);
+extern int idecommon_devprobe(idecommon_t *ide,int noisy);
+void idecommon_attach(cfe_devdisp_t *disp);
+
diff --git a/cfe/cfe/include/dev_newflash.h b/cfe/cfe/include/dev_newflash.h
new file mode 100644
index 0000000..5efced0
--- /dev/null
+++ b/cfe/cfe/include/dev_newflash.h
@@ -0,0 +1,344 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Flash memory definitions File: dev_newflash.h
+ *
+ * Stuff we use when manipulating flash memory devices.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+#ifndef __ASSEMBLER__
+#include "cfe_device.h"
+#include "cfe_iocb.h"
+#endif
+
+/* *********************************************************************
+ * Configuration
+ ********************************************************************* */
+
+/* Bits for compile-time removal of features */
+#define FLASH_DRIVER_INTEL 1 /* support Intel cmd sets */
+#define FLASH_DRIVER_AMD 2 /* support AMD cmd sets */
+#define FLASH_DRIVER_CFI 4 /* support auto probing */
+
+/* Default value unless overridden in bsp_config.h */
+#ifndef FLASH_DRIVERS
+#define FLASH_DRIVERS (FLASH_DRIVER_INTEL | FLASH_DRIVER_AMD | FLASH_DRIVER_CFI)
+#endif
+
+/* *********************************************************************
+ * Flash magic numbers
+ ********************************************************************* */
+
+/*
+ * AMD Flash commands and magic offsets
+ */
+
+#define AMD_FLASH_MAGIC_ADDR_1 0x555 /* AAA for 16-bit devices in 8-bit mode */
+#define AMD_FLASH_MAGIC_ADDR_2 0x2AA /* 554 for 16-bit devices in 8-bit mode */
+
+#define AMD_FLASH_RESET 0xF0
+#define AMD_FLASH_MAGIC_1 0xAA
+#define AMD_FLASH_MAGIC_2 0x55
+#define AMD_FLASH_AUTOSEL 0x90
+#define AMD_FLASH_DEVCODE8 0x2
+#define AMD_FLASH_DEVCODE16 0x1
+#define AMD_FLASH_DEVCODE16B 0x2
+#define AMD_FLASH_MANID 0x0
+#define AMD_FLASH_PROGRAM 0xA0
+#define AMD_FLASH_UNLOCK_BYPASS 0x20
+#define AMD_FLASH_ERASE_3 0x80
+#define AMD_FLASH_ERASE_4 0xAA
+#define AMD_FLASH_ERASE_5 0x55
+#define AMD_FLASH_ERASE_ALL_6 0x10
+#define AMD_FLASH_ERASE_SEC_6 0x30
+
+/*
+ * INTEL Flash commands and magic offsets
+ */
+
+#define INTEL_FLASH_READ_MODE 0xFF
+#define INTEL_FLASH_ERASE_BLOCK 0x20
+#define INTEL_FLASH_ERASE_CONFIRM 0xD0
+#define INTEL_FLASH_PROGRAM 0x40
+
+/* INTEL Flash commands for 16-bit mode */
+#define INTEL_FLASH_16BIT_READ_MODE 0xFF00
+#define INTEL_FLASH_16BIT_ERASE_BLOCK 0x2000
+#define INTEL_FLASH_16BIT_ERASE_CONFIRM 0xD000
+#define INTEL_FLASH_16BIT_PROGRAM 0x4000
+#define INTEL_FLASH_8BIT 0
+#define INTEL_FLASH_16BIT 1
+
+
+/*
+ * Common Flash Interface (CFI) commands and offsets
+ */
+
+#define FLASH_CFI_QUERY_ADDR 0x55
+#define FLASH_CFI_QUERY_MODE 0x98
+#define FLASH_CFI_QUERY_EXIT 0xFF
+
+#define FLASH_CFI_MANUFACTURER 0x00
+#define FLASH_CFI_DEVICE 0x01
+#define FLASH_CFI_SIGNATURE 0x10
+#define FLASH_CFI_QUERY_STRING 0x10
+#define FLASH_CFI_COMMAND_SET 0x13
+#define FLASH_CFI_DEVICE_SIZE 0x27
+#define FLASH_CFI_DEVICE_INTERFACE 0x28
+#define FLASH_CFI_REGION_COUNT 0x2C
+#define FLASH_CFI_REGION_TABLE 0x2D
+
+#define FLASH_CFI_CMDSET_INTEL_ECS 0x0001 /* Intel extended */
+#define FLASH_CFI_CMDSET_AMD_STD 0x0002 /* AMD Standard */
+#define FLASH_CFI_CMDSET_INTEL_STD 0x0003 /* Intel Standard */
+#define FLASH_CFI_CMDSET_AMD_ECS 0x0004 /* AMD Extended */
+
+#define FLASH_CFI_DEVIF_X8 0x0000 /* 8-bit asynchronous */
+#define FLASH_CFI_DEVIF_X16 0x0001 /* 16-bit asynchronous */
+#define FLASH_CFI_DEVIF_X8X16 0x0002 /* 8 or 16-bit with BYTE# pin */
+#define FLASH_CFI_DEVIF_X32 0x0003 /* 32-bit asynchronous */
+
+/*
+ * JEDEC offsets
+ */
+
+#define FLASH_JEDEC_OFFSET_MFR 0
+#define FLASH_JEDEC_OFFSET_DEV 1
+
+/* Vendor-specific flash identifiers */
+
+#define FLASH_MFR_HYUNDAI 0xAD
+#define FLASH_MFR_AMD 0x01
+
+/* *********************************************************************
+ * Macros for defining custom sector tables
+ ********************************************************************* */
+
+#define FLASH_SECTOR_RANGE(nblks,size) (((nblks)-1) << 16) + ((size)/256)
+#define FLASH_SECTOR_NBLKS(x) (((x) >> 16)+1)
+#define FLASH_SECTOR_SIZE(x) (((x) & 0xFFFF)*256)
+#define FLASH_MAXSECTORS 8
+
+/* *********************************************************************
+ * Flashop engine constants and structures
+ * The flashop engine interprets a little table of commands
+ * to manipulate flash parts - we do this so we can operate
+ * on the flash that we're currently running from.
+ ********************************************************************* */
+
+/*
+ * Structure of the "instruction" table is six words,
+ * size dependant on the machine word size (32 or 64 bits).
+ *
+ * opcode
+ * flash base
+ * destination
+ * source
+ * length
+ * result
+ */
+
+#define FEINST_OP _TBLIDX(0)
+#define FEINST_BASE _TBLIDX(1)
+#define FEINST_DEST _TBLIDX(2)
+#define FEINST_SRC _TBLIDX(3)
+#define FEINST_CNT _TBLIDX(4)
+#define FEINST_RESULT _TBLIDX(5)
+#define FEINST_SIZE _TBLIDX(6) /* size of an instruction */
+
+#ifndef __ASSEMBLER__
+typedef struct flashinstr_s { /* must match offsets above */
+ long fi_op;
+ long fi_base;
+ long fi_dest;
+ long fi_src;
+ long fi_cnt;
+ long fi_result;
+} flashinstr_t;
+#endif
+
+/*
+ * Flash opcodes
+ */
+
+#define FEOP_RETURN 0 /* return to CFE */
+#define FEOP_REBOOT 1 /* Reboot system */
+#define FEOP_READ8 2 /* read, 8 bits at a time */
+#define FEOP_READ16 3 /* read, 16 bits at a time */
+#define FEOP_CFIQUERY8 4 /* CFI Query 8-bit */
+#define FEOP_CFIQUERY16 5 /* CFI Query 16-bit */
+#define FEOP_CFIQUERY16B 6 /* CFI Query 16-bit */
+#define FEOP_MEMCPY 7 /* generic memcpy */
+#define FEOP_AMD_ERASE8 8 /* AMD-style 8-bit erase-sector */
+#define FEOP_AMD_ERASE16 9 /* AMD-style 16-bit erase-sector */
+#define FEOP_AMD_ERASE16B 10 /* AMD-style 16-bit erase-sector */
+#define FEOP_AMD_PGM8 11 /* AMD-style 8-bit program */
+#define FEOP_AMD_PGM16 12 /* AMD-style 16-bit program */
+#define FEOP_AMD_PGM16B 13 /* AMD-style 16-bit program */
+#define FEOP_AMD_DEVCODE8 14 /* AMD-style 8-bit Boot Block Info */
+#define FEOP_AMD_DEVCODE16 15 /* AMD-style 8-bit Boot Block Info */
+#define FEOP_AMD_DEVCODE16B 16 /* AMD-style 8-bit Boot Block Info */
+#define FEOP_AMD_MANID8 17 /* AMD-style 8-bit Boot Block Info */
+#define FEOP_AMD_MANID16 18 /* AMD-style 8-bit Boot Block Info */
+#define FEOP_AMD_MANID16B 19 /* AMD-style 8-bit Boot Block Info */
+#define FEOP_INTEL_ERASE8 20 /* Intel-style 8-bit erase-sector */
+#define FEOP_INTEL_ERASE16 21 /* Intel-style 16-bit erase-sector */
+#define FEOP_INTEL_PGM8 22 /* Intel-style 8-bit program */
+#define FEOP_INTEL_PGM16 23 /* Intel-style 16-bit program */
+
+/*
+ * Flashop result values.
+ */
+
+#define FERES_OK 0
+#define FERES_ERROR -1
+
+
+
+/* *********************************************************************
+ * Structures
+ ********************************************************************* */
+
+/*
+ * Flags. If you instantiate the driver with probe_a = physical
+ * address and probe_b = size, you should also OR in the
+ * bus and device width below.
+ */
+
+#define FLASH_FLG_AUTOSIZE 0x00000002 /* resize to actual device size */
+#define FLASH_FLG_BUS8 0
+#define FLASH_FLG_BUS16 0x00000004 /* ROM is connected to 16-bit bus */
+#define FLASH_FLG_DEV8 0
+#define FLASH_FLG_DEV16 0x00000010 /* ROM has 16-bit data width */
+#define FLASH_FLG_MANUAL 0x00000008 /* Not CFI, manual sectoring */
+#define FLASH_FLG_MASK 0x000000FF /* mask of probe bits for flags */
+#define FLASH_SIZE_MASK 0xFFFFFF00 /* mask of probe bits for size */
+/* you don't have to shift the size, we assume it's in multiples of 256bytes */
+
+#ifndef __ASSEMBLER__
+
+/*
+ * Partition structure - use this to define a flash "partition."
+ * The partitions are assigned in order from the beginning of the flash.
+ * The special size '0' means 'fill to end of flash', and you can
+ * have more partitions after that which are aligned with the top
+ * of the flash.
+ * Therefore if you have a 1MB flash and set up
+ * partitions for 256KB, 0, 128KB, the 128KB part will be aligned
+ * to the top of the flash and the middle block will be 768KB.
+ * Partitions can be on byte boundaries.
+ */
+
+typedef struct newflash_part_t {
+ int fp_size;
+ char *fp_name;
+} newflash_part_t;
+#define FLASH_MAX_PARTITIONS 8
+
+/*
+ * Probe structure - this is used when we want to describe to the flash
+ * driver the layout of our flash, particularly when you want to
+ * manually describe the sectors.
+ */
+
+typedef struct newflash_probe_t {
+ long flash_phys; /* physical address of flash */
+ int flash_size; /* total flash size */
+ int flash_flags; /* flags (FLASH_FLG_xxx) */
+ int flash_type; /* FLASH_TYPE_xxx */
+ /* The following are used when manually sectoring */
+ int flash_cmdset; /* FLASH_CMDSET_xxx */
+ int flash_nsectors; /* number of ranges */
+ int flash_sectors[FLASH_MAXSECTORS];
+ /* This says how many contiguous flash chips are in this region */
+ int flash_nchips; /* "flash_size" is just for one chip */
+ /* The following are used for partitioned flashes */
+ int flash_nparts; /* zero means not partitioned */
+ newflash_part_t flash_parts[FLASH_MAX_PARTITIONS];
+ /* The following are used for whacky, weird flashes */
+ int (*flash_ioctl_hook)(cfe_devctx_t *ctx,iocb_buffer_t *buffer);
+ /* You can replace the flash engine with your own */
+ int (*flash_engine_hook)(flashinstr_t *prog);
+} newflash_probe_t;
+
+
+/* *********************************************************************
+ * PRIVATE STRUCTURES
+ *
+ * These structures are actually the "property" of the
+ * flash driver. The only reason a board package might
+ * want to dig around in here is if it implements a hook
+ * or overrides functions to support special, weird flash parts.
+ ********************************************************************* */
+
+typedef struct flashdev_s flashdev_t;
+
+typedef struct flashpart_s {
+ flashdev_t *fp_dev;
+ int fp_offset;
+ int fp_size;
+} flashpart_t;
+
+#define FLASH_MAX_CFIDATA 256 /* total size of CFI Data */
+#define FLASH_MAX_INST 8 /* instructions we use during probing */
+
+struct flashdev_s {
+ newflash_probe_t fd_probe; /* probe information */
+
+ uint8_t fd_erasefunc; /* Erase routine to use */
+ uint8_t fd_pgmfunc; /* program routine to use */
+ uint8_t fd_readfunc; /* Read routine to use */
+ flashpart_t fd_parts[FLASH_MAX_PARTITIONS];
+
+ uint8_t *fd_sectorbuffer; /* sector copy buffer */
+ int fd_ttlsect; /* total sectors on one device */
+ int fd_ttlsize; /* total size of all devices (flash size * nchips) */
+
+ int fd_iptr; /* flashop engine instructions */
+ flashinstr_t *fd_inst;
+};
+
+
+
+#endif
+
+
+
diff --git a/cfe/cfe/include/elf.h b/cfe/cfe/include/elf.h
new file mode 100644
index 0000000..944aab4
--- /dev/null
+++ b/cfe/cfe/include/elf.h
@@ -0,0 +1,194 @@
+/*
+ * ELF data structures and values
+ */
+
+typedef unsigned short Elf32_Half;
+typedef unsigned int Elf32_Word;
+typedef signed int Elf32_Sword;
+typedef unsigned int Elf32_Off;
+typedef unsigned int Elf32_Addr;
+typedef unsigned char Elf_Char;
+
+/*
+ * File Header
+ */
+
+#define EI_NIDENT 16
+
+typedef struct {
+ Elf_Char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry;
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shstrndx;
+} Elf32_Ehdr;
+
+/* e_indent */
+#define EI_MAG0 0 /* File identification byte 0 index */
+#define EI_MAG1 1 /* File identification byte 1 index */
+#define EI_MAG2 2 /* File identification byte 2 index */
+#define EI_MAG3 3 /* File identification byte 3 index */
+#define EI_CLASS 4 /* File class */
+#define ELFCLASSNONE 0 /* Invalid class */
+#define ELFCLASS32 1 /* 32-bit objects */
+#define ELFCLASS64 2 /* 64-bit objects */
+#define EI_DATA 5 /* Data encoding */
+#define ELFDATANONE 0 /* Invalid data encoding */
+#define ELFDATA2LSB 1 /* 2's complement, little endian */
+#define ELFDATA2MSB 2 /* 2's complement, big endian */
+#define EI_VERSION 6 /* File version */
+#define EI_PAD 7 /* Start of padding bytes */
+
+#define ELFMAG0 0x7F /* Magic number byte 0 */
+#define ELFMAG1 'E' /* Magic number byte 1 */
+#define ELFMAG2 'L' /* Magic number byte 2 */
+#define ELFMAG3 'F' /* Magic number byte 3 */
+
+/* e_type */
+#define ET_NONE 0 /* No file type */
+#define ET_REL 1 /* Relocatable file */
+#define ET_EXEC 2 /* Executable file */
+#define ET_DYN 3 /* Shared object file */
+#define ET_CORE 4 /* Core file */
+#define ET_LOPROC 0xFF00 /* Processor-specific */
+#define ET_HIPROC 0xFFFF /* Processor-specific */
+
+/* e_machine */
+#define EM_NONE 0 /* No machine */
+#define EM_M32 1 /* AT&T WE 32100 */
+#define EM_SPARC 2 /* SUN SPARC */
+#define EM_386 3 /* Intel 80386 */
+#define EM_68K 4 /* Motorola m68k family */
+#define EM_88K 5 /* Motorola m88k family */
+#define EM_860 7 /* Intel 80860 */
+#define EM_MIPS 8 /* MIPS R3000 */
+
+/* e_version */
+#define EV_NONE 0 /* Invalid ELF version */
+#define EV_CURRENT 1 /* Current version */
+
+
+/*
+ * Program Header
+ */
+typedef struct {
+ Elf32_Word p_type; /* Identifies program segment type */
+ Elf32_Off p_offset; /* Segment file offset */
+ Elf32_Addr p_vaddr; /* Segment virtual address */
+ Elf32_Addr p_paddr; /* Segment physical address */
+ Elf32_Word p_filesz; /* Segment size in file */
+ Elf32_Word p_memsz; /* Segment size in memory */
+ Elf32_Word p_flags; /* Segment flags */
+ Elf32_Word p_align; /* Segment alignment, file & memory */
+} Elf32_Phdr;
+
+
+/* p_type */
+#define PT_NULL 0 /* Program header table entry unused */
+#define PT_LOAD 1 /* Loadable program segment */
+#define PT_DYNAMIC 2 /* Dynamic linking information */
+#define PT_INTERP 3 /* Program interpreter */
+#define PT_NOTE 4 /* Auxiliary information */
+#define PT_SHLIB 5 /* Reserved, unspecified semantics */
+#define PT_PHDR 6 /* Entry for header table itself */
+#define PT_LOPROC 0x70000000 /* Processor-specific */
+#define PT_HIPROC 0x7FFFFFFF /* Processor-specific */
+
+/* p_flags */
+#define PF_X (1 << 0) /* Segment is executable */
+#define PF_W (1 << 1) /* Segment is writable */
+#define PF_R (1 << 2) /* Segment is readable */
+#define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */
+
+
+/*
+ * Section Header
+ */
+typedef struct {
+ Elf32_Word sh_name;
+ Elf32_Word sh_type;
+ Elf32_Word sh_flags;
+ Elf32_Addr sh_addr;
+ Elf32_Off sh_offset;
+ Elf32_Word sh_size;
+ Elf32_Word sh_link;
+ Elf32_Word sh_info;
+ Elf32_Word sh_addralign;
+ Elf32_Word sh_entsize;
+} Elf32_Shdr;
+
+/* sh_type */
+#define SHT_NULL 0 /* Section header table entry unused */
+#define SHT_PROGBITS 1 /* Program specific (private) data */
+#define SHT_SYMTAB 2 /* Link editing symbol table */
+#define SHT_STRTAB 3 /* A string table */
+#define SHT_RELA 4 /* Relocation entries with addends */
+#define SHT_HASH 5 /* A symbol hash table */
+#define SHT_DYNAMIC 6 /* Information for dynamic linking */
+#define SHT_NOTE 7 /* Information that marks file */
+#define SHT_NOBITS 8 /* Section occupies no space in file */
+#define SHT_REL 9 /* Relocation entries, no addends */
+#define SHT_SHLIB 10 /* Reserved, unspecified semantics */
+#define SHT_DYNSYM 11 /* Dynamic linking symbol table */
+#define SHT_LOPROC 0x70000000 /* Processor-specific semantics, lo */
+#define SHT_HIPROC 0x7FFFFFFF /* Processor-specific semantics, hi */
+#define SHT_LOUSER 0x80000000 /* Application-specific semantics */
+#define SHT_HIUSER 0x8FFFFFFF /* Application-specific semantics */
+
+/* sh_flags */
+#define SHF_WRITE (1 << 0) /* Writable data during execution */
+#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
+#define SHF_EXECINSTR (1 << 2) /* Executable machine instructions */
+#define SHF_MASKPROC 0xF0000000 /* Processor-specific semantics */
+
+
+/*
+ * Symbol Table
+ */
+typedef struct {
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ Elf_Char st_info;
+ Elf_Char st_other;
+ Elf32_Half st_shndx;
+} Elf32_Sym;
+
+
+#define ELF_ST_BIND(val) (((unsigned int)(val)) >> 4)
+#define ELF_ST_TYPE(val) ((val) & 0xF)
+#define ELF_ST_INFO(bind,type) (((bind) << 4) | ((type) & 0xF))
+
+/* symbol binding */
+#define STB_LOCAL 0 /* Symbol not visible outside obj */
+#define STB_GLOBAL 1 /* Symbol visible outside obj */
+#define STB_WEAK 2 /* Like globals, lower precedence */
+#define STB_LOPROC 13 /* Application-specific semantics */
+#define STB_HIPROC 15 /* Application-specific semantics */
+
+/* symbol type */
+#define STT_NOTYPE 0 /* Symbol type is unspecified */
+#define STT_OBJECT 1 /* Symbol is a data object */
+#define STT_FUNC 2 /* Symbol is a code object */
+#define STT_SECTION 3 /* Symbol associated with a section */
+#define STT_FILE 4 /* Symbol gives a file name */
+#define STT_LOPROC 13 /* Application-specific semantics */
+#define STT_HIPROC 15 /* Application-specific semantics */
+
+/* special values st_shndx */
+#define SHN_UNDEF 0 /* Undefined section reference */
+#define SHN_LORESERV 0xFF00 /* Begin range of reserved indices */
+#define SHN_LOPROC 0xFF00 /* Begin range of appl-specific */
+#define SHN_HIPROC 0xFF1F /* End range of appl-specific */
+#define SHN_ABS 0xFFF1 /* Associated symbol is absolute */
+#define SHN_COMMON 0xFFF2 /* Associated symbol is in common */
+#define SHN_HIRESERVE 0xFFFF /* End range of reserved indices */
diff --git a/cfe/cfe/include/env_subr.h b/cfe/cfe/include/env_subr.h
new file mode 100644
index 0000000..f5dfb9f
--- /dev/null
+++ b/cfe/cfe/include/env_subr.h
@@ -0,0 +1,117 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Environment helper routines File: env_subr.h
+ *
+ * Definitions and prototypes for environment variable subroutines
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+
+/*
+ * TLV types. These codes are used in the "type-length-value"
+ * encoding of the items stored in the NVRAM device (flash or EEPROM)
+ *
+ * The layout of the flash/nvram is as follows:
+ *
+ * <type> <length> <data ...> <type> <length> <data ...> <type_end>
+ *
+ * The type code of "ENV_TLV_TYPE_END" marks the end of the list.
+ * The "length" field marks the length of the data section, not
+ * including the type and length fields.
+ *
+ * Environment variables are stored as follows:
+ *
+ * <type_env> <length> <flags> <name> = <value>
+ *
+ * If bit 0 (low bit) is set, the length is an 8-bit value.
+ * If bit 0 (low bit) is clear, the length is a 16-bit value
+ *
+ * Bit 7 set indicates "user" TLVs. In this case, bit 0 still
+ * indicates the size of the length field.
+ *
+ * Flags are from the constants below:
+ *
+ */
+
+#define ENV_LENGTH_16BITS 0x00 /* for low bit */
+#define ENV_LENGTH_8BITS 0x01
+
+#define ENV_TYPE_USER 0x80
+
+#define ENV_CODE_SYS(n,l) (((n)<<1)|(l))
+#define ENV_CODE_USER(n,l) ((((n)<<1)|(l)) | ENV_TYPE_USER)
+
+/*
+ * The actual TLV types we support
+ */
+
+#define ENV_TLV_TYPE_END 0x00
+#define ENV_TLV_TYPE_ENV ENV_CODE_SYS(0,ENV_LENGTH_8BITS)
+
+/*
+ * Environment variable flags
+ */
+
+#define ENV_FLG_NORMAL 0x00 /* normal read/write */
+#define ENV_FLG_BUILTIN 0x01 /* builtin - not stored in flash */
+#define ENV_FLG_READONLY 0x02 /* read-only - cannot be changed */
+
+#define ENV_FLG_MASK 0xFF /* mask of attributes we keep */
+#define ENV_FLG_ADMIN 0x100 /* lets us internally override permissions */
+
+/* *********************************************************************
+ * Prototypes
+ ********************************************************************* */
+
+int env_delenv(const char *name);
+char *env_getenv(const char *name);
+int env_setenv(const char *name,char *value,int flags);
+int env_load(void);
+int env_save(void);
+int env_enum(int idx,char *name,int *namelen,char *val,int *vallen);
+int env_envtype(const char *name);
+
diff --git a/cfe/cfe/include/foxconnCfg.h b/cfe/cfe/include/foxconnCfg.h
new file mode 100755
index 0000000..3c43675
--- /dev/null
+++ b/cfe/cfe/include/foxconnCfg.h
@@ -0,0 +1,9 @@
+#ifndef _FOXCONNCFG_H
+#define _FOXCONNCFG_H
+
+#define FOXCONN_BOARD_ID "U12L161T00_NETGEAR"
+#define GPIO_POWER_RED_LED 18
+#define GPIO_POWER_RED_LED_ON 1
+#define GPIO_POWER_RED_LED_OFF 0
+
+#endif \ No newline at end of file
diff --git a/cfe/cfe/include/lib_arena.h b/cfe/cfe/include/lib_arena.h
new file mode 100644
index 0000000..2ae49d6
--- /dev/null
+++ b/cfe/cfe/include/lib_arena.h
@@ -0,0 +1,76 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Arena definitions File: lib_arena.h
+ *
+ * Definitions for the arena manager, which is used to keep
+ * track of ranges of physical memory.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+
+/* *********************************************************************
+ * Structures
+ ********************************************************************* */
+
+typedef struct arena_node_s {
+ queue_t an_next;
+ uint64_t an_address;
+ uint64_t an_length;
+ int an_type;
+ char *an_descr;
+} arena_node_t;
+
+
+typedef struct arena_s {
+ queue_t arena_list;
+ uint64_t arena_base;
+ uint64_t arena_size;
+} arena_t;
+
+/* *********************************************************************
+ * Prototypes
+ ********************************************************************* */
+
+int arena_markrange(arena_t *arena,uint64_t address,uint64_t length,
+ int type,char *descr);
+void arena_init(arena_t *arena,uint64_t physmembase,uint64_t physmemsize);
+
diff --git a/cfe/cfe/include/lib_malloc.h b/cfe/cfe/include/lib_malloc.h
new file mode 100644
index 0000000..da1e27b
--- /dev/null
+++ b/cfe/cfe/include/lib_malloc.h
@@ -0,0 +1,78 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Local memory manager File: mempool.h
+ *
+ * This routine is used to manage memory allocated within the
+ * firmware. You give it a chunk of memory to manage, and then
+ * these routines manage suballocations from there.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+#ifndef _LIB_MALLOC_H
+#define _LIB_MALLOC_H
+
+typedef struct memstats_s {
+ int mem_totalbytes;
+ int mem_allocbytes;
+ int mem_freebytes;
+ int mem_allocnodes;
+ int mem_freenodes;
+ int mem_largest;
+} memstats_t;
+
+typedef struct mempool_s mempool_t;
+void kmeminit(mempool_t *pool,unsigned char *buffer,int length);
+void kfree(mempool_t *pool,void *ptr);
+void *kmalloc(mempool_t *pool,unsigned int size,unsigned int align);
+int kmemchk(mempool_t *pool,int verbose);
+extern mempool_t kmempool;
+void *kmempoolbase(mempool_t *pool);
+int kmempoolsize(mempool_t *pool);
+int kmemstats(mempool_t *pool,memstats_t *stats);
+
+#define KMEMINIT(buffer,length) kmeminit(&kmempool,(buffer),(length))
+#define KMEMPOOLBASE() kmempoolbase(&kmempool)
+#define KMEMPOOLSIZE() kmempoolsize(&kmempool)
+#define KMALLOC(size,align) kmalloc(&kmempool,(size),(align))
+#define KFREE(ptr) kfree(&kmempool,(ptr))
+#define KMEMSTATS(s) kmemstats(&kmempool,(s))
+
+#endif
diff --git a/cfe/cfe/include/lib_printf.h b/cfe/cfe/include/lib_printf.h
new file mode 100755
index 0000000..e4d2860
--- /dev/null
+++ b/cfe/cfe/include/lib_printf.h
@@ -0,0 +1,69 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * simple printf File: lib_printf.h
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ * This module contains a very, very, very simple printf
+ * suitable for use in the boot ROM.
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+#include <stdarg.h>
+
+int xvsprintf(char *outbuf,const char *templat,va_list marker);
+int xsprintf(char *buf,const char *templat,...);
+#if CFG_RAMAPP
+int xprintf(const char *templat,...);
+#else
+#define xprintf(...)
+#endif
+
+extern int (*xprinthook)(const char *);
+int xvprintf(const char *template,va_list marker);
+
+/*
+ * compatibility macros
+ */
+
+
+#define printf xprintf
+#define sprintf xsprintf
+#define vsprintf xvsprintf
+#define vprintf xvprintf
diff --git a/cfe/cfe/include/lib_queue.h b/cfe/cfe/include/lib_queue.h
new file mode 100644
index 0000000..530c70f
--- /dev/null
+++ b/cfe/cfe/include/lib_queue.h
@@ -0,0 +1,85 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Queue management prototypes File: lib_queue.h
+ *
+ * Constants, structures, and function prototypes for the queue
+ * manager.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+#ifndef _LIB_QUEUE_H
+#define _LIB_QUEUE_H
+
+/* *********************************************************************
+ * Macros
+ ********************************************************************* */
+
+#define q_init(q) (q)->q_prev = (q), (q)->q_next = (q)
+#define q_isempty(q) ((q)->q_next == (q))
+#define q_getfirst(q) ((q)->q_next)
+#define q_getlast(q) ((q)->q_prev)
+
+/* *********************************************************************
+ * Types
+ ********************************************************************* */
+
+
+typedef struct queue_s {
+ struct queue_s *q_next;
+ struct queue_s *q_prev;
+} queue_t;
+
+
+/* *********************************************************************
+ * Prototypes
+ ********************************************************************* */
+
+void q_enqueue(queue_t *,queue_t *);
+void q_dequeue(queue_t *);
+queue_t *q_deqnext(queue_t *);
+int q_map(queue_t *qb,int (*func)(queue_t *,unsigned int,unsigned int),
+ unsigned int a,unsigned int b);
+int q_count(queue_t *);
+int q_find(queue_t *,queue_t *);
+
+
+#endif
diff --git a/cfe/cfe/include/lib_string.h b/cfe/cfe/include/lib_string.h
new file mode 100644
index 0000000..4d0f3d8
--- /dev/null
+++ b/cfe/cfe/include/lib_string.h
@@ -0,0 +1,117 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * string prototypes File: lib_string.h
+ *
+ * Function prototypes for the string routines
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+char *lib_strcpy(char *dest,const char *src);
+char *lib_strncpy(char *dest,const char *src,size_t cnt);
+size_t lib_xstrncpy(char *dest,const char *src,size_t cnt);
+size_t lib_strlen(const char *str);
+
+int lib_strcmp(const char *dest,const char *src);
+
+/* Foxconn add start by Cliff Wang, 03/23/2010 */
+int lib_strncmp(const char *dest, const char *src, size_t cnt );
+/* Foxconn add end by Cliff Wang, 03/23/2010 */
+
+int lib_strcmpi(const char *dest,const char *src);
+char *lib_strchr(const char *dest,int c);
+char *lib_strrchr(const char *dest,int c);
+int lib_memcmp(const void *dest,const void *src,size_t cnt);
+void *lib_memcpy(void *dest,const void *src,size_t cnt);
+void *lib_memset(void *dest,int c,size_t cnt);
+char *lib_strdup(char *str);
+void lib_trimleading(char *str);
+void lib_chop_filename(char *str,char **host,char **file);
+void lib_strupr(char *s);
+char lib_toupper(char c);
+char *lib_strcat(char *dest,const char *src);
+char *lib_gettoken(char **str);
+char *lib_strnchr(const char *dest,int c,size_t cnt);
+int lib_parseipaddr(const char *ipaddr,uint8_t *dest);
+int lib_atoi(const char *dest);
+int lib_lookup(const cons_t *list,char *str);
+int lib_setoptions(const cons_t *list,char *str,unsigned int *flags);
+int lib_xtoi(const char *dest);
+uint64_t lib_xtoq(const char *dest);
+
+
+
+#ifndef _LIB_NO_MACROS_
+#define strcpy(d,s) lib_strcpy(d,s)
+#define strncpy(d,s,c) lib_strncpy(d,s,c)
+#define xstrncpy(d,s,c) lib_xstrncpy(d,s,c)
+#define strlen(s) lib_strlen(s)
+#define strchr(s,c) lib_strchr(s,c)
+#define strrchr(s,c) lib_strrchr(s,c)
+#define strdup(s) lib_strdup(s)
+#define strcmp(d,s) lib_strcmp(d,s)
+
+/* Foxconn add start by Cliff Wang, 03/23/2010 */
+#define strncmp(d,s,c) lib_strncmp(d,s,c)
+/* Foxconn add end by Cliff Wang, 03/23/2010 */
+
+#define strcmpi(d,s) lib_strcmpi(d,s)
+#define memcmp(d,s,c) lib_memcmp(d,s,c)
+#define memset(d,s,c) lib_memset(d,s,c)
+#define memcpy(d,s,c) lib_memcpy(d,s,c)
+#define bcopy(s,d,c) lib_memcpy(d,s,c)
+#define bzero(d,c) lib_memset(d,0,c)
+#define strupr(s) lib_strupr(s)
+#define toupper(c) lib_toupper(c)
+#define strcat(d,s) lib_strcat(d,s)
+#define gettoken(s) lib_gettoken(s)
+#define strnchr(d,ch,cnt) lib_strnchr(d,ch,cnt)
+#define atoi(d) lib_atoi(d)
+#define xtoi(d) lib_xtoi(d)
+#define xtoq(d) lib_xtoq(d)
+#define parseipaddr(i,d) lib_parseipaddr(i,d)
+#define lookup(x,y) lib_lookup(x,y)
+#define setoptions(x,y,z) lib_setoptions(x,y,z)
+#endif
+
+void
+qsort(void *bot, size_t nmemb, size_t size, int (*compar)(const void *,const void *));
+
diff --git a/cfe/cfe/include/lib_types.h b/cfe/cfe/include/lib_types.h
new file mode 100644
index 0000000..7453a0d
--- /dev/null
+++ b/cfe/cfe/include/lib_types.h
@@ -0,0 +1,120 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Basic types File: lib_types.h
+ *
+ * This module defines the basic types used in CFE. Simple
+ * types, such as uint64_t, are defined here.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+#ifdef __mips
+#if ((defined(__MIPSEB)+defined(__MIPSEL)) != 1)
+#error "Either __MIPSEB or __MIPSEL must be defined!"
+#endif
+#endif
+
+
+#ifndef _LIB_TYPES_H
+#define _LIB_TYPES_H
+
+/* *********************************************************************
+ * Constants
+ ********************************************************************* */
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+/* *********************************************************************
+ * Basic types
+ ********************************************************************* */
+
+typedef int size_t;
+
+typedef char int8_t;
+typedef unsigned char uint8_t;
+
+typedef short int16_t;
+typedef unsigned short uint16_t;
+
+#ifdef __long64
+typedef int int32_t;
+typedef unsigned int uint32_t;
+#else
+typedef long int32_t;
+typedef unsigned long uint32_t;
+#endif
+
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+
+#define unsigned signed /* Kludge to get unsigned size-shaped type. */
+typedef __SIZE_TYPE__ intptr_t;
+#undef unsigned
+typedef __SIZE_TYPE__ uintptr_t;
+
+/* *********************************************************************
+ * Macros
+ ********************************************************************* */
+
+#ifndef offsetof
+#define offsetof(type,memb) ((size_t)&((type *)0)->memb)
+#endif
+
+/* *********************************************************************
+ * Structures
+ ********************************************************************* */
+
+typedef struct cons_s {
+ char *str;
+ int num;
+} cons_t;
+
+#endif
diff --git a/cfe/cfe/include/socregs.h b/cfe/cfe/include/socregs.h
new file mode 100644
index 0000000..835f8aa
--- /dev/null
+++ b/cfe/cfe/include/socregs.h
@@ -0,0 +1,63 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * SOC Register table defs File: socregs.h
+ *
+ * Data structures related to the "show soc" command and the
+ * "makereg" program.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+
+typedef struct socreg_s socreg_t;
+
+struct socreg_s {
+ uint32_t reg_addr;
+ uint32_t reg_agent;
+ const char *reg_inst;
+ const char *reg_subinst;
+ uint32_t reg_mask;
+ void (*reg_printfunc)(const socreg_t *reg,uint64_t value);
+ const char *reg_descr;
+};
+
+
+
+
diff --git a/cfe/cfe/include/tftpd.h b/cfe/cfe/include/tftpd.h
new file mode 100755
index 0000000..d7a15a9
--- /dev/null
+++ b/cfe/cfe/include/tftpd.h
@@ -0,0 +1,26 @@
+/***************************************************************************
+***
+*** Copyright 2005 Hon Hai Precision Ind. Co. Ltd.
+*** All Rights Reserved.
+*** No portions of this material shall be reproduced in any form without the
+*** written permission of Hon Hai Precision Ind. Co. Ltd.
+***
+*** All information contained in this document is Hon Hai Precision Ind.
+*** Co. Ltd. company private, proprietary, and trade secret property and
+*** are protected by international intellectual property laws and treaties.
+***
+****************************************************************************/
+
+#ifndef __TFTPD_H
+#define __TFTPD_H
+
+/* Foxconn add start by Cliff Wang, 03/23/2010 */
+#define TFTPD_STATE_OFF 0
+#define TFTPD_STATE_WAIT_IMAGE 1
+#define TFTPD_STATE_WRITE_IMAGE 2
+
+extern int get_tftpd_state(void);
+extern int set_tftpd_state(int state);
+/* Foxconn add end by Cliff Wang, 03/23/2010 */
+
+#endif
diff --git a/cfe/cfe/include/ui_command.h b/cfe/cfe/include/ui_command.h
new file mode 100644
index 0000000..e85a3ae
--- /dev/null
+++ b/cfe/cfe/include/ui_command.h
@@ -0,0 +1,140 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Command interpreter defs File: ui_command.h
+ *
+ * This file contains structures related to the
+ * command interpreter.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * Copyright 2000,2001,2002,2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the following terms and
+ * conditions. Subject to these conditions, you may download,
+ * copy, install, use, modify and distribute modified or unmodified
+ * copies of this software in source and/or binary form. No title
+ * or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce
+ * and retain this copyright notice and list of conditions
+ * as they appear in the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or
+ * logo of Broadcom Corporation. The "Broadcom Corporation"
+ * name may not be used to endorse or promote products derived
+ * from this software without the prior written permission of
+ * Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+ * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+ * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ ********************************************************************* */
+
+#ifndef _LIB_QUEUE_H
+#include "lib_queue.h"
+#endif
+
+typedef struct ui_cmdsw_s {
+ int swidx;
+ char *swname;
+ char *swvalue;
+} ui_cmdsw_t;
+
+#define MAX_TOKENS 64
+#define MAX_SWITCHES 16
+#define MAX_TOKEN_SIZE 1000
+typedef struct ui_cmdline_s {
+ int argc;
+ char *argv[MAX_TOKENS];
+ int swc;
+ ui_cmdsw_t swv[MAX_SWITCHES];
+ int (*func)(struct ui_cmdline_s *,int argc,char *argv[]);
+ int argidx;
+ char *ref;
+ char *usage;
+ char *switches;
+} ui_cmdline_t;
+
+typedef struct ui_command_s {
+ queue_t list;
+ int term;
+ char *ptr;
+ queue_t head;
+} ui_command_t;
+
+typedef struct ui_token_s {
+ queue_t qb;
+ char token;
+} ui_token_t;
+
+#define CMD_TERM_EOL 0
+#define CMD_TERM_SEMI 1
+#define CMD_TERM_AND 2
+#define CMD_TERM_OR 3
+
+int cmd_sw_value(ui_cmdline_t *cmd,char *swname,char **swvalue);
+int cmd_sw_posn(ui_cmdline_t *cmd,char *swname);
+char *cmd_sw_name(ui_cmdline_t *cmd,int swidx);
+int cmd_sw_isset(ui_cmdline_t *cmd,char *swname);
+char *cmd_getarg(ui_cmdline_t *cmd,int argnum);
+void cmd_free(ui_cmdline_t *cmd);
+int cmd_sw_validate(ui_cmdline_t *cmd,char *validstr);
+void cmd_parse(ui_cmdline_t *cmd,char *line);
+int cmd_addcmd(char *command,
+ int (*func)(ui_cmdline_t *,int argc,char *argv[]),
+ void *ref,
+ char *help,
+ char *usage,
+ char *switches);
+int cmd_lookup(queue_t *head,ui_cmdline_t *cmd);
+void cmd_init(void);
+int cmd_getcommand(ui_cmdline_t *cmd);
+void cmd_showusage(ui_cmdline_t *cmd);
+
+
+
+#define CMD_ERR_INVALID -1
+#define CMD_ERR_AMBIGUOUS -2
+#define CMD_ERR_BLANK -3
+
+
+/* *********************************************************************
+ * Prototypes (public routines)
+ ********************************************************************* */
+
+const char *ui_errstring(int errcode);
+int ui_showerror(int errcode,char *tmplt,...);
+int ui_showusage(ui_cmdline_t *cmd);
+int ui_docommands(char *str);
+#define ui_docommand(str) ui_docommands(str)
+void ui_restart(int);
+int ui_init_cmddisp(void);
+
+
+/* *********************************************************************
+ * Prototypes (internal routines)
+ ********************************************************************* */
+
+ui_command_t *cmd_readcommand(queue_t *head);
+void cmd_build_list(queue_t *qb,char *buf);
+void cmd_walk_and_expand(queue_t *qb);
+ui_command_t *cmd_readcommand(queue_t *head);
+void cmd_free_tokens(queue_t *list);
+void cmd_build_cmdline(queue_t *head, ui_cmdline_t *cmd);
+
+