A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 94 lines 3.0 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * 9 * Copyright (C) 2017 by Amaury Pouly 10 * 11 * This program is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; either version 2 14 * of the License, or (at your option) any later version. 15 * 16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 17 * KIND, either express or implied. 18 * 19 ****************************************************************************/ 20#ifndef __RB_BOOTDATA__ 21#define __RB_BOOTDATA__ 22 23#ifndef __ASSEMBLER__ 24#include <stdint.h> 25#include "system.h" 26#endif 27 28/* /!\ This file can be included in assembly files /!\ */ 29 30/** The boot data will be filled by the bootloader with information that might 31 * be relevant for Rockbox. The bootloader will search for the structure using 32 * the magic header within the first BOOT_DATA_SEARCH_SIZE bytes of the binary. 33 * Typically, this structure should be as close as possible to the entry point */ 34 35/* Search size for the data structure after entry point */ 36#define BOOT_DATA_SEARCH_SIZE 1024 37 38#define BOOT_DATA_MAGIC0 ('r' | 'b' << 8 | 'm' << 16 | 'a' << 24) 39#define BOOT_DATA_MAGIC1 ('g' | 'i' << 8 | 'c' << 16 | '!' << 24) 40#define BOOT_DATA_VERSION 1 41 42/* maximum size of payload */ 43#define BOOT_DATA_PAYLOAD_SIZE 4 44 45#ifndef __ASSEMBLER__ 46/* This is the C structure */ 47struct boot_data_t 48{ 49 union 50 { 51 uint32_t crc; /* crc of payload data (CRC32 with 0xffffffff for initial value) */ 52 uint32_t magic[2]; /* BOOT_DATA_MAGIC0/1 */ 53 }; 54 55 uint32_t length; /* length of the payload */ 56 57 /* add fields here */ 58 union 59 { 60 struct 61 { 62 uint8_t _boot_volume; /* IGNORED */ 63 uint8_t version; 64 uint8_t boot_drive; 65 uint8_t boot_partition; 66 }; 67 uint8_t payload[BOOT_DATA_PAYLOAD_SIZE]; 68 }; 69} __attribute__((packed)); 70 71#if !defined(BOOTLOADER) 72extern struct boot_data_t boot_data; 73extern bool boot_data_valid; 74 75void verify_boot_data(void) INIT_ATTR; 76#endif 77#else /* __ASSEMBLER__ */ 78 79/* This assembler macro implements an empty boot structure with just the magic 80 * string */ 81.macro put_boot_data_here 82.global boot_data 83boot_data: 84 .word BOOT_DATA_MAGIC0 85 .word BOOT_DATA_MAGIC1 86 .word BOOT_DATA_PAYLOAD_SIZE 87 .byte 0xff /* boot volume */ 88 .byte BOOT_DATA_VERSION /* maximum supported boot protocol version */ 89 .space (BOOT_DATA_PAYLOAD_SIZE - 2), 0xff /* remainder of payload */ 90.endm 91 92#endif 93 94#endif /* __RB_BOOTDATA__ */