summaryrefslogtreecommitdiffstats
path: root/qemu/roms/SLOF/include
diff options
context:
space:
mode:
Diffstat (limited to 'qemu/roms/SLOF/include')
-rw-r--r--qemu/roms/SLOF/include/allocator.h23
-rw-r--r--qemu/roms/SLOF/include/byteorder.h98
-rw-r--r--qemu/roms/SLOF/include/calculatecrc.h66
-rw-r--r--qemu/roms/SLOF/include/helpers.h42
-rw-r--r--qemu/roms/SLOF/include/libelf.h99
-rw-r--r--qemu/roms/SLOF/include/macros.h58
-rw-r--r--qemu/roms/SLOF/include/memmap.h26
-rw-r--r--qemu/roms/SLOF/include/netdriver.h24
-rw-r--r--qemu/roms/SLOF/include/pcd.h58
-rw-r--r--qemu/roms/SLOF/include/ppc970/cache.h86
-rw-r--r--qemu/roms/SLOF/include/ppc970/cpu.h113
-rw-r--r--qemu/roms/SLOF/include/ppcp7/cache.h150
-rw-r--r--qemu/roms/SLOF/include/ppcp7/cpu.h66
-rw-r--r--qemu/roms/SLOF/include/romfs.h60
-rw-r--r--qemu/roms/SLOF/include/rtas.h42
-rw-r--r--qemu/roms/SLOF/include/rtas_table.h32
-rw-r--r--qemu/roms/SLOF/include/termctrl.h62
-rw-r--r--qemu/roms/SLOF/include/xvect.h21
18 files changed, 1126 insertions, 0 deletions
diff --git a/qemu/roms/SLOF/include/allocator.h b/qemu/roms/SLOF/include/allocator.h
new file mode 100644
index 000000000..0f75fce35
--- /dev/null
+++ b/qemu/roms/SLOF/include/allocator.h
@@ -0,0 +1,23 @@
+/******************************************************************************
+ * Copyright (c) 2007, 2012, 2013 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#ifndef _ALLOCATOR_H
+#define _ALLOCATOR_H
+
+extern void SLOF_bm_print(unsigned long handle);
+extern unsigned long SLOF_bm_allocator_init(unsigned long start,
+ unsigned long size,
+ unsigned long blocksize);
+extern unsigned long SLOF_bm_alloc(unsigned long handle, unsigned long size);
+extern void SLOF_bm_free(unsigned long handle, unsigned long ptr, unsigned long size);
+
+#endif /* _ALLOCATOR_H */
diff --git a/qemu/roms/SLOF/include/byteorder.h b/qemu/roms/SLOF/include/byteorder.h
new file mode 100644
index 000000000..60ca67267
--- /dev/null
+++ b/qemu/roms/SLOF/include/byteorder.h
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * Copyright (c) 2011 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+/*
+ * Common byteorder (endianness) macros
+ */
+
+#ifndef BYTEORDER_H
+#define BYTEORDER_H
+
+#include <stdint.h>
+
+static inline uint16_t
+bswap_16 (uint16_t x)
+{
+ return __builtin_bswap16(x);
+}
+
+static inline uint32_t
+bswap_32 (uint32_t x)
+{
+ return __builtin_bswap32(x);
+}
+
+static inline uint64_t
+bswap_64 (uint64_t x)
+{
+ return __builtin_bswap64(x);
+}
+
+static inline void
+bswap_16p (uint16_t *x)
+{
+ *x = __builtin_bswap16(*x);
+}
+
+static inline void
+bswap_32p (uint32_t *x)
+{
+ *x = __builtin_bswap32(*x);
+}
+
+static inline void
+bswap_64p (uint64_t *x)
+{
+ *x = __builtin_bswap64(*x);
+}
+
+
+/* gcc defines __BIG_ENDIAN__ on big endian targets */
+#ifdef __BIG_ENDIAN__
+
+#define cpu_to_be16(x) (x)
+#define cpu_to_be32(x) (x)
+#define cpu_to_be64(x) (x)
+
+#define be16_to_cpu(x) (x)
+#define be32_to_cpu(x) (x)
+#define be64_to_cpu(x) (x)
+
+#define le16_to_cpu(x) bswap_16(x)
+#define le32_to_cpu(x) bswap_32(x)
+#define le64_to_cpu(x) bswap_64(x)
+
+#define cpu_to_le16(x) bswap_16(x)
+#define cpu_to_le32(x) bswap_32(x)
+#define cpu_to_le64(x) bswap_64(x)
+
+#else
+
+#define cpu_to_be16(x) bswap_16(x)
+#define cpu_to_be32(x) bswap_32(x)
+#define cpu_to_be64(x) bswap_64(x)
+
+#define be16_to_cpu(x) bswap_16(x)
+#define be32_to_cpu(x) bswap_32(x)
+#define be64_to_cpu(x) bswap_64(x)
+
+#define le16_to_cpu(x) (x)
+#define le32_to_cpu(x) (x)
+#define le64_to_cpu(x) (x)
+
+#define cpu_to_le16(x) (x)
+#define cpu_to_le32(x) (x)
+#define cpu_to_le64(x) (x)
+
+#endif /* __BIG_ENDIAN__ */
+
+#endif /* BYTEORDER_H */
diff --git a/qemu/roms/SLOF/include/calculatecrc.h b/qemu/roms/SLOF/include/calculatecrc.h
new file mode 100644
index 000000000..216847813
--- /dev/null
+++ b/qemu/roms/SLOF/include/calculatecrc.h
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+#ifndef CALCULATECRC_H
+#define CALCULATECRC_H
+
+ #define FLASHFS_DATADDR 0x18 // uint64_t position of pointer to data
+ #define FLASHFS_FILE_SIZE_ADDR 0x08 // uint64_t pos of total flashimage size value relative to data
+ #define FLASHFS_HEADER_SIZE_ADDR 0x08 // uint64_t position of total flash header size value
+
+ #ifdef __ASSEMBLER__
+ // "CRC_GENERATOR" must contain equal inforamtion as "CRC_METHODE"
+ #define CRC_GENERATOR 0x0000000004C11DB7
+ #define CRC_REGISTERMASK 0x00000000FFFFFFFF
+ #define CRC_REGISTERLENGTH 32
+ #endif /* __ASSEMBLER__ */
+
+ #ifndef __ASSEMBLER__
+ #define FLASHFS_ROMADDR 0x00 // uint64_t position of pointer to next file
+ #define FLASHFS_HEADER_DATA_SIZE 0x68 // 104 bytes of total header data size
+ #define CRC_METHODE Ethernet_32 // define the CRc genarator (CRC 16 bit to 64 is supported)
+
+ //--- header format ---------------------------------
+ struct stH {
+ char magic[8]; // (generic!) headerfile
+ uint64_t flashlen; // dyn
+ char version[16]; // $DRIVER_INFO alignment!
+ char platform_name[32]; // (hardware) headerfile
+ char date[6]; // dyn (format -> JB)
+ char padding1[2]; // padding byte
+ char mdate[6]; // modify date
+ char padding2[2]; // padding byte
+ char platform_revision[4];// (hardware) headerfile
+ uint32_t padding;
+ uint64_t ui64CRC; // insert calculated CRC here
+ uint64_t ui64FileEnd; // = 0xFFFF FFFF FFFF FFFF
+ };
+ #endif /* __ASSEMBLER__ */
+
+#endif /* CALCULATECRC_H */
+
+/*--- supported CRC Generators -------------------------
++ Name length usage Generator
++ Tap_16 16 bit Tape 0x00008005
++ Floppy_16 16 bit Floppy 0x00001021
++ Ethernet_32 32 bit Ethernet 0x04C11DB7
++ SPTrEMBL_64 64 bit white noise like date 0x0000001B
++ SPTrEMBL_improved_64 64 bit DNA code like date 0xAD93D23594C9362D
++ DLT1_64 64 bit Tape 0x42F0E1EBA9EA3693
++
++ CRC_REGISTERLENGTH = bit length
++ CRC_REGISTERMASK = -1 for a n-bit numer where n = bit length
++ example TAP_16: CRC_REGSISTERLENGTH = 16
++ CRC_REGISTERMASK = 0xFFFFFFFF = (-1 if 16 bit number is used)
++
++ TrEMBL see also http://www.cs.ud.ac.uk/staff/D.Jones/crcbote.pdf
++ DLT1 se also http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-182.pdf
++--------------------------------------------------------*/
diff --git a/qemu/roms/SLOF/include/helpers.h b/qemu/roms/SLOF/include/helpers.h
new file mode 100644
index 000000000..fb105345e
--- /dev/null
+++ b/qemu/roms/SLOF/include/helpers.h
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * Copyright (c) 2007, 2012, 2013 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+/*
+ * USB SLOF Prototypes
+ */
+
+#ifndef _USB_SLOF_H
+#define _USB_SLOF_H
+
+#include <stdint.h>
+
+extern uint32_t SLOF_GetTimer(void);
+extern void SLOF_msleep(uint32_t time);
+extern void SLOF_usleep(uint32_t time);
+extern void *SLOF_dma_alloc(long size);
+extern void SLOF_dma_free(void *virt, long size);
+extern void *SLOF_alloc_mem(long size);
+extern void *SLOF_alloc_mem_aligned(long size, long align);
+extern void SLOF_free_mem(void *addr, long size);
+extern long SLOF_dma_map_in(void *virt, long size, int cacheable);
+extern void SLOF_dma_map_out(long phys, void *virt, long size);
+extern long SLOF_pci_config_read32(long offset);
+extern long SLOF_pci_config_read16(long offset);
+extern void SLOF_pci_config_write32(long offset, long value);
+extern void SLOF_pci_config_write16(long offset, long value);
+extern void *SLOF_translate_my_address(void *addr);
+
+#define offset_of(type, member) ((long) &((type *)0)->member)
+#define container_of(ptr, type, member) ({ \
+ const typeof(((type *)0)->member)* struct_ptr = (ptr); \
+ (type *)((char *)struct_ptr - offset_of(type, member)); })
+
+#endif
diff --git a/qemu/roms/SLOF/include/libelf.h b/qemu/roms/SLOF/include/libelf.h
new file mode 100644
index 000000000..5fbf27927
--- /dev/null
+++ b/qemu/roms/SLOF/include/libelf.h
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2011 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+/*
+ * ELF loader library
+ */
+
+#ifndef __LIBELF_H
+#define __LIBELF_H
+
+#include <stdint.h>
+
+/* ELF object file types */
+#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 */
+
+/* ELF object endian */
+#define ELFDATA2LSB 1 /* 2's complement, little endian */
+#define ELFDATA2MSB 2 /* 2's complement, big endian */
+
+/* Generic ELF header */
+struct ehdr {
+ uint32_t ei_ident;
+ uint8_t ei_class;
+ uint8_t ei_data;
+ uint8_t ei_version;
+ uint8_t ei_pad[9];
+ uint16_t e_type;
+ uint16_t e_machine;
+ uint32_t e_version;
+};
+
+/* Section types (sh_type) */
+#define SHT_NULL 0 /* Unused section header */
+#define SHT_PROGBITS 1 /* Information defined by the program */
+#define SHT_SYMTAB 2 /* Linker symbol table */
+#define SHT_STRTAB 3 /* String table */
+#define SHT_RELA 4 /* "Rela" type relocation entries */
+#define SHT_HASH 5 /* Symbol hash table */
+#define SHT_DYNAMIC 6 /* Dynamic linking tables */
+#define SHT_NOTE 7 /* Note information */
+#define SHT_NOBITS 8 /* Uninitialized space */
+#define SHT_REL 9 /* "Rel" type relocation entries */
+#define SHT_SHLIB 10 /* Reserved */
+#define SHT_DYNSYM 11 /* Dynamic loader symbol table */
+
+/* Section attributs (sh_flags) */
+#define SHF_WRITE 0x1
+#define SHF_ALLOC 0x2
+#define SHF_EXECINSTR 0x4
+
+/* Segment types (p_type) */
+#define PT_NULL 0 /* Unused entry */
+#define PT_LOAD 1 /* Loadable segment */
+#define PT_DYNAMIC 2 /* Dynamic linking tables */
+#define PT_INTERP 3 /* Program interpreter path name */
+#define PT_NOTE 4 /* Note sections */
+
+
+int elf_load_file(void *file_addr, unsigned long *entry,
+ int (*pre_load)(void*, long),
+ void (*post_load)(void*, long));
+int elf_load_file_to_addr(void *file_addr, void *addr, unsigned long *entry,
+ int (*pre_load)(void*, long),
+ void (*post_load)(void*, long));
+
+void elf_byteswap_header32(void *file_addr);
+void elf_byteswap_header64(void *file_addr);
+
+unsigned int elf_load_segments32(void *file_addr, signed long offset,
+ int (*pre_load)(void*, long),
+ void (*post_load)(void*, long));
+unsigned long elf_load_segments64(void *file_addr, signed long offset,
+ int (*pre_load)(void*, long),
+ void (*post_load)(void*, long));
+
+long elf_get_base_addr(void *file_addr);
+long elf_get_base_addr32(void *file_addr);
+long elf_get_base_addr64(void *file_addr);
+uint32_t elf_get_eflags_32(void *file_addr);
+uint32_t elf_get_eflags_64(void *file_addr);
+
+void elf_relocate64(void *file_addr, signed long offset);
+
+int elf_forth_claim(void *addr, long size);
+
+#endif /* __LIBELF_H */
diff --git a/qemu/roms/SLOF/include/macros.h b/qemu/roms/SLOF/include/macros.h
new file mode 100644
index 000000000..f519bb8a7
--- /dev/null
+++ b/qemu/roms/SLOF/include/macros.h
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#define LOAD64(rn,name) \
+ lis rn,name##@highest; \
+ ori rn,rn,name##@higher; \
+ rldicr rn,rn,32,31; \
+ oris rn,rn,name##@h; \
+ ori rn,rn,name##@l
+
+#define LOAD32(rn, name) \
+ lis rn,name##@h; \
+ ori rn,rn,name##@l
+
+// load 32 bit constant in little endian order
+#define LOAD32le(rn,name) \
+ lis rn,(((name>>8)&0x00FF)|((name<<8)&0xFF00)); \
+ ori rn,rn,(((name>>24)&0x00FF)|((name>>8)&0xFF00))
+
+// load 16 bit constant in little endian order
+#define LOAD16le(rn,name) \
+ li rn,(((name>>8)&0x00FF)|((name<<8)&0xFF00))
+
+#define ENTRY(func_name) \
+ .text; \
+ .align 2; \
+ .globl .func_name; \
+ .func_name: \
+ .globl func_name; \
+ func_name:
+
+#define C_ENTRY(func_name) \
+ .section ".text"; \
+ .align 2; \
+ .globl func_name; \
+ .section ".opd","aw"; \
+ .align 3; \
+ func_name: \
+ .quad .func_name,.TOC.@tocbase,0; \
+ .previous; \
+ .size func_name,24; \
+ .type .func_name,@function; \
+ .globl .func_name; \
+ .func_name:
+
+#define ASM_ENTRY(fn) \
+ .globl fn; \
+fn:
+
diff --git a/qemu/roms/SLOF/include/memmap.h b/qemu/roms/SLOF/include/memmap.h
new file mode 100644
index 000000000..abf3c1f03
--- /dev/null
+++ b/qemu/roms/SLOF/include/memmap.h
@@ -0,0 +1,26 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+#ifndef MEMMAP_H
+#define MEMMAP_H
+
+#define MEG 0x100000
+
+#define SLAVELOOP_LOADBASE 0x0000000000003f00
+#define STAGE2_LOADBASE (60 * MEG)
+#define OF_LOADBASE 0x000000000000a000
+
+#define MEM_HALF (512 * MEG)
+
+/* BE Engines Offsets */
+#define BE_MIC_BASE 0x50A000
+
+#endif
diff --git a/qemu/roms/SLOF/include/netdriver.h b/qemu/roms/SLOF/include/netdriver.h
new file mode 100644
index 000000000..d81134eac
--- /dev/null
+++ b/qemu/roms/SLOF/include/netdriver.h
@@ -0,0 +1,24 @@
+/******************************************************************************
+ * Copyright (c) 2013 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ ******************************************************************************/
+
+#ifndef _NETDRIVER_H
+#define _NETDRIVER_H
+
+#include <stdint.h>
+
+typedef struct net_driver {
+ uint8_t mac_addr[6];
+ uint32_t reg;
+ int running;
+} net_driver_t;
+
+#endif
diff --git a/qemu/roms/SLOF/include/pcd.h b/qemu/roms/SLOF/include/pcd.h
new file mode 100644
index 000000000..9794b767f
--- /dev/null
+++ b/qemu/roms/SLOF/include/pcd.h
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+#ifndef PCD_H
+#define PCD_H
+
+#define PCD_START_ADDR 0xFF00000 // FIXME: this should not interfere with
+ // other parts of the firmware
+#define PCD_HDR_SIZE (6 * 8) /* only use for ctrl file */
+
+/* PCD File Definition ****************************************/
+/* File = "p:ctrl" 0x703a6374726c0000 */
+/* Data : */
+/* [00:07] - pointer to header of last file which was created */
+/* [08:0f] - pointer to header of next file for creation */
+/**************************************************************/
+#define PCDF_CTRL_LAST 0
+#define PCDF_CTRL_NEXT 8
+
+/* PCD File Definition ****************************************/
+/* File = "p:pXmem" */
+/* Data : */
+/* [00:07] - number of memory segments */
+/* [08:0f] - real base of memory segment #n */
+/* [10:17] - real size of memory segment #n */
+/* [18:1f] - real base of memory segment #n+1 */
+/* [20:27] - real size of memory segment #n+1 */
+/* ... and so on.. */
+/**************************************************************/
+#define PCDF_MEM_NUM 0
+#define PCDF_MEMN_BASE(N) (8 + ((N) * 16))
+#define PCDF_MEMN_SIZE(M) (PCDF_MEMN_BASE(M) + 8)
+
+/* PCD File Definition ****************************************/
+/* File = "p:pXcfg" */
+/* Data : */
+/* [00:07] - number of memory segments */
+/* [08:0f] - real base of memory segment #n */
+/* [10:17] - real size of memory segment #n */
+/* [18:1f] - real base of memory segment #n+1 */
+/* [20:27] - real size of memory segment #n+1 */
+/* ... and so on.. */
+/**************************************************************/
+#define PCDF_PCFG_IOCBASE (0 * 8)
+#define PCDF_PCFG_BPBASE (1 * 8)
+#define PCDF_PCFG_SPUMAP (2 * 8)
+#define PCDF_PCFG_TIMEBASE (3 * 8)
+#define PCDF_PCFG_CPUFREQ (4 * 8)
+
+#endif
diff --git a/qemu/roms/SLOF/include/ppc970/cache.h b/qemu/roms/SLOF/include/ppc970/cache.h
new file mode 100644
index 000000000..b74868986
--- /dev/null
+++ b/qemu/roms/SLOF/include/ppc970/cache.h
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#ifndef __CACHE_H
+#define __CACHE_H
+
+#include <cpu.h>
+#include <stdint.h>
+
+#define cache_inhibited_access(type,name) \
+ static inline type ci_read_##name(type * addr) \
+ { \
+ type val; \
+ set_ci(); \
+ val = *addr; \
+ clr_ci(); \
+ return val; \
+ } \
+ static inline void ci_write_##name(type * addr, type data) \
+ { \
+ set_ci(); \
+ *addr = data; \
+ clr_ci(); \
+ }
+
+cache_inhibited_access(uint8_t, 8)
+cache_inhibited_access(uint16_t, 16)
+cache_inhibited_access(uint32_t, 32)
+cache_inhibited_access(uint64_t, 64)
+
+#define _FWOVERLAP(s, d, size) ((d >= s) && ((type_u)d < ((type_u)s + size)))
+
+// 3.1
+#define _FWMOVE(s, d, size, t) \
+ { t *s1=(t *)s, *d1=(t *)d; \
+ while (size > 0) { *d1++ = *s1++; size -= sizeof(t); } }
+
+#define _BWMOVE(s, d, size, t) { \
+ t *s1=(t *)((char *)s+size), *d1=(t *)((char *)d+size); \
+ while (size > 0) { *--d1 = *--s1; size -= sizeof(t); } \
+}
+
+
+#define _MOVE(s, d, size, t) if _FWOVERLAP(s, d, size) _BWMOVE(s, d, size, t) else _FWMOVE(s, d, size, t)
+
+#define _FASTMOVE(s, d, size) \
+ switch (((type_u)s | (type_u)d | size) & (sizeof(type_u)-1)) { \
+ case 0: _MOVE(s, d, size, type_u); break; \
+ case sizeof(type_l): _MOVE(s, d, size, type_l); break; \
+ case sizeof(type_w): _MOVE(s, d, size, type_w); break; \
+ default: _MOVE(s, d, size, type_c); break; \
+ }
+
+// Device IO block data helpers
+#define _FWRMOVE(s, d, size, t) \
+ { t *s1=(t *)s, *d1=(t *)d; SET_CI; \
+ while (size > 0) { *d1++ = *s1++; size -= sizeof(t); } \
+ CLR_CI; \
+}
+
+#define _BWRMOVE(s, d, size, t) { \
+ t *s1=(t *)((char *)s+size), *d1=(t *)((char *)d+size); SET_CI; \
+ while (size > 0) { *--d1 = *--s1; size -= sizeof(t); } \
+ CLR_CI; \
+}
+
+#define _RMOVE(s, d, size, t) if _FWOVERLAP(s, d, size) _BWRMOVE(s, d, size, t) else _FWRMOVE(s, d, size, t)
+
+#define _FASTRMOVE(s, d, size) \
+ switch (((type_u)s | (type_u)d | size) & (sizeof(type_u)-1)) { \
+ case 0: _RMOVE(s, d, size, type_u); break; \
+ case sizeof(type_l): _RMOVE(s, d, size, type_l); break; \
+ case sizeof(type_w): _RMOVE(s, d, size, type_w); break; \
+ default: _RMOVE(s, d, size, type_c); break; \
+ }
+
+#endif
diff --git a/qemu/roms/SLOF/include/ppc970/cpu.h b/qemu/roms/SLOF/include/ppc970/cpu.h
new file mode 100644
index 000000000..0e66dff36
--- /dev/null
+++ b/qemu/roms/SLOF/include/ppc970/cpu.h
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#ifndef __PPC970_H
+#define __PPC970_H
+
+/* SPRs numbers */
+
+#define CTRL_RD 136
+#define CTRL_WR 152
+#define PVR 287
+#define HSPRG0 304
+#define HSPRG1 305
+#define HIOR 311
+#define HID0 1008
+#define HID1 1009
+#define HID4 1012
+#define HID6 1017
+#define PIR 1023
+
+#define SETCI(r) sync; \
+ mfspr r, HID4; \
+ sync; \
+ rldicl r, r, 32,0; \
+ ori r, r, 0x0100; \
+ rldicl r, r, 32,0; \
+ sync; \
+ slbia; \
+ mtspr HID4, r; \
+ isync; \
+ eieio;
+
+#define CLRCI(r) sync; \
+ mfspr r, HID4; \
+ sync; \
+ rldicl r, r, 32, 0; \
+ ori r, r, 0x0100; \
+ xori r, r, 0x0100; \
+ rldicl r, r, 32, 0; \
+ sync; \
+ slbia; \
+ mtspr HID4, r; \
+ isync; \
+ eieio;
+
+/* This macro uses r0 */
+#define FLUSH_CACHE(r, n) add n, n, r; \
+ addi n, n, 127; \
+ rlwinm r, r, 0,0,24; \
+ rlwinm n, n, 0,0,24; \
+ sub n, n, r; \
+ srwi n, n, 7; \
+ mtctr n; \
+ 0: dcbst 0, r; \
+ sync; \
+ icbi 0, r; \
+ sync; \
+ isync; \
+ addi r, r, 128; \
+ bdnz 0b;
+
+#ifndef __ASSEMBLER__
+#define STRINGIFY(x...) #x
+#define EXPAND(x) STRINGIFY(x)
+
+static inline void
+set_ci(void)
+{
+ unsigned long tmp;
+ asm volatile(EXPAND(SETCI(%0)) : "=r"(tmp) :: "memory", "cc");
+}
+
+static inline void
+clr_ci(void)
+{
+ unsigned long tmp;
+ asm volatile(EXPAND(CLRCI(%0)) : "=r"(tmp) :: "memory", "cc");
+}
+
+static inline void eieio(void)
+{
+ asm volatile ("eieio":::"memory");
+}
+
+static inline void barrier(void)
+{
+ asm volatile("" : : : "memory");
+}
+#define cpu_relax() barrier()
+
+static inline void sync(void)
+{
+ asm volatile ("sync" ::: "memory");
+}
+#define mb() sync()
+
+static inline void flush_cache(void* r, long n)
+{
+ asm volatile(EXPAND(FLUSH_CACHE(%0, %1)) : "+r"(r), "+r"(n) :: "memory", "cc", "r0", "ctr");
+}
+
+#endif /* __ASSEMBLER__ */
+
+#endif
diff --git a/qemu/roms/SLOF/include/ppcp7/cache.h b/qemu/roms/SLOF/include/ppcp7/cache.h
new file mode 100644
index 000000000..dc6837196
--- /dev/null
+++ b/qemu/roms/SLOF/include/ppcp7/cache.h
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#ifndef __CACHE_H
+#define __CACHE_H
+
+#include <cpu.h>
+#include <stdint.h>
+
+// XXX FIXME: Use proper CI load/store */
+#define cache_inhibited_access(type,size) \
+ static inline type ci_read_##size(type * addr) \
+ { \
+ register uint64_t arg0 asm ("r3"); \
+ register uint64_t arg1 asm ("r4"); \
+ register uint64_t arg2 asm ("r5"); \
+ \
+ arg0 = 0x3c; /* H_LOGICAL_CI_LOAD*/ \
+ arg1 = size / 8; \
+ arg2 = (uint64_t)addr; \
+ \
+ asm volatile( \
+ ".long 0x44000022 \n" /* HVCALL */ \
+ : "=&r" (arg0), "=&r"(arg1), "=&r"(arg2) \
+ : "0"(arg0), "1"(arg1), "2"(arg2) \
+ : "r0", "r6", "r7", "r8", "r9", "r10", "r11", \
+ "r12", "memory", "cr0", "cr1", "cr5", \
+ "cr6", "cr7", "ctr", "xer"); \
+ return arg0 ? (type)-1 : arg1; \
+ } \
+ static inline void ci_write_##size(type * addr, type data) \
+ { \
+ register uint64_t arg0 asm ("r3"); \
+ register uint64_t arg1 asm ("r4"); \
+ register uint64_t arg2 asm ("r5"); \
+ register uint64_t arg3 asm ("r6"); \
+ \
+ arg0 = 0x40; /* H_LOGICAL_CI_STORE*/ \
+ arg1 = size / 8; \
+ arg2 = (uint64_t)addr; \
+ arg3 = (uint64_t)data; \
+ \
+ asm volatile( \
+ ".long 0x44000022 \n" /* HVCALL */ \
+ : "=&r"(arg0),"=&r"(arg1),"=&r"(arg2),"=&r"(arg3) \
+ : "0"(arg0),"1"(arg1),"2"(arg2),"3"(arg3) \
+ : "r0", "r7", "r8", "r9", "r10", "r11", \
+ "r12", "memory", "cr0", "cr1", "cr5", \
+ "cr6", "cr7", "ctr", "xer"); \
+ }
+
+cache_inhibited_access(uint8_t, 8)
+cache_inhibited_access(uint16_t, 16)
+cache_inhibited_access(uint32_t, 32)
+cache_inhibited_access(uint64_t, 64)
+
+#define _FWOVERLAP(s, d, size) ((d >= s) && ((type_u)d < ((type_u)s + size)))
+
+// 3.1
+#define _FWMOVE(s, d, size, t) \
+ { t *s1=(t *)s, *d1=(t *)d; \
+ while (size > 0) { *d1++ = *s1++; size -= sizeof(t); } }
+
+#define _BWMOVE(s, d, size, t) { \
+ t *s1=(t *)((char *)s+size), *d1=(t *)((char *)d+size); \
+ while (size > 0) { *--d1 = *--s1; size -= sizeof(t); } \
+}
+
+
+#define _MOVE(s, d, size, t) if _FWOVERLAP(s, d, size) _BWMOVE(s, d, size, t) else _FWMOVE(s, d, size, t)
+
+#define _FASTMOVE(s, d, size) \
+ switch (((type_u)s | (type_u)d | size) & (sizeof(type_u)-1)) { \
+ case 0: _MOVE(s, d, size, type_u); break; \
+ case sizeof(type_l): _MOVE(s, d, size, type_l); break; \
+ case sizeof(type_w): _MOVE(s, d, size, type_w); break; \
+ default: _MOVE(s, d, size, type_c); break; \
+ }
+
+static inline void ci_rmove(void *dst, void *src, unsigned long esize,
+ unsigned long count)
+{
+ register uint64_t arg0 asm ("r3");
+ register uint64_t arg1 asm ("r4");
+ register uint64_t arg2 asm ("r5");
+ register uint64_t arg3 asm ("r6");
+ register uint64_t arg4 asm ("r7");
+ register uint64_t arg5 asm ("r8");
+
+ arg0 = 0xf001; /* KVMPPC_H_LOGICAL_MEMOP */
+ arg1 = (uint64_t)dst;
+ arg2 = (uint64_t)src;
+ arg3 = esize;
+ arg4 = count;
+ arg5 = 0; /* 0 = copy */
+
+ asm volatile(".long 0x44000022 \n" /* HVCALL */
+ : "=&r"(arg0),"=&r"(arg1),"=&r"(arg2),
+ "=&r"(arg3),"=&r"(arg4),"=&r"(arg5)
+ : "0"(arg0),"1"(arg1),"2"(arg2),
+ "3"(arg3),"4"(arg4),"5"(arg5)
+ : "r0", "r9", "r10", "r11",
+ "r12", "memory", "cr0", "cr1", "cr5",
+ "cr6", "cr7", "ctr", "xer");
+}
+
+#define _FASTRMOVE(s, d, size) do { \
+ switch (((type_u)s | (type_u)d | size) & (sizeof(type_u)-1)) {\
+ case 0: ci_rmove(d,s,3,size>>3); break; \
+ case sizeof(type_l): ci_rmove(d,s,2,size>>2); break; \
+ case sizeof(type_w): ci_rmove(d,s,1,size>>1); break; \
+ default: ci_rmove(d,s,0,size); break; \
+ } \
+ } while(0)
+
+static inline uint16_t bswap16_load(uint64_t addr)
+{
+ unsigned int val;
+ asm volatile ("lhbrx %0, 0, %1":"=r" (val):"r"(addr));
+ return val;
+}
+
+static inline uint32_t bswap32_load(uint64_t addr)
+{
+ unsigned int val;
+ asm volatile ("lwbrx %0, 0, %1":"=r" (val):"r"(addr));
+ return val;
+}
+
+static inline void bswap16_store(uint64_t addr, uint16_t val)
+{
+ asm volatile ("sthbrx %0, 0, %1"::"r" (val), "r"(addr));
+}
+
+static inline void bswap32_store(uint64_t addr, uint32_t val)
+{
+ asm volatile ("stwbrx %0, 0, %1"::"r" (val), "r"(addr));
+}
+
+#endif /* __CACHE_H */
+
diff --git a/qemu/roms/SLOF/include/ppcp7/cpu.h b/qemu/roms/SLOF/include/ppcp7/cpu.h
new file mode 100644
index 000000000..1b1fadd82
--- /dev/null
+++ b/qemu/roms/SLOF/include/ppcp7/cpu.h
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#ifndef __CPU_H
+#define __CPU_H
+
+/* Used in boot_abort.S, will need something better for KVM */
+#define HSPRG0 304
+
+/* XXX FIXME: Can be more efficient, no dcbst nor loop needed on P7 */
+/* This macro uses r0 */
+#define FLUSH_CACHE(r, n) add n, n, r; \
+ addi n, n, 127; \
+ rlwinm r, r, 0,0,24; \
+ rlwinm n, n, 0,0,24; \
+ sub n, n, r; \
+ srwi n, n, 7; \
+ mtctr n; \
+ 0: dcbst 0, r; \
+ sync; \
+ icbi 0, r; \
+ sync; \
+ isync; \
+ addi r, r, 128; \
+ bdnz 0b;
+
+#ifndef __ASSEMBLER__
+#define STRINGIFY(x...) #x
+#define EXPAND(x) STRINGIFY(x)
+
+static inline void flush_cache(void* r, long n)
+{
+ asm volatile(EXPAND(FLUSH_CACHE(%0, %1))
+ : "+r"(r), "+r"(n)
+ :: "memory", "cc", "r0", "ctr");
+}
+
+static inline void eieio(void)
+{
+ asm volatile ("eieio":::"memory");
+}
+
+static inline void barrier(void)
+{
+ asm volatile("" : : : "memory");
+}
+#define cpu_relax() barrier()
+
+static inline void sync(void)
+{
+ asm volatile ("sync" ::: "memory");
+}
+#define mb() sync()
+
+#endif /* __ASSEMBLER__ */
+
+#endif
diff --git a/qemu/roms/SLOF/include/romfs.h b/qemu/roms/SLOF/include/romfs.h
new file mode 100644
index 000000000..7228502c9
--- /dev/null
+++ b/qemu/roms/SLOF/include/romfs.h
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+#ifndef ROMFS_H
+#define ROMFS_H
+
+#define RFS_T_SIZE 0x00
+#define RFS_T_FLAGS 0x08
+#define RFS_T_FILEADDR 0x10
+#define RFS_T_NEXT 0x18
+#define RFS_T_NAME 0x20
+#define RFS_T_DATA 0x28
+
+#define RFS_H_NEXT 0x00
+#define RFS_H_SIZE 0x08
+#define RFS_H_FLAGS 0x10
+#define RFS_H_DATA 0x18
+#define RFS_H_NAME 0x20
+
+#define ROMFS_HDR_NEXT (0 * 8)
+#define ROMFS_HDR_LEN (1 * 8)
+#define ROMFS_HDR_FLAG (2 * 8)
+#define ROMFS_HDR_DPTR (3 * 8)
+#define ROMFS_HDR_NAME (4 * 8)
+
+#ifndef __ASSEMBLER__
+/* no not change except if you change romfs.S */
+struct romfs_t {
+ unsigned long size;
+ unsigned long flags;
+ unsigned long fileaddr;
+ unsigned long nexfile;
+ unsigned char *namep;
+ unsigned char *datap;
+};
+
+struct romfs_lookup_t {
+ unsigned long addr_header;
+ unsigned long addr_data;
+ unsigned long size_data;
+ unsigned long flags;
+};
+
+int romfs_stat(char *filename, struct romfs_t *hnd);
+
+int romfs_stat_file(char *filename, struct romfs_t *hnd);
+
+int c_romfs_lookup(char *filename, unsigned long rombase,
+ struct romfs_lookup_t *ret);
+
+#endif /* __ASSEMBLER__ */
+#endif /* ROMFS_H */
diff --git a/qemu/roms/SLOF/include/rtas.h b/qemu/roms/SLOF/include/rtas.h
new file mode 100644
index 000000000..e44dedb1e
--- /dev/null
+++ b/qemu/roms/SLOF/include/rtas.h
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#ifndef __RTAS_H
+#define __RTAS_H
+
+#ifndef __ASSEMBLER__
+
+#include <stddef.h>
+
+typedef int rtas_arg_t;
+typedef struct {
+ int token;
+ int nargs;
+ int nret;
+ rtas_arg_t args[16];
+} rtas_args_t;
+
+#else
+
+#define RTAS_STACKSIZE 0x1000
+
+#define RTAS_PARM_0 0x0c
+#define RTAS_PARM_1 0x10
+#define RTAS_PARM_2 0x14
+#define RTAS_PARM_3 0x18
+#define RTAS_PARM_4 0x1C
+#define RTAS_PARM_5 0x20
+#define RTAS_PARM_6 0x24
+#define RTAS_PARM_7 0x28
+
+#endif /* __ASSEMBLER__ */
+#endif /* __RTAS_H */
diff --git a/qemu/roms/SLOF/include/rtas_table.h b/qemu/roms/SLOF/include/rtas_table.h
new file mode 100644
index 000000000..cdf9db7cd
--- /dev/null
+++ b/qemu/roms/SLOF/include/rtas_table.h
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#ifndef __RTAS_TABLE_H
+#define __RTAS_TABLE_H
+
+
+typedef struct {
+ char *name;
+ void (*func)(rtas_args_t *args);
+ unsigned long flags;
+} rtas_funcdescr_t;
+
+
+// Flags for the RTAS table:
+#define RTAS_TBLFLG_INTERNAL 1
+
+
+extern const rtas_funcdescr_t rtas_func_tab[];
+extern const int rtas_func_tab_size;
+
+
+#endif // __RTAS_TABLE_H
diff --git a/qemu/roms/SLOF/include/termctrl.h b/qemu/roms/SLOF/include/termctrl.h
new file mode 100644
index 000000000..502ecae4c
--- /dev/null
+++ b/qemu/roms/SLOF/include/termctrl.h
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+#ifndef TERMCTRL_H
+#define TERMCTRL_H
+
+/* foreground colors */
+#define TERM_FG_BLACK ""
+#define TERM_FG_RED ""
+#define TERM_FG_GREEN ""
+#define TERM_FG_YELLOW ""
+#define TERM_FG_BLUE ""
+#define TERM_FG_MAGENTA ""
+#define TERM_FG_CYAN ""
+#define TERM_FG_WHITE ""
+
+/* background colors */
+#define TERM_BG_BLACK ""
+#define TERM_BG_RED ""
+#define TERM_BG_GREEN ""
+#define TERM_BG_YELLOW ""
+#define TERM_BG_BLUE ""
+#define TERM_BG_MAGENTA ""
+#define TERM_BG_CYAN ""
+#define TERM_BG_WHITE ""
+
+/* control */
+#define TERM_CTRL_RESET ""
+#define TERM_CTRL_BRIGHT ""
+#define TERM_CTRL_DIM ""
+#define TERM_CTRL_UNDERSCORE ""
+#define TERM_CTRL_BLINK ""
+#define TERM_CTRL_REVERSE ""
+#define TERM_CTRL_HIDDEN ""
+#define TERM_CTRL_CLEAR ""
+#define TERM_CTRL_HOME ""
+
+#define TERM_CTRL_1UP ""
+#define TERM_CTRL_1BACK ""
+#define TERM_CTRL_SAVECRS ""
+#define TERM_CTRL_RESTCRS ""
+#define TERM_CTRL_CRSON "[?25h"
+#define TERM_CTRL_CRSOFF "[?25l"
+#define TERM_CTRL_CRSFWDN "[%dC"
+#define TERM_CTRL_CRSX "[%dC"
+#define TERM_CTRL_CRSY "[%dB"
+#define TERM_CTRL_CRSXY "[%d;%dH" /* y,x */
+
+/* keys */
+#define KEY_CTRL 0x1b
+#define KEY_UP 0x41
+#define KEY_DN 0x42
+
+#endif
diff --git a/qemu/roms/SLOF/include/xvect.h b/qemu/roms/SLOF/include/xvect.h
new file mode 100644
index 000000000..5926b1869
--- /dev/null
+++ b/qemu/roms/SLOF/include/xvect.h
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#ifndef __XVECT_H
+#define __XVECT_H
+
+#define XVECT_M_HANDLER 0x2ff0 /* Master Handler */
+#define XVECT_S_HANDLER 0x2ff8 /* Slave Handler */
+#define XVECT_TOPADDR 0x3fff
+#define XVECT_SLP_ENTRY SLAVELOOP_LOADBASE
+
+#endif