summaryrefslogtreecommitdiffstats
path: root/uisimulator
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-02-22 12:19:12 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-02-22 12:19:12 +0000
commit22b7701fe75cce9afdbc27046821dc089f9e7dac (patch)
treeca5b4f0428fad0fc9c775dfb0ac879ddee863846 /uisimulator
parent376057d2b67bae0a7b24ae1715d3cbb0b540b7a9 (diff)
downloadrockbox-22b7701fe75cce9afdbc27046821dc089f9e7dac.tar.gz
rockbox-22b7701fe75cce9afdbc27046821dc089f9e7dac.zip
Build cleanup and general fixes. fprintf() is now fdprintf(), the separation
between uisimulator files and firmware/apps files are better done. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6031 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/common/Makefile6
-rw-r--r--uisimulator/common/dir.h45
-rw-r--r--uisimulator/common/file.h76
-rw-r--r--uisimulator/common/io.c124
-rw-r--r--uisimulator/common/lcd-common.c4
-rw-r--r--uisimulator/common/stubs.c3
-rw-r--r--uisimulator/win32/Makefile15
-rw-r--r--uisimulator/win32/SOURCES2
-rw-r--r--uisimulator/win32/dir-win32.h1
-rw-r--r--uisimulator/x11/Makefile3
-rw-r--r--uisimulator/x11/kernel.h31
-rw-r--r--uisimulator/x11/thread.c15
12 files changed, 147 insertions, 178 deletions
diff --git a/uisimulator/common/Makefile b/uisimulator/common/Makefile
index b044440adf..e2b6b2a4f8 100644
--- a/uisimulator/common/Makefile
+++ b/uisimulator/common/Makefile
@@ -23,7 +23,7 @@ RM = rm -f
DEBUG = -g
# Use this for simulator-only files
-INCLUDES = -I. -I$(OBJDIR) -I$(FIRMDIR)/export -I$(APPSDIR)
+INCLUDES = -I. -I$(OBJDIR) -I$(FIRMDIR)/export -I$(APPSDIR) -I$(ROOTDIR)/uisimulator/$(SIMVER)
SRC := $(shell cat SOURCES | gcc -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \
$(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - )
@@ -38,7 +38,7 @@ DIRS = .
CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) $(GCCOPTS)
-OUTFILE = $(OBJDIR)/libsim.a
+OUTFILE = $(OBJDIR)/libcomsim.a
all: $(OUTFILE)
@@ -46,7 +46,7 @@ include $(TOOLSDIR)/make.inc
clean:
@echo "cleaning commonsim"
- @$(RM) $(OBJS) *~ core $(DEPFILE)
+ @$(RM) $(OBJS) *~ core $(DEPFILE) $(OUTFILE)
$(OUTFILE): $(OBJS)
@echo "AR+RANLIB $@"
diff --git a/uisimulator/common/dir.h b/uisimulator/common/dir.h
deleted file mode 100644
index 18cfbb3736..0000000000
--- a/uisimulator/common/dir.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
- *
- * 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 _SIM_DIR_H_
-#define _SIM_DIR_H_
-
-#include <sys/types.h>
-
-#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */
-#define dirent sim_dirent
-#include "../../firmware/include/dir.h"
-#undef dirent
-
-typedef void * MYDIR;
-
-extern MYDIR *sim_opendir(const char *name);
-extern struct sim_dirent* sim_readdir(MYDIR* dir);
-extern int sim_closedir(MYDIR *dir);
-extern int sim_mkdir(const char *name, int mode);
-extern int sim_rmdir(char *name);
-
-#define DIR MYDIR
-#define dirent sim_dirent
-#define opendir(x) sim_opendir(x)
-#define readdir(x) sim_readdir(x)
-#define closedir(x) sim_closedir(x)
-#define mkdir(x, y) sim_mkdir(x, y)
-#define rmdir(x) sim_rmdir(x)
-
-#endif
diff --git a/uisimulator/common/file.h b/uisimulator/common/file.h
deleted file mode 100644
index 7ea59a0b74..0000000000
--- a/uisimulator/common/file.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
- *
- * 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 _SIM_FILE_H_
-#define _SIM_FILE_H_
-
-#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
-#else
-#include <stdio.h>
-#endif
-
-#include <sys/types.h>
-
-#ifdef WIN32
-#ifndef _commit
-extern int _commit( int handle );
-
-#ifdef _MSC_VER
-typedef unsigned int mode_t;
-#endif
-
-#endif
-#endif
-
-int sim_open(const char *name, int opts);
-int sim_close(int fd);
-int sim_rename(const char *oldpath, const char *newpath);
-off_t sim_filesize(int fd);
-int sim_creat(const char *name, mode_t mode);
-int sim_remove(const char *name);
-
-#ifndef NO_REDEFINES_PLEASE
-#define open(x,y) sim_open(x,y)
-#define close(x) sim_close(x)
-#define filesize(x) sim_filesize(x)
-#define creat(x,y) sim_creat(x,y)
-#define remove(x) sim_remove(x)
-#define rename(x,y) sim_rename(x,y)
-#ifdef WIN32
-#define fsync _commit
-#endif
-#endif
-
-#include "../../firmware/include/file.h"
-
-#ifndef WIN32
-int open(const char* pathname, int flags);
-int close(int fd);
-int printf(const char *format, ...);
-int ftruncate(int fd, off_t length);
-int fsync(int fd);
-
-off_t lseek(int fildes, off_t offset, int whence);
-ssize_t read(int fd, void *buf, size_t count);
-ssize_t write(int fd, const void *buf, size_t count);
-#endif
-
-#endif
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 6335735f8f..48b888a027 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
#include <sys/stat.h>
#ifdef __FreeBSD__
#include <sys/param.h>
@@ -28,6 +29,10 @@
#include <sys/vfs.h>
#endif
+#ifdef WIN32
+#include <windows.h>
+#endif
+
#ifndef _MSC_VER
#include <dirent.h>
#include <unistd.h>
@@ -35,18 +40,27 @@
#include "dir-win32.h"
#endif
+#define MAX_PATH 260
+
#include <fcntl.h>
#include "debug.h"
-#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */
-#define dirent sim_dirent
-#define DIR SIMDIR
-#include "../../firmware/include/dir.h"
-#undef dirent
-#undef DIR
-
#define SIMULATOR_ARCHOS_ROOT "archos"
+struct sim_dirent {
+ unsigned char d_name[MAX_PATH];
+ int attribute;
+ int size;
+ int startcluster;
+ unsigned short wrtdate; /* Last write date */
+ unsigned short wrttime; /* Last write time */
+};
+
+struct dirstruct {
+ void *dir; /* actually a DIR* dir */
+ char *name;
+} SIM_DIR;
+
struct mydir {
DIR *dir;
char *name;
@@ -113,6 +127,8 @@ struct sim_dirent *sim_readdir(MYDIR *dir)
dir->name, x11->d_name);
stat(buffer, &s); /* get info */
+#define ATTR_DIRECTORY 0x10
+
secret.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0;
secret.size = s.st_size;
secret.wrtdate = (unsigned short)(s.st_mtime >> 16);
@@ -181,6 +197,7 @@ int sim_mkdir(const char *name, mode_t mode)
debugf("We create the real directory '%s'\n", buffer);
#ifdef WIN32
+ /* since we build with -DNOCYGWIN we have the plain win32 version */
return (mkdir)(buffer);
#else
return (mkdir)(buffer, 0666);
@@ -260,3 +277,96 @@ void fat_size(unsigned int* size, unsigned int* free)
}
#endif
}
+
+int sim_fsync(int fd)
+{
+#ifdef WIN32
+ return _commit(fd);
+#else
+ return fsync(fd);
+#endif
+}
+
+#ifdef WIN32
+/* sim-win32 */
+typedef enum plugin_status (*plugin_fn)(void* api, void* param);
+#define dlopen(_x_, _y_) LoadLibrary(_x_)
+#define dlsym(_x_, _y_) (plugin_fn)GetProcAddress(_x_, _y_)
+#define dlclose(_x_) FreeLibrary(_x_)
+#define dlerror() "Unknown"
+#else
+/* sim-x11 */
+#include <dlfcn.h>
+#endif
+
+void *sim_plugin_load(char *plugin, int *fd)
+{
+ void* pd;
+ char path[256];
+ char buf[256];
+ int (*plugin_start)(void * api, void* param);
+
+ snprintf(path, sizeof path, "archos%s", plugin);
+
+ *fd = -1;
+
+ pd = dlopen(path, RTLD_NOW);
+ if (!pd) {
+ snprintf(buf, sizeof buf, "failed to load %s", plugin);
+ DEBUGF("dlopen(%s): %s\n",path,dlerror());
+ dlclose(pd);
+ return NULL;
+ }
+
+ plugin_start = dlsym(pd, "plugin_start");
+ if (!plugin_start) {
+ plugin_start = dlsym(pd, "_plugin_start");
+ if (!plugin_start) {
+ dlclose(pd);
+ return NULL;
+ }
+ }
+ *fd = pd; /* success */
+ return plugin_start;
+}
+
+void sim_plugin_close(int pd)
+{
+ dlclose(pd);
+}
+
+#ifndef WIN32
+/* the win32 version is in debug-win32.c */
+
+void debug_init(void)
+{
+ /* nothing to be done */
+}
+
+void debugf(const char *fmt, ...)
+{
+ va_list ap;
+ va_start( ap, fmt );
+ vfprintf( stderr, fmt, ap );
+ va_end( ap );
+}
+
+void ldebugf(const char* file, int line, const char *fmt, ...)
+{
+ va_list ap;
+ va_start( ap, fmt );
+ fprintf( stderr, "%s:%d ", file, line );
+ vfprintf( stderr, fmt, ap );
+ va_end( ap );
+}
+
+#endif
+
+int sim_ftruncate(int fd, off_t length)
+{
+#ifdef WIN32
+ return _chsize(fd, length);
+#else
+ return ftruncate(fd, length);
+#endif
+}
diff --git a/uisimulator/common/lcd-common.c b/uisimulator/common/lcd-common.c
index c69ef06f1f..95c42ad8db 100644
--- a/uisimulator/common/lcd-common.c
+++ b/uisimulator/common/lcd-common.c
@@ -25,9 +25,9 @@
#include "lcd.h"
#ifdef WIN32
- #include "lcd-win32.h"
+#include "lcd-win32.h"
#else
- #include "lcd-x11.h"
+#include "lcd-x11.h"
#endif
void lcd_blit(const unsigned char* p_data, int x, int y, int width, int height,
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index c43fb5f1f2..3ed16e8e34 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -28,7 +28,7 @@
#include "string.h"
#include "lcd.h"
-#include "settings.h"
+
#include "ata.h" /* for volume definitions */
extern char having_new_lcd;
@@ -285,5 +285,6 @@ void remove_thread(int threadnum)
}
/* assure an unused place to direct virtual pointers to */
+#define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */
unsigned char vp_dummy[VIRT_SIZE];
diff --git a/uisimulator/win32/Makefile b/uisimulator/win32/Makefile
index 4878d85bf1..f429cad8b5 100644
--- a/uisimulator/win32/Makefile
+++ b/uisimulator/win32/Makefile
@@ -29,8 +29,6 @@ INCLUDES = -I. -I$(SIMCOMMON) -I$(OBJDIR) -I$(FIRMDIR)/export -I$(APPSDIR)
DEFINES = -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \
$(TARGET) -DAPPSVERSION=\"$(VERSION)\" -DMEM=${MEMORYSIZE} $(EXTRA_DEFINES)
-LDFLAGS = -lgdi32 -luser32
-
SRC := $(shell cat SOURCES | gcc -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \
$(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - )
OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
@@ -40,20 +38,15 @@ DIRS = .
CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) -W -Wall -mno-cygwin
-DLLTOOLFLAGS = --export-all
-DLLWRAPFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 -mno-cygwin
-
OUTFILE = $(OBJDIR)/libsim.a
all: $(OUTFILE)
@echo "MAKE in common sim"
$(MAKE) -C $(SIMCOMMON)
-include $(TOOLSDIR)/make.inc
-
-$(OUTFILE): $(OBJS)
+$(OUTFILE): $(OBJS) $(OBJDIR)/UI256.bmp $(OBJDIR)/uisw32-res.o
@echo "AR+RANLIB $@"
- @$(AR) ruv $@ $(OBJS) >/dev/null 2>&1
+ @$(AR) ruv $@ $(OBJS) $(OBJDIR)/uisw32-res.o >/dev/null 2>&1
@$(RANLIB) $@
clean:
@@ -68,6 +61,8 @@ $(OBJDIR)/UI256.bmp: UI-$(ARCHOS).bmp
@cp $< $@
$(OBJDIR)/uisw32-res.o: uisw32.rc $(OBJDIR)/UI256.bmp
- $(WINDRES) -I$(OBJDIR) -i $< -o $@
+ $(WINDRES) --include-dir $(OBJDIR) -i $< -o $@
+
+include $(TOOLSDIR)/make.inc
-include $(DEPFILE)
diff --git a/uisimulator/win32/SOURCES b/uisimulator/win32/SOURCES
index 6a52c5ed5e..a88115ade6 100644
--- a/uisimulator/win32/SOURCES
+++ b/uisimulator/win32/SOURCES
@@ -1,6 +1,8 @@
button.c
debug-win32.c
+#if 0 /* this is only for non-cygwin simulator builds */
dir-win32.c
+#endif
kernel.c
lcd-win32.c
mpeg-win32.c
diff --git a/uisimulator/win32/dir-win32.h b/uisimulator/win32/dir-win32.h
index 888a83767a..95ce326e9f 100644
--- a/uisimulator/win32/dir-win32.h
+++ b/uisimulator/win32/dir-win32.h
@@ -20,7 +20,6 @@
#define _DIR_WIN32_H_
#include <stdbool.h>
-#include "file.h"
struct dirent {
unsigned char d_name[MAX_PATH];
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile
index 68815fe8d8..0c0c31183d 100644
--- a/uisimulator/x11/Makefile
+++ b/uisimulator/x11/Makefile
@@ -43,8 +43,7 @@ CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) $(GCCOPTS)
OUTFILE = $(OBJDIR)/libsim.a
all: $(OUTFILE)
- @echo "MAKE in common sim"
- $(MAKE) -C $(SIMCOMMON)
+ @$(MAKE) -C $(SIMCOMMON)
include $(TOOLSDIR)/make.inc
diff --git a/uisimulator/x11/kernel.h b/uisimulator/x11/kernel.h
deleted file mode 100644
index f165d92eb3..0000000000
--- a/uisimulator/x11/kernel.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
- *
- * 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.
- *
- ****************************************************************************/
-
-#include "../../firmware/export/kernel.h"
-
-#ifndef NO_REDEFINES_PLEASE
-
-#define sleep(x) sim_sleep(x)
-#define mutex_init(x) (void)x
-#define mutex_lock(x) (void)x
-#define mutex_unlock(x) (void)x
-
-#endif
-
-void sim_sleep(int);
diff --git a/uisimulator/x11/thread.c b/uisimulator/x11/thread.c
index e37373dc54..25adf6a3c0 100644
--- a/uisimulator/x11/thread.c
+++ b/uisimulator/x11/thread.c
@@ -94,3 +94,18 @@ void sim_sleep(int ticks)
pthread_mutex_lock(&mp); /* get it again */
}
+
+void mutex_init(struct mutex *m)
+{
+ (void)m;
+}
+
+void mutex_lock(struct mutex *m)
+{
+ (void)m;
+}
+
+void mutex_unlock(struct mutex *m)
+{
+ (void)m;
+}