summaryrefslogtreecommitdiff
path: root/uisimulator/common/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/common/io.c')
-rw-r--r--uisimulator/common/io.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 260e880b62..4c0fa33be5 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -25,7 +25,11 @@
25#include <stdarg.h> 25#include <stdarg.h>
26#include <sys/stat.h> 26#include <sys/stat.h>
27#include <time.h> 27#include <time.h>
28#ifndef WIN32 28#include "config.h"
29
30#define HAVE_STATVFS (0 == (CONFIG_PLATFORM & PLATFORM_ANDROID) && !defined(WIN32))
31
32#if HAVE_STATVFS
29#include <sys/statvfs.h> 33#include <sys/statvfs.h>
30#endif 34#endif
31 35
@@ -41,14 +45,18 @@
41#endif 45#endif
42 46
43#include <fcntl.h> 47#include <fcntl.h>
48#if (CONFIG_PLATFORM & PLATFORM_SDL)
44#include <SDL.h> 49#include <SDL.h>
45#include <SDL_thread.h> 50#include <SDL_thread.h>
51#include "thread-sdl.h"
52#else
53#define sim_thread_unlock() NULL
54#define sim_thread_lock(a)
55#endif
46#include "thread.h" 56#include "thread.h"
47#include "kernel.h" 57#include "kernel.h"
48#include "debug.h" 58#include "debug.h"
49#include "config.h"
50#include "ata.h" /* for IF_MV2 et al. */ 59#include "ata.h" /* for IF_MV2 et al. */
51#include "thread-sdl.h"
52#include "rbpaths.h" 60#include "rbpaths.h"
53 61
54/* keep this in sync with file.h! */ 62/* keep this in sync with file.h! */
@@ -193,7 +201,7 @@ static unsigned int rockbox2sim(int opt)
193/** Simulator I/O engine routines **/ 201/** Simulator I/O engine routines **/
194#define IO_YIELD_THRESHOLD 512 202#define IO_YIELD_THRESHOLD 512
195 203
196enum 204enum io_dir
197{ 205{
198 IO_READ, 206 IO_READ,
199 IO_WRITE, 207 IO_WRITE,
@@ -225,7 +233,7 @@ int ata_spinup_time(void)
225 return HZ; 233 return HZ;
226} 234}
227 235
228static ssize_t io_trigger_and_wait(int cmd) 236static ssize_t io_trigger_and_wait(enum io_dir cmd)
229{ 237{
230 void *mythread = NULL; 238 void *mythread = NULL;
231 ssize_t result; 239 ssize_t result;
@@ -246,6 +254,9 @@ static ssize_t io_trigger_and_wait(int cmd)
246 case IO_WRITE: 254 case IO_WRITE:
247 result = write(io.fd, io.buf, io.count); 255 result = write(io.fd, io.buf, io.count);
248 break; 256 break;
257 /* shut up gcc */
258 default:
259 result = -1;
249 } 260 }
250 261
251 /* Regain our status as current */ 262 /* Regain our status as current */
@@ -480,7 +491,7 @@ void fat_size(IF_MV2(int volume,) unsigned long* size, unsigned long* free)
480 if (free) 491 if (free)
481 *free = free_clusters * secperclus / 2 * (bytespersec / 512); 492 *free = free_clusters * secperclus / 2 * (bytespersec / 512);
482 } 493 }
483#else 494#elif HAVE_STATVFS
484 struct statvfs vfs; 495 struct statvfs vfs;
485 496
486 if (!statvfs(".", &vfs)) { 497 if (!statvfs(".", &vfs)) {
@@ -490,9 +501,9 @@ void fat_size(IF_MV2(int volume,) unsigned long* size, unsigned long* free)
490 *size = vfs.f_blocks / 2 * (vfs.f_frsize / 512); 501 *size = vfs.f_blocks / 2 * (vfs.f_frsize / 512);
491 if (free) 502 if (free)
492 *free = vfs.f_bfree / 2 * (vfs.f_frsize / 512); 503 *free = vfs.f_bfree / 2 * (vfs.f_frsize / 512);
493 } 504 } else
494#endif 505#endif
495 else { 506 {
496 if (size) 507 if (size)
497 *size = 0; 508 *size = 0;
498 if (free) 509 if (free)
@@ -537,9 +548,19 @@ void *sim_codec_load_ram(char* codecptr, int size, void **pd)
537 to find an unused filename */ 548 to find an unused filename */
538 for (codec_count = 0; codec_count < 10; codec_count++) 549 for (codec_count = 0; codec_count < 10; codec_count++)
539 { 550 {
551#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
552 /* we need that path fixed, since get_user_file_path()
553 * gives us the folder on the sdcard where we cannot load libraries
554 * from (no exec permissions)
555 */
556 snprintf(path, sizeof(path),
557 "/data/data/org.rockbox/app_rockbox/libtemp_codec_%d.so",
558 codec_count);
559#else
540 char name[MAX_PATH]; 560 char name[MAX_PATH];
541 const char *_name = get_user_file_path(ROCKBOX_DIR, 0, name, sizeof(name)); 561 const char *_name = get_user_file_path(ROCKBOX_DIR, 0, name, sizeof(name));
542 snprintf(path, sizeof(path), "%s/_temp_codec%d.dll", get_sim_pathname(_name), codec_count); 562 snprintf(path, sizeof(path), "%s/_temp_codec%d.dll", get_sim_pathname(_name), codec_count);
563#endif
543 fd = OPEN(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU); 564 fd = OPEN(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU);
544 if (fd >= 0) 565 if (fd >= 0)
545 break; /* Created a file ok */ 566 break; /* Created a file ok */