mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-10 08:03:04 -04:00
firmware: move iriver flash helper functions into target tree
Move the iriver-specific functions for detecting flashed Rockbox/OF images into system-iriver.c and remove the HAVE_FLASHED_ROCKBOX define which is now redundant (all targets using system-iriver.c enable it). Copyright attribution on the new system-iriver.h header is a best guess from Git history. Change-Id: If1933f881a63fd517162ab9ca8f4a3007b997739
This commit is contained in:
parent
190822f261
commit
c6abf3382a
12 changed files with 74 additions and 62 deletions
|
|
@ -67,6 +67,10 @@
|
||||||
#include "usbstack/usb_audio.h"
|
#include "usbstack/usb_audio.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
|
||||||
|
#include "system-iriver.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define WRAPPER(_x_) _x_ ## _wrapper
|
#define WRAPPER(_x_) _x_ ## _wrapper
|
||||||
|
|
||||||
#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
|
#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "lib/helper.h"
|
#include "lib/helper.h"
|
||||||
#include "checksum.h"
|
#include "checksum.h"
|
||||||
|
#include "system-iriver.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flash commands may rely on null pointer dereferences to work correctly.
|
* Flash commands may rely on null pointer dereferences to work correctly.
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "system-iriver.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "lcd-remote.h"
|
#include "lcd-remote.h"
|
||||||
#include "scroll_engine.h"
|
#include "scroll_engine.h"
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "system-iriver.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "logf.h"
|
#include "logf.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,10 +141,6 @@
|
||||||
/* Define this if you want to use coldfire's i2c interface */
|
/* Define this if you want to use coldfire's i2c interface */
|
||||||
#define CONFIG_I2C I2C_COLDFIRE
|
#define CONFIG_I2C I2C_COLDFIRE
|
||||||
|
|
||||||
/* Define this if you can run rockbox from flash memory */
|
|
||||||
/* In theory we can, but somebody needs to verify there are no issues. */
|
|
||||||
#define HAVE_FLASHED_ROCKBOX
|
|
||||||
|
|
||||||
/* define this if the hardware can be powered off while charging */
|
/* define this if the hardware can be powered off while charging */
|
||||||
#define HAVE_POWEROFF_WHILE_CHARGING
|
#define HAVE_POWEROFF_WHILE_CHARGING
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,9 +148,6 @@
|
||||||
/* Define this if you want to use coldfire's i2c interface */
|
/* Define this if you want to use coldfire's i2c interface */
|
||||||
#define CONFIG_I2C I2C_COLDFIRE
|
#define CONFIG_I2C I2C_COLDFIRE
|
||||||
|
|
||||||
/* Define this if you can run rockbox from flash memory */
|
|
||||||
#define HAVE_FLASHED_ROCKBOX
|
|
||||||
|
|
||||||
/* define this if the hardware can be powered off while charging */
|
/* define this if the hardware can be powered off while charging */
|
||||||
#define HAVE_POWEROFF_WHILE_CHARGING
|
#define HAVE_POWEROFF_WHILE_CHARGING
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,9 +157,6 @@
|
||||||
/* Define this if you want to use coldfire's i2c interface */
|
/* Define this if you want to use coldfire's i2c interface */
|
||||||
#define CONFIG_I2C I2C_COLDFIRE
|
#define CONFIG_I2C I2C_COLDFIRE
|
||||||
|
|
||||||
/* Define this if you can run rockbox from flash memory */
|
|
||||||
#define HAVE_FLASHED_ROCKBOX
|
|
||||||
|
|
||||||
/* The size of the flash ROM */
|
/* The size of the flash ROM */
|
||||||
#define FLASH_SIZE 0x400000
|
#define FLASH_SIZE 0x400000
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,6 @@
|
||||||
|
|
||||||
#undef INCLUDE_TIMEOUT_API
|
#undef INCLUDE_TIMEOUT_API
|
||||||
|
|
||||||
#undef HAVE_FLASHED_ROCKBOX
|
|
||||||
|
|
||||||
#undef IPOD_ACCESSORY_PROTOCOL
|
#undef IPOD_ACCESSORY_PROTOCOL
|
||||||
|
|
||||||
#undef HAVE_WHEEL_POSITION
|
#undef HAVE_WHEEL_POSITION
|
||||||
|
|
|
||||||
|
|
@ -40,16 +40,6 @@ extern void system_init(void);
|
||||||
|
|
||||||
extern long cpu_frequency;
|
extern long cpu_frequency;
|
||||||
|
|
||||||
struct flash_header {
|
|
||||||
uint32_t magic;
|
|
||||||
uint32_t length;
|
|
||||||
char version[32];
|
|
||||||
};
|
|
||||||
|
|
||||||
bool detect_flashed_romimage(void);
|
|
||||||
bool detect_flashed_ramimage(void);
|
|
||||||
bool detect_original_firmware(void);
|
|
||||||
|
|
||||||
#if defined(HAVE_ADJUSTABLE_CPU_FREQ) \
|
#if defined(HAVE_ADJUSTABLE_CPU_FREQ) \
|
||||||
&& defined(ROCKBOX_HAS_LOGF) && (NUM_CORES == 1)
|
&& defined(ROCKBOX_HAS_LOGF) && (NUM_CORES == 1)
|
||||||
#define CPU_BOOST_LOGGING
|
#define CPU_BOOST_LOGGING
|
||||||
|
|
|
||||||
|
|
@ -161,43 +161,3 @@ void cpu_idle_mode(bool on_off)
|
||||||
cpu_boost_unlock();
|
cpu_boost_unlock();
|
||||||
}
|
}
|
||||||
#endif /* HAVE_ADJUSTABLE_CPU_FREQ */
|
#endif /* HAVE_ADJUSTABLE_CPU_FREQ */
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_FLASHED_ROCKBOX
|
|
||||||
static bool detect_flash_header(uint8_t *addr)
|
|
||||||
{
|
|
||||||
#ifndef BOOTLOADER
|
|
||||||
int oldmode = system_memory_guard(MEMGUARD_NONE);
|
|
||||||
#endif
|
|
||||||
struct flash_header hdr;
|
|
||||||
memcpy(&hdr, addr, sizeof(struct flash_header));
|
|
||||||
#ifndef BOOTLOADER
|
|
||||||
system_memory_guard(oldmode);
|
|
||||||
#endif
|
|
||||||
return hdr.magic == FLASH_MAGIC;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool detect_flashed_romimage(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_FLASHED_ROCKBOX
|
|
||||||
return detect_flash_header((uint8_t *)FLASH_ROMIMAGE_ENTRY);
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif /* HAVE_FLASHED_ROCKBOX */
|
|
||||||
}
|
|
||||||
|
|
||||||
bool detect_flashed_ramimage(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_FLASHED_ROCKBOX
|
|
||||||
return detect_flash_header((uint8_t *)FLASH_RAMIMAGE_ENTRY);
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif /* HAVE_FLASHED_ROCKBOX */
|
|
||||||
}
|
|
||||||
|
|
||||||
bool detect_original_firmware(void)
|
|
||||||
{
|
|
||||||
return !(detect_flashed_ramimage() || detect_flashed_romimage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,11 @@
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "system-iriver.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "pcf50606.h"
|
#include "pcf50606.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* Settings for all possible clock frequencies (with properly working timers)
|
/* Settings for all possible clock frequencies (with properly working timers)
|
||||||
* NOTE: Some 5249 chips don't like having PLLDIV set to 0. We must avoid that!
|
* NOTE: Some 5249 chips don't like having PLLDIV set to 0. We must avoid that!
|
||||||
|
|
@ -161,3 +163,31 @@ void cf_set_cpu_frequency(long frequency)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool detect_flash_header(uint8_t *addr)
|
||||||
|
{
|
||||||
|
#ifndef BOOTLOADER
|
||||||
|
int oldmode = system_memory_guard(MEMGUARD_NONE);
|
||||||
|
#endif
|
||||||
|
struct flash_header hdr;
|
||||||
|
memcpy(&hdr, addr, sizeof(struct flash_header));
|
||||||
|
#ifndef BOOTLOADER
|
||||||
|
system_memory_guard(oldmode);
|
||||||
|
#endif
|
||||||
|
return hdr.magic == FLASH_MAGIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool detect_flashed_romimage(void)
|
||||||
|
{
|
||||||
|
return detect_flash_header((uint8_t *)FLASH_ROMIMAGE_ENTRY);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool detect_flashed_ramimage(void)
|
||||||
|
{
|
||||||
|
return detect_flash_header((uint8_t *)FLASH_RAMIMAGE_ENTRY);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool detect_original_firmware(void)
|
||||||
|
{
|
||||||
|
return !(detect_flashed_ramimage() || detect_flashed_romimage());
|
||||||
|
}
|
||||||
|
|
|
||||||
37
firmware/target/coldfire/iriver/system-iriver.h
Normal file
37
firmware/target/coldfire/iriver/system-iriver.h
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 Miika Pekkarinen
|
||||||
|
*
|
||||||
|
* 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 __SYSTEM_IRIVER_H__
|
||||||
|
#define __SYSTEM_IRIVER_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct flash_header
|
||||||
|
{
|
||||||
|
uint32_t magic;
|
||||||
|
uint32_t length;
|
||||||
|
char version[32];
|
||||||
|
};
|
||||||
|
|
||||||
|
bool detect_flashed_romimage(void);
|
||||||
|
bool detect_flashed_ramimage(void);
|
||||||
|
bool detect_original_firmware(void);
|
||||||
|
|
||||||
|
#endif /* __SYSTEM_IRIVER_H__ */
|
||||||
Loading…
Add table
Add a link
Reference in a new issue