1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Daniel Stenberg 2005-02-22 12:19:12 +00:00
parent 376057d2b6
commit 22b7701fe7
33 changed files with 327 additions and 339 deletions

View file

@ -43,6 +43,8 @@ MAXOUTFILE = $(OBJDIR)/romstart
ifdef SIMVER
# this is a sim build
all: $(OBJDIR)/$(BINARY) $(CODECS) $(ROCKS)
@$(MAKE) -C $(SIMDIR)
@$(MAKE) -C $(ROOTDIR)/uisimulator/common
else
# regular target build
all: $(OBJDIR)/$(BINARY) $(FLASHFILE) $(CODECS) $(ROCKS) $(ARCHOSROM)
@ -101,12 +103,22 @@ $(OBJDIR)/$(BINARY) : $(OBJDIR)/rockbox.bin
else
# this is a simulator build
$(OBJDIR)/$(BINARY) : $(OBJS) $(OBJDIR)/librockbox.a $(DEPFILE) $(OBJDIR)/libsim.a
ifeq ($(SIMVER), win32)
# OK, this is ugly but we need it on the link line to make it do right
EXTRAOBJ = $(OBJDIR)/uisw32-res.o
endif
$(OBJDIR)/$(BINARY) : $(OBJS) $(OBJDIR)/librockbox.a $(DEPFILE) $(OBJDIR)/libsim.a $(OBJDIR)/libcomsim.a
@echo "LD $(BINARY)"
$(CC) $(GCCOPTS) -o $@ $(OBJS) $(LDOPTS) -L$(OBJDIR) -lrockbox -lsim -Wl,-Map,$(OBJDIR)/rockbox.map
$(CC) $(GCCOPTS) -o $@ $(OBJS) -L$(OBJDIR) -lrockbox -lsim -lcomsim $(LDOPTS) $(EXTRAOBJ) -Wl,-Map,$(OBJDIR)/rockbox.map
$(OBJDIR)/libsim.a:
@$(MAKE) -C $(SIMDIR)
$(OBJDIR)/libcomsim.a:
@$(MAKE) -C $(ROOTDIR)/uisimulator/common
endif
$(OBJDIR)/rockbox.ucl: $(OBJDIR)/rockbox.bin

View file

