[haiku-commits] haiku: hrev46057 - src/add-ons/kernel/drivers/disk/norflash

  • From: ithamar@xxxxxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 15 Sep 2013 07:29:49 +0200 (CEST)

hrev46057 adds 1 changeset to branch 'master'
old head: c00e42d577c7034dc92729d8d76f5bae7577463f
new head: b9fa914d1e42be8611aacbe62977c998bb0b1c78
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=b9fa914+%5Ec00e42d

----------------------------------------------------------------------------

b9fa914: 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!

                          [ Ithamar R. Adema <ithamar@xxxxxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46057
Commit:      b9fa914d1e42be8611aacbe62977c998bb0b1c78
URL:         http://cgit.haiku-os.org/haiku/commit/?id=b9fa914
Author:      Ithamar R. Adema <ithamar@xxxxxxxxxxxxxxxxxxx>
Date:        Sun Sep 15 05:26:02 2013 UTC

----------------------------------------------------------------------------

1 file changed, 6 insertions(+), 1 deletion(-)
src/add-ons/kernel/drivers/disk/norflash/norflash.cpp | 7 ++++++-

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/drivers/disk/norflash/norflash.cpp 
b/src/add-ons/kernel/drivers/disk/norflash/norflash.cpp
index 37b9186..4bd20bd 100644
--- a/src/add-ons/kernel/drivers/disk/norflash/norflash.cpp
+++ b/src/add-ons/kernel/drivers/disk/norflash/norflash.cpp
@@ -31,7 +31,10 @@
 
 
 #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 {
        device_node *node;
@@ -54,7 +57,7 @@ nor_init_device(void *_info, void **_cookie)
 
        info->mapped = NULL;
        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);
        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;
        TRACE("read(%Ld,%lu)\n", position, *numbytes);
 
+       position += HIDDEN_BLOCKS * info->blocksize;
+
        if (position + *numbytes > info->totalsize)
                *numbytes = info->totalsize - (position + *numbytes);
 


Other related posts:

  • » [haiku-commits] haiku: hrev46057 - src/add-ons/kernel/drivers/disk/norflash - ithamar