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) |
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) else LCDSRSC = lcd-playersim.c lcd-player.c font-player.c lcd-player-charset.c endif +COMMONSRCS = io.c + FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\ powermgmt.c panic.c mp3data.c sprintf.c buffer.c timefuncs.c @@ -111,8 +113,8 @@ ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP) endif SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \ - button-x11.c io.c thread.c sim_icons.c $(APPS) $(MENUS) $(FIRMSRCS) \ - lcd-common.c + button-x11.c thread.c sim_icons.c $(APPS) $(MENUS) $(FIRMSRCS) \ + $(COMMONSRCS) lcd-common.c ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c) ROCKS := $(ROCKSRC:$(APPDIR)/plugins/%.c=$(OBJDIR)/%.rock) @@ -276,6 +278,9 @@ $(OBJDIR)/stubs.o: $(SIMCOMMON)/stubs.c $(OBJDIR)/sim_icons.o: $(SIMCOMMON)/sim_icons.c $(CC) $(CFLAGS) -c $< -o $@ +$(OBJDIR)/io.o: $(SIMCOMMON)/io.c + $(CC) $(CFLAGS) -c $< -o $@ + $(OBJDIR)/usb.o: $(FIRMWAREDIR)/usb.c $(CC) $(CFLAGS) -c $< -o $@ 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) for(i=0; i< ticks; i++) { bits = get_raw_button(); if(!bits) - x11_sleep(1); + sim_sleep(1); else break; } @@ -193,14 +193,14 @@ int button_get(bool block) do { bits = get_raw_button(); if(block && !bits) - x11_sleep(HZ/10); + sim_sleep(HZ/10); else break; } while(1); if(!block) /* delay a bit */ - x11_sleep(1); + sim_sleep(1); return bits; } 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 @@ -/*************************************************************************** - * __________ __ ___. - * 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 _X11_DIR_H_ -#define _X11_DIR_H_ - -#include <sys/types.h> -typedef void DIR; - -#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */ -#define dirent x11_dirent -#include "../../firmware/include/dir.h" -#undef dirent - -typedef void * MYDIR; - -extern MYDIR *x11_opendir(const char *name); -extern struct x11_dirent* x11_readdir(MYDIR* dir); -extern int x11_closedir(MYDIR *dir); -extern int x11_mkdir(char *name, int mode); -extern int x11_rmdir(char *name); - -#ifndef NO_REDEFINES_PLEASE - -#define DIR MYDIR -#define dirent x11_dirent -#define opendir(x) x11_opendir(x) -#define readdir(x) x11_readdir(x) -#define closedir(x) x11_closedir(x) -#define mkdir(x, y) x11_mkdir(x, y) -#define rmdir(x) x11_rmdir(x) - -#endif - -#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 @@ -/*************************************************************************** - * __________ __ ___. - * 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 ROCKBOX_FILE_H -#define ROCKBOX_FILE_H - -#include <stdio.h> -#include <sys/types.h> - -int x11_open(const char *name, int opts); -int x11_close(int fd); -int x11_filesize(int fd); -int x11_creat(const char *name, mode_t mode); -int x11_remove(char *name); -int x11_rename(char *oldpath, char *newpath); - -#ifndef NO_REDEFINES_PLEASE -#define open(x,y) x11_open(x,y) -#define close(x) x11_close(x) -#define filesize(x) x11_filesize(x) -#define creat(x,y) x11_creat(x,y) -#define remove(x) x11_remove(x) -#define rename(x,y) x11_rename(x,y) -#endif - -#include "../../firmware/include/file.h" - -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 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 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 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. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> -#ifdef __FreeBSD__ -#include <sys/param.h> -#include <sys/mount.h> -#else -#include <sys/vfs.h> -#endif -#include <dirent.h> -#include <unistd.h> - -#include <fcntl.h> -#include "debug.h" - -#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */ -#define dirent x11_dirent -#include "../../firmware/include/dir.h" -#undef dirent - -#define SIMULATOR_ARCHOS_ROOT "archos" - -struct mydir { - DIR *dir; - char *name; -}; - -typedef struct mydir MYDIR; - -MYDIR *x11_opendir(const char *name) -{ - char buffer[256]; /* sufficiently big */ - DIR *dir; - - if(name[0] == '/') { - sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); - dir=(DIR *)opendir(buffer); - } - else - dir=(DIR *)opendir(name); - - if(dir) { - MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR)); - my->dir = dir; - my->name = (char *)strdup(name); - - return my; - } - /* failed open, return NULL */ - return (MYDIR *)0; -} - -struct x11_dirent *x11_readdir(MYDIR *dir) -{ - char buffer[512]; /* sufficiently big */ - static struct x11_dirent secret; - struct stat s; - struct dirent *x11 = (readdir)(dir->dir); - - if(!x11) - return (struct x11_dirent *)0; - - strcpy(secret.d_name, x11->d_name); - - /* build file name */ - sprintf(buffer, SIMULATOR_ARCHOS_ROOT "%s/%s", - dir->name, x11->d_name); - stat(buffer, &s); /* get info */ - - secret.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0; - secret.size = s.st_size; - - return &secret; -} - -void x11_closedir(MYDIR *dir) -{ - free(dir->name); - (closedir)(dir->dir); - - free(dir); -} - - -int x11_open(const char *name, int opts) -{ - char buffer[256]; /* sufficiently big */ - - if(name[0] == '/') { - sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); - - debugf("We open the real file '%s'\n", buffer); - return (open)(buffer, opts); - } - return (open)(name, opts); -} - -int x11_close(int fd) -{ - return (close)(fd); -} - -int x11_creat(const char *name, mode_t mode) -{ - char buffer[256]; /* sufficiently big */ - (void)mode; - if(name[0] == '/') { - sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); - - debugf("We create the real file '%s'\n", buffer); - return (creat)(buffer, 0666); - } - return (creat)(name, 0666); -} - -int x11_mkdir(const char *name, mode_t mode) -{ - char buffer[256]; /* sufficiently big */ - (void)mode; - if(name[0] == '/') { - sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); - - debugf("We create the real directory '%s'\n", buffer); - return (mkdir)(buffer, 0666); - } - return (mkdir)(name, 0666); -} - -int x11_rmdir(const char *name) -{ - char buffer[256]; /* sufficiently big */ - if(name[0] == '/') { - sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); - - debugf("We remove the real directory '%s'\n", buffer); - return (rmdir)(buffer); - } - return (rmdir)(name); -} - -int x11_remove(char *name) -{ - char buffer[256]; /* sufficiently big */ - - if(name[0] == '/') { - sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); - - debugf("We remove the real file '%s'\n", buffer); - return (remove)(buffer); - } - return (remove)(name); -} - -int x11_rename(char *oldpath, char* newpath) -{ - char buffer1[256]; - char buffer2[256]; - - if(oldpath[0] == '/') { - sprintf(buffer1, "%s%s", SIMULATOR_ARCHOS_ROOT, oldpath); - sprintf(buffer2, "%s%s", SIMULATOR_ARCHOS_ROOT, newpath); - - debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2); - return (rename)(buffer1, buffer2); - } - return -1; -} - -int x11_filesize(int fd) -{ - int old = lseek(fd, 0, SEEK_CUR); - int size = lseek(fd, 0, SEEK_END); - lseek(fd, old, SEEK_SET); - - return(size); -} - -void fat_size(unsigned int* size, unsigned int* free) -{ - struct statfs fs; - - if (!statfs(".", &fs)) { - DEBUGF("statfs: bsize=%d blocks=%d free=%d\n", - fs.f_bsize, fs.f_blocks, fs.f_bfree); - if (size) - *size = fs.f_blocks * (fs.f_bsize / 1024); - if (free) - *free = fs.f_bfree * (fs.f_bsize / 1024); - } - else { - if (size) - *size = 0; - if (free) - *free = 0; - } -} 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 @@ #ifndef NO_REDEFINES_PLEASE -#define sleep(x) x11_sleep(x) +#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 x11_sleep(int); +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) } /* ticks is HZ per second */ -void x11_sleep(int ticks) +void sim_sleep(int ticks) { current_tick+=5; pthread_mutex_unlock(&mp); /* return */ |