@ -231,7 +231,7 @@ static void new_playlist(struct playlist_info* playlist, const char *dir,
if (playlist->control_fd >= 0)
{
if (fprintf(playlist->control_fd, "P:%d:%s:%s\n",
if (fdprintf(playlist->control_fd, "P:%d:%s:%s\n",
PLAYLIST_CONTROL_FILE_VERSION, dir, file) > 0)
fsync(playlist->control_fd);
else
@ -279,7 +279,7 @@ static int check_control(struct playlist_info* playlist)
playlist->filename[playlist->dirlen-1] = '\0';
if (fprintf(playlist->control_fd, "P:%d:%s:%s\n",
if (fdprintf(playlist->control_fd, "P:%d:%s:%s\n",
PLAYLIST_CONTROL_FILE_VERSION, dir, file) > 0)
fsync(playlist->control_fd);
else
@ -499,13 +499,13 @@ static int add_track_to_playlist(struct playlist_info* playlist,
if (lseek(playlist->control_fd, 0, SEEK_END) >= 0)
{
if (fprintf(playlist->control_fd, "%c:%d:%d:", (queue?'Q':'A'),
if (fdprintf(playlist->control_fd, "%c:%d:%d:", (queue?'Q':'A'),
position, playlist->last_insert_pos) > 0)
{
/* save the position in file where track name is written */
seek_pos = lseek(playlist->control_fd, 0, SEEK_CUR);
if (fprintf(playlist->control_fd, "%s\n", filename) > 0)
if (fdprintf(playlist->control_fd, "%s\n", filename) > 0)
result = 0;
}
}
@ -697,7 +697,7 @@ static int remove_track_from_playlist(struct playlist_info* playlist,
if (lseek(playlist->control_fd, 0, SEEK_END) >= 0)
{
if (fprintf(playlist->control_fd, "D:%d\n", position) > 0)
if (fdprintf(playlist->control_fd, "D:%d\n", position) > 0)
{
fsync(playlist->control_fd);
result = 0;
@ -1098,10 +1098,10 @@ static int flush_pending_control(struct playlist_info* playlist)
if (lseek(playlist->control_fd, 0, SEEK_END) >= 0)
{
if (global_settings.resume_seed == 0)
result = fprintf(playlist->control_fd, "U:%d\n",
result = fdprintf(playlist->control_fd, "U:%d\n",
playlist->first_index);
else
result = fprintf(playlist->control_fd, "S:%d:%d\n",
result = fdprintf(playlist->control_fd, "S:%d:%d\n",
global_settings.resume_seed, playlist->first_index);
if (result > 0)
@ -1737,7 +1737,7 @@ int playlist_next(int steps)
if (lseek(playlist->control_fd, 0, SEEK_END) >= 0)
{
if (fprintf(playlist->control_fd, "R\n") > 0)
if (fdprintf(playlist->control_fd, "R\n") > 0)
{
fsync(playlist->control_fd);
result = 0;
@ -2407,7 +2407,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
break;
}
if (fprintf(fd, "%s\n", tmp_buf) < 0)
if (fdprintf(fd, "%s\n", tmp_buf) < 0)
{
splash(HZ*2, true, str(LANG_PLAYLIST_CONTROL_UPDATE_ERROR));
result = -1;

View file

@ -50,18 +50,6 @@
#include "widgets.h"
#endif
#ifdef SIMULATOR
#include <debug.h>
#ifdef WIN32
#include "plugin-win32.h"
#else
#include <dlfcn.h>
#endif
#define PREFIX(_x_) sim_ ## _x_
#else
#define PREFIX(_x_) _x_
#endif
#if MEM >= 32
#define PLUGIN_BUFFER_SIZE 0xC0000
#else
@ -70,7 +58,9 @@
#ifdef SIMULATOR
static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE];
void *sim_plugin_load(char *plugin, int *fd);
#else
#define sim_plugin_close(x)
extern unsigned char pluginbuf[];
#include "bitswap.h"
#endif
@ -142,16 +132,16 @@ static const struct plugin_api rockbox_api = {
/* file */
(open_func)PREFIX(open),
PREFIX(close),
close,
(read_func)read,
lseek,
(creat_func)PREFIX(creat),
(write_func)write,
PREFIX(remove),
PREFIX(rename),
ftruncate,
PREFIX(ftruncate),
PREFIX(filesize),
fprintf,
fdprintf,
read_line,
settings_parseline,
#ifndef SIMULATOR
@ -189,6 +179,9 @@ static const struct plugin_api rockbox_api = {
memcpy,
_ctype_,
atoi,
strchr,
strcat,
memcmp,
/* sound */
mpeg_sound_set,
@ -201,7 +194,7 @@ static const struct plugin_api rockbox_api = {
#endif
/* playback control */
mpeg_play,
PREFIX(mpeg_play),
mpeg_stop,
mpeg_pause,
mpeg_resume,
@ -264,10 +257,6 @@ static const struct plugin_api rockbox_api = {
/* new stuff at the end, sort into place next time
the API gets incompatible */
strchr,
strcat,
memcmp
};
int plugin_load(const char* plugin, void* parameter)
@ -275,12 +264,8 @@ int plugin_load(const char* plugin, void* parameter)
enum plugin_status (*plugin_start)(struct plugin_api* api, void* param);
int rc;
char buf[64];
#ifdef SIMULATOR
void* pd;
char path[256];
#else
int fd;
#endif
#ifdef HAVE_LCD_BITMAP
int xm,ym;
#endif
@ -301,26 +286,9 @@ int plugin_load(const char* plugin, void* parameter)
lcd_clear_display();
#endif
#ifdef SIMULATOR
snprintf(path, sizeof path, "archos%s", plugin);
pd = dlopen(path, RTLD_NOW);
if (!pd) {
snprintf(buf, sizeof buf, str(LANG_PLUGIN_CANT_OPEN), plugin);
splash(HZ*2, true, buf);
DEBUGF("dlopen(%s): %s\n",path,dlerror());
dlclose(pd);
plugin_start = sim_plugin_load(plugin, &fd);
if(!plugin_start)
return -1;
}
plugin_start = dlsym(pd, "plugin_start");
if (!plugin_start) {
plugin_start = dlsym(pd, "_plugin_start");
if (!plugin_start) {
splash(HZ*2, true, "Can't find entry point");
dlclose(pd);
return -1;
}
}
#else
fd = open(plugin, O_RDONLY);
if (fd < 0) {
@ -379,9 +347,7 @@ int plugin_load(const char* plugin, void* parameter)
break;
}
#ifdef SIMULATOR
dlclose(pd);
#endif
sim_plugin_close(fd);
#ifdef HAVE_LCD_BITMAP
/* restore margins */

View file

@ -32,6 +32,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include "config.h"
#include "dir.h"
#include "kernel.h"
@ -51,7 +52,9 @@
#ifdef PLUGIN
#if defined(DEBUG) || defined(SIMULATOR)
#undef DEBUGF
#define DEBUGF rb->debugf
#undef LDEBUGF
#define LDEBUGF rb->debugf
#else
#define DEBUGF(...)
@ -59,13 +62,19 @@
#endif
#endif
#ifdef SIMULATOR
#define PREFIX(_x_) sim_ ## _x_
#else
#define PREFIX(_x_) _x_
#endif
/* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 31
#define PLUGIN_API_VERSION 32
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 29
#define PLUGIN_MIN_API_VERSION 32
/* plugin return codes */
enum plugin_status {
@ -165,17 +174,17 @@ struct plugin_api {
void (*button_clear_queue)(void);
/* file */
int (*open)(const char* pathname, int flags);
int (*PREFIX(open))(const char* pathname, int flags);
int (*close)(int fd);
ssize_t (*read)(int fd, void* buf, size_t count);
off_t (*lseek)(int fd, off_t offset, int whence);
int (*creat)(const char *pathname, mode_t mode);
int (*PREFIX(creat))(const char *pathname, mode_t mode);
ssize_t (*write)(int fd, const void* buf, size_t count);
int (*remove)(const char* pathname);
int (*rename)(const char* path, const char* newname);
int (*ftruncate)(int fd, off_t length);
off_t (*filesize)(int fd);
int (*fprintf)(int fd, const char *fmt, ...);
int (*PREFIX(remove))(const char* pathname);
int (*PREFIX(rename))(const char* path, const char* newname);
int (*PREFIX(ftruncate))(int fd, off_t length);
off_t (*PREFIX(filesize))(int fd);
int (*fdprintf)(int fd, const char *fmt, ...);
int (*read_line)(int fd, char* buffer, int buffer_size);
bool (*settings_parseline)(char* line, char** name, char** value);
#ifndef SIMULATOR
@ -188,7 +197,7 @@ struct plugin_api {
struct dirent* (*readdir)(DIR* dir);
/* kernel/ system */
void (*sleep)(int ticks);
void (*PREFIX(sleep))(int ticks);
void (*yield)(void);
long* current_tick;
long (*default_event_handler)(long event);
@ -213,6 +222,9 @@ struct plugin_api {
void* (*memcpy)(void *out, const void *in, size_t n);
const char *_ctype_;
int (*atoi)(const char *str);
char *(*strchr)(const char *s, int c);
char *(*strcat)(char *s1, const char *s2);
int (*memcmp)(const void *s1, const void *s2, size_t n);
/* sound */
void (*mpeg_sound_set)(int setting, int value);
@ -225,7 +237,7 @@ struct plugin_api {
#endif
/* playback control */
void (*mpeg_play)(int offset);
void (*PREFIX(mpeg_play))(int offset);
void (*mpeg_stop)(void);
void (*mpeg_pause)(void);
void (*mpeg_resume)(void);
@ -295,10 +307,6 @@ struct plugin_api {
/* new stuff at the end, sort into place next time
the API gets incompatible */
char *(*strchr)(const char *s, int c);
char *(*strcat)(char *s1, const char *s2);
int (*memcmp)(const void *s1, const void *s2, size_t n);
};
/* defined by the plugin loader (plugin.c) */

View file

@ -71,7 +71,13 @@ $(OBJDIR)/%.rock : $(OBJDIR)/%.o $(APPSDIR)/plugin.h
@echo "DLL $@"
@$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $<
@$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $< $(OBJDIR)/libplugin.a -o $@
ifeq ($(UNAME),CYGWIN)
# 'x' must be kept or you'll have "Win32 error 5"
# $ fgrep 5 /usr/include/w32api/winerror.h | head -1
# #define ERROR_ACCESS_DENIED 5L
else
@chmod -x $@
endif
endif # end of win32-simulator
endif # end of simulator section

View file

@ -325,7 +325,7 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
}
if (new_mod)
{
rb->fprintf(fq, "%02d%02d%04d%01d%01d%s\n",
rb->fdprintf(fq, "%02d%02d%04d%01d%01d%s\n",
memos[changed].day,
memos[changed].month,
memos[changed].year,

View file

@ -38,24 +38,24 @@ int configfile_save(const char *filename, struct configdata *cfg,
if(fd < 0)
return fd*10 - 1;
cfg_rb->fprintf(fd, "file version: %d\n", version);
cfg_rb->fdprintf(fd, "file version: %d\n", version);
for(i = 0;i < num_items;i++) {
switch(cfg[i].type) {
case TYPE_INT:
cfg_rb->fprintf(fd, "%s: %d\n",
cfg_rb->fdprintf(fd, "%s: %d\n",
cfg[i].name,
*cfg[i].val);
break;
case TYPE_ENUM:
cfg_rb->fprintf(fd, "%s: %s\n",
cfg_rb->fdprintf(fd, "%s: %s\n",
cfg[i].name,
cfg[i].values[*cfg[i].val]);
break;
case TYPE_STRING:
cfg_rb->fprintf(fd, "%s: %s\n",
cfg_rb->fdprintf(fd, "%s: %s\n",
cfg[i].name,
cfg[i].string);
break;

View file

@ -1127,13 +1127,13 @@ static void save_cfg_table(const struct bit_entry* p_table, int count, int fd)
if (p_run->cfg_val == NULL) /* write as number */
{
fprintf(fd, "%s: %ld\r\n", p_run->cfg_name, value);
fdprintf(fd, "%s: %ld\r\n", p_run->cfg_name, value);
}
else /* write as item */
{
const char* p = p_run->cfg_val;
fprintf(fd, "%s: ", p_run->cfg_name);
fdprintf(fd, "%s: ", p_run->cfg_name);
while(value >= 0)
{
@ -1146,9 +1146,9 @@ static void save_cfg_table(const struct bit_entry* p_table, int count, int fd)
write(fd, &c, 1); /* char by char, this is lame, OK */
}
fprintf(fd, "\r\n");
fdprintf(fd, "\r\n");
if (p_run->cfg_val != off_on) /* explaination for non-bool */
fprintf(fd, "# (possible values: %s)\r\n", p_run->cfg_val);
fdprintf(fd, "# (possible values: %s)\r\n", p_run->cfg_val);
}
}
}
@ -1195,21 +1195,21 @@ bool settings_save_config(void)
return false;
}
fprintf(fd, "# >>> .cfg file created by rockbox %s <<<\r\n", appsversion);
fprintf(fd, "# >>> http://rockbox.haxx.se <<<\r\n#\r\n");
fprintf(fd, "#\r\n# wps / language / font \r\n#\r\n");
fdprintf(fd, "# .cfg file created by rockbox %s - ", appsversion);
fdprintf(fd, "http://www.rockbox.org\r\n#\r\n");
fdprintf(fd, "#\r\n# wps / language / font \r\n#\r\n");
if (global_settings.wps_file[0] != 0)
fprintf(fd, "wps: %s/%s.wps\r\n", ROCKBOX_DIR,
fdprintf(fd, "wps: %s/%s.wps\r\n", ROCKBOX_DIR,
global_settings.wps_file);
if (global_settings.lang_file[0] != 0)
fprintf(fd, "lang: %s/%s.lng\r\n", ROCKBOX_DIR LANG_DIR,
fdprintf(fd, "lang: %s/%s.lng\r\n", ROCKBOX_DIR LANG_DIR,
global_settings.lang_file);
#ifdef HAVE_LCD_BITMAP
if (global_settings.font_file[0] != 0)
fprintf(fd, "font: %s/%s.fnt\r\n", ROCKBOX_DIR FONT_DIR,
fdprintf(fd, "font: %s/%s.fnt\r\n", ROCKBOX_DIR FONT_DIR,
global_settings.font_file);
#endif

View file

@ -231,7 +231,7 @@ static int fprfunc(void *pr, unsigned char letter)
}
int fprintf(int fd, const char *fmt, ...)
int fdprintf(int fd, const char *fmt, ...)
{
bool ok;
va_list ap;

View file

@ -216,28 +216,4 @@ void debugf(const char *fmt, ...)
#endif
}
#else /* SIMULATOR code coming up */
void debug_init(void)
{
}
extern void *stderr;
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

View file

@ -65,6 +65,10 @@ struct mutex
/* global tick variable */
extern long current_tick;
#ifdef SIMULATOR
#define sleep(x) sim_sleep(x)
#endif
/* kernel functions */
extern void kernel_init(void);
extern void yield(void);

View file

@ -27,6 +27,10 @@
#define STYLE_DEFAULT 0
#define STYLE_INVERT 1
#ifdef SIMULATOR
#define lcd_icon(x,y) sim_lcd_icon(x,y)
#endif
/* common functions */
extern void lcd_init(void);
extern void lcd_clear_display(void);
@ -61,10 +65,6 @@ extern void lcd_update_rect(int x, int y, int width, int height);
#define lcd_update_rect(x,y,w,h)
#endif
#if defined(SIMULATOR)
#include "sim_icons.h"
#endif
#ifdef HAVE_LCD_CHARCELLS
/* Icon definitions for lcd_icon() */

View file

@ -42,6 +42,10 @@
/* For ID3 info and VBR header */
#define MPEG_RESERVED_HEADER_SPACE (4096 + 1500)
#ifdef SIMULATOR
#define mpeg_play(x) sim_mpeg_play(x)
#endif
struct mpeg_debug
{
int mp3buflen;

View file

@ -30,6 +30,16 @@
#define ATTR_ARCHIVE 0x20
#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
#ifdef SIMULATOR
#define dirent sim_dirent
#define DIR SIM_DIR
#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
#ifndef DIRENT_DEFINED
struct dirent {
@ -42,12 +52,10 @@ struct dirent {
};
#endif
#ifndef SIMULATOR
#include "fat.h"
typedef struct {
#ifndef SIMULATOR
bool busy;
int startcluster;
struct fat_dir fatdir;
@ -56,25 +64,13 @@ typedef struct {
#ifdef HAVE_MULTIVOLUME
int volumecounter; /* running counter for faked volume entries */
#endif
#else
/* simulator: */
void *dir; /* actually a DIR* dir */
char *name;
#endif
} DIR;
#else /* SIMULATOR */
#ifdef WIN32
#ifndef __MINGW32__
#include <io.h>
#endif /* __MINGW32__ */
typedef struct DIRtag
{
struct dirent fd;
int handle;
} DIR;
#endif /* WIN32 */
#endif /* SIMULATOR */
#ifndef DIRFUNCTIONS_DEFINED
extern DIR* opendir(const char* name);

View file

@ -20,6 +20,8 @@
#ifndef _FILE_H_
#define _FILE_H_
#include <sys/types.h>
#undef MAX_PATH /* this avoids problems when building simulator */
#define MAX_PATH 260
@ -42,30 +44,14 @@
#define O_TRUNC 0x10
#endif
#if !defined(__ssize_t_defined) && !defined(_SSIZE_T_) && !defined(ssize_t)
#define __ssize_t_defined
#define _SSIZE_T_
#define ssize_t ssize_t
typedef signed long ssize_t;
#endif
#if !defined(__off_t_defined) && !defined(_OFF_T_) && !defined(off_t)
#define __off_t_defined
#define _OFF_T_
#define off_t off_t
typedef signed long off_t;
#endif
#if !defined(__mode_t_defined) && !defined(_MODE_T_) && !defined(mode_t)
#define __mode_t_defined
#define _MODE_T_
#define mode_t mode_t
typedef unsigned int mode_t;
#endif
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned long size_t;
#ifdef SIMULATOR
#define open(x,y) sim_open(x,y)
#define creat(x,y) sim_creat(x,y)
#define remove(x) sim_remove(x)
#define rename(x,y) sim_rename(x,y)
#define filesize(x) sim_filesize(x)
#define fsync(x) sim_fsync(x)
#define ftruncate(x,y) sim_ftruncate(x,y)
#endif
typedef int (*open_func)(const char* pathname, int flags);
@ -75,7 +61,6 @@ typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
int(*_compar)(const void *, const void *));
#ifndef SIMULATOR
extern int open(const char* pathname, int flags);
extern int close(int fd);
extern int fsync(int fd);
@ -88,6 +73,5 @@ extern int rename(const char* path, const char* newname);
extern int ftruncate(int fd, off_t length);
extern off_t filesize(int fd);
extern int release_files(int volume);
#endif /* SIMULATOR */
#endif

View file

@ -33,7 +33,7 @@ int snprintf (char *buf, size_t size, const char *fmt, ...)
ATTRIBUTE_PRINTF(3, 4);
int vsnprintf (char *buf, int size, const char *fmt, va_list ap);
int fprintf (int fd, const char *fmt, ...)
int fdprintf (int fd, const char *fmt, ...)
ATTRIBUTE_PRINTF(2, 3);
#endif /* __SPRINTF_H__ */

View file

@ -39,7 +39,6 @@ int vsnprintf (char *buf, int size, const char *fmt, __VALIST ap);
#ifdef SIMULATOR
typedef void FILE;
int vfprintf(FILE *stream, const char *format, __VALIST ap);
int fprintf(FILE *stream, const char *format, ...);
#ifdef WIN32
#define FILENAME_MAX 260 /* ugly hard-coded value of a limit that is set
in file.h */

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
* Copyright (C) 2005 by Daniel Stenberg
*
* 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.
@ -17,15 +17,33 @@
*
****************************************************************************/
#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
#ifndef _SYS_TYPES_H_
#define _SYS_TYPES_H_
#if !defined(__ssize_t_defined) && !defined(_SSIZE_T_) && !defined(ssize_t)
#define __ssize_t_defined
#define _SSIZE_T_
#define ssize_t ssize_t
typedef signed long ssize_t;
#endif
void sim_sleep(int);
#if !defined(__off_t_defined) && !defined(_OFF_T_) && !defined(off_t)
#define __off_t_defined
#define _OFF_T_
#define off_t off_t
typedef signed long off_t;
#endif
#if !defined(__mode_t_defined) && !defined(_MODE_T_) && !defined(mode_t)
#define __mode_t_defined
#define _MODE_T_
#define mode_t mode_t
typedef unsigned int mode_t;
#endif
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned long size_t;
#endif
#endif /* _SYS_TYPES_H */

View file

@ -352,6 +352,11 @@ int tick_remove_task(void (*f)(void))
return -1;
}
#ifndef SIMULATOR
/*
* Simulator versions in uisimulator/SIMVER/
*/
/****************************************************************************
* Simple mutex functions
****************************************************************************/
@ -375,3 +380,5 @@ void mutex_unlock(struct mutex *m)
{
m->locked = false;
}
#endif

View file

@ -39,8 +39,6 @@
#include "usb.h"
#include "file.h"
#include "hwcompat.h"
#else
#include "mpegplay.h"
#endif /* #ifndef SIMULATOR */
#include "bitswap.h"

12
tools/configure vendored
View file

@ -48,19 +48,29 @@ simcc () {
# default tool setup for native building
prefixtools ""
GCCOPTS='-W -Wall -g -fno-builtin -I$(ROOTDIR)/uisimulator/common -I$(ROOTDIR)/uisimulator/$(SIMVER)'
GCCOPTS='-W -Wall -g -fno-builtin'
output="rockboxui" # use this as default output binary name
case $uname in
CYGWIN*)
echo "Cygwin host detected"
if [ "$simver" = "win32" ]; then
# win32 version
GCCOPTS="$GCCOPTS -mno-cygwin -DNOCYGWIN"
LDOPTS="-lgdi32 -luser32 -mno-cygwin"
else
# x11 version
GCCOPTS="$GCCOPTS -DNOCYGWIN"
LDOPTS='-L/usr/X11R6/lib -lSM -lICE -lXt -lX11 -lXmu -lSM -lICE -lX11 -lpthread'
fi
output="rockboxui.exe" # use this as output binary name
;;
Linux)
echo "Linux host detected"
GCCOPTS="$GCCOPTS"
LDOPTS='-L/usr/X11R6/lib -lX11 -lm -lXt -lXmu -lnsl -ldl -lpthread'
if [ "$simver" = "win32" ]; then
crosswincc # setup cross-compiler

View file

@ -3,7 +3,7 @@
$(OBJDIR)/%.o: %.c
@mkdir -p `dirname $@`
@echo "CC $<"
@$(CC) $(CFLAGS) -c $< -o $@
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o: %.S
@mkdir -p `dirname $@`

View file

@ -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 $@"

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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,

View file

@ -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];

View file

@ -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)

View file

@ -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

View file

@ -20,7 +20,6 @@
#define _DIR_WIN32_H_
#include <stdbool.h>
#include "file.h"
struct dirent {
unsigned char d_name[MAX_PATH];

View file

@ -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

View file

@ -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;
}