diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2004-06-10 13:29:52 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2004-06-10 13:29:52 +0000 |
commit | a6142ab7ab58f69a3f1a034db4bdf1eff24d3dd6 (patch) | |
tree | ef00c3ec8074ccb080b221c7d1dd4b3d03c8fd87 /uisimulator/x11 | |
parent | 5fc1b64ae051e454d2b3bf3a20be5d88937e55e7 (diff) | |
download | rockbox-a6142ab7ab58f69a3f1a034db4bdf1eff24d3dd6.tar.gz rockbox-a6142ab7ab58f69a3f1a034db4bdf1eff24d3dd6.zip |
Finally, the archos directory sandbox works in the same way for both X11 and win32 simulators. Unfortunately, this breaks the VC++ compatibility. Also, the plugin API now supports DEBUGF. Last, but not least, we have a new plugin, vbrfix.rock.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4726 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/x11')
-rw-r--r-- | uisimulator/x11/Makefile | 9 | ||||
-rw-r--r-- | uisimulator/x11/button-x11.c | 6 | ||||
-rw-r--r-- | uisimulator/x11/dir.h | 50 | ||||
-rw-r--r-- | uisimulator/x11/file.h | 54 | ||||
-rw-r--r-- | uisimulator/x11/io.c | 216 | ||||
-rw-r--r-- | uisimulator/x11/kernel.h | 4 | ||||
-rw-r--r-- | uisimulator/x11/thread.c | 2 |
7 files changed, 13 insertions, 328 deletions
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile index 65f0b8d5a2..03b23acef3 100644 --- a/uisimulator/x11/Makefile +++ b/uisimulator/x11/Makefile | |||
@@ -96,6 +96,8 @@ ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP) | |||
96 | else | 96 | else |
97 | LCDSRSC = lcd-playersim.c lcd-player.c font-player.c lcd-player-charset.c | 97 | LCDSRSC = lcd-playersim.c lcd-player.c font-player.c lcd-player-charset.c |
98 | endif | 98 | endif |
99 | COMMONSRCS = io.c | ||
100 | |||
99 | FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\ | 101 | FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\ |
100 | powermgmt.c panic.c mp3data.c sprintf.c buffer.c timefuncs.c | 102 | powermgmt.c panic.c mp3data.c sprintf.c buffer.c timefuncs.c |
101 | 103 | ||
@@ -111,8 +113,8 @@ ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP) | |||
111 | endif | 113 | endif |
112 | 114 | ||
113 | SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \ | 115 | SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \ |
114 | button-x11.c io.c thread.c sim_icons.c $(APPS) $(MENUS) $(FIRMSRCS) \ | 116 | button-x11.c thread.c sim_icons.c $(APPS) $(MENUS) $(FIRMSRCS) \ |
115 | lcd-common.c | 117 | $(COMMONSRCS) lcd-common.c |
116 | 118 | ||
117 | ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c) | 119 | ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c) |
118 | ROCKS := $(ROCKSRC:$(APPDIR)/plugins/%.c=$(OBJDIR)/%.rock) | 120 | ROCKS := $(ROCKSRC:$(APPDIR)/plugins/%.c=$(OBJDIR)/%.rock) |
@@ -276,6 +278,9 @@ $(OBJDIR)/stubs.o: $(SIMCOMMON)/stubs.c | |||
276 | $(OBJDIR)/sim_icons.o: $(SIMCOMMON)/sim_icons.c | 278 | $(OBJDIR)/sim_icons.o: $(SIMCOMMON)/sim_icons.c |
277 | $(CC) $(CFLAGS) -c $< -o $@ | 279 | $(CC) $(CFLAGS) -c $< -o $@ |
278 | 280 | ||
281 | $(OBJDIR)/io.o: $(SIMCOMMON)/io.c | ||
282 | $(CC) $(CFLAGS) -c $< -o $@ | ||
283 | |||
279 | $(OBJDIR)/usb.o: $(FIRMWAREDIR)/usb.c | 284 | $(OBJDIR)/usb.o: $(FIRMWAREDIR)/usb.c |
280 | $(CC) $(CFLAGS) -c $< -o $@ | 285 | $(CC) $(CFLAGS) -c $< -o $@ |
281 | 286 | ||
diff --git a/uisimulator/x11/button-x11.c b/uisimulator/x11/button-x11.c index ae16e2e891..eae55318ad 100644 --- a/uisimulator/x11/button-x11.c +++ b/uisimulator/x11/button-x11.c | |||
@@ -172,7 +172,7 @@ int button_get_w_tmo(int ticks) | |||
172 | for(i=0; i< ticks; i++) { | 172 | for(i=0; i< ticks; i++) { |
173 | bits = get_raw_button(); | 173 | bits = get_raw_button(); |
174 | if(!bits) | 174 | if(!bits) |
175 | x11_sleep(1); | 175 | sim_sleep(1); |
176 | else | 176 | else |
177 | break; | 177 | break; |
178 | } | 178 | } |
@@ -193,14 +193,14 @@ int button_get(bool block) | |||
193 | do { | 193 | do { |
194 | bits = get_raw_button(); | 194 | bits = get_raw_button(); |
195 | if(block && !bits) | 195 | if(block && !bits) |
196 | x11_sleep(HZ/10); | 196 | sim_sleep(HZ/10); |
197 | else | 197 | else |
198 | break; | 198 | break; |
199 | } while(1); | 199 | } while(1); |
200 | 200 | ||
201 | if(!block) | 201 | if(!block) |
202 | /* delay a bit */ | 202 | /* delay a bit */ |
203 | x11_sleep(1); | 203 | sim_sleep(1); |
204 | 204 | ||
205 | return bits; | 205 | return bits; |
206 | } | 206 | } |
diff --git a/uisimulator/x11/dir.h b/uisimulator/x11/dir.h deleted file mode 100644 index 48696c23b8..0000000000 --- a/uisimulator/x11/dir.h +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
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 _X11_DIR_H_ | ||
20 | #define _X11_DIR_H_ | ||
21 | |||
22 | #include <sys/types.h> | ||
23 | typedef void DIR; | ||
24 | |||
25 | #define DIRFUNCTIONS_DEFINED /* prevent those prototypes */ | ||
26 | #define dirent x11_dirent | ||
27 | #include "../../firmware/include/dir.h" | ||
28 | #undef dirent | ||
29 | |||
30 | typedef void * MYDIR; | ||
31 | |||
32 | extern MYDIR *x11_opendir(const char *name); | ||
33 | extern struct x11_dirent* x11_readdir(MYDIR* dir); | ||
34 | extern int x11_closedir(MYDIR *dir); | ||
35 | extern int x11_mkdir(char *name, int mode); | ||
36 | extern int x11_rmdir(char *name); | ||
37 | |||
38 | #ifndef NO_REDEFINES_PLEASE | ||
39 | |||
40 | #define DIR MYDIR | ||
41 | #define dirent x11_dirent | ||
42 | #define opendir(x) x11_opendir(x) | ||
43 | #define readdir(x) x11_readdir(x) | ||
44 | #define closedir(x) x11_closedir(x) | ||
45 | #define mkdir(x, y) x11_mkdir(x, y) | ||
46 | #define rmdir(x) x11_rmdir(x) | ||
47 | |||
48 | #endif | ||
49 | |||
50 | #endif | ||
diff --git a/uisimulator/x11/file.h b/uisimulator/x11/file.h deleted file mode 100644 index b30167ecbd..0000000000 --- a/uisimulator/x11/file.h +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
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 | |||
20 | #ifndef ROCKBOX_FILE_H | ||
21 | #define ROCKBOX_FILE_H | ||
22 | |||
23 | #include <stdio.h> | ||
24 | #include <sys/types.h> | ||
25 | |||
26 | int x11_open(const char *name, int opts); | ||
27 | int x11_close(int fd); | ||
28 | int x11_filesize(int fd); | ||
29 | int x11_creat(const char *name, mode_t mode); | ||
30 | int x11_remove(char *name); | ||
31 | int x11_rename(char *oldpath, char *newpath); | ||
32 | |||
33 | #ifndef NO_REDEFINES_PLEASE | ||
34 | #define open(x,y) x11_open(x,y) | ||
35 | #define close(x) x11_close(x) | ||
36 | #define filesize(x) x11_filesize(x) | ||
37 | #define creat(x,y) x11_creat(x,y) | ||
38 | #define remove(x) x11_remove(x) | ||
39 | #define rename(x,y) x11_rename(x,y) | ||
40 | #endif | ||
41 | |||
42 | #include "../../firmware/include/file.h" | ||
43 | |||
44 | int open(const char* pathname, int flags); | ||
45 | int close(int fd); | ||
46 | int printf(const char *format, ...); | ||
47 | int ftruncate(int fd, off_t length); | ||
48 | int fsync(int fd); | ||
49 | |||
50 | off_t lseek(int fildes, off_t offset, int whence); | ||
51 | ssize_t read(int fd, void *buf, size_t count); | ||
52 | ssize_t write(int fd, const void *buf, size_t count); | ||
53 | |||
54 | #endif | ||
diff --git a/uisimulator/x11/io.c b/uisimulator/x11/io.c deleted file mode 100644 index d4d2714026..0000000000 --- a/uisimulator/x11/io.c +++ /dev/null | |||
@@ -1,216 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Daniel Stenberg | ||
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 | |||
20 | #include <stdio.h> | ||
21 | #include <stdlib.h> | ||
22 | #include <string.h> | ||
23 | #include <sys/stat.h> | ||
24 | #ifdef __FreeBSD__ | ||
25 | #include <sys/param.h> | ||
26 | #include <sys/mount.h> | ||
27 | #else | ||
28 | #include <sys/vfs.h> | ||
29 | #endif | ||
30 | #include <dirent.h> | ||
31 | #include <unistd.h> | ||
32 | |||
33 | #include <fcntl.h> | ||
34 | #include "debug.h" | ||
35 | |||
36 | #define DIRFUNCTIONS_DEFINED /* prevent those prototypes */ | ||
37 | #define dirent x11_dirent | ||
38 | #include "../../firmware/include/dir.h" | ||
39 | #undef dirent | ||
40 | |||
41 | #define SIMULATOR_ARCHOS_ROOT "archos" | ||
42 | |||
43 | struct mydir { | ||
44 | DIR *dir; | ||
45 | char *name; | ||
46 | }; | ||
47 | |||
48 | typedef struct mydir MYDIR; | ||
49 | |||
50 | MYDIR *x11_opendir(const char *name) | ||
51 | { | ||
52 | char buffer[256]; /* sufficiently big */ | ||
53 | DIR *dir; | ||
54 | |||
55 | if(name[0] == '/') { | ||
56 | sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); | ||
57 | dir=(DIR *)opendir(buffer); | ||
58 | } | ||
59 | else | ||
60 | dir=(DIR *)opendir(name); | ||
61 | |||
62 | if(dir) { | ||
63 | MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR)); | ||
64 | my->dir = dir; | ||
65 | my->name = (char *)strdup(name); | ||
66 | |||
67 | return my; | ||
68 | } | ||
69 | /* failed open, return NULL */ | ||
70 | return (MYDIR *)0; | ||
71 | } | ||
72 | |||
73 | struct x11_dirent *x11_readdir(MYDIR *dir) | ||
74 | { | ||
75 | char buffer[512]; /* sufficiently big */ | ||
76 | static struct x11_dirent secret; | ||
77 | struct stat s; | ||
78 | struct dirent *x11 = (readdir)(dir->dir); | ||
79 | |||
80 | if(!x11) | ||
81 | return (struct x11_dirent *)0; | ||
82 | |||
83 | strcpy(secret.d_name, x11->d_name); | ||
84 | |||
85 | /* build file name */ | ||
86 | sprintf(buffer, SIMULATOR_ARCHOS_ROOT "%s/%s", | ||
87 | dir->name, x11->d_name); | ||
88 | stat(buffer, &s); /* get info */ | ||
89 | |||
90 | secret.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0; | ||
91 | secret.size = s.st_size; | ||
92 | |||
93 | return &secret; | ||
94 | } | ||
95 | |||
96 | void x11_closedir(MYDIR *dir) | ||
97 | { | ||
98 | free(dir->name); | ||
99 | (closedir)(dir->dir); | ||
100 | |||
101 | free(dir); | ||
102 | } | ||
103 | |||
104 | |||
105 | int x11_open(const char *name, int opts) | ||
106 | { | ||
107 | char buffer[256]; /* sufficiently big */ | ||
108 | |||
109 | if(name[0] == '/') { | ||
110 | sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); | ||
111 | |||
112 | debugf("We open the real file '%s'\n", buffer); | ||
113 | return (open)(buffer, opts); | ||
114 | } | ||
115 | return (open)(name, opts); | ||
116 | } | ||
117 | |||
118 | int x11_close(int fd) | ||
119 | { | ||
120 | return (close)(fd); | ||
121 | } | ||
122 | |||
123 | int x11_creat(const char *name, mode_t mode) | ||
124 | { | ||
125 | char buffer[256]; /* sufficiently big */ | ||
126 | (void)mode; | ||
127 | if(name[0] == '/') { | ||
128 | sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); | ||
129 | |||
130 | debugf("We create the real file '%s'\n", buffer); | ||
131 | return (creat)(buffer, 0666); | ||
132 | } | ||
133 | return (creat)(name, 0666); | ||
134 | } | ||
135 | |||
136 | int x11_mkdir(const char *name, mode_t mode) | ||
137 | { | ||
138 | char buffer[256]; /* sufficiently big */ | ||
139 | (void)mode; | ||
140 | if(name[0] == '/') { | ||
141 | sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); | ||
142 | |||
143 | debugf("We create the real directory '%s'\n", buffer); | ||
144 | return (mkdir)(buffer, 0666); | ||
145 | } | ||
146 | return (mkdir)(name, 0666); | ||
147 | } | ||
148 | |||
149 | int x11_rmdir(const char *name) | ||
150 | { | ||
151 | char buffer[256]; /* sufficiently big */ | ||
152 | if(name[0] == '/') { | ||
153 | sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); | ||
154 | |||
155 | debugf("We remove the real directory '%s'\n", buffer); | ||
156 | return (rmdir)(buffer); | ||
157 | } | ||
158 | return (rmdir)(name); | ||
159 | } | ||
160 | |||
161 | int x11_remove(char *name) | ||
162 | { | ||
163 | char buffer[256]; /* sufficiently big */ | ||
164 | |||
165 | if(name[0] == '/') { | ||
166 | sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); | ||
167 | |||
168 | debugf("We remove the real file '%s'\n", buffer); | ||
169 | return (remove)(buffer); | ||
170 | } | ||
171 | return (remove)(name); | ||
172 | } | ||
173 | |||
174 | int x11_rename(char *oldpath, char* newpath) | ||
175 | { | ||
176 | char buffer1[256]; | ||
177 | char buffer2[256]; | ||
178 | |||
179 | if(oldpath[0] == '/') { | ||
180 | sprintf(buffer1, "%s%s", SIMULATOR_ARCHOS_ROOT, oldpath); | ||
181 | sprintf(buffer2, "%s%s", SIMULATOR_ARCHOS_ROOT, newpath); | ||
182 | |||
183 | debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2); | ||
184 | return (rename)(buffer1, buffer2); | ||
185 | } | ||
186 | return -1; | ||
187 | } | ||
188 | |||
189 | int x11_filesize(int fd) | ||
190 | { | ||
191 | int old = lseek(fd, 0, SEEK_CUR); | ||
192 | int size = lseek(fd, 0, SEEK_END); | ||
193 | lseek(fd, old, SEEK_SET); | ||
194 | |||
195 | return(size); | ||
196 | } | ||
197 | |||
198 | void fat_size(unsigned int* size, unsigned int* free) | ||
199 | { | ||
200 | struct statfs fs; | ||
201 | |||
202 | if (!statfs(".", &fs)) { | ||
203 | DEBUGF("statfs: bsize=%d blocks=%d free=%d\n", | ||
204 | fs.f_bsize, fs.f_blocks, fs.f_bfree); | ||
205 | if (size) | ||
206 | *size = fs.f_blocks * (fs.f_bsize / 1024); | ||
207 | if (free) | ||
208 | *free = fs.f_bfree * (fs.f_bsize / 1024); | ||
209 | } | ||
210 | else { | ||
211 | if (size) | ||
212 | *size = 0; | ||
213 | if (free) | ||
214 | *free = 0; | ||
215 | } | ||
216 | } | ||
diff --git a/uisimulator/x11/kernel.h b/uisimulator/x11/kernel.h index a045a3f117..f165d92eb3 100644 --- a/uisimulator/x11/kernel.h +++ b/uisimulator/x11/kernel.h | |||
@@ -21,11 +21,11 @@ | |||
21 | 21 | ||
22 | #ifndef NO_REDEFINES_PLEASE | 22 | #ifndef NO_REDEFINES_PLEASE |
23 | 23 | ||
24 | #define sleep(x) x11_sleep(x) | 24 | #define sleep(x) sim_sleep(x) |
25 | #define mutex_init(x) (void)x | 25 | #define mutex_init(x) (void)x |
26 | #define mutex_lock(x) (void)x | 26 | #define mutex_lock(x) (void)x |
27 | #define mutex_unlock(x) (void)x | 27 | #define mutex_unlock(x) (void)x |
28 | 28 | ||
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | void x11_sleep(int); | 31 | void sim_sleep(int); |
diff --git a/uisimulator/x11/thread.c b/uisimulator/x11/thread.c index 437080acc9..e37373dc54 100644 --- a/uisimulator/x11/thread.c +++ b/uisimulator/x11/thread.c | |||
@@ -85,7 +85,7 @@ int create_thread(void* fp, void* sp, int stk_size) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | /* ticks is HZ per second */ | 87 | /* ticks is HZ per second */ |
88 | void x11_sleep(int ticks) | 88 | void sim_sleep(int ticks) |
89 | { | 89 | { |
90 | current_tick+=5; | 90 | current_tick+=5; |
91 | pthread_mutex_unlock(&mp); /* return */ | 91 | pthread_mutex_unlock(&mp); /* return */ |