A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 96 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_DEVICEDATA__ 21#define __RB_DEVICEDATA__ 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 device 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 DEVICE_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 DEVICE_DATA_SEARCH_SIZE 1024 37 38#define DEVICE_DATA_MAGIC0 ('r' | 'b' << 8 | 'd' << 16 | 'e' << 24) 39#define DEVICE_DATA_MAGIC1 ('v' | 'i' << 8 | 'c' << 16 | 'e' << 24) 40#define DEIVCE_DATA_VERSION 0 41 42/* maximum size of payload */ 43#define DEVICE_DATA_PAYLOAD_SIZE 4 44 45#ifndef __ASSEMBLER__ 46/* This is the C structure */ 47struct device_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]; /* DEVICE_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#if defined(EROS_QN) 63 uint8_t hw_rev; 64#endif 65 uint8_t version; 66 }; 67 uint8_t payload[DEVICE_DATA_PAYLOAD_SIZE]; 68 }; 69} __attribute__((packed)); 70 71 72void fill_devicedata(struct device_data_t *data); 73bool write_devicedata(unsigned char* buf, int len); 74#ifndef BOOTLOADER 75extern struct device_data_t device_data; 76 77void verify_device_data(void) INIT_ATTR; 78 79#endif 80 81#else /* __ASSEMBLER__ */ 82 83/* This assembler macro implements an empty device data structure with just the magic 84 * string and payload size */ 85.macro put_device_data_here 86.global device_data 87device_data: 88 .word DEVICE_DATA_MAGIC0 89 .word DEVICE_DATA_MAGIC1 90 .word DEVICE_DATA_PAYLOAD_SIZE 91 .space BOOT_DATA_PAYLOAD_SIZE, 0xff /* payload, initialised with value 0xff */ 92.endm 93 94#endif 95 96#endif /* __RB_DEVICEDATA__ */