diff options
-rw-r--r-- | firmware/SOURCES | 8 | ||||
-rw-r--r-- | firmware/target/hosted/android/kernel-android.c | 117 | ||||
-rw-r--r-- | firmware/target/hosted/android/system-target.h | 11 | ||||
-rw-r--r-- | firmware/target/hosted/kernel-unix.c (renamed from firmware/target/hosted/ypr0/kernel-ypr0.c) | 21 | ||||
-rw-r--r-- | firmware/target/hosted/kernel-unix.h | 34 | ||||
-rw-r--r-- | firmware/target/hosted/ypr0/system-target.h | 8 |
6 files changed, 55 insertions, 144 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 18f877ba3d..19b0efd089 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -1,3 +1,6 @@ | |||
1 | #undef unix /* causes problems with some files */ | ||
2 | #undef linux | ||
3 | |||
1 | ata_idle_notify.c | 4 | ata_idle_notify.c |
2 | events.c | 5 | events.c |
3 | backlight.c | 6 | backlight.c |
@@ -9,7 +12,6 @@ powermgmt.c | |||
9 | #if (CONFIG_PLATFORM & PLATFORM_HOSTED) | 12 | #if (CONFIG_PLATFORM & PLATFORM_HOSTED) |
10 | 13 | ||
11 | #ifdef __linux__ | 14 | #ifdef __linux__ |
12 | #undef linux | ||
13 | target/hosted/cpuinfo-linux.c | 15 | target/hosted/cpuinfo-linux.c |
14 | #endif | 16 | #endif |
15 | 17 | ||
@@ -75,8 +77,8 @@ drivers/rtc/rtc_as3514.c | |||
75 | #else | 77 | #else |
76 | target/hosted/rtc.c | 78 | target/hosted/rtc.c |
77 | #endif | 79 | #endif |
80 | target/hosted/kernel-unix.c | ||
78 | target/hosted/ypr0/button-ypr0.c | 81 | target/hosted/ypr0/button-ypr0.c |
79 | target/hosted/ypr0/kernel-ypr0.c | ||
80 | target/hosted/ypr0/lcd-ypr0.c | 82 | target/hosted/ypr0/lcd-ypr0.c |
81 | target/hosted/ypr0/system-ypr0.c | 83 | target/hosted/ypr0/system-ypr0.c |
82 | target/hosted/ypr0/fs-ypr0.c | 84 | target/hosted/ypr0/fs-ypr0.c |
@@ -1690,6 +1692,7 @@ target/arm/rk27xx/hm801/power-hm801.c | |||
1690 | #endif | 1692 | #endif |
1691 | 1693 | ||
1692 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) | 1694 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) |
1695 | target/hosted/kernel-unix.c | ||
1693 | target/hosted/android/fs-android.c | 1696 | target/hosted/android/fs-android.c |
1694 | target/hosted/android/lcd-android.c | 1697 | target/hosted/android/lcd-android.c |
1695 | target/hosted/android/lc-android.c | 1698 | target/hosted/android/lc-android.c |
@@ -1697,7 +1700,6 @@ target/hosted/android/button-android.c | |||
1697 | #ifdef DEBUG | 1700 | #ifdef DEBUG |
1698 | target/hosted/android/debug-android.c | 1701 | target/hosted/android/debug-android.c |
1699 | #endif | 1702 | #endif |
1700 | target/hosted/android/kernel-android.c | ||
1701 | target/hosted/android/pcm-android.c | 1703 | target/hosted/android/pcm-android.c |
1702 | target/hosted/android/powermgmt-android.c | 1704 | target/hosted/android/powermgmt-android.c |
1703 | target/hosted/android/system-android.c | 1705 | target/hosted/android/system-android.c |
diff --git a/firmware/target/hosted/android/kernel-android.c b/firmware/target/hosted/android/kernel-android.c deleted file mode 100644 index e3522418fe..0000000000 --- a/firmware/target/hosted/android/kernel-android.c +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (c) 2010 Thomas Martitz | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | |||
23 | #include <time.h> | ||
24 | #include <signal.h> | ||
25 | #include <errno.h> | ||
26 | #include <unistd.h> | ||
27 | #include <pthread.h> | ||
28 | #include "config.h" | ||
29 | #include "system.h" | ||
30 | #include "button.h" | ||
31 | #include "audio.h" | ||
32 | #include "panic.h" | ||
33 | |||
34 | |||
35 | static pthread_cond_t wfi_cond = PTHREAD_COND_INITIALIZER; | ||
36 | static pthread_mutex_t wfi_mtx = PTHREAD_MUTEX_INITIALIZER; | ||
37 | /* | ||
38 | * call tick tasks and wake the scheduler up */ | ||
39 | void timer_signal(union sigval arg) | ||
40 | { | ||
41 | (void)arg; | ||
42 | call_tick_tasks(); | ||
43 | interrupt(); | ||
44 | } | ||
45 | |||
46 | /* | ||
47 | * wait on the sem which the signal handler posts to save cpu time (aka sleep) | ||
48 | * | ||
49 | * other mechanisms could use them as well */ | ||
50 | void wait_for_interrupt(void) | ||
51 | { | ||
52 | pthread_cond_wait(&wfi_cond, &wfi_mtx); | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | * Wakeup the kernel, if sleeping (shall not be called from a signal handler) */ | ||
57 | void interrupt(void) | ||
58 | { | ||
59 | pthread_cond_signal(&wfi_cond); | ||
60 | } | ||
61 | |||
62 | /* | ||
63 | * setup a hrtimer to send a signal to our process every tick | ||
64 | * | ||
65 | * WARNING: JNI calls are not permitted from tick tasks, as the | ||
66 | * underlying thread is not attached to the Java VM | ||
67 | * | ||
68 | * Can be possibly be attached if it really needs to be. but let's | ||
69 | * keep this leightweight */ | ||
70 | void tick_start(unsigned int interval_in_ms) | ||
71 | { | ||
72 | int ret = 0; | ||
73 | timer_t timerid; | ||
74 | struct itimerspec ts; | ||
75 | sigevent_t sigev; | ||
76 | |||
77 | /* initializing in the declaration causes some weird warnings */ | ||
78 | memset(&sigev, 0, sizeof(sigevent_t)); | ||
79 | sigev.sigev_notify = SIGEV_THREAD, | ||
80 | sigev.sigev_notify_function = timer_signal, | ||
81 | |||
82 | ts.it_value.tv_sec = ts.it_interval.tv_sec = 0; | ||
83 | ts.it_value.tv_nsec = ts.it_interval.tv_nsec = interval_in_ms*1000*1000; | ||
84 | |||
85 | /* add the timer */ | ||
86 | ret |= timer_create(CLOCK_REALTIME, &sigev, &timerid); | ||
87 | ret |= timer_settime(timerid, 0, &ts, NULL); | ||
88 | |||
89 | /* Grab the mutex already now and leave it to this thread. We don't | ||
90 | * care about race conditions when signaling the condition (because | ||
91 | * they are not critical), but a mutex is necessary due to the API */ | ||
92 | pthread_mutex_lock(&wfi_mtx); | ||
93 | |||
94 | if (ret != 0) | ||
95 | panicf("%s(): %s\n", __func__, strerror(errno)); | ||
96 | } | ||
97 | |||
98 | |||
99 | bool timer_register(int reg_prio, void (*unregister_callback)(void), | ||
100 | long cycles, void (*timer_callback)(void)) | ||
101 | { | ||
102 | (void)reg_prio; | ||
103 | (void)unregister_callback; | ||
104 | (void)cycles; | ||
105 | (void)timer_callback; | ||
106 | return false; | ||
107 | } | ||
108 | |||
109 | bool timer_set_period(long cycles) | ||
110 | { | ||
111 | (void)cycles; | ||
112 | return false; | ||
113 | } | ||
114 | |||
115 | void timer_unregister(void) | ||
116 | { | ||
117 | } | ||
diff --git a/firmware/target/hosted/android/system-target.h b/firmware/target/hosted/android/system-target.h index 12610de42f..aba7e6d6c0 100644 --- a/firmware/target/hosted/android/system-target.h +++ b/firmware/target/hosted/android/system-target.h | |||
@@ -18,22 +18,16 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | |||
21 | #ifndef __SYSTEM_TARGET_H__ | 22 | #ifndef __SYSTEM_TARGET_H__ |
22 | #define __SYSTEM_TARGET_H__ | 23 | #define __SYSTEM_TARGET_H__ |
23 | 24 | ||
24 | #define disable_irq() | 25 | #include "kernel-unix.h" |
25 | #define enable_irq() | ||
26 | #define disable_irq_save() 0 | ||
27 | #define restore_irq(level) (void)level | ||
28 | 26 | ||
29 | static inline void commit_dcache(void) {} | 27 | static inline void commit_dcache(void) {} |
30 | static inline void commit_discard_dcache(void) {} | 28 | static inline void commit_discard_dcache(void) {} |
31 | static inline void commit_discard_idcache(void) {} | 29 | static inline void commit_discard_idcache(void) {} |
32 | 30 | ||
33 | void power_off(void); | ||
34 | void wait_for_interrupt(void); | ||
35 | void interrupt(void); | ||
36 | |||
37 | /* don't pull in jni.h for every user of this file, it should be only needed | 31 | /* don't pull in jni.h for every user of this file, it should be only needed |
38 | * within the target tree (if at all) | 32 | * within the target tree (if at all) |
39 | * define this before #including system.h or system-target.h */ | 33 | * define this before #including system.h or system-target.h */ |
@@ -47,4 +41,3 @@ extern JNIEnv* getJavaEnvironment(void); | |||
47 | #endif /* __SYSTEM_TARGET_H__ */ | 41 | #endif /* __SYSTEM_TARGET_H__ */ |
48 | 42 | ||
49 | #define NEED_GENERIC_BYTESWAPS | 43 | #define NEED_GENERIC_BYTESWAPS |
50 | |||
diff --git a/firmware/target/hosted/ypr0/kernel-ypr0.c b/firmware/target/hosted/kernel-unix.c index bcf2cee583..a0167d46c5 100644 --- a/firmware/target/hosted/ypr0/kernel-ypr0.c +++ b/firmware/target/hosted/kernel-unix.c | |||
@@ -20,6 +20,7 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | 22 | ||
23 | #include <stdlib.h> | ||
23 | #include <time.h> | 24 | #include <time.h> |
24 | #include <signal.h> | 25 | #include <signal.h> |
25 | #include <errno.h> | 26 | #include <errno.h> |
@@ -63,10 +64,13 @@ void interrupt(void) | |||
63 | 64 | ||
64 | /* | 65 | /* |
65 | * setup a hrtimer to send a signal to our process every tick | 66 | * setup a hrtimer to send a signal to our process every tick |
67 | * | ||
68 | * WARNING for Android: JNI calls are not permitted from tick tasks, as the | ||
69 | * underlying thread is not attached to the Java VM | ||
70 | * | ||
71 | * Can be possibly be attached if it really needs to be. but let's | ||
72 | * keep this leightweight | ||
66 | */ | 73 | */ |
67 | union sigval tick_arg = { | ||
68 | .sival_int = 0, | ||
69 | }; | ||
70 | 74 | ||
71 | void tick_start(unsigned int interval_in_ms) | 75 | void tick_start(unsigned int interval_in_ms) |
72 | { | 76 | { |
@@ -126,13 +130,13 @@ bool timer_register(int reg_prio, void (*unregister_callback)(void), | |||
126 | if (timer_prio >= 0 && global_unreg_callback) | 130 | if (timer_prio >= 0 && global_unreg_callback) |
127 | global_unreg_callback(); | 131 | global_unreg_callback(); |
128 | 132 | ||
129 | /* initializing in the declaration causes some weird warnings */ | ||
130 | memset(&sigev, 0, sizeof(sigevent_t)); | 133 | memset(&sigev, 0, sizeof(sigevent_t)); |
131 | sigev.sigev_notify = SIGEV_THREAD, | 134 | sigev.sigev_notify = SIGEV_THREAD, |
132 | sigev.sigev_notify_function = timer_cb; | 135 | sigev.sigev_notify_function = timer_cb; |
133 | 136 | ||
134 | ts.it_value.tv_sec = ts.it_interval.tv_sec = in_us / 1000000; | 137 | div_t q = div(in_us, 1000000); |
135 | ts.it_value.tv_nsec = ts.it_interval.tv_nsec = (in_us%1000000)*1000; | 138 | ts.it_value.tv_sec = ts.it_interval.tv_sec = q.quot; |
139 | ts.it_value.tv_nsec = ts.it_interval.tv_nsec = q.rem*1000; | ||
136 | 140 | ||
137 | /* add the timer */ | 141 | /* add the timer */ |
138 | ret |= timer_create(CLOCK_REALTIME, &sigev, &timer_tid); | 142 | ret |= timer_create(CLOCK_REALTIME, &sigev, &timer_tid); |
@@ -149,8 +153,9 @@ bool timer_set_period(long cycles) | |||
149 | { | 153 | { |
150 | struct itimerspec ts; | 154 | struct itimerspec ts; |
151 | long in_us = cycles_to_microseconds(cycles); | 155 | long in_us = cycles_to_microseconds(cycles); |
152 | ts.it_value.tv_sec = ts.it_interval.tv_sec = in_us / 1000000; | 156 | div_t q = div(in_us, 1000000); |
153 | ts.it_value.tv_nsec = ts.it_interval.tv_nsec = (in_us%1000000)*1000; | 157 | ts.it_value.tv_sec = ts.it_interval.tv_sec = q.quot; |
158 | ts.it_value.tv_nsec = ts.it_interval.tv_nsec = q.rem*1000; | ||
154 | 159 | ||
155 | return timer_settime(timer_tid, 0, &ts, NULL) == 0; | 160 | return timer_settime(timer_tid, 0, &ts, NULL) == 0; |
156 | } | 161 | } |
diff --git a/firmware/target/hosted/kernel-unix.h b/firmware/target/hosted/kernel-unix.h new file mode 100644 index 0000000000..f296668861 --- /dev/null +++ b/firmware/target/hosted/kernel-unix.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 by Thomas Martitz | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef __KERNEL_UNIX_H__ | ||
23 | #define __KERNEL_UNIX_H__ | ||
24 | |||
25 | /* interrupt emulation incomplete, doesn't seem needed so far */ | ||
26 | #define disable_irq() | ||
27 | #define enable_irq() | ||
28 | #define disable_irq_save() 0 | ||
29 | #define restore_irq(level) (void)level | ||
30 | |||
31 | void wait_for_interrupt(void); | ||
32 | void interrupt(void); | ||
33 | |||
34 | #endif /* __KERNEL_UNIX_H__ */ | ||
diff --git a/firmware/target/hosted/ypr0/system-target.h b/firmware/target/hosted/ypr0/system-target.h index 07a3163ea9..efd235282e 100644 --- a/firmware/target/hosted/ypr0/system-target.h +++ b/firmware/target/hosted/ypr0/system-target.h | |||
@@ -21,13 +21,7 @@ | |||
21 | #ifndef __SYSTEM_TARGET_H__ | 21 | #ifndef __SYSTEM_TARGET_H__ |
22 | #define __SYSTEM_TARGET_H__ | 22 | #define __SYSTEM_TARGET_H__ |
23 | 23 | ||
24 | #define disable_irq() | 24 | #include "kernel-unix.h" |
25 | #define enable_irq() | ||
26 | #define disable_irq_save() 0 | ||
27 | #define restore_irq(level) (void)level | ||
28 | |||
29 | void wait_for_interrupt(void); | ||
30 | void interrupt(void); | ||
31 | 25 | ||
32 | static inline void commit_dcache(void) {} | 26 | static inline void commit_dcache(void) {} |
33 | static inline void commit_discard_dcache(void) {} | 27 | static inline void commit_discard_dcache(void) {} |