2003-02-07 09:41:57 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Alan Korr
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __SYSTEM_H__
|
|
|
|
#define __SYSTEM_H__
|
|
|
|
|
2004-10-06 13:49:48 +00:00
|
|
|
#include "cpu.h"
|
2005-03-01 14:35:10 +00:00
|
|
|
#include "stdbool.h"
|
2003-02-07 09:41:57 +00:00
|
|
|
|
2004-02-25 13:00:36 +00:00
|
|
|
extern void system_reboot (void);
|
|
|
|
extern void system_init(void);
|
|
|
|
|
2005-03-01 14:35:10 +00:00
|
|
|
extern long cpu_frequency;
|
|
|
|
|
2006-08-03 09:41:09 +00:00
|
|
|
#ifdef CPU_PP
|
2005-11-07 23:07:19 +00:00
|
|
|
#define inl(a) (*(volatile unsigned long *) (a))
|
|
|
|
#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
|
|
|
|
#define inb(a) (*(volatile unsigned char *) (a))
|
|
|
|
#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
|
2005-12-18 13:04:00 +00:00
|
|
|
#define inw(a) (*(volatile unsigned short *) (a))
|
|
|
|
#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
|
2006-01-31 01:50:07 +00:00
|
|
|
extern unsigned int ipod_hw_rev;
|
|
|
|
|
2005-12-17 19:11:43 +00:00
|
|
|
static inline void udelay(unsigned usecs)
|
|
|
|
{
|
2006-02-05 16:52:22 +00:00
|
|
|
unsigned start = USEC_TIMER;
|
|
|
|
while ((USEC_TIMER - start) < usecs);
|
2005-12-17 19:11:43 +00:00
|
|
|
}
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
|
|
unsigned int current_core(void);
|
2005-11-07 23:07:19 +00:00
|
|
|
#endif
|
|
|
|
|
2006-08-05 20:19:10 +00:00
|
|
|
struct flash_header {
|
|
|
|
unsigned long magic;
|
|
|
|
unsigned long length;
|
|
|
|
char version[32];
|
|
|
|
};
|
|
|
|
|
|
|
|
bool detect_flashed_rockbox(void);
|
|
|
|
|
2005-03-01 14:35:10 +00:00
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
#define FREQ cpu_frequency
|
2005-03-03 16:29:02 +00:00
|
|
|
void set_cpu_frequency(long frequency);
|
|
|
|
void cpu_boost(bool on_off);
|
2005-07-05 07:58:19 +00:00
|
|
|
void cpu_idle_mode(bool on_off);
|
2006-10-05 10:07:03 +00:00
|
|
|
int get_cpu_boost_counter(void);
|
|
|
|
|
|
|
|
#if MEM > 1
|
|
|
|
#define CPU_BOOST_TRACKING
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CPU_BOOST_TRACKING
|
|
|
|
void cpu_boost_id(bool on_off, char id);
|
|
|
|
const char *get_cpu_boost_tracker(void);
|
|
|
|
/* CPU boost ID chars, in alphabetical order */
|
|
|
|
#define CPUBOOSTID_PLAYBACK_AUDIO 'A'
|
|
|
|
#define CPUBOOSTID_TAGTREE 'a'
|
|
|
|
#define CPUBOOSTID_BACKLIGHT 'b'
|
|
|
|
#define CPUBOOSTID_PLAYBACK_CODEC 'c'
|
|
|
|
#define CPUBOOSTID_DIRCACHE 'd'
|
|
|
|
#define CPUBOOSTID_MAININIT 'i'
|
|
|
|
#define CPUBOOSTID_DEBUGMENU_MANUAL 'm'
|
|
|
|
#define CPUBOOSTID_PLAYLIST 'P'
|
2006-10-05 10:19:13 +00:00
|
|
|
#define CPUBOOSTID_PCMBUF 'p'
|
2006-10-05 10:07:03 +00:00
|
|
|
#define CPUBOOSTID_PCMRECORD 'R'
|
|
|
|
#define CPUBOOSTID_TREE 'r'
|
|
|
|
#define CPUBOOSTID_TALK 'T'
|
|
|
|
#define CPUBOOSTID_TAGCACHE 't'
|
|
|
|
#define CPUBOOSTID_PLAYBACK_VOICE 'v'
|
|
|
|
#else
|
|
|
|
#define cpu_boost_id(on_off,id) cpu_boost(on_off)
|
|
|
|
#endif
|
2005-03-01 14:35:10 +00:00
|
|
|
#else
|
2003-02-07 09:41:57 +00:00
|
|
|
#define FREQ CPU_FREQ
|
2005-09-12 10:34:27 +00:00
|
|
|
#define set_cpu_frequency(frequency)
|
2005-06-20 19:10:47 +00:00
|
|
|
#define cpu_boost(on_off)
|
2006-10-05 10:07:03 +00:00
|
|
|
#define cpu_boost_id(on_off, id)
|
2005-07-05 07:58:19 +00:00
|
|
|
#define cpu_idle_mode(on_off)
|
2006-10-05 10:07:03 +00:00
|
|
|
#define get_cpu_boost_counter()
|
|
|
|
#define get_cpu_boost_tracker()
|
2005-03-01 14:35:10 +00:00
|
|
|
#endif
|
2005-03-03 16:29:02 +00:00
|
|
|
|
2003-02-07 09:41:57 +00:00
|
|
|
#define BAUDRATE 9600
|
|
|
|
|
|
|
|
#ifndef NULL
|
|
|
|
#define NULL ((void*)0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a, b) (((a)<(b))?(a):(b))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MAX
|
|
|
|
#define MAX(a, b) (((a)>(b))?(a):(b))
|
|
|
|
#endif
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
/* return number of elements in array a */
|
|
|
|
#define ARRAYLEN(a) (sizeof(a)/sizeof((a)[0]))
|
|
|
|
|
|
|
|
/* return p incremented by specified number of bytes */
|
|
|
|
#define SKIPBYTES(p, count) ((typeof (p))((char *)(p) + (count)))
|
|
|
|
|
|
|
|
#define P2_M1(p2) ((1 << (p2))-1)
|
|
|
|
|
|
|
|
/* align up or down to nearest 2^p2 */
|
|
|
|
#define ALIGN_DOWN_P2(n, p2) ((n) & ~P2_M1(p2))
|
|
|
|
#define ALIGN_UP_P2(n, p2) ALIGN_DOWN_P2((n) + P2_M1(p2),p2)
|
|
|
|
|
|
|
|
/* align up or down to nearest integer multiple of a */
|
|
|
|
#define ALIGN_DOWN(n, a) ((n)/(a)*(a))
|
|
|
|
#define ALIGN_UP(n, a) ALIGN_DOWN((n)+((a)-1),a)
|
|
|
|
|
|
|
|
/* live endianness conversion */
|
2005-05-07 22:41:17 +00:00
|
|
|
#ifdef ROCKBOX_LITTLE_ENDIAN
|
2005-10-06 19:27:43 +00:00
|
|
|
#define letoh16(x) (x)
|
|
|
|
#define letoh32(x) (x)
|
|
|
|
#define htole16(x) (x)
|
|
|
|
#define htole32(x) (x)
|
|
|
|
#define betoh16(x) swap16(x)
|
|
|
|
#define betoh32(x) swap32(x)
|
|
|
|
#define htobe16(x) swap16(x)
|
|
|
|
#define htobe32(x) swap32(x)
|
2006-11-06 18:07:30 +00:00
|
|
|
#define swap_odd_even_be32(x) (x)
|
|
|
|
#define swap_odd_even_le32(x) swap_odd_even32(x)
|
2006-08-21 17:35:35 +00:00
|
|
|
#else
|
2005-10-06 19:27:43 +00:00
|
|
|
#define letoh16(x) swap16(x)
|
|
|
|
#define letoh32(x) swap32(x)
|
|
|
|
#define htole16(x) swap16(x)
|
|
|
|
#define htole32(x) swap32(x)
|
|
|
|
#define betoh16(x) (x)
|
|
|
|
#define betoh32(x) (x)
|
|
|
|
#define htobe16(x) (x)
|
|
|
|
#define htobe32(x) (x)
|
2006-11-06 18:07:30 +00:00
|
|
|
#define swap_odd_even_be32(x) swap_odd_even32(x)
|
|
|
|
#define swap_odd_even_le32(x) (x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* static endianness conversion */
|
|
|
|
#define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
|
|
|
|
((unsigned short)(x) << 8)))
|
|
|
|
|
|
|
|
#define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
|
|
|
|
(((unsigned long)(x) & 0xff0000ul) >> 8) | \
|
|
|
|
(((unsigned long)(x) & 0xff00ul) << 8) | \
|
|
|
|
((unsigned long)(x) << 24)))
|
|
|
|
|
|
|
|
#ifdef ROCKBOX_LITTLE_ENDIAN
|
|
|
|
#define LE_TO_H16(x) (x)
|
|
|
|
#define LE_TO_H32(x) (x)
|
|
|
|
#define H_TO_LE16(x) (x)
|
|
|
|
#define H_TO_LE32(x) (x)
|
|
|
|
#define BE_TO_H16(x) SWAP_16(x)
|
|
|
|
#define BE_TO_H32(x) SWAP_32(x)
|
|
|
|
#define H_TO_BE16(x) SWAP_16(x)
|
|
|
|
#define H_TO_BE32(x) SWAP_32(x)
|
|
|
|
#else
|
|
|
|
#define LE_TO_H16(x) SWAP_16(x)
|
|
|
|
#define LE_TO_H32(x) SWAP_32(x)
|
|
|
|
#define H_TO_LE16(x) SWAP_16(x)
|
|
|
|
#define H_TO_LE32(x) SWAP_32(x)
|
|
|
|
#define BE_TO_H16(x) (x)
|
|
|
|
#define BE_TO_H32(x) (x)
|
|
|
|
#define H_TO_BE16(x) (x)
|
|
|
|
#define H_TO_BE32(x) (x)
|
2003-02-07 09:41:57 +00:00
|
|
|
#endif
|
|
|
|
|
2005-10-06 19:27:43 +00:00
|
|
|
|
2003-02-07 09:41:57 +00:00
|
|
|
#define nop \
|
|
|
|
asm volatile ("nop")
|
|
|
|
|
2004-07-24 11:39:17 +00:00
|
|
|
/* gcc 3.4 changed the format of the constraints */
|
2005-04-22 19:34:01 +00:00
|
|
|
#if (__GNUC__ >= 3) && (__GNUC_MINOR__ > 3) || (__GNUC__ >= 4)
|
2004-07-24 11:39:17 +00:00
|
|
|
#define I_CONSTRAINT "I08"
|
|
|
|
#else
|
|
|
|
#define I_CONSTRAINT "I"
|
|
|
|
#endif
|
|
|
|
|
2005-02-02 21:45:56 +00:00
|
|
|
/* Utilize the user break controller to catch invalid memory accesses. */
|
|
|
|
int system_memory_guard(int newmode);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MEMGUARD_KEEP = -1, /* don't change the mode; for reading */
|
|
|
|
MEMGUARD_NONE = 0, /* catch nothing */
|
|
|
|
MEMGUARD_FLASH_WRITES, /* catch writes to area 02 (flash ROM) */
|
|
|
|
MEMGUARD_ZERO_AREA, /* catch all accesses to areas 00 and 01 */
|
|
|
|
MAXMEMGUARD
|
|
|
|
};
|
|
|
|
|
2006-10-30 14:17:14 +00:00
|
|
|
#ifndef SIMULATOR
|
|
|
|
#ifdef CPU_COLDFIRE
|
|
|
|
#include "system-target.h"
|
|
|
|
#endif
|
|
|
|
#endif
|
2005-02-02 21:45:56 +00:00
|
|
|
|
2004-10-15 11:32:58 +00:00
|
|
|
#if CONFIG_CPU == SH7034
|
2003-11-07 12:15:24 +00:00
|
|
|
#define or_b(mask, address) \
|
2005-07-02 12:18:10 +00:00
|
|
|
asm \
|
|
|
|
("or.b %0,@(r0,gbr)" \
|
|
|
|
: \
|
2004-07-24 11:39:17 +00:00
|
|
|
: /* %0 */ I_CONSTRAINT((char)(mask)), \
|
2003-02-07 09:41:57 +00:00
|
|
|
/* %1 */ "z"(address-GBR))
|
|
|
|
|
2003-11-07 12:15:24 +00:00
|
|
|
#define and_b(mask, address) \
|
2003-02-07 09:41:57 +00:00
|
|
|
asm \
|
2005-07-02 12:18:10 +00:00
|
|
|
("and.b %0,@(r0,gbr)" \
|
2003-02-07 09:41:57 +00:00
|
|
|
: \
|
2005-07-02 12:18:10 +00:00
|
|
|
: /* %0 */ I_CONSTRAINT((char)(mask)), \
|
2003-02-07 09:41:57 +00:00
|
|
|
/* %1 */ "z"(address-GBR))
|
|
|
|
|
2003-11-07 12:15:24 +00:00
|
|
|
#define xor_b(mask, address) \
|
2003-02-07 09:41:57 +00:00
|
|
|
asm \
|
2005-07-02 12:18:10 +00:00
|
|
|
("xor.b %0,@(r0,gbr)" \
|
2003-02-07 09:41:57 +00:00
|
|
|
: \
|
2005-07-02 12:18:10 +00:00
|
|
|
: /* %0 */ I_CONSTRAINT((char)(mask)), \
|
2003-02-07 09:41:57 +00:00
|
|
|
/* %1 */ "z"(address-GBR))
|
2005-07-02 12:18:10 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
|
2006-10-30 14:17:14 +00:00
|
|
|
#endif /* CONFIG_CPU == SH7034 */
|
2003-02-07 09:41:57 +00:00
|
|
|
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
2004-03-02 11:32:59 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* Interrupt level setting
|
|
|
|
* The level is left shifted 4 bits
|
|
|
|
****************************************************************************/
|
2004-10-15 11:32:58 +00:00
|
|
|
#if CONFIG_CPU == SH7034
|
2004-03-02 11:32:59 +00:00
|
|
|
#define HIGHEST_IRQ_LEVEL (15<<4)
|
|
|
|
static inline int set_irq_level(int level)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
/* Read the old level and set the new one */
|
|
|
|
asm volatile ("stc sr, %0" : "=r" (i));
|
|
|
|
asm volatile ("ldc %0, sr" : : "r" (level));
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2005-10-06 19:27:43 +00:00
|
|
|
static inline unsigned short swap16(unsigned short value)
|
2003-02-07 09:41:57 +00:00
|
|
|
/*
|
|
|
|
result[15..8] = value[ 7..0];
|
|
|
|
result[ 7..0] = value[15..8];
|
2005-01-10 22:02:26 +00:00
|
|
|
*/
|
2003-02-07 09:41:57 +00:00
|
|
|
{
|
2005-08-01 01:27:10 +00:00
|
|
|
unsigned short result;
|
2003-02-07 09:41:57 +00:00
|
|
|
asm volatile ("swap.b\t%1,%0" : "=r"(result) : "r"(value));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-10-06 23:16:38 +00:00
|
|
|
static inline unsigned long SWAW32(unsigned long value)
|
2003-02-07 09:41:57 +00:00
|
|
|
/*
|
|
|
|
result[31..16] = value[15.. 0];
|
|
|
|
result[15.. 0] = value[31..16];
|
2005-01-10 22:02:26 +00:00
|
|
|
*/
|
2003-02-07 09:41:57 +00:00
|
|
|
{
|
2005-08-01 01:27:10 +00:00
|
|
|
unsigned long result;
|
2003-02-07 09:41:57 +00:00
|
|
|
asm volatile ("swap.w\t%1,%0" : "=r"(result) : "r"(value));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-10-06 19:27:43 +00:00
|
|
|
static inline unsigned long swap32(unsigned long value)
|
2003-02-07 09:41:57 +00:00
|
|
|
/*
|
|
|
|
result[31..24] = value[ 7.. 0];
|
|
|
|
result[23..16] = value[15.. 8];
|
|
|
|
result[15.. 8] = value[23..16];
|
|
|
|
result[ 7.. 0] = value[31..24];
|
2005-01-10 22:02:26 +00:00
|
|
|
*/
|
2003-02-07 09:41:57 +00:00
|
|
|
{
|
|
|
|
asm volatile ("swap.b\t%0,%0\n"
|
|
|
|
"swap.w\t%0,%0\n"
|
|
|
|
"swap.b\t%0,%0\n" : "+r"(value));
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2005-02-09 14:18:46 +00:00
|
|
|
#define invalidate_icache()
|
|
|
|
|
2006-01-12 00:35:50 +00:00
|
|
|
#elif defined(CPU_ARM)
|
2005-11-07 23:07:19 +00:00
|
|
|
|
2005-11-11 17:51:35 +00:00
|
|
|
/* TODO: Implement set_irq_level and check CPU frequencies */
|
2005-11-07 23:07:19 +00:00
|
|
|
|
2006-03-17 02:02:13 +00:00
|
|
|
#define CPUFREQ_DEFAULT_MULT 8
|
2006-03-17 02:45:06 +00:00
|
|
|
#define CPUFREQ_DEFAULT 24000000
|
2006-08-21 17:35:35 +00:00
|
|
|
#define CPUFREQ_NORMAL_MULT 10
|
2006-03-17 02:02:13 +00:00
|
|
|
#define CPUFREQ_NORMAL 30000000
|
|
|
|
#define CPUFREQ_MAX_MULT 25
|
2005-11-07 23:07:19 +00:00
|
|
|
#define CPUFREQ_MAX 75000000
|
|
|
|
|
|
|
|
static inline unsigned short swap16(unsigned short value)
|
|
|
|
/*
|
|
|
|
result[15..8] = value[ 7..0];
|
|
|
|
result[ 7..0] = value[15..8];
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
return (value >> 8) | (value << 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long swap32(unsigned long value)
|
|
|
|
/*
|
|
|
|
result[31..24] = value[ 7.. 0];
|
|
|
|
result[23..16] = value[15.. 8];
|
|
|
|
result[15.. 8] = value[23..16];
|
|
|
|
result[ 7.. 0] = value[31..24];
|
|
|
|
*/
|
2006-08-21 17:35:35 +00:00
|
|
|
{
|
2006-03-17 02:45:06 +00:00
|
|
|
unsigned int tmp;
|
|
|
|
|
|
|
|
asm volatile (
|
|
|
|
"eor %1, %0, %0, ror #16 \n\t"
|
|
|
|
"bic %1, %1, #0xff0000 \n\t"
|
|
|
|
"mov %0, %0, ror #8 \n\t"
|
|
|
|
"eor %0, %0, %1, lsr #8 \n\t"
|
|
|
|
: "+r" (value), "=r" (tmp)
|
|
|
|
);
|
|
|
|
return value;
|
2005-11-07 23:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define HIGHEST_IRQ_LEVEL (1)
|
2006-01-12 00:35:50 +00:00
|
|
|
|
2005-11-07 23:07:19 +00:00
|
|
|
static inline int set_irq_level(int level)
|
|
|
|
{
|
2006-01-12 00:35:50 +00:00
|
|
|
unsigned long cpsr;
|
|
|
|
/* Read the old level and set the new one */
|
|
|
|
asm volatile ("mrs %0,cpsr" : "=r" (cpsr));
|
|
|
|
asm volatile ("msr cpsr_c,%0"
|
|
|
|
: : "r" ((cpsr & ~0x80) | (level << 7)));
|
|
|
|
return (cpsr >> 7) & 1;
|
2005-11-07 23:07:19 +00:00
|
|
|
}
|
|
|
|
|
2006-01-28 20:33:57 +00:00
|
|
|
static inline void enable_fiq(void)
|
|
|
|
{
|
2006-02-07 20:49:13 +00:00
|
|
|
/* Clear FIQ disable bit */
|
2006-01-28 20:33:57 +00:00
|
|
|
asm volatile (
|
|
|
|
"mrs r0, cpsr \n"\
|
|
|
|
"bic r0, r0, #0x40 \n"\
|
|
|
|
"msr cpsr_c, r0 "
|
|
|
|
: : : "r0"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2006-02-07 20:49:13 +00:00
|
|
|
static inline void disable_fiq(void)
|
|
|
|
{
|
|
|
|
/* Set FIQ disable bit */
|
|
|
|
asm volatile (
|
|
|
|
"mrs r0, cpsr \n"\
|
|
|
|
"orr r0, r0, #0x40 \n"\
|
|
|
|
"msr cpsr_c, r0 "
|
|
|
|
: : : "r0"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2005-11-12 15:26:51 +00:00
|
|
|
#define invalidate_icache()
|
|
|
|
|
2006-01-12 00:35:50 +00:00
|
|
|
#if CONFIG_CPU == PNX0101
|
|
|
|
typedef void (*interrupt_handler_t)(void);
|
|
|
|
|
|
|
|
void irq_set_int_handler(int n, interrupt_handler_t handler);
|
|
|
|
void irq_enable_int(int n);
|
|
|
|
#endif
|
|
|
|
|
2004-10-15 11:32:58 +00:00
|
|
|
#endif
|
2006-11-06 18:07:30 +00:00
|
|
|
|
|
|
|
#ifndef CPU_COLDFIRE
|
|
|
|
static inline unsigned long swap_odd_even32(unsigned long value)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
|
|
|
|
result[23..16],[ 7.. 0] = value[31..24],[15.. 8]
|
|
|
|
*/
|
|
|
|
unsigned long t = value & 0xff00ff00;
|
|
|
|
return (t >> 8) | ((t ^ value) << 8);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else /* SIMULATOR */
|
2005-02-09 14:23:35 +00:00
|
|
|
|
2005-10-06 19:27:43 +00:00
|
|
|
static inline unsigned short swap16(unsigned short value)
|
|
|
|
/*
|
|
|
|
result[15..8] = value[ 7..0];
|
|
|
|
result[ 7..0] = value[15..8];
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
return (value >> 8) | (value << 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long swap32(unsigned long value)
|
|
|
|
/*
|
|
|
|
result[31..24] = value[ 7.. 0];
|
|
|
|
result[23..16] = value[15.. 8];
|
|
|
|
result[15.. 8] = value[23..16];
|
|
|
|
result[ 7.. 0] = value[31..24];
|
|
|
|
*/
|
|
|
|
{
|
2006-03-17 02:45:06 +00:00
|
|
|
unsigned long hi = swap16(value >> 16);
|
|
|
|
unsigned long lo = swap16(value & 0xffff);
|
|
|
|
return (lo << 16) | hi;
|
2005-10-06 19:27:43 +00:00
|
|
|
}
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
static inline unsigned long swap_odd_even32(unsigned long value)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
|
|
|
|
result[23..16],[ 7.. 0] = value[31..24],[15.. 8]
|
|
|
|
*/
|
|
|
|
unsigned long t = value & 0xff00ff00;
|
|
|
|
return (t >> 8) | ((t ^ value) << 8);
|
|
|
|
}
|
|
|
|
|
2005-02-09 14:23:35 +00:00
|
|
|
#define invalidate_icache()
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif /* !SIMULATOR */
|
2003-02-07 09:41:57 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif /* __SYSTEM_H__ */
|