mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-20 10:32:42 -05:00
imx233: move the freescale partition handling to its own file
The freescale firmware partitions has a lots of quirks that need to be dealt with, so do it the proper way. Change-Id: I8a5bd3fb462a4df143bc6c931057f3ffedd4b3d3
This commit is contained in:
parent
61b129ac1e
commit
07138ba2ba
5 changed files with 133 additions and 36 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#include "storage.h"
|
||||
#include "ssp-imx233.h"
|
||||
#include "pinctrl-imx233.h"
|
||||
#include "partitions-imx233.h"
|
||||
|
||||
/**
|
||||
* This code assumes a single eMMC internal flash
|
||||
|
|
@ -39,12 +40,13 @@
|
|||
#define MMC_RCA 1
|
||||
|
||||
/** When set, this values restrict the windows of the read and writes */
|
||||
static unsigned mmc_window_start = 0;
|
||||
static unsigned mmc_window_end = INT_MAX;
|
||||
static unsigned mmc_window_start;
|
||||
static unsigned mmc_window_end;
|
||||
static bool mmc_window_enable = true;
|
||||
static long mmc_last_activity = -1;
|
||||
static bool mmc_is_active = false;
|
||||
static unsigned mmc_size = 0;
|
||||
static int mmc_first_drive = 0;
|
||||
|
||||
static struct mutex mmc_mutex;
|
||||
|
||||
|
|
@ -142,37 +144,19 @@ int mmc_init(void)
|
|||
mmc_size = *sec_count;
|
||||
}
|
||||
|
||||
mmc_window_start = 0;
|
||||
mmc_window_end = INT_MAX;
|
||||
#ifdef SANSA_FUZEPLUS
|
||||
if(mmc_window_enable)
|
||||
if(imx233_partitions_is_window_enabled())
|
||||
{
|
||||
/**
|
||||
* The Fuze+ uses a strange layout: is has a first MBR at sector 0 with four entries:
|
||||
* 1) Actual user partition
|
||||
* 2) Sigmatel boot partition
|
||||
* 3)4) Other (certificate related ?) partitions
|
||||
* The partition 1) has type 1 but it's actually a type 5 (logical partition) with
|
||||
* a second partition table with usually one entry which is the FAT32 one.
|
||||
* The first table uses 512-byte sector size and the second one usually uses
|
||||
* 2048-byte logical sector size.
|
||||
*
|
||||
* We restrict mmc window to the user partition */
|
||||
/* WARNING: mmc_first_drive is not set yet at this point */
|
||||
uint8_t mbr[512];
|
||||
mmc_window_start = 0;
|
||||
mmc_window_end = INT_MAX;
|
||||
ret = mmc_read_sectors(IF_MD2(0,) 0, 1, mbr);
|
||||
if(ret != 0)
|
||||
return -100;
|
||||
if(mbr[510] != 0x55 || mbr[511] != 0xAA)
|
||||
return -101; /* invalid MBR */
|
||||
/* sanity check that the first partition is greater than 2Gib */
|
||||
uint8_t *ent = &mbr[446];
|
||||
mmc_window_start = ent[8] | ent[9] << 8 | ent[10] << 16 | ent[11] << 24;
|
||||
mmc_window_end = (ent[12] | ent[13] << 8 | ent[14] << 16 | ent[15] << 24) +
|
||||
mmc_window_start;
|
||||
if(ent[4] == 0x53)
|
||||
return -102; /* sigmatel partition */
|
||||
if((mmc_window_end - mmc_window_start) < 4 * 1024 * 1024)
|
||||
return -103; /* partition too small */
|
||||
if(ret)
|
||||
panicf("cannot read MBR: %d", ret);
|
||||
ret = imx233_partitions_compute_window(mbr, &mmc_window_start, &mmc_window_end);
|
||||
if(ret)
|
||||
panicf("cannot compute partitions window: %d", ret);
|
||||
mmc_size = mmc_window_end - mmc_window_start;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -182,7 +166,7 @@ int mmc_init(void)
|
|||
|
||||
int mmc_num_drives(int first_drive)
|
||||
{
|
||||
(void) first_drive;
|
||||
mmc_first_drive = first_drive;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue