diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/calculatecrc.h | 66 | ||||
-rw-r--r-- | include/libelf.h | 18 | ||||
-rw-r--r-- | include/macros.h | 58 | ||||
-rw-r--r-- | include/memmap.h | 26 | ||||
-rw-r--r-- | include/pcd.h | 58 | ||||
-rw-r--r-- | include/ppc970/cache.h | 40 | ||||
-rw-r--r-- | include/ppc970/cpu.h | 103 | ||||
-rw-r--r-- | include/romfs.h | 60 | ||||
-rw-r--r-- | include/rtas.h | 42 | ||||
-rw-r--r-- | include/rtas_table.h | 32 | ||||
-rw-r--r-- | include/termctrl.h | 62 | ||||
-rw-r--r-- | include/types.h | 28 | ||||
-rw-r--r-- | include/xvect.h | 21 |
13 files changed, 614 insertions, 0 deletions
diff --git a/include/calculatecrc.h b/include/calculatecrc.h new file mode 100644 index 0000000..2168478 --- /dev/null +++ b/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/include/libelf.h b/include/libelf.h new file mode 100644 index 0000000..905c76b --- /dev/null +++ b/include/libelf.h @@ -0,0 +1,18 @@ +/****************************************************************************** + * 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 __LIBELF_H +#define __LIBELF_H + +int load_elf_file(unsigned long *, unsigned long *); + +#endif /* __LIBELF_H */ diff --git a/include/macros.h b/include/macros.h new file mode 100644 index 0000000..f519bb8 --- /dev/null +++ b/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/include/memmap.h b/include/memmap.h new file mode 100644 index 0000000..abf3c1f --- /dev/null +++ b/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/include/pcd.h b/include/pcd.h new file mode 100644 index 0000000..9794b76 --- /dev/null +++ b/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/include/ppc970/cache.h b/include/ppc970/cache.h new file mode 100644 index 0000000..284ebde --- /dev/null +++ b/include/ppc970/cache.h @@ -0,0 +1,40 @@ +/****************************************************************************** + * 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) + +#endif diff --git a/include/ppc970/cpu.h b/include/ppc970/cpu.h new file mode 100644 index 0000000..f42fd48 --- /dev/null +++ b/include/ppc970/cpu.h @@ -0,0 +1,103 @@ +/****************************************************************************** + * 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() +{ + unsigned long tmp; + asm volatile(EXPAND(SETCI(%0)) : "=r"(tmp) :: "memory", "cc"); +} + +static inline void +clr_ci() +{ + unsigned long tmp; + asm volatile(EXPAND(CLRCI(%0)) : "=r"(tmp) :: "memory", "cc"); +} + +static inline void +eieio() +{ + asm volatile ("eieio":::"memory"); +} + +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/include/romfs.h b/include/romfs.h new file mode 100644 index 0000000..7228502 --- /dev/null +++ b/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/include/rtas.h b/include/rtas.h new file mode 100644 index 0000000..e44dedb --- /dev/null +++ b/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/include/rtas_table.h b/include/rtas_table.h new file mode 100644 index 0000000..cdf9db7 --- /dev/null +++ b/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/include/termctrl.h b/include/termctrl.h new file mode 100644 index 0000000..502ecae --- /dev/null +++ b/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 "[30m" +#define TERM_FG_RED "[31m" +#define TERM_FG_GREEN "[32m" +#define TERM_FG_YELLOW "[33m" +#define TERM_FG_BLUE "[34m" +#define TERM_FG_MAGENTA "[35m" +#define TERM_FG_CYAN "[36m" +#define TERM_FG_WHITE "[37m" + +/* background colors */ +#define TERM_BG_BLACK "[40m" +#define TERM_BG_RED "[41m" +#define TERM_BG_GREEN "[42m" +#define TERM_BG_YELLOW "[43m" +#define TERM_BG_BLUE "[44m" +#define TERM_BG_MAGENTA "[45m" +#define TERM_BG_CYAN "[46m" +#define TERM_BG_WHITE "[47m" + +/* control */ +#define TERM_CTRL_RESET "[0m" +#define TERM_CTRL_BRIGHT "[1m" +#define TERM_CTRL_DIM "[2m" +#define TERM_CTRL_UNDERSCORE "[3m" +#define TERM_CTRL_BLINK "[4m" +#define TERM_CTRL_REVERSE "[5m" +#define TERM_CTRL_HIDDEN "[6m" +#define TERM_CTRL_CLEAR "[2J" +#define TERM_CTRL_HOME "[H" + +#define TERM_CTRL_1UP "[1A" +#define TERM_CTRL_1BACK "[1D" +#define TERM_CTRL_SAVECRS "[s" +#define TERM_CTRL_RESTCRS "[u" +#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/include/types.h b/include/types.h new file mode 100644 index 0000000..cbadd7c --- /dev/null +++ b/include/types.h @@ -0,0 +1,28 @@ +/****************************************************************************** + * 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 _TYPES_H +#define _TYPES_H + +#warning "This file is obsolete. Please use #include <stdint.h> instead." + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef signed long long int64_t; + +#endif diff --git a/include/xvect.h b/include/xvect.h new file mode 100644 index 0000000..5926b18 --- /dev/null +++ b/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 |