summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/gui/skin_engine/skin_engine.c1
-rw-r--r--apps/menus/main_menu.c1
-rw-r--r--apps/mp3data.c1
-rw-r--r--apps/plugin.c1
-rw-r--r--apps/recorder/pcm_record.c1
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/buffer.c202
-rw-r--r--firmware/buflib.c1
-rw-r--r--firmware/core_alloc.c35
-rw-r--r--firmware/include/buffer.h38
-rw-r--r--firmware/thread.c11
-rw-r--r--flash/bootbox/main.c2
12 files changed, 29 insertions, 266 deletions
diff --git a/apps/gui/skin_engine/skin_engine.c b/apps/gui/skin_engine/skin_engine.c
index 30ec0e75b8..74abd92fdf 100644
--- a/apps/gui/skin_engine/skin_engine.c
+++ b/apps/gui/skin_engine/skin_engine.c
@@ -30,7 +30,6 @@
#include "settings.h"
#include "wps.h"
#include "file.h"
-#include "buffer.h"
#if CONFIG_TUNER
#include "radio.h"
#endif
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index bb8ea276fb..b6ce9e75c6 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -42,7 +42,6 @@
#include "screens.h"
#include "plugin.h"
#include "talk.h"
-#include "buffer.h"
#include "splash.h"
#include "debug_menu.h"
#include "version.h"
diff --git a/apps/mp3data.c b/apps/mp3data.c
index 53f13f4f64..79baec3df2 100644
--- a/apps/mp3data.c
+++ b/apps/mp3data.c
@@ -38,7 +38,6 @@
#include "logf.h"
#include "mp3data.h"
#include "file.h"
-#include "buffer.h"
#include "system.h"
//#define DEBUG_VERBOSE
diff --git a/apps/plugin.c b/apps/plugin.c
index b9c2e7cb5b..3cc9e6c413 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -27,7 +27,6 @@
#include "lang.h"
#include "led.h"
#include "keyboard.h"
-#include "buffer.h"
#include "backlight.h"
#include "sound_menu.h"
#include "mp3data.h"
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c
index 3b069b6dc8..e83db0f418 100644
--- a/apps/recorder/pcm_record.c
+++ b/apps/recorder/pcm_record.c
@@ -29,7 +29,6 @@
#include "string-extra.h"
#include "storage.h"
#include "usb.h"
-#include "buffer.h"
#include "general.h"
#include "codec_thread.h"
#include "audio.h"
diff --git a/firmware/SOURCES b/firmware/SOURCES
index b918a19418..f5ee7873a2 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1,7 +1,6 @@
ata_idle_notify.c
events.c
backlight.c
-buffer.c
buflib.c
core_alloc.c
general.c
diff --git a/firmware/buffer.c b/firmware/buffer.c
deleted file mode 100644
index e0496fe149..0000000000
--- a/firmware/buffer.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-#include <stdio.h>
-#include <stdint.h>
-#include "system.h"
-#include "buffer.h"
-#include "panic.h"
-#include "logf.h"
-
-#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
-#else
-#endif
-
-/* defined in linker script */
-#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
-#if defined(IPOD_VIDEO) && !defined(BOOTLOADER)
-extern unsigned char *audiobufend_lds[];
-unsigned char *audiobufend;
-#else /* !IPOD_VIDEO */
-extern unsigned char audiobufend[];
-#endif
-/* defined in linker script */
-extern unsigned char audiobuffer[];
-#else /* PLATFORM_HOSTED */
-unsigned char audiobuffer[(MEMORYSIZE*1024-256)*1024];
-unsigned char *audiobufend = audiobuffer + sizeof(audiobuffer);
-extern unsigned char *audiobufend;
-#endif
-
-static unsigned char *audiobuf;
-
-#ifdef BUFFER_ALLOC_DEBUG
-static unsigned char *audiobuf_orig_start;
-
-struct buffer_start_marker
-{
- unsigned int magic;
- size_t buffer_size;
-};
-#define BUF_MAGIC 0xDEADD0D0
-
-struct buffer_end_marker
-{
- unsigned int magic;
- int last;
-};
-#endif /* BUFFER_ALLOC_DEBUG */
-
-void buffer_init(void)
-{
- /* 32-bit aligned */
- audiobuf = (void *)(((unsigned long)audiobuffer + 3) & ~3);
-
-#if defined(IPOD_VIDEO) && !defined(BOOTLOADER) && !defined(SIMULATOR)
- audiobufend=(unsigned char *)audiobufend_lds;
- if(MEMORYSIZE==64 && probed_ramsize!=64)
- {
- audiobufend -= (32<<20);
- }
-#endif
-
-#ifdef BUFFER_ALLOC_DEBUG
- audiobuf_orig_start = audiobuf;
-#endif /* BUFFER_ALLOC_DEBUG */
-}
-
-/* protect concurrent access */
-static volatile int lock;
-
-/*
- * Give the entire buffer, return the size in size.
- * The caller needs to make sure audiobuf is not otherwise used
- *
- * Note that this does not modify the buffer position (buffer_release_buffer()
- * does), so call this if you want to aquire temporary memory
- **/
-void *buffer_get_buffer(size_t *size)
-{
- if (lock)
- panicf("concurrent audiobuf access");
- lock = 1;
- audiobuf = ALIGN_UP(audiobuf, sizeof(intptr_t));
- *size = (audiobufend - audiobuf);
- return audiobuf;
-}
-
-/*
- * Release the buffer gotten with buffer_get_buffer
- *
- * size should have the amount of bytes (from the front) that caller keeps for
- * its own, 0 if the entire buffer is to be released
- *
- * safe to be called with size=0 even if the buffer wasn't claimed before
- **/
-void buffer_release_buffer(size_t size)
-{
- audiobuf += size;
- /* ensure alignment */
- audiobuf = ALIGN_UP(audiobuf, sizeof(intptr_t));
- lock = 0;
-}
-
-/*
- * Query how much free space the buffer has */
-size_t buffer_available(void)
-{
- return audiobufend - audiobuf;
-}
-
-void *buffer_alloc(size_t size)
-{
- if (lock) /* it's not save to call this here */
- panicf("buffer_alloc(): exclusive buffer owner");
- void *retval;
-#ifdef BUFFER_ALLOC_DEBUG
- struct buffer_start_marker *start;
- struct buffer_end_marker *end;
-#endif /* BUFFER_ALLOC_DEBUG */
-
- /* 32-bit aligned */
- size = (size + 3) & ~3;
-
- /* Other code touches audiobuf. Make sure it stays aligned */
- audiobuf = (void *)(((unsigned long)audiobuf + 3) & ~3);
-
- retval = audiobuf;
-
-#ifdef BUFFER_ALLOC_DEBUG
- retval +=sizeof(struct buffer_start_marker);
- if(size>0)
- {
- end=(struct buffer_end_marker*)(audiobuf - sizeof(struct buffer_end_marker));
- if(end->magic == BUF_MAGIC)
- {
- end->last=0;
- }
- start=(struct buffer_start_marker*)audiobuf;
- start->magic = BUF_MAGIC;
- start->buffer_size = size;
- end=(struct buffer_end_marker*)(audiobuf+sizeof(struct buffer_start_marker)+size);
- end->magic = BUF_MAGIC;
- end->last = 1;
-
- audiobuf = ((unsigned char *)end) + sizeof(struct buffer_end_marker);
- }
-
- logf("Alloc %x %d",(unsigned int)retval,size);
-#else /* !BUFFER_ALLOC_DEBUG */
- audiobuf += size;
-#endif /* BUFFER_ALLOC_DEBUG */
-
- if (audiobuf > audiobufend) {
- panicf("OOM: %d bytes", (int) size);
- }
-
- return retval;
-}
-
-#ifdef BUFFER_ALLOC_DEBUG
-void buffer_alloc_check(char *name)
-{
- unsigned char *buf_ptr = audiobuf_orig_start;
- struct buffer_start_marker *start;
- struct buffer_end_marker *end;
-
-
- while(buf_ptr < audiobuf)
- {
- start=(struct buffer_start_marker*)buf_ptr;
- if(start->magic != BUF_MAGIC)
- {
- panicf("%s corrupted buffer %x start", name,(unsigned int)buf_ptr+sizeof(struct buffer_start_marker));
- }
- end=(struct buffer_end_marker*)(buf_ptr+sizeof(struct buffer_start_marker)+start->buffer_size);
- if(end->magic != BUF_MAGIC)
- {
- panicf("%s corrupted %x end", name,(unsigned int)buf_ptr+sizeof(struct buffer_start_marker));
- }
- if(end->last)
- break;
- buf_ptr=((unsigned char *)end)+sizeof(struct buffer_end_marker);
- }
-}
-#endif /* BUFFER_ALLOC_DEBUG */
diff --git a/firmware/buflib.c b/firmware/buflib.c
index 748e8a2378..d3f1455c99 100644
--- a/firmware/buflib.c
+++ b/firmware/buflib.c
@@ -30,7 +30,6 @@
#include "buflib.h"
#include "string-extra.h" /* strlcpy() */
#include "debug.h"
-#include "buffer.h"
#include "system.h" /* for ALIGN_*() */
/* The main goal of this design is fast fetching of the pointer for a handle.
diff --git a/firmware/core_alloc.c b/firmware/core_alloc.c
index 21dd1319dd..34ed48b39f 100644
--- a/firmware/core_alloc.c
+++ b/firmware/core_alloc.c
@@ -1,21 +1,44 @@
+#include "config.h"
#include <string.h>
+#include "system.h"
#include "core_alloc.h"
#include "buflib.h"
-#include "buffer.h"
/* not static so it can be discovered by core_get_data() */
struct buflib_context core_ctx;
+/* defined in linker script */
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
+#if defined(IPOD_VIDEO) && !defined(BOOTLOADER)
+extern unsigned char *audiobufend_lds[];
+unsigned char *audiobufend;
+#else /* !IPOD_VIDEO */
+extern unsigned char audiobufend[];
+#endif
+/* defined in linker script */
+extern unsigned char audiobuffer[];
+#else /* PLATFORM_HOSTED */
+unsigned char audiobuffer[(MEMORYSIZE*1024-256)*1024];
+unsigned char *audiobufend = audiobuffer + sizeof(audiobuffer);
+extern unsigned char *audiobufend;
+#endif
+
/* debug test alloc */
static int test_alloc;
void core_allocator_init(void)
{
- buffer_init();
- size_t size;
- void *start = buffer_get_buffer(&size);
- buflib_init(&core_ctx, start, size);
- buffer_release_buffer(size);
+ unsigned char *start = ALIGN_UP(audiobuffer, sizeof(intptr_t));
+
+#if defined(IPOD_VIDEO) && !defined(BOOTLOADER) && !defined(SIMULATOR)
+ audiobufend=(unsigned char *)audiobufend_lds;
+ if(MEMORYSIZE==64 && probed_ramsize!=64)
+ {
+ audiobufend -= (32<<20);
+ }
+#endif
+
+ buflib_init(&core_ctx, start, audiobufend - start);
test_alloc = core_alloc("test", 112);
}
diff --git a/firmware/include/buffer.h b/firmware/include/buffer.h
deleted file mode 100644
index bdf91bcb3f..0000000000
--- a/firmware/include/buffer.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-#ifndef BUFFER_H
-#define BUFFER_H
-
-#include "config.h"
-
-void buffer_init(void) INIT_ATTR;
-
-void* buffer_get_buffer(size_t *size);
-void buffer_release_buffer(size_t size);
-size_t buffer_available(void);
-
-void *buffer_alloc(size_t size);
-
-#ifdef BUFFER_ALLOC_DEBUG
-void buffer_alloc_check(char *name);
-#endif
-
-#endif
diff --git a/firmware/thread.c b/firmware/thread.c
index cfedbbedba..a1886cbc07 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -27,7 +27,6 @@
#include "kernel.h"
#include "cpu.h"
#include "string.h"
-#include "buffer.h"
#ifdef RB_PROFILE
#include <profile.h>
#endif
@@ -1168,16 +1167,6 @@ void switch_thread(void)
if (UNLIKELY(thread->stack[0] != DEADBEEF) && thread->stack_size > 0)
thread_stkov(thread);
-#ifdef BUFFER_ALLOC_DEBUG
- /* Check if the current thread just did bad things with buffer_alloc()ed
- * memory */
- {
- static char name[32];
- thread_get_name(name, 32, thread);
- buffer_alloc_check(name);
- }
-#endif
-
#if NUM_CORES > 1
/* Run any blocking operations requested before switching/sleeping */
run_blocking_ops(core, thread);
diff --git a/flash/bootbox/main.c b/flash/bootbox/main.c
index e4be785beb..ff6b8374e9 100644
--- a/flash/bootbox/main.c
+++ b/flash/bootbox/main.c
@@ -39,7 +39,6 @@
#include "panic.h"
#include "power.h"
#include "file.h"
-#include "buffer.h"
#include "rolo.h"
#include "usb.h"
#include "powermgmt.h"
@@ -146,7 +145,6 @@ void main(void)
power_init();
system_init();
kernel_init();
- buffer_init();
lcd_init();
show_logo();
enable_irq();