summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2023-01-02 19:49:56 +0000
committerAidan MacDonald <amachronic@protonmail.com>2023-01-15 10:04:13 +0000
commitf995c26de92eadbf3d961ad3e0fb233410798dd2 (patch)
treec21b09cf52d2f9d08d88c9b5fbd3b8f3551e35f6
parent680261fbb7c3c0a4cde4321c35ce3fe0e6b0cce8 (diff)
downloadrockbox-f995c26de92eadbf3d961ad3e0fb233410798dd2.tar.gz
rockbox-f995c26de92eadbf3d961ad3e0fb233410798dd2.zip
buflib: Add CONFIG_BUFLIB_BACKEND for selecting a buflib backend
Defaults to the normal "mempool" backend, which is currently the only implementation. Change-Id: I56d034a6e0f5edc90c39526d1551945eec6ca336
-rw-r--r--apps/plugin.h2
-rw-r--r--firmware/SOURCES2
-rw-r--r--firmware/buflib_mempool.c2
-rw-r--r--firmware/core_alloc.c2
-rw-r--r--firmware/export/config.h7
-rw-r--r--firmware/include/buflib.h30
-rw-r--r--firmware/include/buflib_mempool.h4
-rw-r--r--firmware/include/chunk_alloc.h2
-rw-r--r--firmware/include/core_alloc.h2
9 files changed, 48 insertions, 5 deletions
diff --git a/apps/plugin.h b/apps/plugin.h
index ea69cbe2b2..850e7484d9 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -100,7 +100,7 @@ int plugin_open(const char *plugin, const char *parameter);
100#include "list.h" 100#include "list.h"
101#include "tree.h" 101#include "tree.h"
102#include "color_picker.h" 102#include "color_picker.h"
103#include "buflib_mempool.h" 103#include "buflib.h"
104#include "buffering.h" 104#include "buffering.h"
105#include "tagcache.h" 105#include "tagcache.h"
106#include "viewport.h" 106#include "viewport.h"
diff --git a/firmware/SOURCES b/firmware/SOURCES
index c8789756aa..02e962c0c3 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -4,7 +4,9 @@
4ata_idle_notify.c 4ata_idle_notify.c
5events.c 5events.c
6backlight.c 6backlight.c
7#if CONFIG_BUFLIB_BACKEND == BUFLIB_BACKEND_MEMPOOL
7buflib_mempool.c 8buflib_mempool.c
9#endif
8core_alloc.c 10core_alloc.c
9general.c 11general.c
10powermgmt.c 12powermgmt.c
diff --git a/firmware/buflib_mempool.c b/firmware/buflib_mempool.c
index 18e4f118ff..cb35290c03 100644
--- a/firmware/buflib_mempool.c
+++ b/firmware/buflib_mempool.c
@@ -29,7 +29,7 @@
29#include <stdlib.h> /* for abs() */ 29#include <stdlib.h> /* for abs() */
30#include <stdio.h> /* for snprintf() */ 30#include <stdio.h> /* for snprintf() */
31#include <stddef.h> /* for ptrdiff_t */ 31#include <stddef.h> /* for ptrdiff_t */
32#include "buflib_mempool.h" 32#include "buflib.h"
33#include "string-extra.h" /* strmemccpy() */ 33#include "string-extra.h" /* strmemccpy() */
34#include "debug.h" 34#include "debug.h"
35#include "panic.h" 35#include "panic.h"
diff --git a/firmware/core_alloc.c b/firmware/core_alloc.c
index 6f6c385597..948911b973 100644
--- a/firmware/core_alloc.c
+++ b/firmware/core_alloc.c
@@ -3,7 +3,7 @@
3#include <string.h> 3#include <string.h>
4#include "system.h" 4#include "system.h"
5#include "core_alloc.h" 5#include "core_alloc.h"
6#include "buflib_mempool.h" 6#include "buflib.h"
7 7
8/* not static so it can be discovered by core_get_data() */ 8/* not static so it can be discovered by core_get_data() */
9struct buflib_context core_ctx; 9struct buflib_context core_ctx;
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 8726a8d6f4..d8674c40f2 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -380,6 +380,9 @@ Lyre prototype 1 */
380#define IMX233_FREESCALE (1 << 0) /* Freescale I.MX233 nonstandard two-level MBR */ 380#define IMX233_FREESCALE (1 << 0) /* Freescale I.MX233 nonstandard two-level MBR */
381#define IMX233_CREATIVE (1 << 1) /* Creative MBLK windowing */ 381#define IMX233_CREATIVE (1 << 1) /* Creative MBLK windowing */
382 382
383/* CONFIG_BUFLIB_BACKEND */
384#define BUFLIB_BACKEND_MEMPOOL 0 /* Default memory pool backed buflib */
385
383/* now go and pick yours */ 386/* now go and pick yours */
384#if defined(IRIVER_H100) 387#if defined(IRIVER_H100)
385#include "config/iriverh100.h" 388#include "config/iriverh100.h"
@@ -606,6 +609,10 @@ Lyre prototype 1 */
606#undef CONFIG_STORAGE 609#undef CONFIG_STORAGE
607#endif 610#endif
608 611
612#ifndef CONFIG_BUFLIB_BACKEND
613# define CONFIG_BUFLIB_BACKEND BUFLIB_BACKEND_MEMPOOL
614#endif
615
609#ifdef APPLICATION 616#ifdef APPLICATION
610#define CONFIG_CPU 0 617#define CONFIG_CPU 0
611#endif 618#endif
diff --git a/firmware/include/buflib.h b/firmware/include/buflib.h
new file mode 100644
index 0000000000..36d171963a
--- /dev/null
+++ b/firmware/include/buflib.h
@@ -0,0 +1,30 @@
1/**************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2023 Aidan MacDonald
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef _BUFLIB_H_
22#define _BUFLIB_H_
23
24#include "config.h"
25
26#if CONFIG_BUFLIB_BACKEND == BUFLIB_BACKEND_MEMPOOL
27#include "buflib_mempool.h"
28#endif
29
30#endif /* _BUFLIB_H_ */
diff --git a/firmware/include/buflib_mempool.h b/firmware/include/buflib_mempool.h
index 61fe2168b0..f261d4abda 100644
--- a/firmware/include/buflib_mempool.h
+++ b/firmware/include/buflib_mempool.h
@@ -26,6 +26,10 @@
26#ifndef _BUFLIB_MEMPOOL_H_ 26#ifndef _BUFLIB_MEMPOOL_H_
27#define _BUFLIB_MEMPOOL_H_ 27#define _BUFLIB_MEMPOOL_H_
28 28
29#ifndef _BUFLIB_H_
30# error "include buflib.h instead"
31#endif
32
29#include <stdint.h> 33#include <stdint.h>
30#include <stdbool.h> 34#include <stdbool.h>
31#include <string.h> 35#include <string.h>
diff --git a/firmware/include/chunk_alloc.h b/firmware/include/chunk_alloc.h
index f589cc0870..7d64d4b591 100644
--- a/firmware/include/chunk_alloc.h
+++ b/firmware/include/chunk_alloc.h
@@ -24,7 +24,7 @@
24#include <stdbool.h> 24#include <stdbool.h>
25#include <string.h> 25#include <string.h>
26#include "config.h" 26#include "config.h"
27#include "buflib_mempool.h" 27#include "buflib.h"
28 28
29#define CHUNK_ALLOC_INVALID ((size_t)-1) 29#define CHUNK_ALLOC_INVALID ((size_t)-1)
30 30
diff --git a/firmware/include/core_alloc.h b/firmware/include/core_alloc.h
index 382200dd75..22cc1988da 100644
--- a/firmware/include/core_alloc.h
+++ b/firmware/include/core_alloc.h
@@ -4,7 +4,7 @@
4#include <string.h> 4#include <string.h>
5#include <stdbool.h> 5#include <stdbool.h>
6#include "config.h" 6#include "config.h"
7#include "buflib_mempool.h" 7#include "buflib.h"
8#include "chunk_alloc.h" 8#include "chunk_alloc.h"
9 9
10/* All functions below are wrappers for functions in buflib.h, except 10/* All functions below are wrappers for functions in buflib.h, except