Ticket #11067: Reserve-8MB-space-for-kernel-before-RAM_loader.patch

File Reserve-8MB-space-for-kernel-before-RAM_loader.patch, 5.4 KB (added by arvindsraj, 6 years ago)
  • build/jam/board/beagle/BoardSetup

    From 288acd3748c0dd496831987b0f44f6eedef5d552 Mon Sep 17 00:00:00 2001
    From: Arvind S Raj <sraj.arvind@gmail.com>
    Date: Thu, 7 Aug 2014 17:15:27 +0530
    Subject: [PATCH] Reserve 8MB space for kernel before RAM_loader so that kernel
     does not overwrite the loader.
    
    ---
     build/jam/board/beagle/BoardSetup                | 10 +++----
     headers/private/kernel/arch/arm/omap3.h          |  2 ++
     src/system/boot/arch/arm/arch_mmu.cpp            | 35 ++++++++++++++++--------
     src/system/boot/platform/u-boot/Jamfile          |  4 +--
     src/system/boot/platform/u-boot/arch/arm/shell.S |  2 +-
     5 files changed, 33 insertions(+), 20 deletions(-)
    
    diff --git a/build/jam/board/beagle/BoardSetup b/build/jam/board/beagle/BoardSetup
    index 0c54643..50ac16b 100644
    a b HAIKU_BOARD_DESCRIPTION = "BeagleBoard" ;  
    88#
    99
    1010# load address for haiku_loader
    11 HAIKU_BOARD_LOADER_BASE = 0x80008000 ;
     11HAIKU_BOARD_LOADER_BASE = 0x80800000 ;
    1212# entry points (raw binary, and netbsd loader emulation)
    13 HAIKU_BOARD_LOADER_ENTRY_RAW = 0x80008000 ;
    14 HAIKU_BOARD_LOADER_ENTRY_NBSD = 0x80008008 ;
     13HAIKU_BOARD_LOADER_ENTRY_RAW = 0x80800000 ;
     14HAIKU_BOARD_LOADER_ENTRY_NBSD = 0x80800008 ;
    1515
    1616HAIKU_BOARD_LOADER_ENTRY = $(HAIKU_BOARD_LOADER_ENTRY_NBSD) ;
    1717HAIKU_BOARD_LOADER_FAKE_OS = netbsd ;
    1818
    1919# load address for haiku_loader uimage
    2020# (must be different than real load address)
    21 HAIKU_BOARD_LOADER_UIBASE = 0x84000000 ;
     21HAIKU_BOARD_LOADER_UIBASE = 0x82800000 ;
    2222
    23 HAIKU_BOARD_LOADER_STACK_BASE = 0x84000000 ;
     23HAIKU_BOARD_LOADER_STACK_BASE = 0x83000000 ;
    2424
    2525#
    2626# Flash image
  • headers/private/kernel/arch/arm/omap3.h

    diff --git a/headers/private/kernel/arch/arm/omap3.h b/headers/private/kernel/arch/arm/omap3.h
    index c0b7e18..44a8325 100644
    a b  
    2424#define __PLATFORM_OMAP3_H
    2525
    2626#define SDRAM_BASE 0x80000000
     27// Offset of stack top defined with respect to SDRAM_BASE
     28#define KSTACK_TOP 0x27fffff
    2729
    2830#define VECT_BASE 0x00000000
    2931#define VECT_SIZE 0x1000
  • src/system/boot/arch/arm/arch_mmu.cpp

    diff --git a/src/system/boot/arch/arm/arch_mmu.cpp b/src/system/boot/arch/arm/arch_mmu.cpp
    index 22dc535..2be2a86 100644
    a b TODO:  
    5858*/
    5959
    6060
     61// 8 MB for the kernel, kernel args, modules, driver settings, ...
     62static const size_t kMaxKernelSize = 0x800000;
     63
     64// Base address for loader
     65static const size_t kLoaderBaseAddress = KERNEL_LOAD_BASE + kMaxKernelSize;
     66
    6167/*
    6268*defines a block in memory
    6369*/
    static struct memblock LOADER_MEMORYMAP[] = {  
    8187        ARM_MMU_L2_FLAG_B,
    8288    },
    8389    {
     90        "RAM_kernel", // 8MB space for kernel, drivers etc
     91        KERNEL_LOAD_BASE,
     92        KERNEL_LOAD_BASE + kMaxKernelSize - 1,
     93        ARM_MMU_L2_FLAG_C,
     94    },
     95    {
    8496        "RAM_loader", // 1MB loader
    85         SDRAM_BASE + 0,
    86         SDRAM_BASE + 0x0fffff,
     97        kLoaderBaseAddress + 0,
     98        kLoaderBaseAddress + 0x0fffff,
    8799        ARM_MMU_L2_FLAG_C,
    88100    },
    89101    {
    90102        "RAM_pt", // Page Table 1MB
    91         SDRAM_BASE + 0x100000,
    92         SDRAM_BASE + 0x1FFFFF,
     103        kLoaderBaseAddress + 0x100000,
     104        kLoaderBaseAddress + 0x1FFFFF,
    93105        ARM_MMU_L2_FLAG_C,
    94106    },
    95107    {
    96108        "RAM_free", // 16MB free RAM (more but we don't map it automaticaly)
    97         SDRAM_BASE + 0x0200000,
    98         SDRAM_BASE + 0x11FFFFF,
     109        kLoaderBaseAddress + 0x0200000,
     110        kLoaderBaseAddress + 0x11FFFFF,
    99111        ARM_MMU_L2_FLAG_C,
    100112    },
    101113    {
    102114        "RAM_stack", // stack
    103         SDRAM_BASE + 0x1200000,
    104         SDRAM_BASE + 0x2000000,
     115        kLoaderBaseAddress + 0x1200000,
     116        kLoaderBaseAddress + 0x1ffffff,
    105117        ARM_MMU_L2_FLAG_C,
    106118    },
    107119    {
    108120        "RAM_initrd", // stack
    109         SDRAM_BASE + 0x2000000,
    110         SDRAM_BASE + 0x2500000,
     121        kLoaderBaseAddress + 0x2000000,
     122        kLoaderBaseAddress + 0x2500000,
    111123        ARM_MMU_L2_FLAG_C,
    112124    },
    113125
    static struct memblock LOADER_MEMORYMAP[] = {  
    124136
    125137//static const uint32 kDefaultPageTableFlags = MMU_FLAG_READWRITE;
    126138    // not cached not buffered, R/W
    127 static const size_t kMaxKernelSize = 0x200000;      // 2 MB for the kernel
    128139
    129140static addr_t sNextPhysicalAddress = 0; //will be set by mmu_init
    130 static addr_t sNextVirtualAddress = KERNEL_LOAD_BASE + kMaxKernelSize;
     141static addr_t sNextVirtualAddress = LOADER_MEMORYMAP[4].start;
    131142
    132143static addr_t sNextPageTableAddress = 0;
    133144//the page directory is in front of the pagetable
  • src/system/boot/platform/u-boot/Jamfile

    diff --git a/src/system/boot/platform/u-boot/Jamfile b/src/system/boot/platform/u-boot/Jamfile
    index fc61049..6f2cab6 100644
    a b actions BuildUBootSDImage1  
    184184    # We load the uImage 2MB above its final destination, bootm will decode
    185185    # it to the proper location. Our image is smaller than 2MB so this works.
    186186    echo 'uenvcmd=run loadImage; run mmcboot;
    187         loadImage=fatload mmc0 0 0x80200000 haiku_loader_nbsd.ub
    188         mmcboot=bootm 0x80200000' > uEnv.txt
     187        loadImage=fatload mmc0 0 $(HAIKU_BOARD_LOADER_UIBASE) haiku_loader_nbsd.ub
     188        mmcboot=bootm $(HAIKU_BOARD_LOADER_UIBASE)' > uEnv.txt
    189189    # populate
    190190    MTOOLSRC=$(1).mtools mcopy $(2[1-]) i:
    191191    MTOOLSRC=$(1).mtools mcopy uEnv.txt i:
  • src/system/boot/platform/u-boot/arch/arm/shell.S

    diff --git a/src/system/boot/platform/u-boot/arch/arm/shell.S b/src/system/boot/platform/u-boot/arch/arm/shell.S
    index 69b1ff3..ca945c9 100644
    a b SYMBOL(_start_common):  
    6262
    6363
    6464
    65     ldr sp,=SDRAM_BASE + 0x2000000
     65    ldr sp,=SDRAM_BASE + KSTACK_TOP
    6666    ldrb    r4,gUBootOS
    6767    cmp r4,#0
    6868    beq start_raw