summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-04-14 01:18:06 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-04-14 01:18:06 +0000
commit20c6bf50fe89c94e57ba7920d667ad28541c3ce1 (patch)
tree9588e3ba1703323744dd5681941f4feb8a5778ee /firmware/target
parentca6f4abcf17a84d52646a8a6b305ab1011efe6d0 (diff)
downloadrockbox-20c6bf50fe89c94e57ba7920d667ad28541c3ce1.tar.gz
rockbox-20c6bf50fe89c94e57ba7920d667ad28541c3ce1.zip
Do the target shuffle again a better way by including from higher levels
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13151 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/gigabeat/meg-fx/system-target.h (renamed from firmware/target/arm/gigabeat/meg-fx/system-meg-fx.h)8
-rw-r--r--firmware/target/arm/iriver/ifp7xx/system-target.h34
-rw-r--r--firmware/target/arm/system-arm.h130
-rw-r--r--firmware/target/arm/system-pp.h53
-rw-r--r--firmware/target/arm/system-target.h142
5 files changed, 195 insertions, 172 deletions
diff --git a/firmware/target/arm/gigabeat/meg-fx/system-meg-fx.h b/firmware/target/arm/gigabeat/meg-fx/system-target.h
index 7d598af360..215b5a4daa 100644
--- a/firmware/target/arm/gigabeat/meg-fx/system-meg-fx.h
+++ b/firmware/target/arm/gigabeat/meg-fx/system-target.h
@@ -16,8 +16,15 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19#ifndef SYSTEM_TARGET_H
20#define SYSTEM_TARGET_H
19 21
20#include "mmu-meg-fx.h" 22#include "mmu-meg-fx.h"
23#include "system-arm.h"
24
25#define CPUFREQ_DEFAULT 98784000
26#define CPUFREQ_NORMAL 98784000
27#define CPUFREQ_MAX 296352000
21 28
22#define HAVE_INVALIDATE_ICACHE 29#define HAVE_INVALIDATE_ICACHE
23static inline void invalidate_icache(void) 30static inline void invalidate_icache(void)
@@ -30,3 +37,4 @@ static inline void invalidate_icache(void)
30 ); 37 );
31} 38}
32 39
40#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/iriver/ifp7xx/system-target.h b/firmware/target/arm/iriver/ifp7xx/system-target.h
new file mode 100644
index 0000000000..dc11bb74da
--- /dev/null
+++ b/firmware/target/arm/iriver/ifp7xx/system-target.h
@@ -0,0 +1,34 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Alan Korr
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef SYSTEM_TARGET_H
20#define SYSTEM_TARGET_H
21
22#include "system-arm.h"
23
24#define CPUFREQ_DEFAULT 12000000
25#define CPUFREQ_NORMAL 48000000
26#define CPUFREQ_MAX 60000000
27
28typedef void (*interrupt_handler_t)(void);
29
30void irq_set_int_handler(int n, interrupt_handler_t handler);
31void irq_enable_int(int n);
32void irq_disable_int(int n);
33
34#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/system-arm.h b/firmware/target/arm/system-arm.h
new file mode 100644
index 0000000000..7126350a64
--- /dev/null
+++ b/firmware/target/arm/system-arm.h
@@ -0,0 +1,130 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Alan Korr
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef SYSTEM_ARM_H
20#define SYSTEM_ARM_H
21
22#define nop \
23 asm volatile ("nop")
24
25/* This gets too complicated otherwise with all the ARM variation and would
26 have conflicts with another system-target.h elsewhere so include a
27 subheader from here. */
28
29/* TODO: Implement set_irq_level and check CPU frequencies */
30
31#if CONFIG_CPU != S3C2440 && CONFIG_CPU != PNX0101
32
33/* TODO: Finish targeting this stuff */
34#define CPUFREQ_DEFAULT_MULT 8
35#define CPUFREQ_DEFAULT 24000000
36#define CPUFREQ_NORMAL_MULT 10
37#define CPUFREQ_NORMAL 30000000
38#define CPUFREQ_MAX_MULT 25
39#define CPUFREQ_MAX 75000000
40
41#endif
42
43static inline uint16_t swap16(uint16_t value)
44 /*
45 result[15..8] = value[ 7..0];
46 result[ 7..0] = value[15..8];
47 */
48{
49 return (value >> 8) | (value << 8);
50}
51
52static inline uint32_t swap32(uint32_t value)
53 /*
54 result[31..24] = value[ 7.. 0];
55 result[23..16] = value[15.. 8];
56 result[15.. 8] = value[23..16];
57 result[ 7.. 0] = value[31..24];
58 */
59{
60 uint32_t tmp;
61
62 asm volatile (
63 "eor %1, %0, %0, ror #16 \n\t"
64 "bic %1, %1, #0xff0000 \n\t"
65 "mov %0, %0, ror #8 \n\t"
66 "eor %0, %0, %1, lsr #8 \n\t"
67 : "+r" (value), "=r" (tmp)
68 );
69 return value;
70}
71
72static inline uint32_t swap_odd_even32(uint32_t value)
73{
74 /*
75 result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
76 result[23..16],[ 7.. 0] = value[31..24],[15.. 8]
77 */
78 uint32_t tmp;
79
80 asm volatile ( /* ABCD */
81 "bic %1, %0, #0x00ff00 \n\t" /* AB.D */
82 "bic %0, %0, #0xff0000 \n\t" /* A.CD */
83 "mov %0, %0, lsr #8 \n\t" /* .A.C */
84 "orr %0, %0, %1, lsl #8 \n\t" /* B.D.|.A.C */
85 : "+r" (value), "=r" (tmp) /* BADC */
86 );
87 return value;
88}
89
90#define HIGHEST_IRQ_LEVEL (1)
91
92static inline int set_irq_level(int level)
93{
94 unsigned long cpsr;
95 /* Read the old level and set the new one */
96 asm volatile ("mrs %0,cpsr" : "=r" (cpsr));
97 asm volatile ("msr cpsr_c,%0"
98 : : "r" ((cpsr & ~0x80) | (level << 7)));
99 return (cpsr >> 7) & 1;
100}
101
102static inline void set_fiq_handler(void(*fiq_handler)(void))
103{
104 /* Install the FIQ handler */
105 *((unsigned int*)(15*4)) = (unsigned int)fiq_handler;
106}
107
108static inline void enable_fiq(void)
109{
110 /* Clear FIQ disable bit */
111 asm volatile (
112 "mrs r0, cpsr \n"\
113 "bic r0, r0, #0x40 \n"\
114 "msr cpsr_c, r0 "
115 : : : "r0"
116 );
117}
118
119static inline void disable_fiq(void)
120{
121 /* Set FIQ disable bit */
122 asm volatile (
123 "mrs r0, cpsr \n"\
124 "orr r0, r0, #0x40 \n"\
125 "msr cpsr_c, r0 "
126 : : : "r0"
127 );
128}
129
130#endif /* SYSTEM_ARM_H */
diff --git a/firmware/target/arm/system-pp.h b/firmware/target/arm/system-pp.h
deleted file mode 100644
index 47ef48218c..0000000000
--- a/firmware/target/arm/system-pp.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Alan Korr
11 * Copyright (C) 2007 by Michael Sevakis
12 *
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#define inl(a) (*(volatile unsigned long *) (a))
22#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
23#define inb(a) (*(volatile unsigned char *) (a))
24#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
25#define inw(a) (*(volatile unsigned short *) (a))
26#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
27extern unsigned int ipod_hw_rev;
28
29static inline void udelay(unsigned usecs)
30{
31 unsigned stop = USEC_TIMER + usecs;
32 while (TIME_BEFORE(USEC_TIMER, stop));
33}
34
35unsigned int current_core(void);
36
37#if CONFIG_CPU != PP5002
38
39#define HAVE_INVALIDATE_ICACHE
40static inline void invalidate_icache(void)
41{
42 outl(inl(0xf000f044) | 0x6, 0xf000f044);
43 while ((CACHE_CTL & 0x8000) != 0);
44}
45
46#define HAVE_FLUSH_ICACHE
47static inline void flush_icache(void)
48{
49 outl(inl(0xf000f044) | 0x2, 0xf000f044);
50 while ((CACHE_CTL & 0x8000) != 0);
51}
52
53#endif /* CONFIG_CPU */
diff --git a/firmware/target/arm/system-target.h b/firmware/target/arm/system-target.h
index ceb8be2079..2b72e9293e 100644
--- a/firmware/target/arm/system-target.h
+++ b/firmware/target/arm/system-target.h
@@ -8,6 +8,7 @@
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2002 by Alan Korr 10 * Copyright (C) 2002 by Alan Korr
11 * Copyright (C) 2007 by Michael Sevakis
11 * 12 *
12 * All files in this archive are subject to the GNU General Public License. 13 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement. 14 * See the file COPYING in the source tree root for full license agreement.
@@ -19,137 +20,40 @@
19#ifndef SYSTEM_TARGET_H 20#ifndef SYSTEM_TARGET_H
20#define SYSTEM_TARGET_H 21#define SYSTEM_TARGET_H
21 22
22#define nop \ 23#include "system-arm.h"
23 asm volatile ("nop")
24 24
25/* This gets too complicated otherwise with all the ARM variation and would 25#define inl(a) (*(volatile unsigned long *) (a))
26 have conflicts with another system-target.h elsewhere so include a 26#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
27 subheader from here. */ 27#define inb(a) (*(volatile unsigned char *) (a))
28#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
29#define inw(a) (*(volatile unsigned short *) (a))
30#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
31extern unsigned int ipod_hw_rev;
28 32
29#ifdef CPU_PP 33static inline void udelay(unsigned usecs)
30#include "system-pp.h"
31#elif CONFIG_CPU == S3C2440
32#include "system-meg-fx.h"
33#endif
34
35/* TODO: Implement set_irq_level and check CPU frequencies */
36
37#if CONFIG_CPU == S3C2440
38
39#define CPUFREQ_DEFAULT 98784000
40#define CPUFREQ_NORMAL 98784000
41#define CPUFREQ_MAX 296352000
42
43#elif CONFIG_CPU == PNX0101
44
45#define CPUFREQ_DEFAULT 12000000
46#define CPUFREQ_NORMAL 48000000
47#define CPUFREQ_MAX 60000000
48
49#else
50
51#define CPUFREQ_DEFAULT_MULT 8
52#define CPUFREQ_DEFAULT 24000000
53#define CPUFREQ_NORMAL_MULT 10
54#define CPUFREQ_NORMAL 30000000
55#define CPUFREQ_MAX_MULT 25
56#define CPUFREQ_MAX 75000000
57
58#endif
59
60static inline uint16_t swap16(uint16_t value)
61 /*
62 result[15..8] = value[ 7..0];
63 result[ 7..0] = value[15..8];
64 */
65{ 34{
66 return (value >> 8) | (value << 8); 35 unsigned stop = USEC_TIMER + usecs;
36 while (TIME_BEFORE(USEC_TIMER, stop));
67} 37}
68 38
69static inline uint32_t swap32(uint32_t value) 39unsigned int current_core(void);
70 /*
71 result[31..24] = value[ 7.. 0];
72 result[23..16] = value[15.. 8];
73 result[15.. 8] = value[23..16];
74 result[ 7.. 0] = value[31..24];
75 */
76{
77 uint32_t tmp;
78 40
79 asm volatile ( 41#if CONFIG_CPU != PP5002
80 "eor %1, %0, %0, ror #16 \n\t"
81 "bic %1, %1, #0xff0000 \n\t"
82 "mov %0, %0, ror #8 \n\t"
83 "eor %0, %0, %1, lsr #8 \n\t"
84 : "+r" (value), "=r" (tmp)
85 );
86 return value;
87}
88 42
89static inline uint32_t swap_odd_even32(uint32_t value) 43#define HAVE_INVALIDATE_ICACHE
44static inline void invalidate_icache(void)
90{ 45{
91 /* 46 outl(inl(0xf000f044) | 0x6, 0xf000f044);
92 result[31..24],[15.. 8] = value[23..16],[ 7.. 0] 47 while ((CACHE_CTL & 0x8000) != 0);
93 result[23..16],[ 7.. 0] = value[31..24],[15.. 8]
94 */
95 uint32_t tmp;
96
97 asm volatile ( /* ABCD */
98 "bic %1, %0, #0x00ff00 \n\t" /* AB.D */
99 "bic %0, %0, #0xff0000 \n\t" /* A.CD */
100 "mov %0, %0, lsr #8 \n\t" /* .A.C */
101 "orr %0, %0, %1, lsl #8 \n\t" /* B.D.|.A.C */
102 : "+r" (value), "=r" (tmp) /* BADC */
103 );
104 return value;
105} 48}
106 49
107#define HIGHEST_IRQ_LEVEL (1) 50#define HAVE_FLUSH_ICACHE
108 51static inline void flush_icache(void)
109static inline int set_irq_level(int level)
110{
111 unsigned long cpsr;
112 /* Read the old level and set the new one */
113 asm volatile ("mrs %0,cpsr" : "=r" (cpsr));
114 asm volatile ("msr cpsr_c,%0"
115 : : "r" ((cpsr & ~0x80) | (level << 7)));
116 return (cpsr >> 7) & 1;
117}
118
119static inline void set_fiq_handler(void(*fiq_handler)(void))
120{ 52{
121 /* Install the FIQ handler */ 53 outl(inl(0xf000f044) | 0x2, 0xf000f044);
122 *((unsigned int*)(15*4)) = (unsigned int)fiq_handler; 54 while ((CACHE_CTL & 0x8000) != 0);
123} 55}
124 56
125static inline void enable_fiq(void) 57#endif /* CONFIG_CPU */
126{
127 /* Clear FIQ disable bit */
128 asm volatile (
129 "mrs r0, cpsr \n"\
130 "bic r0, r0, #0x40 \n"\
131 "msr cpsr_c, r0 "
132 : : : "r0"
133 );
134}
135
136static inline void disable_fiq(void)
137{
138 /* Set FIQ disable bit */
139 asm volatile (
140 "mrs r0, cpsr \n"\
141 "orr r0, r0, #0x40 \n"\
142 "msr cpsr_c, r0 "
143 : : : "r0"
144 );
145}
146
147#if CONFIG_CPU == PNX0101
148typedef void (*interrupt_handler_t)(void);
149
150void irq_set_int_handler(int n, interrupt_handler_t handler);
151void irq_enable_int(int n);
152void irq_disable_int(int n);
153#endif
154 58
155#endif /* SYSTEM_TARGET_H */ 59#endif /* SYSTEM_TARGET_H */