summaryrefslogtreecommitdiffstats
path: root/firmware/export
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/ak4376.h4
-rw-r--r--firmware/export/backtrace.h3
-rw-r--r--firmware/export/config.h12
-rw-r--r--firmware/export/config/erosqnative.h6
-rw-r--r--firmware/export/config/fiiom3k.h15
-rw-r--r--firmware/export/config/gigabeats.h3
-rw-r--r--firmware/export/config/sansaclipplus.h1
-rw-r--r--firmware/export/config/sansaclipzip.h1
-rw-r--r--firmware/export/config/sansae200.h1
-rw-r--r--firmware/export/config/sansafuze.h1
-rw-r--r--firmware/export/config/sansafuzeplus.h1
-rw-r--r--firmware/export/config/sansafuzev2.h1
-rw-r--r--firmware/export/config/shanlingq1.h6
-rw-r--r--firmware/export/lcd.h11
-rw-r--r--firmware/export/linuxboot.h192
-rw-r--r--firmware/export/mi4-loader.h22
-rw-r--r--firmware/export/multiboot.h30
-rw-r--r--firmware/export/mv.h4
-rw-r--r--firmware/export/pathfuncs.h7
-rw-r--r--firmware/export/powermgmt.h9
-rw-r--r--firmware/export/rbpaths.h3
-rw-r--r--firmware/export/screendump.h14
-rw-r--r--firmware/export/si4700.h8
-rw-r--r--firmware/export/system.h7
-rw-r--r--firmware/export/usb.h1
-rw-r--r--firmware/export/x1000.h55
26 files changed, 367 insertions, 51 deletions
diff --git a/firmware/export/ak4376.h b/firmware/export/ak4376.h
index 0ae156bc37..ad842b2b80 100644
--- a/firmware/export/ak4376.h
+++ b/firmware/export/ak4376.h
@@ -22,7 +22,9 @@
#ifndef __AK4376_H__
#define __AK4376_H__
-#define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP|POWER_MODE_CAP)
+/* The target config must define this; defining it here would prevent
+ the target from supporting audio recording via an alternate codec. */
+/* #define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP|POWER_MODE_CAP) */
#define AUDIOHW_HAVE_SHORT2_ROLL_OFF
#define AK4376_MIN_VOLUME (-890)
diff --git a/firmware/export/backtrace.h b/firmware/export/backtrace.h
index 283e293b2a..fb007ab004 100644
--- a/firmware/export/backtrace.h
+++ b/firmware/export/backtrace.h
@@ -25,6 +25,9 @@
#ifdef BACKTRACE_UNWARMINDER
#include "backtrace-unwarminder.h"
#endif
+#ifdef BACKTRACE_MIPSUNWINDER
+#include "backtrace-mipsunwinder.h"
+#endif
/* Print a backtrace using lcd_* functions, starting at the given line and updating
* the line number. On targets that support it (typically native targets), the
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 2ae7ef2c53..6465bdcb0e 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -728,7 +728,7 @@ Lyre prototype 1 */
#ifdef HAVE_RDS_CAP
/* combinable bitflags */
-#define RDS_CFG_ISR 0x1 /* uses ISR to process packets */
+/* 0x01 can be reused, was RDS_CFG_ISR */
#define RDS_CFG_PROCESS 0x2 /* uses raw packet processing */
#define RDS_CFG_PUSH 0x4 /* pushes processed information */
#define RDS_CFG_POLL 0x8 /* tuner driver provides a polling function */
@@ -869,6 +869,12 @@ Lyre prototype 1 */
#define HAVE_MULTIBOOT
#endif
+/* The lowest numbered volume to read a multiboot redirect from; default is to
+ * allow any volume but some targets may wish to exclude the internal drive. */
+#if defined(HAVE_MULTIBOOT) && !defined(MULTIBOOT_MIN_VOLUME)
+# define MULTIBOOT_MIN_VOLUME 0
+#endif
+
#ifndef NUM_DRIVES
#define NUM_DRIVES 1
#endif
@@ -1281,6 +1287,10 @@ Lyre prototype 1 */
#endif /* SIMULATOR */
#endif /* default SDL SW volume conditions */
+#if !defined(BOOTLOADER) || defined(HAVE_BOOTLOADER_SCREENDUMP)
+# define HAVE_SCREENDUMP
+#endif
+
/* null audiohw setting macro for when codec header is included for reasons
other than audio support */
#define AUDIOHW_SETTING(name, us, nd, st, minv, maxv, defv, expr...)
diff --git a/firmware/export/config/erosqnative.h b/firmware/export/config/erosqnative.h
index a76e8f6426..c71f7ade49 100644
--- a/firmware/export/config/erosqnative.h
+++ b/firmware/export/config/erosqnative.h
@@ -78,6 +78,7 @@
#define HAVE_HOTSWAP
#define HAVE_HOTSWAP_STORAGE_AS_MAIN
#define HAVE_MULTIDRIVE
+#define HAVE_MULTIVOLUME
#define NUM_DRIVES 1
#define STORAGE_WANTS_ALIGN
#define STORAGE_NEEDS_BOUNCE_BUFFER
@@ -103,6 +104,10 @@
#define CURRENT_BACKLIGHT 180
#define CURRENT_MAX_CHG 500 // bursts higher if needed
+/* Multiboot */
+#define HAVE_BOOTDATA
+#define BOOT_REDIR "rockbox_main.aigo_erosqn"
+
/* USB support */
#ifndef SIMULATOR
#define CONFIG_USBOTG USBOTG_DESIGNWARE
@@ -136,3 +141,4 @@
#define HAVE_TAGCACHE
#define HAVE_QUICKSCREEN
#define HAVE_HOTKEY
+#define HAVE_BOOTLOADER_SCREENDUMP
diff --git a/firmware/export/config/fiiom3k.h b/firmware/export/config/fiiom3k.h
index 45c2150208..ab3e274243 100644
--- a/firmware/export/config/fiiom3k.h
+++ b/firmware/export/config/fiiom3k.h
@@ -55,11 +55,16 @@
/* Codec / audio hardware defines */
#define HW_SAMPR_CAPS SAMPR_CAP_ALL_192
+#define REC_SAMPR_CAPS (SAMPR_CAP_ALL_96 & ~SAMPR_CAP_64)
+#define INPUT_SRC_CAPS SRC_CAP_MIC
+#define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP|POWER_MODE_CAP|MIC_GAIN_CAP)
+#define HAVE_RECORDING
+#define HAVE_RECORDING_WITHOUT_MONITORING
#define HAVE_AK4376
+#define HAVE_X1000_ICODEC_REC
#define HAVE_SW_TONE_CONTROLS
#define HAVE_SW_VOLUME_CONTROL
-
-/* TODO: Need to implement recording */
+#define DEFAULT_REC_MIC_GAIN 12
/* Button defines */
#define CONFIG_KEYPAD FIIO_M3K_PAD
@@ -79,6 +84,7 @@
#define HAVE_HOTSWAP
#define HAVE_HOTSWAP_STORAGE_AS_MAIN
#define HAVE_MULTIDRIVE
+#define HAVE_MULTIVOLUME
#define NUM_DRIVES 1
#define STORAGE_WANTS_ALIGN
#define STORAGE_NEEDS_BOUNCE_BUFFER
@@ -104,6 +110,10 @@
#define BATTERY_CAPACITY_INC 0
#define BATTERY_TYPES_COUNT 1
+/* Multiboot */
+#define HAVE_BOOTDATA
+#define BOOT_REDIR "rockbox_main.fiio_m3k"
+
/* USB support */
#ifndef SIMULATOR
#define CONFIG_USBOTG USBOTG_DESIGNWARE
@@ -139,3 +149,4 @@
#define HAVE_HOTKEY
#define HAVE_LOCKED_ACTIONS
#define AB_REPEAT_ENABLE
+#define HAVE_BOOTLOADER_SCREENDUMP
diff --git a/firmware/export/config/gigabeats.h b/firmware/export/config/gigabeats.h
index 8d82b44065..edf76d0e98 100644
--- a/firmware/export/config/gigabeats.h
+++ b/firmware/export/config/gigabeats.h
@@ -121,7 +121,6 @@
/* Define this if you have a SI4700 fm radio tuner */
#define CONFIG_TUNER SI4700
#define HAVE_RDS_CAP
-#define CONFIG_RDS (RDS_CFG_ISR | RDS_CFG_PROCESS)
/* define this if you can flip your LCD */
#define HAVE_LCD_FLIP
@@ -164,7 +163,7 @@
#define GPIO_EVENT_MASK (USE_GPIO1_EVENTS)
/* Define this if target has an additional number of threads specific to it */
-#define TARGET_EXTRA_THREADS 1
+#define TARGET_EXTRA_THREADS 2 /* one is for RDS */
/* Type of mobile power - check this out */
#define BATTERY_CAPACITY_DEFAULT 700 /* default battery capacity */
diff --git a/firmware/export/config/sansaclipplus.h b/firmware/export/config/sansaclipplus.h
index e0df0c28c3..e78063ef02 100644
--- a/firmware/export/config/sansaclipplus.h
+++ b/firmware/export/config/sansaclipplus.h
@@ -11,6 +11,7 @@
#define HAVE_BOOTDATA
/* define boot redirect file name allows booting from external drives */
#define BOOT_REDIR "rockbox_main.clip+"
+#define MULTIBOOT_MIN_VOLUME 1
#define HAVE_MULTIDRIVE
#define NUM_DRIVES 2
diff --git a/firmware/export/config/sansaclipzip.h b/firmware/export/config/sansaclipzip.h
index 6afe6e129e..d8b18e1a18 100644
--- a/firmware/export/config/sansaclipzip.h
+++ b/firmware/export/config/sansaclipzip.h
@@ -11,6 +11,7 @@
#define HAVE_BOOTDATA
/* define boot redirect file name allows booting from external drives */
#define BOOT_REDIR "rockbox_main.clipzip"
+#define MULTIBOOT_MIN_VOLUME 1
#define HAVE_MULTIDRIVE
#define NUM_DRIVES 2
diff --git a/firmware/export/config/sansae200.h b/firmware/export/config/sansae200.h
index 59e531241f..6bb2df9bc8 100644
--- a/firmware/export/config/sansae200.h
+++ b/firmware/export/config/sansae200.h
@@ -13,6 +13,7 @@
/* define boot redirect file name allows booting from external drives */
#define BOOT_REDIR "rockbox_main.e200"
+#define MULTIBOOT_MIN_VOLUME 1
/* define this if you have recording possibility */
#define HAVE_RECORDING
diff --git a/firmware/export/config/sansafuze.h b/firmware/export/config/sansafuze.h
index b72f5b5198..e8f7157deb 100644
--- a/firmware/export/config/sansafuze.h
+++ b/firmware/export/config/sansafuze.h
@@ -10,6 +10,7 @@
/* define boot redirect file name allows booting from external drives */
#define BOOT_REDIR "rockbox_main.fuze"
+#define MULTIBOOT_MIN_VOLUME 1
#define HW_SAMPR_CAPS SAMPR_CAP_ALL_96
diff --git a/firmware/export/config/sansafuzeplus.h b/firmware/export/config/sansafuzeplus.h
index a853cb13b5..9b91e114bc 100644
--- a/firmware/export/config/sansafuzeplus.h
+++ b/firmware/export/config/sansafuzeplus.h
@@ -12,6 +12,7 @@
#define HAVE_BOOTDATA
/* define boot redirect file name allows booting from external drives */
#define BOOT_REDIR "rockbox_main.fuze+"
+#define MULTIBOOT_MIN_VOLUME 1
// HW can do it but we don't have the IRAM for mix buffers
//#define HW_SAMPR_CAPS SAMPR_CAP_ALL_192
diff --git a/firmware/export/config/sansafuzev2.h b/firmware/export/config/sansafuzev2.h
index fc2ff68257..96d3b2deee 100644
--- a/firmware/export/config/sansafuzev2.h
+++ b/firmware/export/config/sansafuzev2.h
@@ -10,6 +10,7 @@
/* define boot redirect file name allows booting from external drives */
#define BOOT_REDIR "rockbox_main.fuze2"
+#define MULTIBOOT_MIN_VOLUME 1
#define HW_SAMPR_CAPS SAMPR_CAP_ALL_96
diff --git a/firmware/export/config/shanlingq1.h b/firmware/export/config/shanlingq1.h
index 1355c1824e..6f5365a97e 100644
--- a/firmware/export/config/shanlingq1.h
+++ b/firmware/export/config/shanlingq1.h
@@ -67,6 +67,7 @@
#define HAVE_HOTSWAP
#define HAVE_HOTSWAP_STORAGE_AS_MAIN
#define HAVE_MULTIDRIVE
+#define HAVE_MULTIVOLUME
#define NUM_DRIVES 1
#define STORAGE_WANTS_ALIGN
#define STORAGE_NEEDS_BOUNCE_BUFFER
@@ -94,6 +95,10 @@
#define BATTERY_CAPACITY_INC 0
#define BATTERY_TYPES_COUNT 1
+/* Multiboot */
+#define HAVE_BOOTDATA
+#define BOOT_REDIR "rockbox_main.shanling_q1"
+
/* USB support */
#ifndef SIMULATOR
#define CONFIG_USBOTG USBOTG_DESIGNWARE
@@ -128,3 +133,4 @@
#define HAVE_QUICKSCREEN
#define HAVE_HOTKEY
#define AB_REPEAT_ENABLE
+#define HAVE_BOOTLOADER_SCREENDUMP
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index ffaf1a63d2..0edef7b866 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -178,9 +178,12 @@ struct frame_buffer_t {
#define VP_IS_RTL(vp) (((vp)->flags & VP_FLAG_ALIGNMENT_MASK) == VP_FLAG_ALIGN_RIGHT)
-#define VP_FLAG_VP_DIRTY 0x4000
-#define VP_FLAG_CLEAR_FLAG 0x8000
+#define VP_FLAG_OWNER_UPDATE 0x2000 /* block update_vp functions */
+#define VP_FLAG_VP_DIRTY 0x4000
+#define VP_FLAG_CLEAR_FLAG 0x8000
#define VP_FLAG_VP_SET_CLEAN (VP_FLAG_CLEAR_FLAG | VP_FLAG_VP_DIRTY)
+/* flags set by viewport_set_defaults() */
+#define VP_DEFAULT_FLAGS (VP_FLAG_VP_DIRTY)
struct viewport {
int x;
@@ -507,7 +510,9 @@ typedef void lcd_blockfunc_type(fb_data *address, unsigned mask, unsigned bits);
extern struct viewport* lcd_current_viewport;
-#define FBADDR(x,y) ((fb_data*) lcd_current_viewport->buffer->get_address_fn(x, y))
+#define FB_CURRENTVP_BUFFER (lcd_current_viewport->buffer)
+#define FBADDRBUF(buffer,x,y) ((fb_data*) buffer->get_address_fn(x,y))
+#define FBADDR(x,y) (FBADDRBUF(lcd_current_viewport->buffer,x,y))
#define FRAMEBUFFER_SIZE (sizeof(fb_data)*LCD_FBWIDTH*LCD_FBHEIGHT)
diff --git a/firmware/export/linuxboot.h b/firmware/export/linuxboot.h
new file mode 100644
index 0000000000..de6f24bf57
--- /dev/null
+++ b/firmware/export/linuxboot.h
@@ -0,0 +1,192 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2022 Aidan MacDonald
+ *
+ * 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 __LINUXBOOT_H__
+#define __LINUXBOOT_H__
+
+#include "system.h"
+#include <stddef.h>
+#include <sys/types.h>
+
+/*
+ * From u-boot's include/image.h
+ * SPDX-License-Identifier: GPL-2.0+
+ * (C) Copyright 2008 Semihalf
+ * (C) Copyright 2000-2005
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ */
+
+#define IH_MAGIC 0x27051956
+#define IH_NMLEN 32
+
+enum
+{
+ IH_ARCH_INVALID,
+ IH_ARCH_ALPHA,
+ IH_ARCH_ARM,
+ IH_ARCH_I386,
+ IH_ARCH_IA64,
+ IH_ARCH_MIPS,
+ IH_ARCH_MIPS64,
+ IH_ARCH_PPC,
+ IH_ARCH_S390,
+ IH_ARCH_SH,
+ IH_ARCH_SPARC,
+ IH_ARCH_SPARC64,
+ IH_ARCH_M68K,
+ /* NOTE: Other archs not relevant and omitted here, can add if needed */
+ IH_ARCH_COUNT,
+};
+
+enum
+{
+ IH_TYPE_INVALID = 0,
+ IN_TYPE_STANDALONE,
+ IH_TYPE_KERNEL,
+ IH_TYPE_RAMDISK,
+ IH_TYPE_MULTI,
+ IH_TYPE_FIRMWARE,
+ IH_TYPE_SCRIPT,
+ IH_TYPE_FILESYSTEM,
+ IH_TYPE_FLATDT,
+ /* NOTE: Other types not relevant and omitted here, can add if needed */
+ IH_TYPE_COUNT,
+};
+
+enum
+{
+ IH_COMP_NONE = 0,
+ IH_COMP_GZIP,
+ IH_COMP_BZIP2,
+ IH_COMP_LZMA,
+ IH_COMP_LZO,
+ IH_COMP_LZ4,
+ IH_COMP_ZSTD,
+ IH_COMP_COUNT,
+};
+
+/* Legacy U-Boot image header as produced by mkimage(1).
+ *
+ * WARNING: all fields are big-endian so you usually do not want to
+ * access them directly, use the accessor functions instead.
+ */
+struct uimage_header
+{
+ uint32_t ih_magic;
+ uint32_t ih_hcrc;
+ uint32_t ih_time;
+ uint32_t ih_size;
+ uint32_t ih_load;
+ uint32_t ih_ep;
+ uint32_t ih_dcrc;
+ uint8_t ih_os;
+ uint8_t ih_arch;
+ uint8_t ih_type;
+ uint8_t ih_comp;
+ uint8_t ih_name[IH_NMLEN];
+};
+
+#define _uimage_get32_f(name) \
+ static inline uint32_t uimage_get_##name(const struct uimage_header* uh) \
+ { return betoh32(uh->ih_##name); }
+_uimage_get32_f(magic)
+_uimage_get32_f(hcrc)
+_uimage_get32_f(time)
+_uimage_get32_f(size)
+_uimage_get32_f(load)
+_uimage_get32_f(ep)
+_uimage_get32_f(dcrc)
+#undef _uimage_get32_f
+
+#define _uimage_set32_f(name) \
+ static inline void uimage_set_##name(struct uimage_header* uh, uint32_t val) \
+ { uh->ih_##name = htobe32(val); }
+_uimage_set32_f(magic)
+_uimage_set32_f(hcrc)
+_uimage_set32_f(time)
+_uimage_set32_f(size)
+_uimage_set32_f(load)
+_uimage_set32_f(ep)
+_uimage_set32_f(dcrc)
+#undef _uimage_set32_f
+
+#define _uimage_get8_f(name) \
+ static inline uint8_t uimage_get_##name(const struct uimage_header* uh) \
+ { return uh->ih_##name; }
+_uimage_get8_f(os)
+_uimage_get8_f(arch)
+_uimage_get8_f(type)
+_uimage_get8_f(comp)
+#undef _uimage_get8_f
+
+#define _uimage_set8_f(name) \
+ static inline void uimage_set_##name(struct uimage_header* uh, uint8_t val) \
+ { uh->ih_##name = val; }
+_uimage_set8_f(os)
+_uimage_set8_f(arch)
+_uimage_set8_f(type)
+_uimage_set8_f(comp)
+#undef _uimage_set8_f
+
+/*
+ * uImage utilities
+ */
+
+/** Reader callback for use with `uimage_load`
+ *
+ * \param buf Buffer to write into
+ * \param size Number of bytes to read
+ * \param ctx State argument
+ * \return Number of bytes actually read, or -1 on error.
+ */
+typedef ssize_t(*uimage_reader)(void* buf, size_t size, void* ctx);
+
+/** Calculate U-Boot style CRC */
+uint32_t uimage_crc(uint32_t crc, const void* data, size_t size);
+
+/** Calculate CRC of a uImage header */
+uint32_t uimage_calc_hcrc(const struct uimage_header* uh);
+
+/** Load and decompress a uImage
+ *
+ * \param uh Returned header struct (will be filled with read data)
+ * \param out_size Returned size of the decompressed data
+ * \param reader Data reader function
+ * \param rctx Context argument for the reader function
+ * \return Buflib handle containing the decompressed data, or negative on error
+ *
+ * This function will read a uImage, verify checksums and decompress the image
+ * data into a non-moveable buflib allocation. The length of the compressed
+ * data will be taken from the uImage header.
+ */
+int uimage_load(struct uimage_header* uh, size_t* out_size,
+ uimage_reader reader, void* rctx);
+
+/** File reader for use with `uimage_load`
+ *
+ * \param ctx File descriptor, casted to `void*`
+ */
+ssize_t uimage_fd_reader(void* buf, size_t size, void* ctx);
+
+/* helper for patching broken self-extracting kernels on MIPS */
+uint32_t mips_linux_stub_get_entry(void** code_start, size_t code_size);
+
+#endif /* __LINUXBOOT_H__ */
diff --git a/firmware/export/mi4-loader.h b/firmware/export/mi4-loader.h
index f66164ec2c..adc43ebf64 100644
--- a/firmware/export/mi4-loader.h
+++ b/firmware/export/mi4-loader.h
@@ -21,6 +21,9 @@
*
****************************************************************************/
+#ifndef __MI4_LOADER_H__
+#define __MI4_LOADER_H__
+
#include <stdint.h>
#define MI4_HEADER_SIZE 0x200
@@ -50,21 +53,4 @@ struct tea_key {
int load_mi4(unsigned char* buf, const char* firmware, unsigned int buffer_size);
const char *mi4_strerror(int8_t errno);
-#ifdef HAVE_MULTIBOOT /* defined by config.h */
-/* Check in root of this <volume> for rockbox_main.<playername>
- * if this file empty or there is a single slash '/'
- * buf = '<volume#>/<rootdir>/<firmware(name)>\0'
- * If instead '/<*DIRECTORY*>' is supplied
- * addpath will be set to this DIRECTORY buf =
- * '/<volume#>/addpath/<rootdir>/<firmware(name)>\0'
- * On error returns Negative number or 0
- * On success returns bytes from snprintf
- * and generated path will be placed in buf
- * note: if supplied buffer is too small return will be
- * the number of bytes that would have been written
- */
-
-/* TODO needs mapped back to debug_menu if root redirect ever becomes a reality */
-int get_redirect_dir(char* buf, int buffer_size, int volume,
- const char* rootdir, const char* firmware);
-#endif
+#endif /* __MI4_LOADER_H__ */
diff --git a/firmware/export/multiboot.h b/firmware/export/multiboot.h
new file mode 100644
index 0000000000..0132b8531f
--- /dev/null
+++ b/firmware/export/multiboot.h
@@ -0,0 +1,30 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017, 2020 by William Wilgus
+ *
+ * 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 __MULTIBOOT_H__
+#define __MULTIBOOT_H__
+
+extern int write_bootdata(unsigned char* buf, int len, unsigned int boot_volume);
+#ifdef HAVE_MULTIBOOT
+extern int get_redirect_dir(char* buf, int buffer_size, int volume,
+ const char* rootdir, const char* firmware);
+#endif
+
+#endif /* __MULTIBOOT_H__ */
diff --git a/firmware/export/mv.h b/firmware/export/mv.h
index 3657ef6c98..08daf50b34 100644
--- a/firmware/export/mv.h
+++ b/firmware/export/mv.h
@@ -87,6 +87,10 @@
#define VOL_MAX_LEN (1 + VOL_DEC_MAX_LEN + 2 + 1)
#define VOL_NUM_MAX 100
+#ifndef ROOT_VOLUME
+#define ROOT_VOLUME INT_MAX
+#endif
+
#else /* empty definitions if no multi-volume */
#define IF_MV(x...)
#define IF_MV_NONVOID(x...) void
diff --git a/firmware/export/pathfuncs.h b/firmware/export/pathfuncs.h
index 350dd4e548..d4fa4eb460 100644
--- a/firmware/export/pathfuncs.h
+++ b/firmware/export/pathfuncs.h
@@ -30,10 +30,15 @@
/* useful char constants that could be reconfigured if desired */
#define PATH_SEPCH '/'
#define PATH_SEPSTR "/"
+#define PATH_ROOTCHR '/'
#define PATH_ROOTSTR "/"
#define PATH_BADSEPCH '\\'
#define PATH_DRVSEPCH ':'
+#ifndef ROOT_VOLUME
+#define ROOT_VOLUME INT_MAX
+#endif
+
/* a nicer way to check for "." and ".." than two strcmp() calls */
static inline bool is_dotdir_name(const char *name)
{
@@ -74,7 +79,9 @@ static inline bool name_is_dot_dot(const char *name)
#ifdef HAVE_MULTIVOLUME
int path_strip_volume(const char *name, const char **nameptr, bool greedy);
+int path_strip_last_volume(const char *name, const char **nameptr, bool greedy);
int get_volume_name(int volume, char *name);
+int make_volume_root(int volume, char *dst);
#endif
int path_strip_drive(const char *name, const char **nameptr, bool greedy);
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index 3095d2c97b..6ae5ccfd13 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -70,6 +70,12 @@ extern unsigned int power_thread_inputs;
#endif /* CONFIG_CHARGING */
+enum shutdown_type
+{
+ SHUTDOWN_POWER_OFF,
+ SHUTDOWN_REBOOT,
+};
+
#if CONFIG_CHARGING == CHARGING_TARGET
/* Include target-specific definitions */
#include "powermgmt-target.h"
@@ -164,8 +170,9 @@ void handle_auto_poweroff(void);
void set_car_adapter_mode(bool setting);
void reset_poweroff_timer(void);
void cancel_shutdown(void);
-void shutdown_hw(void);
+void shutdown_hw(enum shutdown_type sd_type);
void sys_poweroff(void);
+void sys_reboot(void);
/* Returns true if the system should force shutdown for some reason -
* eg. low battery */
bool query_force_shutdown(void);
diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h
index a3042d80bc..9dd0a24c6f 100644
--- a/firmware/export/rbpaths.h
+++ b/firmware/export/rbpaths.h
@@ -52,6 +52,9 @@
#define PLUGIN_DIR ROCKBOX_DIR "/rocks"
#define CODECS_DIR ROCKBOX_DIR "/codecs"
+#define RB_ROOT_VOL_HIDDEN(v) (IF_MV_VOL(v) == 0)
+#define RB_ROOT_CONTENTS_DIR "/" IF_MV("<0>")
+
#else /* APPLICATION */
#define HOME_DIR "<HOME>" /* replaced at runtime */
diff --git a/firmware/export/screendump.h b/firmware/export/screendump.h
index cd7793b9d3..b8fc27047d 100644
--- a/firmware/export/screendump.h
+++ b/firmware/export/screendump.h
@@ -52,12 +52,7 @@
#define DUMP_BMP_LINESIZE ((LCD_WIDTH*3 + 3) & ~3)
#endif
-#ifdef BOOTLOADER
-
-#define screen_dump()
-#define remote_screen_dump()
-
-#else /* !BOOTLOADER */
+#ifdef HAVE_SCREENDUMP
/* Save a .BMP file containing the current screen contents. */
void screen_dump(void);
@@ -69,6 +64,11 @@ void screen_dump_set_hook(void (*hook)(int fd));
void remote_screen_dump(void);
#endif
-#endif /* !BOOTLOADER */
+#else /* !HAVE_SCREENDUMP */
+
+#define screen_dump() do { } while(0)
+#define remote_screen_dump() do { } while(0)
+
+#endif /* HAVE_SCREENDUMP */
#endif /* __SCREENDUMP_H__ */
diff --git a/firmware/export/si4700.h b/firmware/export/si4700.h
index 033b435f2a..cf9e0f077b 100644
--- a/firmware/export/si4700.h
+++ b/firmware/export/si4700.h
@@ -49,15 +49,7 @@ void si4700_rds_init(void) INIT_ATTR;
/* Radio is fully powered up or about to be powered down */
void si4700_rds_powerup(bool on);
-#if (CONFIG_RDS & RDS_CFG_ISR)
-/* Read raw RDS info for processing - asynchronously */
-void si4700_rds_read_raw_async(unsigned char *buf, int count); /* implemented by target */
-void si4700_rds_interrupt(void);
-#endif /* (CONFIG_RDS & RDS_CFG_ISR) */
-
/* Read raw RDS info for processing.
- * - If RDS_CFG_ISR is set, the tuner driver will call si4700_rds_read_raw_async() which should
- * perform an asynchronous read and call this function when the data has been read.
* - If RDS_CFG_POLL is set, this function will read status and RDS data and process it if a new
* packet is available.
* - Otherwise this function will read a RDS packet and process it under the assumption that it is
diff --git a/firmware/export/system.h b/firmware/export/system.h
index f554ac7cf1..def3122205 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -258,7 +258,8 @@ static inline void cpu_boost_unlock(void)
#endif
/* Define this if target has support for generating backtraces */
-#ifdef CPU_ARM
+#if defined(CPU_ARM) || \
+ (defined(CPU_MIPS) && (CONFIG_PLATFORM & PLATFORM_NATIVE))
#define HAVE_RB_BACKTRACE
#endif
@@ -307,8 +308,8 @@ static inline void cpu_boost_unlock(void)
/* Define MEM_ALIGN_ATTR which may be used to align e.g. buffers for faster
* access. */
-#if defined(CPU_ARM)
- /* Use ARMs cache alignment. */
+#if defined(HAVE_CPU_CACHE_ALIGN)
+ /* Align to a cache line. */
#define MEM_ALIGN_ATTR CACHEALIGN_ATTR
#define MEM_ALIGN_SIZE CACHEALIGN_SIZE
#elif defined(CPU_COLDFIRE)
diff --git a/firmware/export/usb.h b/firmware/export/usb.h
index fe9f3bcfa1..c075fa83ec 100644
--- a/firmware/export/usb.h
+++ b/firmware/export/usb.h
@@ -134,7 +134,6 @@ enum
/* Supported usb modes. */
enum
{
- USB_MODE_ASK = 0,
USB_MODE_MASS_STORAGE,
USB_MODE_CHARGE,
USB_MODE_ADB
diff --git a/firmware/export/x1000.h b/firmware/export/x1000.h
index de3d394c02..b71d37d64d 100644
--- a/firmware/export/x1000.h
+++ b/firmware/export/x1000.h
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2021 Aidan MacDonald
+ * Copyright (C) 2021-2022 Aidan MacDonald
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -39,24 +39,71 @@
# error "Unsupported EXCLK freq"
#endif
-/* On-chip TCSM (tightly coupled shared memory), aka IRAM */
+/* On-chip TCSM (tightly coupled shared memory), aka IRAM. The SPL runs from
+ * here, but the rest of Rockbox doesn't use it - it is too difficult to use
+ * as a normal memory region because it's not in KSEG0. */
#define X1000_TCSM_BASE 0xf4000000
#define X1000_TCSM_SIZE (16 * 1024)
-/* External SDRAM */
+/* SPL load and entry point addresses, this is defined by the HW boot ROM.
+ * First 4K is used by mask ROM for stack + variables, and the next 2K are
+ * occupied by SPL header. Usable code+data size is 10K. */
+#define X1000_SPL_LOAD_ADDR (X1000_TCSM_BASE + 0x1000)
+#define X1000_SPL_EXEC_ADDR (X1000_TCSM_BASE + 0x1800)
+#define X1000_SPL_SIZE (X1000_TCSM_SIZE - 0x1800)
+
+/* External SDRAM - just one big linear mapping in KSEG0. */
#define X1000_SDRAM_BASE 0x80000000
#define X1000_SDRAM_SIZE (MEMORYSIZE * 1024 * 1024)
+#define X1000_SDRAM_END (X1000_SDRAM_BASE + X1000_SDRAM_SIZE)
-/* Memory definitions for Rockbox */
+/* Memory definitions for Rockbox
+ *
+ * IRAM - Contains the exception handlers and acts as a safe stub area
+ * from which you can overwrite the rest of DRAM (used by RoLo).
+ *
+ * DRAM - This is the main RAM area used for code, data, and bss sections.
+ * The audio, codec, and plugin buffers also reside in here.
+ *
+ * X1000_IRAM_BASE is the base of the exception vectors and must be set to
+ * the base of kseg0 (0x80000000). The X1000 supports the EBase register so
+ * the vectors can be remapped, allowing IRAM to be moved to any 4K-aligned
+ * address, but it would introduce more complexity and there's currently no
+ * good reason to do this.
+ *
+ * X1000_DRAM_BASE doubles as the entry point address. There is some legacy
+ * baggage surrounding this value so be careful when changing it.
+ *
+ * - Rockbox's DRAM_BASE should always equal X1000_STANDARD_DRAM_BASE because
+ * this value is hardcoded by old bootloaders released in 2021. This can be
+ * changed if truly necessary, but it should be avoided.
+ * - The bootloader's DRAM_BASE can be changed freely but if it isn't equal
+ * to X1000_STANDARD_DRAM_BASE, the update package generation *must* be
+ * updated to use the "bootloader2.ucl" filename to ensure old jztools do
+ * not try to incorrectly boot the binary at the wrong load address.
+ *
+ * The bootloader DRAM_BASE is also hardcoded in the SPL, but the SPL is
+ * considered as part of the bootloader to avoid introducing unnecessary
+ * ABI boundaries. Therefore this hardcoded use can safely be ignored.
+ *
+ * There is no requirement that IRAM and DRAM are contiguous, but they must
+ * reside in the same segment (ie. upper 3 address bits must be identical),
+ * otherwise we need long calls to go between the two.
+ */
#define X1000_IRAM_BASE X1000_SDRAM_BASE
#define X1000_IRAM_SIZE (16 * 1024)
#define X1000_IRAM_END (X1000_IRAM_BASE + X1000_IRAM_SIZE)
#define X1000_DRAM_BASE X1000_IRAM_END
#define X1000_DRAM_SIZE (X1000_SDRAM_SIZE - X1000_IRAM_SIZE)
#define X1000_DRAM_END (X1000_DRAM_BASE + X1000_DRAM_SIZE)
+
+/* Stacks are placed in IRAM to avoid various annoying issues in boot code. */
#define X1000_STACKSIZE 0x1e00
#define X1000_IRQSTACKSIZE 0x300
+/* Standard DRAM base address for backward compatibility */
+#define X1000_STANDARD_DRAM_BASE 0x80004000
+
/* Required for pcm_rec_dma_get_peak_buffer(), doesn't do anything
* except on targets with recording. */
#define HAVE_PCM_DMA_ADDRESS