summaryrefslogtreecommitdiff
path: root/uisimulator
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/common/dir.h (renamed from uisimulator/x11/dir.h)33
-rw-r--r--uisimulator/common/file.h (renamed from uisimulator/x11/file.h)45
-rw-r--r--uisimulator/common/io.c (renamed from uisimulator/x11/io.c)51
-rw-r--r--uisimulator/win32/Makefile11
-rw-r--r--uisimulator/win32/dir-win32.c97
-rw-r--r--uisimulator/win32/dir-win32.h26
-rw-r--r--uisimulator/win32/dir.h82
-rw-r--r--uisimulator/win32/file.h43
-rw-r--r--uisimulator/win32/io.c63
-rw-r--r--uisimulator/win32/kernel.c2
-rw-r--r--uisimulator/win32/kernel.h6
-rw-r--r--uisimulator/x11/Makefile9
-rw-r--r--uisimulator/x11/button-x11.c6
-rw-r--r--uisimulator/x11/kernel.h4
-rw-r--r--uisimulator/x11/thread.c2
15 files changed, 103 insertions, 377 deletions
diff --git a/uisimulator/x11/dir.h b/uisimulator/common/dir.h
index 48696c23b8..15332be54e 100644
--- a/uisimulator/x11/dir.h
+++ b/uisimulator/common/dir.h
@@ -16,35 +16,30 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19#ifndef _X11_DIR_H_ 19#ifndef _SIM_DIR_H_
20#define _X11_DIR_H_ 20#define _SIM_DIR_H_
21 21
22#include <sys/types.h> 22#include <sys/types.h>
23typedef void DIR;
24 23
25#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */ 24#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */
26#define dirent x11_dirent 25#define dirent sim_dirent
27#include "../../firmware/include/dir.h" 26#include "../../firmware/include/dir.h"
28#undef dirent 27#undef dirent
29 28
30typedef void * MYDIR; 29typedef void * MYDIR;
31 30
32extern MYDIR *x11_opendir(const char *name); 31extern MYDIR *sim_opendir(const char *name);
33extern struct x11_dirent* x11_readdir(MYDIR* dir); 32extern struct sim_dirent* sim_readdir(MYDIR* dir);
34extern int x11_closedir(MYDIR *dir); 33extern int sim_closedir(MYDIR *dir);
35extern int x11_mkdir(char *name, int mode); 34extern int sim_mkdir(char *name, int mode);
36extern int x11_rmdir(char *name); 35extern int sim_rmdir(char *name);
37
38#ifndef NO_REDEFINES_PLEASE
39 36
40#define DIR MYDIR 37#define DIR MYDIR
41#define dirent x11_dirent 38#define dirent sim_dirent
42#define opendir(x) x11_opendir(x) 39#define opendir(x) sim_opendir(x)
43#define readdir(x) x11_readdir(x) 40#define readdir(x) sim_readdir(x)
44#define closedir(x) x11_closedir(x) 41#define closedir(x) sim_closedir(x)
45#define mkdir(x, y) x11_mkdir(x, y) 42#define mkdir(x, y) sim_mkdir(x, y)
46#define rmdir(x) x11_rmdir(x) 43#define rmdir(x) sim_rmdir(x)
47
48#endif
49 44
50#endif 45#endif
diff --git a/uisimulator/x11/file.h b/uisimulator/common/file.h
index b30167ecbd..8d91b61831 100644
--- a/uisimulator/x11/file.h
+++ b/uisimulator/common/file.h
@@ -17,30 +17,46 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#ifndef ROCKBOX_FILE_H 20#ifndef _SIM_FILE_H_
21#define ROCKBOX_FILE_H 21#define _SIM_FILE_H_
22 22
23#ifdef WIN32
24#include <io.h>
25#include <fcntl.h>
26#else
23#include <stdio.h> 27#include <stdio.h>
28#endif
29
24#include <sys/types.h> 30#include <sys/types.h>
25 31
26int x11_open(const char *name, int opts); 32#ifdef WIN32
27int x11_close(int fd); 33#ifndef _commit
28int x11_filesize(int fd); 34extern int _commit( int handle );
29int x11_creat(const char *name, mode_t mode); 35#endif
30int x11_remove(char *name); 36#endif
31int x11_rename(char *oldpath, char *newpath); 37
38int sim_open(const char *name, int opts);
39int sim_close(int fd);
40int sim_rename(const char *oldpath, const char *newpath);
41int sim_filesize(int fd);
42int sim_creat(const char *name, mode_t mode);
43int sim_remove(const char *name);
32 44
33#ifndef NO_REDEFINES_PLEASE 45#ifndef NO_REDEFINES_PLEASE
34#define open(x,y) x11_open(x,y) 46#define open(x,y) sim_open(x,y)
35#define close(x) x11_close(x) 47#define close(x) sim_close(x)
36#define filesize(x) x11_filesize(x) 48#define filesize(x) sim_filesize(x)
37#define creat(x,y) x11_creat(x,y) 49#define creat(x,y) sim_creat(x,y)
38#define remove(x) x11_remove(x) 50#define remove(x) sim_remove(x)
39#define rename(x,y) x11_rename(x,y) 51#define rename(x,y) sim_rename(x,y)
52#ifdef WIN32
53#define fsync _commit
54#endif
40#endif 55#endif
41 56
42#include "../../firmware/include/file.h" 57#include "../../firmware/include/file.h"
43 58
59#ifndef WIN32
44int open(const char* pathname, int flags); 60int open(const char* pathname, int flags);
45int close(int fd); 61int close(int fd);
46int printf(const char *format, ...); 62int printf(const char *format, ...);
@@ -50,5 +66,6 @@ int fsync(int fd);
50off_t lseek(int fildes, off_t offset, int whence); 66off_t lseek(int fildes, off_t offset, int whence);
51ssize_t read(int fd, void *buf, size_t count); 67ssize_t read(int fd, void *buf, size_t count);
52ssize_t write(int fd, const void *buf, size_t count); 68ssize_t write(int fd, const void *buf, size_t count);
69#endif
53 70
54#endif 71#endif
diff --git a/uisimulator/x11/io.c b/uisimulator/common/io.c
index d4d2714026..745e417fa6 100644
--- a/uisimulator/x11/io.c
+++ b/uisimulator/common/io.c
@@ -24,7 +24,7 @@
24#ifdef __FreeBSD__ 24#ifdef __FreeBSD__
25#include <sys/param.h> 25#include <sys/param.h>
26#include <sys/mount.h> 26#include <sys/mount.h>
27#else 27#elif !defined(WIN32)
28#include <sys/vfs.h> 28#include <sys/vfs.h>
29#endif 29#endif
30#include <dirent.h> 30#include <dirent.h>
@@ -34,9 +34,11 @@
34#include "debug.h" 34#include "debug.h"
35 35
36#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */ 36#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */
37#define dirent x11_dirent 37#define dirent sim_dirent
38#define DIR SIMDIR
38#include "../../firmware/include/dir.h" 39#include "../../firmware/include/dir.h"
39#undef dirent 40#undef dirent
41#undef DIR
40 42
41#define SIMULATOR_ARCHOS_ROOT "archos" 43#define SIMULATOR_ARCHOS_ROOT "archos"
42 44
@@ -47,7 +49,7 @@ struct mydir {
47 49
48typedef struct mydir MYDIR; 50typedef struct mydir MYDIR;
49 51
50MYDIR *x11_opendir(const char *name) 52MYDIR *sim_opendir(const char *name)
51{ 53{
52 char buffer[256]; /* sufficiently big */ 54 char buffer[256]; /* sufficiently big */
53 DIR *dir; 55 DIR *dir;
@@ -70,15 +72,15 @@ MYDIR *x11_opendir(const char *name)
70 return (MYDIR *)0; 72 return (MYDIR *)0;
71} 73}
72 74
73struct x11_dirent *x11_readdir(MYDIR *dir) 75struct sim_dirent *sim_readdir(MYDIR *dir)
74{ 76{
75 char buffer[512]; /* sufficiently big */ 77 char buffer[512]; /* sufficiently big */
76 static struct x11_dirent secret; 78 static struct sim_dirent secret;
77 struct stat s; 79 struct stat s;
78 struct dirent *x11 = (readdir)(dir->dir); 80 struct dirent *x11 = (readdir)(dir->dir);
79 81
80 if(!x11) 82 if(!x11)
81 return (struct x11_dirent *)0; 83 return (struct sim_dirent *)0;
82 84
83 strcpy(secret.d_name, x11->d_name); 85 strcpy(secret.d_name, x11->d_name);
84 86
@@ -93,7 +95,7 @@ struct x11_dirent *x11_readdir(MYDIR *dir)
93 return &secret; 95 return &secret;
94} 96}
95 97
96void x11_closedir(MYDIR *dir) 98void sim_closedir(MYDIR *dir)
97{ 99{
98 free(dir->name); 100 free(dir->name);
99 (closedir)(dir->dir); 101 (closedir)(dir->dir);
@@ -102,7 +104,7 @@ void x11_closedir(MYDIR *dir)
102} 104}
103 105
104 106
105int x11_open(const char *name, int opts) 107int sim_open(const char *name, int opts)
106{ 108{
107 char buffer[256]; /* sufficiently big */ 109 char buffer[256]; /* sufficiently big */
108 110
@@ -115,12 +117,12 @@ int x11_open(const char *name, int opts)
115 return (open)(name, opts); 117 return (open)(name, opts);
116} 118}
117 119
118int x11_close(int fd) 120int sim_close(int fd)
119{ 121{
120 return (close)(fd); 122 return (close)(fd);
121} 123}
122 124
123int x11_creat(const char *name, mode_t mode) 125int sim_creat(const char *name, mode_t mode)
124{ 126{
125 char buffer[256]; /* sufficiently big */ 127 char buffer[256]; /* sufficiently big */
126 (void)mode; 128 (void)mode;
@@ -133,20 +135,22 @@ int x11_creat(const char *name, mode_t mode)
133 return (creat)(name, 0666); 135 return (creat)(name, 0666);
134} 136}
135 137
136int x11_mkdir(const char *name, mode_t mode) 138int sim_mkdir(const char *name, mode_t mode)
137{ 139{
138 char buffer[256]; /* sufficiently big */ 140 char buffer[256]; /* sufficiently big */
139 (void)mode; 141 (void)mode;
140 if(name[0] == '/') { 142
141 sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); 143 sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
142 144
143 debugf("We create the real directory '%s'\n", buffer); 145 debugf("We create the real directory '%s'\n", buffer);
144 return (mkdir)(buffer, 0666); 146#ifdef WIN32
145 } 147 return (mkdir)(buffer);
146 return (mkdir)(name, 0666); 148#else
149 return (mkdir)(buffer, 0666);
150#endif
147} 151}
148 152
149int x11_rmdir(const char *name) 153int sim_rmdir(const char *name)
150{ 154{
151 char buffer[256]; /* sufficiently big */ 155 char buffer[256]; /* sufficiently big */
152 if(name[0] == '/') { 156 if(name[0] == '/') {
@@ -158,7 +162,7 @@ int x11_rmdir(const char *name)
158 return (rmdir)(name); 162 return (rmdir)(name);
159} 163}
160 164
161int x11_remove(char *name) 165int sim_remove(const char *name)
162{ 166{
163 char buffer[256]; /* sufficiently big */ 167 char buffer[256]; /* sufficiently big */
164 168
@@ -171,7 +175,7 @@ int x11_remove(char *name)
171 return (remove)(name); 175 return (remove)(name);
172} 176}
173 177
174int x11_rename(char *oldpath, char* newpath) 178int sim_rename(const char *oldpath, const char* newpath)
175{ 179{
176 char buffer1[256]; 180 char buffer1[256];
177 char buffer2[256]; 181 char buffer2[256];
@@ -186,7 +190,7 @@ int x11_rename(char *oldpath, char* newpath)
186 return -1; 190 return -1;
187} 191}
188 192
189int x11_filesize(int fd) 193int sim_filesize(int fd)
190{ 194{
191 int old = lseek(fd, 0, SEEK_CUR); 195 int old = lseek(fd, 0, SEEK_CUR);
192 int size = lseek(fd, 0, SEEK_END); 196 int size = lseek(fd, 0, SEEK_END);
@@ -197,6 +201,10 @@ int x11_filesize(int fd)
197 201
198void fat_size(unsigned int* size, unsigned int* free) 202void fat_size(unsigned int* size, unsigned int* free)
199{ 203{
204#ifdef WIN32
205 *size = 2049;
206 *free = 1037;
207#else
200 struct statfs fs; 208 struct statfs fs;
201 209
202 if (!statfs(".", &fs)) { 210 if (!statfs(".", &fs)) {
@@ -213,4 +221,5 @@ void fat_size(unsigned int* size, unsigned int* free)
213 if (free) 221 if (free)
214 *free = 0; 222 *free = 0;
215 } 223 }
224#endif
216} 225}
diff --git a/uisimulator/win32/Makefile b/uisimulator/win32/Makefile
index 59ef7f5206..402b9addd5 100644
--- a/uisimulator/win32/Makefile
+++ b/uisimulator/win32/Makefile
@@ -96,6 +96,8 @@ ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
96else 96else
97 LCDSRSC = lcd-playersim.c lcd-player.c lcd-player-charset.c font-player.c 97 LCDSRSC = lcd-playersim.c lcd-player.c lcd-player-charset.c font-player.c
98endif 98endif
99COMMONSRCS = io.c
100
99FIRMSRCS = $(LCDSRSC) id3.c mp3data.c usb.c mpeg.c mp3_playback.c \ 101FIRMSRCS = $(LCDSRSC) id3.c mp3data.c usb.c mpeg.c mp3_playback.c \
100 powermgmt.c power.c sprintf.c buffer.c lcd-common.c strtok.c random.c \ 102 powermgmt.c power.c sprintf.c buffer.c lcd-common.c strtok.c random.c \
101 timefuncs.c 103 timefuncs.c
@@ -111,9 +113,9 @@ ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
111 APPS += bmp.c widgets.c 113 APPS += bmp.c widgets.c
112endif 114endif
113 115
114SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \ 116SRCS = button.c lcd-win32.c panic-win32.c thread-win32.c \
115 debug-win32.c kernel.c string-win32.c uisw32.c stubs.c \ 117 debug-win32.c kernel.c string-win32.c uisw32.c stubs.c \
116 $(APPS) $(MENUS) $(FIRMSRCS) sim_icons.c io.c 118 $(APPS) $(MENUS) $(FIRMSRCS) $(COMMONSRCS) sim_icons.c
117 119
118OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o 120OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o
119 121
@@ -303,6 +305,9 @@ $(OBJDIR)/font-player.o: $(SIMCOMMON)/font-player.c
303$(OBJDIR)/sim_icons.o: $(SIMCOMMON)/sim_icons.c 305$(OBJDIR)/sim_icons.o: $(SIMCOMMON)/sim_icons.c
304 $(CC) $(CFLAGS) -c $< -o $@ 306 $(CC) $(CFLAGS) -c $< -o $@
305 307
308$(OBJDIR)/io.o: $(SIMCOMMON)/io.c
309 $(CC) $(CFLAGS) -c $< -o $@
310
306$(OBJDIR)/lcd-playersim.o: $(SIMCOMMON)/lcd-playersim.c 311$(OBJDIR)/lcd-playersim.o: $(SIMCOMMON)/lcd-playersim.c
307 $(CC) $(CFLAGS) -c $< -o $@ 312 $(CC) $(CFLAGS) -c $< -o $@
308 313
@@ -315,7 +320,7 @@ $(OBJDIR)/%.o: %.c
315 $(CC) $(CFLAGS) -c $< -o $@ 320 $(CC) $(CFLAGS) -c $< -o $@
316 321
317$(OBJDIR)/%.po : $(PLUGINDIR)/%.c 322$(OBJDIR)/%.po : $(PLUGINDIR)/%.c
318 $(CC) $(APPCFLAGS) -c $< -o $@ 323 $(CC) $(APPCFLAGS) -DPLUGIN -c $< -o $@
319 324
320$(OBJDIR)/%.rock : $(OBJDIR)/%.po 325$(OBJDIR)/%.rock : $(OBJDIR)/%.po
321 $(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $< 326 $(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $<
diff --git a/uisimulator/win32/dir-win32.c b/uisimulator/win32/dir-win32.c
deleted file mode 100644
index dfdb6364f1..0000000000
--- a/uisimulator/win32/dir-win32.c
+++ /dev/null
@@ -1,97 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Felix Arends
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 <io.h>
21#include <windows.h>
22#include <malloc.h>
23#include "dir-win32.h"
24
25// Directory operations
26//
27
28// opendir
29// open directory for scanning
30DIR *opendir (
31 const char *dirname // directory name
32 )
33{
34 DIR *p = (DIR*)malloc(sizeof(DIR));
35 struct _finddata_t fd;
36 unsigned int i;
37 char *s = (char*)malloc(strlen(dirname) + 5);
38 wsprintf (s, "%s", dirname);
39
40 for (i = 0; i < strlen(s); i++)
41 if (s[i] == '/')
42 s[i] = '\\';
43
44 if (s[i - 1] != '\\')
45 {
46 s[i] = '\\';
47 s[++i] = '\0';
48 }
49
50 OutputDebugString (s);
51
52 wsprintf (s, "%s*.*", s);
53
54 if ((p->handle = _findfirst (s, &fd)) == -1)
55 {
56 free (s);
57 free (p);
58 return 0;
59 }
60 free (s);
61 return p;
62}
63
64// closedir
65// close directory
66int closedir (
67 DIR *dir // previously opened dir search
68 )
69{
70 free(dir);
71 return 0;
72}
73
74// read dir
75// read next entry in directory
76struct dirent *readdir (
77 DIR *dir
78 )
79{
80 struct _finddata_t fd;
81 if (_findnext (dir->handle, &fd) == -1)
82 return 0;
83 memcpy (dir->fd.d_name, fd.name, 256);
84
85 dir->fd.attribute = fd.attrib & 0x3f;
86 dir->fd.size = fd.size;
87 dir->fd.startcluster = 0 ;
88
89
90 return &dir->fd;
91}
92
93void fat_size(unsigned int* size, unsigned int* free)
94{
95 *size = 2049;
96 *free = 1037;
97}
diff --git a/uisimulator/win32/dir-win32.h b/uisimulator/win32/dir-win32.h
deleted file mode 100644
index c34a53aa1e..0000000000
--- a/uisimulator/win32/dir-win32.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Felix Arends
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 __DIR_WIN32_H__
21#define __DIR_WIN32_H__
22
23#include <io.h>
24#include "../../firmware/include/dir.h"
25
26#endif // #ifndef __DIR_WIN32_H__
diff --git a/uisimulator/win32/dir.h b/uisimulator/win32/dir.h
deleted file mode 100644
index da5064c1fb..0000000000
--- a/uisimulator/win32/dir.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Björn 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#ifndef _DIR_H_
20#define _DIR_H_
21
22#include <stdbool.h>
23#include "file.h"
24
25#ifndef DIRENT_DEFINED
26
27#define ATTR_READ_ONLY 0x01
28#define ATTR_HIDDEN 0x02
29#define ATTR_SYSTEM 0x04
30#define ATTR_VOLUME_ID 0x08
31#define ATTR_DIRECTORY 0x10
32#define ATTR_ARCHIVE 0x20
33
34struct dirent {
35 unsigned char d_name[MAX_PATH];
36 int attribute;
37 int size;
38 int startcluster;
39};
40#endif
41
42
43#ifndef SIMULATOR
44
45#include "fat.h"
46
47typedef struct {
48 bool busy;
49 int startcluster;
50 struct fat_dir fatdir;
51 struct dirent theent;
52} DIR;
53
54#else // SIMULATOR
55
56#ifdef WIN32
57#ifndef __MINGW32__
58#include <io.h>
59#endif /* __MINGW32__ */
60
61typedef struct DIRtag
62{
63 struct dirent fd;
64 int handle;
65} DIR;
66
67#endif /* WIN32 */
68
69#endif // SIMULATOR
70
71#ifndef DIRFUNCTIONS_DEFINED
72
73extern DIR* opendir(const char* name);
74extern int closedir(DIR* dir);
75extern int mkdir(const char* name, int mode);
76extern int rmdir(const char* name);
77
78extern struct dirent* readdir(DIR* dir);
79
80#endif /* DIRFUNCTIONS_DEFINED */
81
82#endif
diff --git a/uisimulator/win32/file.h b/uisimulator/win32/file.h
deleted file mode 100644
index 2c94ba320a..0000000000
--- a/uisimulator/win32/file.h
+++ /dev/null
@@ -1,43 +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 _FILE_H_
21
22#ifndef __MINGW32__
23#include <io.h>
24#include <fcntl.h>
25#endif
26
27#ifndef _commit
28extern int _commit( int handle );
29#endif
30
31int win32_rename(char *oldpath, char *newpath);
32int win32_filesize(int fd);
33
34#define rename win32_rename
35#define filesize win32_filesize
36#define fsync _commit
37
38#include "../../firmware/include/file.h"
39
40#undef rename
41#define mkdir(x,y) win32_mkdir(x,y)
42
43#endif
diff --git a/uisimulator/win32/io.c b/uisimulator/win32/io.c
deleted file mode 100644
index 023e767b6a..0000000000
--- a/uisimulator/win32/io.c
+++ /dev/null
@@ -1,63 +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 "file.h"
22#include "debug.h"
23
24#define SIMULATOR_ARCHOS_ROOT "archos"
25
26int win32_rename(char *oldpath, char* newpath)
27{
28 char buffer1[256];
29 char buffer2[256];
30
31 if(oldpath[0] == '/') {
32 sprintf(buffer1, "%s%s", SIMULATOR_ARCHOS_ROOT, oldpath);
33 sprintf(buffer2, "%s%s", SIMULATOR_ARCHOS_ROOT, newpath);
34
35 debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2);
36 return rename(buffer1, buffer2);
37 }
38 return -1;
39}
40
41int win32_filesize(int fd)
42{
43 int old = lseek(fd, 0, SEEK_CUR);
44 int size = lseek(fd, 0, SEEK_END);
45 lseek(fd, old, SEEK_SET);
46
47 return(size);
48}
49
50extern int (mkdir)(const char *name);
51
52int win32_mkdir(const char *name, int mode)
53{
54 char buffer[256]; /* sufficiently big */
55 (void)mode;
56 if(name[0] == '/') {
57 sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
58
59 debugf("We create the real directory '%s'\n", buffer);
60 return (mkdir)(buffer);
61 }
62 return (mkdir)(name);
63}
diff --git a/uisimulator/win32/kernel.c b/uisimulator/win32/kernel.c
index 44ac88ae7c..77ae6bffb2 100644
--- a/uisimulator/win32/kernel.c
+++ b/uisimulator/win32/kernel.c
@@ -34,7 +34,7 @@ int set_irq_level (int level)
34 return (_lv = level); 34 return (_lv = level);
35} 35}
36 36
37void sleep(int ticks) 37void sim_sleep(int ticks)
38{ 38{
39 Sleep (1000 / HZ * ticks); 39 Sleep (1000 / HZ * ticks);
40} 40}
diff --git a/uisimulator/win32/kernel.h b/uisimulator/win32/kernel.h
index 7cbdd1889e..7633ce68b4 100644
--- a/uisimulator/win32/kernel.h
+++ b/uisimulator/win32/kernel.h
@@ -18,3 +18,9 @@
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#include "../../firmware/export/kernel.h" 20#include "../../firmware/export/kernel.h"
21
22#ifndef NO_REDEFINES_PLEASE
23#define sleep(x) sim_sleep(x)
24#endif
25
26void sim_sleep(int);
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)
96else 96else
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
98endif 98endif
99COMMONSRCS = io.c
100
99FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\ 101FIRMSRCS = $(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)
111endif 113endif
112 114
113SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \ 115SRCS = 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
117ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c) 119ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c)
118ROCKS := $(ROCKSRC:$(APPDIR)/plugins/%.c=$(OBJDIR)/%.rock) 120ROCKS := $(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/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
31void x11_sleep(int); 31void 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 */
88void x11_sleep(int ticks) 88void 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 */