norflash: Add hack to hide start of NOR flash
This is a workaround for hiding U-Boot that is stored in the first 2 128k blocks, so we can put a BFS image into NOR to boot from (since we do not have support for SD/MMC yet in Haiku). When manually putting a BFS filesystem at block 3 we actually get right up to the point where BootScript is attempted to be executed!
This commit is contained in:
@@ -31,7 +31,10 @@
|
|||||||
|
|
||||||
|
|
||||||
#define NORFLASH_ADDR 0x00000000
|
#define NORFLASH_ADDR 0x00000000
|
||||||
|
#define SIZE_IN_BLOCKS 256
|
||||||
|
|
||||||
|
/* Hide the start of NOR since U-Boot lives there */
|
||||||
|
#define HIDDEN_BLOCKS 2
|
||||||
|
|
||||||
struct nor_driver_info {
|
struct nor_driver_info {
|
||||||
device_node *node;
|
device_node *node;
|
||||||
@@ -54,7 +57,7 @@ nor_init_device(void *_info, void **_cookie)
|
|||||||
|
|
||||||
info->mapped = NULL;
|
info->mapped = NULL;
|
||||||
info->blocksize = 128 * 1024;
|
info->blocksize = 128 * 1024;
|
||||||
info->totalsize = info->blocksize * 256;
|
info->totalsize = (SIZE_IN_BLOCKS - HIDDEN_BLOCKS) * info->blocksize;
|
||||||
|
|
||||||
info->id = map_physical_memory("NORFlash", NORFLASH_ADDR, info->totalsize, B_ANY_KERNEL_ADDRESS, B_READ_AREA, &info->mapped);
|
info->id = map_physical_memory("NORFlash", NORFLASH_ADDR, info->totalsize, B_ANY_KERNEL_ADDRESS, B_READ_AREA, &info->mapped);
|
||||||
if (info->id < 0)
|
if (info->id < 0)
|
||||||
@@ -139,6 +142,8 @@ nor_read(void *_cookie, off_t position, void *data, size_t *numbytes)
|
|||||||
nor_driver_info *info = (nor_driver_info*)_cookie;
|
nor_driver_info *info = (nor_driver_info*)_cookie;
|
||||||
TRACE("read(%Ld,%lu)\n", position, *numbytes);
|
TRACE("read(%Ld,%lu)\n", position, *numbytes);
|
||||||
|
|
||||||
|
position += HIDDEN_BLOCKS * info->blocksize;
|
||||||
|
|
||||||
if (position + *numbytes > info->totalsize)
|
if (position + *numbytes > info->totalsize)
|
||||||
*numbytes = info->totalsize - (position + *numbytes);
|
*numbytes = info->totalsize - (position + *numbytes);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user