diff -u -r -N rockbox_orig/apps/Makefile rockbox_diff/apps/Makefile
--- rockbox_orig/apps/Makefile 2008-03-15 14:49:07.093750000 +0900
+++ rockbox_diff/apps/Makefile 2008-05-08 21:29:09.359375000 +0900
@@ -84,12 +84,8 @@
else
# regular target build
-ifdef DEBUG
-REALBIN = $(OBJDIR)/rockbox.elf
-else
-# this is not needed to get built when doing debug builds
REALBIN = $(BUILDDIR)/$(BINARY)
-endif
all: $(REALBIN) $(FLASHFILE) $(CODECS) $(ROCKS) $(ARCHOSROM)
endif
diff -u -r -N rockbox_orig/apps/codecs/wma.c rockbox_diff/apps/codecs/wma.c
--- rockbox_orig/apps/codecs/wma.c 2008-05-04 10:40:32.890625000 +0900
+++ rockbox_diff/apps/codecs/wma.c 2008-05-08 23:07:10.984375000 +0900
@@ -459,7 +459,8 @@
asf_waveformatex_t wfx;
size_t resume_offset;
int i;
- int wmares, res;
+ int wmares = 0;
+ int res;
uint8_t* audiobuf;
int audiobufsize;
int packetlength;
diff -u -r -N rockbox_orig/apps/debug_menu.c rockbox_diff/apps/debug_menu.c
--- rockbox_orig/apps/debug_menu.c 2008-05-10 10:32:23.718750000 +0900
+++ rockbox_diff/apps/debug_menu.c 2008-05-10 11:04:01.484375000 +0900
@@ -2418,6 +2418,32 @@
}
#endif
+#if defined(DEBUG) && !defined(SIMULATOR) && CONFIG_CPU != SH7034 && !defined(HAVE_GDB_API)
+static bool dbg_file_output(void)
+{
+ bool old = global_settings.debug_log_file_output;
+ bool result;
+
+ result = set_bool( "debug log file auto output",
+ &global_settings.debug_log_file_output );
+
+ if(old != global_settings.debug_log_file_output)
+ {
+ if(!global_settings.debug_log_file_output)
+ {
+ DEBUGF("debug log file auto output disabled.\n");
+ debug_write_buffer_clear(true);
+ }
+ debug_file_output_enabled(global_settings.debug_log_file_output);
+ if(global_settings.debug_log_file_output)
+ {
+ DEBUGF("debug log file auto output enabled.\n");
+ }
+ }
+ return result;
+}
+#endif
+
#if defined(HAVE_USBSTACK) && defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL)
static bool logf_usb_serial(void)
{
@@ -2577,6 +2603,9 @@
#if defined(HAVE_USBSTACK) && defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL)
{"logf over usb",logf_usb_serial },
#endif
+#if defined(DEBUG) && !defined(SIMULATOR) && CONFIG_CPU != SH7034 && !defined(HAVE_GDB_API)
+ { "debug log file auto output", dbg_file_output },
+#endif
#if defined(HAVE_USBSTACK) && defined(USB_STORAGE)
{"reconnect usb storage",usb_reconnect},
#endif
diff -u -r -N rockbox_orig/apps/lang/english.lang rockbox_diff/apps/lang/english.lang
--- rockbox_orig/apps/lang/english.lang 2008-05-10 19:38:34.593750000 +0900
+++ rockbox_diff/apps/lang/english.lang 2008-05-10 19:44:26.093750000 +0900
@@ -11666,6 +11666,20 @@
+ id: LANG_DEBUG_FILE_OUTPUT
+ desc: when rockbox is debug mode, debug log file automatic output.
+ user:
+
+ *: "debug log file auto output"
+
+
+ *: "debug log file auto output"
+
+
+ *: "debug log file auto output"
+
+
+
id: VOICE_QUICKSCREEN
desc: spoken only, Announces entering the "quick screen"
user:
diff -u -r -N rockbox_orig/apps/main.c rockbox_diff/apps/main.c
--- rockbox_orig/apps/main.c 2008-05-06 11:54:37.656250000 +0900
+++ rockbox_diff/apps/main.c 2008-05-09 14:13:23.937500000 +0900
@@ -70,6 +70,7 @@
#include "eeprom_settings.h"
#include "scrobbler.h"
#include "icon.h"
+#include "asyncfile.h"
#if (CONFIG_CODEC == SWCODEC)
#include "playback.h"
@@ -374,7 +375,11 @@
lang_init();
#ifdef DEBUG
+ asyncfile_init();
debug_init();
+#if CONFIG_CPU != SH7034 && !defined(HAVE_GDB_API)
+ debug_file_open(DEBUG_FILENAME);
+#endif
#else
#if !defined(HAVE_FMADC) && !defined(HAVE_MMC)
serial_setup();
@@ -509,6 +514,14 @@
#endif
settings_load(SETTINGS_ALL);
+#if defined(DEBUG) && CONFIG_CPU != SH7034 && !defined(HAVE_GDB_API)
+ if(!global_settings.debug_log_file_output)
+ {
+ debug_write_buffer_clear(false);
+ debug_file_output_enabled(false);
+ }
+#endif
+
if (init_dircache(true) < 0)
{
#ifdef HAVE_TAGCACHE
diff -u -r -N rockbox_orig/apps/misc.c rockbox_diff/apps/misc.c
--- rockbox_orig/apps/misc.c 2008-05-04 10:40:39.734375000 +0900
+++ rockbox_diff/apps/misc.c 2008-05-08 21:25:50.937500000 +0900
@@ -79,6 +79,11 @@
#endif
#endif
+#ifdef DEBUG
+#include "asyncfile.h"
+#include "debug.h"
+#endif
+
/* Format a large-range value for output, using the appropriate unit so that
* the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
* units) if possible, and 3 significant digits are shown. If a buffer is
@@ -744,6 +749,11 @@
#endif
}
+#ifdef DEBUG
+ debug_finalize();
+ asyncfile_finalize();
+#endif
+
system_flush();
#ifdef HAVE_EEPROM_SETTINGS
if (firmware_settings.initialized)
diff -u -r -N rockbox_orig/apps/plugins/invadrox.c rockbox_diff/apps/plugins/invadrox.c
--- rockbox_orig/apps/plugins/invadrox.c 2008-04-28 16:35:16.218750000 +0900
+++ rockbox_diff/apps/plugins/invadrox.c 2008-05-08 22:56:09.234375000 +0900
@@ -42,9 +42,13 @@
/* #define DEBUG */
#ifdef DEBUG
+#if defined(SIMULATOR)
#include
#define DBG(format, arg...) { printf("%s: " format, __FUNCTION__, ## arg); }
#else
+#define DBG(format, arg...) { DEBUGF("%s: " format, __FUNCTION__, ## arg); }
+#endif
+#else
#define DBG(format, arg...) {}
#endif
@@ -1773,7 +1777,7 @@
PLAYFIELD_Y + 1 - SCORENUM_Y - FONT_HEIGHT);
/* Wait until next frame */
- DBG("%d (%d)\n", end - *rb->current_tick, (CYCLETIME * HZ) / 1000);
+ DBG("%ld (%d)\n", end - *rb->current_tick, (CYCLETIME * HZ) / 1000);
if (end > *rb->current_tick) {
rb->sleep(end - *rb->current_tick);
} else {
diff -u -r -N rockbox_orig/apps/settings.h rockbox_diff/apps/settings.h
--- rockbox_orig/apps/settings.h 2008-05-06 11:54:34.609375000 +0900
+++ rockbox_diff/apps/settings.h 2008-05-08 21:32:20.734375000 +0900
@@ -79,6 +79,7 @@
#define VIEWERS_CONFIG ROCKBOX_DIR "/viewers.config"
#define CONFIGFILE ROCKBOX_DIR "/config.cfg"
#define FIXEDSETTINGSFILE ROCKBOX_DIR "/fixed.cfg"
+#define DEBUG_FILENAME ROCKBOX_DIR "/debug.log"
#define MAX_FILENAME 32
@@ -731,6 +732,11 @@
unsigned char playlist_catalog_dir[MAX_FILENAME+1];
bool study_mode; /* study mode enabled */
int study_hop_step; /* hop step in study mode, in seconds */
+
+#if defined(DEBUG) && CONFIG_CPU != SH7034
+ bool debug_log_file_output;
+#endif
+
};
/** global variables **/
diff -u -r -N rockbox_orig/apps/settings_list.c rockbox_diff/apps/settings_list.c
--- rockbox_orig/apps/settings_list.c 2008-05-06 11:54:35.093750000 +0900
+++ rockbox_diff/apps/settings_list.c 2008-05-10 14:19:54.750000000 +0900
@@ -1251,6 +1251,11 @@
#endif /* CONFIG_CODEC == SWCODEC */
FILENAME_SETTING(0, playlist_catalog_dir, "playlist catalog directory",
PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL, MAX_FILENAME+1),
+
+#if defined(DEBUG) && CONFIG_CPU != SH7034
+ OFFON_SETTING(0, debug_log_file_output, LANG_DEBUG_FILE_OUTPUT,
+ false, "debug file auto output", NULL),
+#endif
};
const int nb_settings = sizeof(settings)/sizeof(*settings);
diff -u -r -N rockbox_orig/firmware/SOURCES rockbox_diff/firmware/SOURCES
--- rockbox_orig/firmware/SOURCES 2008-05-09 23:55:00.906250000 +0900
+++ rockbox_diff/firmware/SOURCES 2008-05-10 11:17:26.953125000 +0900
@@ -20,6 +20,7 @@
#endif /* SIMULATOR */
panic.c
debug.c
+asyncfile.c
/* Common */
common/atoi.c
diff -u -r -N rockbox_orig/firmware/asyncfile.c rockbox_diff/firmware/asyncfile.c
--- rockbox_orig/firmware/asyncfile.c 1970-01-01 09:00:00.000000000 +0900
+++ rockbox_diff/firmware/asyncfile.c 2008-05-10 22:38:35.087520200 +0900
@@ -0,0 +1,714 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: $
+ *
+ * Copyright (C) 2006 by Yoshihisa Uchida
+ *
+ * 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
+#include
+#include
+#include
+#include "asyncfile.h"
+#include "config.h"
+#include "errno.h"
+#include "kernel.h"
+#include "thread.h"
+
+#define MAX_ASYNC_FILES 4
+#define MAX_ASYNC_PROCESS 64
+#define MAX_BUFFER_SIZE 32000
+
+static struct event_queue async_queue;
+
+static long async_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)];
+
+static const char async_thread_name[] = "asyncfile";
+static struct thread_entry* async_thread_id;
+
+#define FD_UNUSED -2
+#define FD_UNOPEN -1
+
+/* Queue commands. */
+enum {
+ QUEUE_NONE = 0,
+ QUEUE_READ,
+ QUEUE_WRITE,
+ QUEUE_QUIT,
+};
+
+/* thread status */
+enum {
+ ASYNC_STOP = 0, /* thread stopping */
+ ASYNC_RUNNING, /* thread running */
+ ASYNC_WAIT, /* thread waiting */
+};
+
+struct async_entry
+{
+ int fd;
+ char path[MAX_PATH];
+ int flags;
+ int thread_status;
+ int process_id;
+ int cbank;
+ int wbank;
+};
+
+struct write_buf
+{
+ int entry_id;
+ bool wflg;
+ int next;
+ size_t size;
+ char *wbuf;
+};
+
+static struct async_process processes[MAX_ASYNC_PROCESS];
+static struct async_entry entries[MAX_ASYNC_FILES];
+static struct write_buf buffer[MAX_ASYNC_FILES * 2];
+static char wbuf[MAX_ASYNC_FILES * 2][MAX_BUFFER_SIZE];
+static bool run_gc = false;
+
+static void init_buffer(void)
+{
+ int i;
+
+ for(i = 0;i < MAX_ASYNC_FILES * 2; i++)
+ {
+ buffer[i].entry_id = -1;
+ buffer[i].wflg = false;
+ buffer[i].next = i;
+ buffer[i].size = 0;
+ buffer[i].wbuf = wbuf[i];
+ }
+}
+
+static int get_unused_buffer(int entry_id)
+{
+ int i;
+
+ while(run_gc)
+ {
+ sleep(2);
+ }
+
+ for(i = 0; i < MAX_ASYNC_FILES * 2; i++)
+ {
+ if(buffer[i].entry_id < 0)
+ {
+ buffer[i].entry_id = entry_id;
+ buffer[i].wflg = false;
+ buffer[i].next = i;
+ buffer[i].size = 0;
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+static void gc_buffer(void)
+{
+ int id;
+
+ while(run_gc)
+ {
+ sleep(2);
+ }
+
+ run_gc = true;
+
+ for(id = 0; id < MAX_ASYNC_FILES; id++)
+ {
+ if(entries[id].fd >= 0)
+ {
+ int cbank = entries[id].cbank;
+ int wbank = entries[id].wbank;
+
+ while(buffer[cbank].next != wbank)
+ {
+ int bank = buffer[cbank].next;
+
+ buffer[cbank].next = buffer[bank].next;
+ buffer[bank].entry_id = -1;
+ }
+ }
+ }
+
+ run_gc = false;
+}
+
+static int add_buffer(int entry_id, int cbank)
+{
+ int bank = get_unused_buffer(entry_id);
+
+ if(bank < 0)
+ {
+ gc_buffer();
+
+ bank = get_unused_buffer(entry_id);
+
+ if(bank < 0)
+ {
+ return -1;
+ }
+ }
+
+ buffer[bank].next = buffer[cbank].next;
+ buffer[cbank].next = bank;
+
+ return bank;
+}
+
+static void init_process(void)
+{
+ int i;
+
+ for(i = 0; i < MAX_ASYNC_PROCESS; i++)
+ {
+ processes[i].entry_id = -1;
+ processes[i].process_id = -1;
+ processes[i].status = PROCESS_NOT_REGISTED;
+ processes[i].result = 0;
+ }
+}
+
+static struct async_process *get_new_process(int entry_id)
+{
+ static unsigned char cur = 0xff;
+ static unsigned int topid = 0;
+
+ cur++;
+ if(cur >= MAX_ASYNC_PROCESS)
+ {
+ cur = 0;
+ topid++;
+ if(topid > 127)
+ {
+ topid = 0;
+ }
+ }
+
+ processes[cur].entry_id = entry_id;
+ processes[cur].process_id = (topid << 8 | cur);
+ processes[cur].status = PROCESS_NOT_RUN;
+ processes[cur].result = 0;
+
+ return &processes[cur];
+}
+
+static struct async_process *get_process(int entry_id, int process_id)
+{
+ unsigned char lowid = process_id & 0xff;
+
+ if(process_id < 0)
+ {
+ return 0;
+ }
+
+ if(lowid < MAX_ASYNC_PROCESS
+ && processes[lowid].entry_id == entry_id
+ && processes[lowid].process_id == process_id
+ && processes[lowid].status != PROCESS_NOT_REGISTED)
+ {
+ return &processes[lowid];
+ }
+ return 0;
+}
+
+static int write_buffer(int entry_id, const void *buf, size_t size)
+{
+ static struct async_process *p = NULL;
+ int bank;
+
+ p = get_new_process(entry_id);
+
+ bank = entries[entry_id].cbank;
+
+ if(buffer[bank].size + size >= MAX_BUFFER_SIZE)
+ {
+ if(buffer[bank].next == entries[entry_id].wbank)
+ {
+ if(buffer[entries[entry_id].wbank].wflg == false)
+ {
+ buffer[entries[entry_id].wbank].wflg = true;
+ queue_post(&async_queue, QUEUE_WRITE, (intptr_t) p);
+ }
+
+ int idx = add_buffer(entry_id, bank);
+ if(idx < 0)
+ {
+ return -1;
+ }
+ entries[entry_id].cbank = idx;
+ }
+ else
+ {
+ entries[entry_id].cbank = buffer[bank].next;
+ }
+ bank = entries[entry_id].cbank;
+ buffer[bank].size = 0;
+ buffer[bank].wflg = false;
+ }
+
+ memcpy(buffer[bank].wbuf + buffer[bank].size, buf, size);
+ buffer[bank].size += size;
+
+ return p->process_id;
+}
+
+static void set_fd(struct async_entry *p)
+{
+ if(p->fd < 0)
+ {
+ p->fd = open(p->path, p->flags);
+ if(p->fd < 0)
+ {
+ p->fd = FD_UNOPEN;
+ }
+ }
+}
+
+static ssize_t read_file(struct async_process *p)
+{
+ ssize_t res;
+ char *buf;
+
+ if(p == 0)
+ {
+ return -1;
+ }
+
+ if(p->process_id < 0)
+ {
+ return -2;
+ }
+
+ if(p->status == PROCESS_NOT_REGISTED)
+ {
+ return -3;
+ }
+
+ p->status = PROCESS_RUNNING;
+
+ if(entries[p->entry_id].fd < 0)
+ {
+ set_fd(&entries[p->entry_id]);
+ }
+
+ if(entries[p->entry_id].fd < 0)
+ {
+ p->result = errno;
+ p->status = PROCESS_ERROR;
+ return -4;
+ }
+
+ buf = p->rbuf;
+ res = read(entries[p->entry_id].fd, buf, p->rcount);
+
+ if(res < 0)
+ {
+ p->result = errno;
+ p->status = PROCESS_ERROR;
+ return -5;
+ }
+
+ p->result = res;
+
+ if(p->rbflg == false && res > 0)
+ {
+ ssize_t i;
+ ssize_t nilidx = res-1;
+
+ for(i = 0; i < res-1; i++)
+ {
+ if(buf[i] == '\0' || buf[i] == '\n')
+ {
+ nilidx = i+1;
+ break;
+ }
+ }
+
+ buf[nilidx] = '\0';
+ lseek(entries[p->entry_id].fd, nilidx - p->rcount, SEEK_CUR);
+ }
+
+ p->status = PROCESS_DONE;
+ return p->result;
+}
+
+static int write_file(struct async_process *p)
+{
+ if(p == 0)
+ {
+ return -1;
+ }
+
+ if(p->process_id < 0)
+ {
+ return -2;
+ }
+
+ if(p->status == PROCESS_NOT_REGISTED)
+ {
+ return -3;
+ }
+
+ p->status = PROCESS_RUNNING;
+
+ if(entries[p->entry_id].fd < 0)
+ {
+ set_fd(&entries[p->entry_id]);
+ }
+
+ if(entries[p->entry_id].fd < 0)
+ {
+ p->result = errno;
+ p->status = PROCESS_ERROR;
+ return -4;
+ }
+
+ int bank = entries[p->entry_id].wbank;
+
+ size_t res = write(entries[p->entry_id].fd, buffer[bank].wbuf, buffer[bank].size);
+ if(res == buffer[bank].size)
+ {
+ fsync(entries[p->entry_id].fd);
+
+ entries[p->entry_id].wbank = buffer[bank].next;
+ buffer[bank].size = 0;
+ buffer[bank].wflg = false;
+
+ p->result = 0;
+ p->status = PROCESS_DONE;
+ return 0;
+ }
+
+ p->result = errno;
+ p->status = PROCESS_ERROR;
+ return -5;
+}
+
+static void async_thread(void)
+{
+ struct queue_event ev;
+ struct async_process *p;
+ int entry_id = 0;
+
+ while (1)
+ {
+ queue_wait_w_tmo(&async_queue, &ev, HZ/2);
+
+ switch(ev.id)
+ {
+ case QUEUE_READ:
+ p = (struct async_process *)ev.data;
+ entry_id = p->entry_id;
+ if(entries[entry_id].thread_status == ASYNC_WAIT)
+ {
+ entries[entry_id].thread_status = ASYNC_RUNNING;
+ entries[entry_id].process_id = p->process_id;
+ read_file(p);
+ entries[entry_id].thread_status = ASYNC_WAIT;
+ }
+ break;
+ case QUEUE_WRITE:
+ p = (struct async_process *)ev.data;
+ entry_id = p->entry_id;
+ if(entries[entry_id].thread_status == ASYNC_WAIT)
+ {
+ entries[entry_id].thread_status = ASYNC_RUNNING;
+ entries[entry_id].process_id = p->process_id;
+ write_file(p);
+ entries[entry_id].thread_status = ASYNC_WAIT;
+ }
+ break;
+ case QUEUE_QUIT:
+ entry_id = (int)ev.data;
+ entries[entry_id].thread_status = ASYNC_RUNNING;
+ while(buffer[entries[entry_id].wbank].size > 0)
+ {
+ p = get_new_process(entry_id);
+ write_file(p);
+ }
+ entries[entry_id].thread_status = ASYNC_STOP;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+int asyncfile_init(void)
+{
+ int i;
+
+ queue_init(&async_queue, true);
+ async_thread_id = create_thread(async_thread, async_stack,
+ sizeof(async_stack), 0, async_thread_name
+ IF_PRIO(, PRIORITY_BACKGROUND)
+ IF_COP(, CPU));
+
+ if(async_thread_id == NULL)
+ {
+ return -1;
+ }
+
+ for(i = 0; i < MAX_ASYNC_FILES; i++)
+ {
+ entries[i].fd = FD_UNUSED;
+ entries[i].thread_status = ASYNC_STOP;
+ entries[i].process_id = 0;
+ entries[i].cbank = -1;
+ entries[i].wbank = -1;
+ }
+
+ init_buffer();
+ init_process();
+
+ return 0;
+}
+
+void asyncfile_finalize(void)
+{
+ int i;
+
+ for(i = 0; i < MAX_ASYNC_FILES; i++)
+ {
+ if(entries[i].fd >= 0)
+ {
+ async_close(i);
+ }
+ }
+
+#ifdef ALLOW_REMOVE_THREAD
+ if(async_thread_id != NULL)
+ {
+ remove_thread(async_thread_id);
+ async_thread_id = NULL;
+ }
+#endif
+ queue_delete(&async_queue);
+}
+
+static int async_readgets(int entry_id, void *buf, size_t count, bool binaryflg)
+{
+ if(entry_id < 0 || entry_id >= MAX_ASYNC_FILES)
+ {
+ return -1;
+ }
+
+ struct async_process *p;
+ p = get_new_process(entry_id);
+
+ if(p == 0)
+ {
+ return -2;
+ }
+
+ p->rbuf = buf;
+ p->rcount = count;
+ p->rbflg = binaryflg;
+
+ queue_post(&async_queue, QUEUE_READ, (intptr_t) p);
+
+ return p->process_id;
+}
+
+static int async_writeputs(int entry_id, const void *buf, size_t count)
+{
+ if(entry_id < 0 || entry_id >= MAX_ASYNC_FILES)
+ {
+ return -1;
+ }
+
+ if(thread_get_current() == async_thread_id)
+ {
+ return -2;
+ }
+ return write_buffer(entry_id, buf, count);
+}
+
+int async_open(const char* pathname, int flags)
+{
+ int i;
+ int entry_id = -1;
+
+ for(i = 0; i < MAX_ASYNC_FILES; i++)
+ {
+ if(entries[i].fd == FD_UNUSED)
+ {
+ entry_id = i;
+ break;
+ }
+ }
+
+ if(entry_id < 0)
+ {
+ return -1;
+ }
+
+ strncpy(entries[entry_id].path, pathname, MAX_PATH);
+ entries[entry_id].flags = flags;
+ entries[entry_id].fd = FD_UNOPEN;
+
+ int idx = get_unused_buffer(entry_id);
+
+ if(idx < 0)
+ {
+ entries[entry_id].fd = FD_UNUSED;
+ return -2;
+ }
+
+ entries[entry_id].cbank = idx;
+ entries[entry_id].wbank = idx;
+
+ entries[entry_id].thread_status = ASYNC_WAIT;
+
+ return entry_id;
+}
+
+int async_write_buffer_clear(int entry_id, bool flushflg)
+{
+ if(entry_id < 0 || entry_id >= MAX_ASYNC_FILES)
+ {
+ return -1;
+ }
+
+ if(flushflg)
+ {
+ queue_post(&async_queue, QUEUE_QUIT, (intptr_t)entry_id);
+
+ while(entries[entry_id].thread_status != ASYNC_STOP)
+ {
+ sleep(HZ/10);
+ }
+ }
+
+ int bank = entries[entry_id].cbank;
+ do
+ {
+ buffer[bank].size = 0;
+ } while((bank = buffer[bank].next) != entries[entry_id].cbank);
+ entries[entry_id].wbank = entries[entry_id].cbank;
+
+ return 0;
+}
+
+int async_close(int entry_id)
+{
+ int res;
+
+ res = async_write_buffer_clear(entry_id, true);
+
+ if(res < 0)
+ {
+ return -1;
+ }
+
+ res = close(entries[entry_id].fd);
+ entries[entry_id].fd = -1;
+
+ return res;
+
+}
+
+int async_read(int entry_id, void *buf, size_t count)
+{
+ return async_readgets(entry_id, buf, count, true);
+}
+
+int async_gets(int entry_id, void *buf, size_t count)
+{
+ return async_readgets(entry_id, buf, count, false);
+}
+
+int async_write(int entry_id, const void *buf, size_t count)
+{
+ return async_writeputs(entry_id, buf, count);
+}
+
+int async_puts(int entry_id, const char *buf)
+{
+ size_t count = 0;
+
+ if(buf == NULL)
+ {
+ return -1;
+ }
+
+ count = strlen(buf);
+
+ if(buf[count-1] == '\n')
+ {
+ return async_writeputs(entry_id, buf, count);
+ }
+
+ count++;
+ char cbuf[count+1];
+ snprintf(cbuf, count+1, "%s\n", buf);
+
+ return async_writeputs(entry_id, cbuf, count);
+}
+
+struct async_process *get_result(int entry_id, int process_id, bool syncflg)
+{
+ struct async_process *p;
+
+ if(entry_id < 0 || entry_id >= MAX_ASYNC_FILES)
+ {
+ return 0;
+ }
+
+ p = get_process(entry_id, process_id);
+
+ if(p != 0)
+ {
+ if(syncflg)
+ {
+ while(p->status == PROCESS_RUNNING)
+ {
+ sleep(HZ/4);
+ }
+ }
+ }
+
+ return p;
+}
+
+struct async_process *get_current_result(int entry_id, bool syncflg)
+{
+ struct async_process *p;
+
+ if(entry_id < 0 || entry_id >= MAX_ASYNC_FILES)
+ {
+ return 0;
+ }
+
+ p = get_process(entry_id, entries[entry_id].process_id);
+
+ if(p != 0)
+ {
+ if(syncflg)
+ {
+ while(p->status == PROCESS_RUNNING)
+ {
+ sleep(HZ/4);
+ }
+ }
+ }
+
+ return p;
+}
diff -u -r -N rockbox_orig/firmware/debug.c rockbox_diff/firmware/debug.c
--- rockbox_orig/firmware/debug.c 2008-05-04 10:41:17.156250000 +0900
+++ rockbox_diff/firmware/debug.c 2008-05-09 14:24:21.015625000 +0900
@@ -37,6 +37,9 @@
#include "kernel.h"
#include "system.h"
#include "debug.h"
+#if defined(DEBUG) && CONFIG_CPU != SH7034
+#include "asyncfile.h"
+#endif
#ifdef DEBUG
#if CONFIG_CPU == SH7034 /* these are still very SH-oriented */
@@ -52,6 +55,10 @@
IPRE |= 0xf000; /* Set to highest priority */
}
+void debug_finalize(void)
+{
+}
+
static int debug_tx_ready(void)
{
return (SSR1 & SCI_TDRE);
@@ -201,6 +208,71 @@
mem2hex(msg, &debugbuf[1], strlen(msg));
putpacket(debugbuf);
}
+
+#else /* CPU != SH7034 */
+
+#ifndef HAVE_GDB_API
+static int dbg_id = -1;
+static bool enabled_debug_file_output = false;
+
+static void debug(const char *msg)
+{
+ if(enabled_debug_file_output)
+ {
+ async_puts(dbg_id, msg);
+ }
+}
+
+int debug_file_open(const char *fname)
+{
+ if(dbg_id >= 0)
+ {
+ debug("already open debug file");
+ return -1;
+ }
+
+ enabled_debug_file_output = false;
+
+ dbg_id = async_open(fname, O_WRONLY | O_CREAT | O_APPEND);
+
+ if(dbg_id >= 0)
+ {
+ enabled_debug_file_output = true;
+ debugf("debug file %s open.", fname);
+ }
+ return 0;
+}
+
+void debug_file_close(void)
+{
+ if(dbg_id >= 0)
+ {
+ debug("debug file close.");
+ async_close(dbg_id);
+ enabled_debug_file_output = false;
+ dbg_id = -1;
+ }
+}
+
+void debug_init(void)
+{
+}
+
+void debug_finalize(void)
+{
+ debug_file_close();
+}
+
+void debug_write_buffer_clear(bool flg)
+{
+ async_write_buffer_clear(dbg_id, flg);
+}
+
+void debug_file_output_enabled(bool flg)
+{
+ enabled_debug_file_output = flg;
+}
+#endif /* HAVE_GDB_API */
#endif /* SH7034 */
#ifdef HAVE_GDB_API
@@ -229,6 +301,10 @@
{
}
+void debug_finalize(void)
+{
+}
+
#endif /* HAVE_GDB_API */
#endif /* end of DEBUG section */
diff -u -r -N rockbox_orig/firmware/drivers/fat.c rockbox_diff/firmware/drivers/fat.c
--- rockbox_orig/firmware/drivers/fat.c 2008-05-04 10:41:15.859375000 +0900
+++ rockbox_diff/firmware/drivers/fat.c 2008-05-10 13:49:00.687500000 +0900
@@ -714,7 +714,7 @@
cluster numbers out of bounds */
if ( c < 2 || c > fat_bpb->dataclusters+1 )
continue;
- LDEBUGF("find_free_cluster(%x) == %x\n",startcluster,c);
+ LDEBUGF("find_free_cluster(%lx) == %ux\n",startcluster,c);
fat_bpb->fsinfo.nextfree = c;
return c;
}
@@ -770,7 +770,7 @@
val &= 0xFFFF;
- LDEBUGF("update_fat_entry(%x,%x)\n",entry,val);
+ LDEBUGF("update_fat_entry(%lx,%lx)\n",entry,val);
if (entry==val)
panicf("Creating FAT loop: %lx,%lx\n",entry,val);
@@ -794,7 +794,7 @@
fat_bpb->fsinfo.freecount++;
}
- LDEBUGF("update_fat_entry: %d free clusters\n",
+ LDEBUGF("update_fat_entry: %ld free clusters\n",
fat_bpb->fsinfo.freecount);
sec[offset] = htole16(val);
diff -u -r -N rockbox_orig/firmware/export/asyncfile.h rockbox_diff/firmware/export/asyncfile.h
--- rockbox_orig/firmware/export/asyncfile.h 1970-01-01 09:00:00.000000000 +0900
+++ rockbox_diff/firmware/export/asyncfile.h 2008-05-10 22:39:02.759395200 +0900
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: $
+ *
+ * Copyright (C) 2006 by Yoshihisa Uchida
+ *
+ * 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 ASYNCFILE_H
+#define ASYNCFILE_H
+
+#include
+#include
+#include "file.h"
+
+enum {
+ PROCESS_NOT_REGISTED = 0,
+ PROCESS_NOT_RUN,
+ PROCESS_RUNNING,
+ PROCESS_DONE,
+ PROCESS_ERROR,
+};
+
+extern int asyncfile_init(void);
+extern void asyncfile_finalize(void);
+extern int async_open(const char* pathname, int flags);
+extern int async_close(int entry_id);
+extern int async_read(int entry_id, void *buf, size_t count);
+extern int async_gets(int entry_id, void *buf, size_t count);
+extern int async_write(int entry_id, const void *buf, size_t count);
+extern int async_puts(int entry_id, const char *buf);
+extern int async_write_buffer_clear(int entry_id, bool flg);
+extern struct async_process *get_result(int entry_id, int process_id, bool syncflg);
+extern struct async_process *get_current_result(int entry_id, bool syncflg);
+
+struct async_process
+{
+ int entry_id;
+ int process_id;
+ int status;
+ ssize_t result;
+ void* rbuf;
+ size_t rcount;
+ bool rbflg;
+};
+
+#endif /*ASYNCFILE_H */
diff -u -r -N rockbox_orig/firmware/export/debug.h rockbox_diff/firmware/export/debug.h
--- rockbox_orig/firmware/export/debug.h 2007-03-31 19:12:51.125000000 +0900
+++ rockbox_diff/firmware/export/debug.h 2008-05-08 22:11:11.203125000 +0900
@@ -20,11 +20,29 @@
#define DEBUG_H
#include "../include/_ansi.h"
+#include
+#include "config.h"
extern void debug_init(void);
+extern void debug_finalize(void);
+
+#if CONFIG_CPU == SH7034
extern void debugf(const char* fmt,...) ATTRIBUTE_PRINTF(1, 2);
extern void ldebugf(const char* file, int line, const char *fmt, ...)
ATTRIBUTE_PRINTF(3, 4);
+#endif
+
+#if defined(DEBUG) && CONFIG_CPU != SH7034
+extern int debug_file_open(const char* fname);
+extern void debug_file_close(void);
+extern void debugf(const char* fmt,...);
+extern void debug_write_buffer_clear(bool flg);
+extern void debug_file_output_enabled(bool flg);
+#define ldebugf(file, line, fmt, args...) debugf("%s:%d "fmt, file, line, ##arg)
+#else
+#define debug_write_buffer_clear(...)
+#define debug_file_output_enabled(...)
+#endif
#ifdef __GNUC__
diff -u -r -N rockbox_orig/firmware/mp3_playback.c rockbox_diff/firmware/mp3_playback.c
--- rockbox_orig/firmware/mp3_playback.c 2008-03-30 16:26:19.671875000 +0900
+++ rockbox_diff/firmware/mp3_playback.c 2008-05-10 13:51:36.234375000 +0900
@@ -376,16 +376,16 @@
mas_version_code = mas_readver();
DEBUGF("MAS3587 derivate %d, version %c%d\n",
- (mas_version_code & 0xf000) >> 12,
- 'A' + ((mas_version_code & 0x0f00) >> 8), mas_version_code & 0xff);
+ (int)((mas_version_code & 0xf000) >> 12),
+ 'A' + (int)((mas_version_code & 0x0f00) >> 8), (int)(mas_version_code & 0xff));
#elif CONFIG_CODEC == MAS3539F
or_b(0x08, &PAIORH); /* output for /PR */
init_playback();
mas_version_code = mas_readver();
DEBUGF("MAS3539 derivate %d, version %c%d\n",
- (mas_version_code & 0xf000) >> 12,
- 'A' + ((mas_version_code & 0x0f00) >> 8), mas_version_code & 0xff);
+ (int)((mas_version_code & 0xf000) >> 12),
+ 'A' + (int)((mas_version_code & 0x0f00) >> 8), (int)(mas_version_code & 0xff));
#endif
#ifdef HAVE_DAC3550A
diff -u -r -N rockbox_orig/firmware/mpeg.c rockbox_diff/firmware/mpeg.c
--- rockbox_orig/firmware/mpeg.c 2008-04-28 16:35:43.578125000 +0900
+++ rockbox_diff/firmware/mpeg.c 2008-05-10 13:18:34.343750000 +0900
@@ -1754,7 +1754,7 @@
startpos = prerecord_buffer[startpos].mempos;
DEBUGF("Start looking at address %x (%x)\n",
- audiobuf+startpos, startpos);
+ (unsigned int)(audiobuf+startpos), startpos);
saved_header = mpeg_get_last_header();
@@ -1766,7 +1766,7 @@
audiobuf_read -= audiobuflen;
DEBUGF("New audiobuf_read address: %x (%x)\n",
- audiobuf+audiobuf_read, audiobuf_read);
+ (unsigned int)(audiobuf+audiobuf_read), audiobuf_read);
level = disable_irq_save();
num_rec_bytes = get_unsaved_space();
@@ -2297,7 +2297,7 @@
/* Stop monitoring and start the encoder */
shadow_io_control_main &= ~(1 << 10);
mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
- DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main);
+ DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", (unsigned int)shadow_io_control_main);
/* Wait until the DSP has accepted the settings */
do
@@ -2328,7 +2328,7 @@
and start the encoder */
shadow_io_control_main &= ~(1 << 10);
mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
- DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main);
+ DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", (unsigned int)shadow_io_control_main);
/* Wait until the DSP has accepted the settings */
do
@@ -2401,7 +2401,7 @@
/* Start monitoring */
shadow_io_control_main |= (1 << 10);
mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
- DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main);
+ DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", (unsigned int)shadow_io_control_main);
/* Wait until the DSP has accepted the settings */
do
@@ -2429,12 +2429,12 @@
(1 << 2) /* Is an original */;
mas_writemem(MAS_BANK_D0, MAS_D0_ENCODER_CONTROL, &shadow_encoder_control,1);
- DEBUGF("mas_writemem(MAS_BANK_D0, ENCODER_CONTROL, %x)\n", shadow_encoder_control);
+ DEBUGF("mas_writemem(MAS_BANK_D0, ENCODER_CONTROL, %x)\n", (unsigned int)shadow_encoder_control);
shadow_soft_mute = options->rec_editable?4:0;
mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &shadow_soft_mute,1);
- DEBUGF("mas_writemem(MAS_BANK_D0, SOFT_MUTE, %x)\n", shadow_soft_mute);
+ DEBUGF("mas_writemem(MAS_BANK_D0, SOFT_MUTE, %x)\n", (unsigned int)shadow_soft_mute);
shadow_io_control_main = ((1 << 10) | /* Monitoring ON */
((options->rec_source < 2)?1:2) << 8) | /* Input select */
@@ -2444,7 +2444,7 @@
1; /* Validate */
mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main,1);
- DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main);
+ DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", (unsigned int)shadow_io_control_main);
if(options->rec_source == AUDIO_SRC_MIC)
{
diff -u -r -N rockbox_orig/firmware/target/arm/ipod/app.lds rockbox_diff/firmware/target/arm/ipod/app.lds
--- rockbox_orig/firmware/target/arm/ipod/app.lds 2008-05-04 10:40:57.500000000 +0900
+++ rockbox_diff/firmware/target/arm/ipod/app.lds 2008-05-08 22:46:04.531250000 +0900
@@ -10,7 +10,7 @@
#define CODECSIZE CODEC_SIZE
#ifdef DEBUG
-#define STUBOFFSET 0x10000
+#define STUBOFFSET 0
#else
#define STUBOFFSET 0
#endif
diff -u -r -N rockbox_orig/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c rockbox_diff/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
--- rockbox_orig/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c 2008-05-06 11:54:50.390625000 +0900
+++ rockbox_diff/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c 2008-05-10 22:24:48.609375000 +0900
@@ -1,109 +1,110 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2008 by Maurus Cuelenaere
- *
- * 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 "config.h"
-#include "cpu.h"
-#include "kernel.h"
-#include "thread.h"
-#include "system.h"
-#include "power.h"
-#include "panic.h"
-#include "ata-target.h"
-#include "dm320.h"
-
-void sleep_ms(int ms)
-{
- sleep(ms*HZ/1000);
-}
-
-void ide_power_enable(bool on)
-{
-/* Disabled until figured out what's wrong */
-#if 0
- int old_level = disable_irq_save();
- if(on)
- {
- IO_GIO_BITSET0 = (1 << 14);
- ata_reset();
- }
- else
- IO_GIO_BITCLR0 = (1 << 14);
- restore_irq(old_level);
-#else
- (void)on;
-#endif
-}
-
-inline bool ide_powered()
-{
-#if 0
- return (IO_GIO_BITSET0 & (1 << 14));
-#else
- return true;
-#endif
-}
-
-void ata_reset(void)
-{
- int old_level = disable_irq_save();
- if(!ide_powered())
- {
- ide_power_enable(true);
- sleep_ms(150);
- }
- else
- {
- IO_GIO_BITSET0 = (1 << 5);
- IO_GIO_BITCLR0 = (1 << 3);
- sleep_ms(1);
- }
- IO_GIO_BITCLR0 = (1 << 5);
- sleep_ms(10);
- IO_GIO_BITSET0 = (1 << 3);
- while(!(ATA_COMMAND & STATUS_RDY))
- sleep_ms(10);
- restore_irq(old_level);
-}
-
-void ata_enable(bool on)
-{
- (void)on;
- return;
-}
-
-bool ata_is_coldstart(void)
-{
- return true;
-}
-
-void ata_device_init(void)
-{
- IO_INTC_EINT1 |= INTR_EINT1_EXT2; /* enable GIO2 interrupt */
- //TODO: mimic OF inits...
- return;
-}
-
-void GIO2(void)
-{
-#ifdef DEBUG
- logf("GIO2 interrupt...");
-#endif
- IO_INTC_IRQ1 = INTR_IRQ1_EXT2; /* Mask GIO2 interrupt */
- return;
-}
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 by Maurus Cuelenaere
+ *
+ * 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 "config.h"
+#include "cpu.h"
+#include "kernel.h"
+#include "thread.h"
+#include "system.h"
+#include "power.h"
+#include "panic.h"
+#include "ata-target.h"
+#include "dm320.h"
+#include "logf.h"
+
+void sleep_ms(int ms)
+{
+ sleep(ms*HZ/1000);
+}
+
+void ide_power_enable(bool on)
+{
+/* Disabled until figured out what's wrong */
+#if 0
+ int old_level = disable_irq_save();
+ if(on)
+ {
+ IO_GIO_BITSET0 = (1 << 14);
+ ata_reset();
+ }
+ else
+ IO_GIO_BITCLR0 = (1 << 14);
+ restore_irq(old_level);
+#else
+ (void)on;
+#endif
+}
+
+inline bool ide_powered()
+{
+#if 0
+ return (IO_GIO_BITSET0 & (1 << 14));
+#else
+ return true;
+#endif
+}
+
+void ata_reset(void)
+{
+ int old_level = disable_irq_save();
+ if(!ide_powered())
+ {
+ ide_power_enable(true);
+ sleep_ms(150);
+ }
+ else
+ {
+ IO_GIO_BITSET0 = (1 << 5);
+ IO_GIO_BITCLR0 = (1 << 3);
+ sleep_ms(1);
+ }
+ IO_GIO_BITCLR0 = (1 << 5);
+ sleep_ms(10);
+ IO_GIO_BITSET0 = (1 << 3);
+ while(!(ATA_COMMAND & STATUS_RDY))
+ sleep_ms(10);
+ restore_irq(old_level);
+}
+
+void ata_enable(bool on)
+{
+ (void)on;
+ return;
+}
+
+bool ata_is_coldstart(void)
+{
+ return true;
+}
+
+void ata_device_init(void)
+{
+ IO_INTC_EINT1 |= INTR_EINT1_EXT2; /* enable GIO2 interrupt */
+ //TODO: mimic OF inits...
+ return;
+}
+
+void GIO2(void)
+{
+#ifdef DEBUG
+ logf("GIO2 interrupt...");
+#endif
+ IO_INTC_IRQ1 = INTR_IRQ1_EXT2; /* Mask GIO2 interrupt */
+ return;
+}