Index: tools/configure =================================================================== --- tools/configure (revisione 29994) +++ tools/configure (copia locale) @@ -3212,7 +3212,7 @@ if [ "$ARG_TYPE" ]; then btype=$ARG_TYPE else - echo "Build (N)ormal, (A)dvanced, (S)imulator, (B)ootloader, (C)heckWPS, (D)atabase tool$gdbstub: (Defaults to N)" + echo "Build (N)ormal, (A)dvanced, (S)imulator, (B)ootloader, (C)heckWPS, (D)atabase tool, Di(R)cache tool$gdbstub: (Defaults to N)" btype=`input`; fi @@ -3324,6 +3324,26 @@ echo "Database tool build selected" ;; + [Rr]) + uname=`uname` + simcc "dircache" + toolset=''; + t_cpu=''; + GCCOPTS=''; + appsdir='\$(ROOTDIR)/tools/dircache'; + archosrom=''; + + case $uname in + CYGWIN*|MINGW*) + output="dircache_${modelname}.exe" + ;; + *) + output='dircache.'${modelname}; + ;; + esac + + echo "Dircache tool build selected" + ;; *) if [ "$modelname" = "sansae200r" ]; then echo "Do not use the e200R target for regular builds. Use e200 instead." Index: tools/root.make =================================================================== --- tools/root.make (revisione 29994) +++ tools/root.make (copia locale) @@ -85,6 +85,8 @@ include $(ROOTDIR)/lib/skin_parser/skin_parser.make else ifneq (,$(findstring database,$(APPSDIR))) include $(APPSDIR)/database.make +else ifneq (,$(findstring dircache,$(APPSDIR))) + include $(APPSDIR)/dircache.make else include $(APPSDIR)/apps.make include $(APPSDIR)/lang/lang.make Index: firmware/common/dircache.c =================================================================== --- firmware/common/dircache.c (revisione 29994) +++ firmware/common/dircache.c (copia locale) @@ -47,6 +47,10 @@ #endif #include "rbpaths.h" +#ifdef __PCTOOL__ +#define yield() do { } while(0) +#endif + /* Queue commands. */ #define DIRCACHE_BUILD 1 #define DIRCACHE_STOP 2 @@ -71,12 +75,16 @@ static unsigned long dircache_size = 0; static unsigned long entry_count = 0; static unsigned long reserve_used = 0; +#ifndef __PCTOOL__ static unsigned int cache_build_ticks = 0; +#endif static unsigned long appflags = 0; +#ifndef __PCTOOL__ static struct event_queue dircache_queue SHAREDBSS_ATTR; static long dircache_stack[(DEFAULT_STACK_SIZE + 0x400)/sizeof(long)]; static const char dircache_thread_name[] = "dircache"; +#endif static struct fdbind_queue fdbind_cache[MAX_PENDING_BINDINGS]; static int fdbind_idx = 0; @@ -172,6 +180,7 @@ * Returns true if there is an event waiting in the queue * that requires the current operation to be aborted. */ +#ifndef __PCTOOL__ static bool check_event_queue(void) { struct queue_event ev; @@ -191,6 +200,7 @@ return false; } +#endif #if (CONFIG_PLATFORM & PLATFORM_NATIVE) /* scan and build static data (avoid redundancy on stack) */ @@ -251,6 +261,7 @@ if(ce == NULL) return -5; +#ifndef __PCTOOL__ /* When simulator is used, it's only safe to yield here. */ if(thread_enabled) { @@ -259,6 +270,7 @@ return -6; yield(); } +#endif } /* add "." and ".." */ @@ -379,6 +391,7 @@ if(ce == NULL) return -5; +#ifndef __PCTOOL__ /* When simulator is used, it's only safe to yield here. */ if(thread_enabled) { @@ -387,6 +400,7 @@ return -1; yield(); } +#endif } /* add "." and ".." */ @@ -610,11 +624,15 @@ */ static int dircache_do_rebuild(void) { +#ifndef __PCTOOL__ unsigned int start_tick; +#endif int i; /* Measure how long it takes build the cache. */ +#ifndef __PCTOOL__ start_tick = current_tick; +#endif dircache_initializing = true; appflags = 0; entry_count = 0; @@ -652,7 +670,9 @@ dircache_initialized = true; dircache_initializing = false; +#ifndef __PCTOOL__ cache_build_ticks = current_tick - start_tick; +#endif /* Initialized fd bindings. */ memset(fd_bindings, 0, sizeof(fd_bindings)); @@ -680,6 +700,7 @@ /** * Internal thread that controls transparent cache building. */ +#ifndef __PCTOOL__ static void dircache_thread(void) { struct queue_event ev; @@ -716,6 +737,7 @@ } } } +#endif /** * Start scanning the disk to build the dircache. @@ -736,7 +758,9 @@ { thread_enabled = true; dircache_initializing = true; +#ifndef __PCTOOL__ queue_post(&dircache_queue, DIRCACHE_BUILD, 0); +#endif return 2; } @@ -744,10 +768,12 @@ { allocated_size = last_size + DIRCACHE_RESERVE; dircache_root = buffer_alloc(allocated_size); +#ifndef __PCTOOL__ thread_enabled = true; /* Start a transparent rebuild. */ queue_post(&dircache_queue, DIRCACHE_BUILD, 0); +#endif return 3; } @@ -792,6 +818,7 @@ opendirs[i].theent.d_name = buffer_alloc(MAX_PATH); } +#ifndef __PCTOOL__ queue_init(&dircache_queue, true); thread_id = create_thread(dircache_thread, dircache_stack, sizeof(dircache_stack), 0, dircache_thread_name @@ -800,6 +827,7 @@ #ifdef HAVE_IO_PRIORITY thread_set_io_priority(thread_id,IO_PRIORITY_BACKGROUND); #endif +#endif } @@ -863,10 +891,12 @@ /** * Returns the time in kernel ticks that took to build the cache. */ +#ifndef __PCTOOL__ int dircache_get_build_ticks(void) { return dircache_is_enabled() ? cache_build_ticks : 0; } +#endif /** * Disables the dircache. Usually called on shutdown or when @@ -877,11 +907,13 @@ int i; bool cache_in_use; +#ifndef __PCTOOL__ if (thread_enabled) queue_post(&dircache_queue, DIRCACHE_STOP, 0); while (thread_enabled) sleep(1); +#endif dircache_initialized = false; logf("Waiting for cached dirs to release"); @@ -1081,7 +1113,7 @@ } void dircache_update_filetime(int fd) { -#if CONFIG_RTC == 0 +#if CONFIG_RTC == 0 || __PCTOOL__ (void)fd; #else short year; @@ -1230,10 +1262,12 @@ entry->startcluster = startcluster; } +#ifndef __PCTOOL__ static bool is_disable_msg_pending(void) { return check_event_queue(); } +#endif DIR_CACHED* opendir_cached(const char* name) { @@ -1260,7 +1294,11 @@ pdir->busy = true; - if (!dircache_initialized || is_disable_msg_pending()) + if (!dircache_initialized +#ifndef __PCTOOL__ + || is_disable_msg_pending() +#endif + ) { pdir->internal_entry = NULL; pdir->regulardir = opendir_uncached(name); Index: firmware/buffer.c =================================================================== --- firmware/buffer.c (revisione 29994) +++ firmware/buffer.c (copia locale) @@ -95,7 +95,12 @@ #endif /* BUFFER_ALLOC_DEBUG */ if (audiobuf > audiobufend) { +#ifdef __PCTOOL__ + printf("OOM: %d bytes", (int) size); + exit(1); +#else panicf("OOM: %d bytes", (int) size); +#endif } return retval;