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

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

    From e411604726c509525c2e50fdfb83de497709c06b Mon Sep 17 00:00:00 2001
    From: Arvind S Raj <sraj.arvind@gmail.com>
    Date: Fri, 8 Aug 2014 20:14:54 +0530
    Subject: [PATCH] Reserve 8MB space for kernel before RAM_loader so that kernel
     does not overwrite the loader.
    
    ---
     build/jam/board/beagle/BoardSetup                | 22 +++++++++-----
     headers/private/kernel/arch/arm/omap3.h          |  2 ++
     src/system/boot/arch/arm/arch_mmu.cpp            | 37 +++++++++++++++---------
     src/system/boot/platform/u-boot/Jamfile          |  4 +--
     src/system/boot/platform/u-boot/arch/arm/shell.S |  2 +-
     5 files changed, 43 insertions(+), 24 deletions(-)
    
    diff --git a/build/jam/board/beagle/BoardSetup b/build/jam/board/beagle/BoardSetup
    index 0c54643..5ee0a11 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 = $(HAIKU_BOARD_LOADER_BASE) ;
     14HAIKU_BOARD_LOADER_ENTRY_NBSD = `printf \"obase=16;ibase=16;8 + %x\\n\" $(HAIKU_BOARD_LOADER_BASE)|bc` ;
    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 = 0x81a00000 ;
    2424
    2525#
    2626# Flash image
    HAIKU_BOARD_SDIMAGE_FILES =  
    6565#
    6666
    6767HAIKU_ASFLAGS_$(HAIKU_PACKAGING_ARCH)
    68     += -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard ;
     68    += -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard
     69       -DHAIKU_BOARD_LOADER_STACK_BASE=$(HAIKU_BOARD_LOADER_STACK_BASE)
     70       -DHAIKU_BOARD_LOADER_UIBASE=$(HAIKU_BOARD_LOADER_UIBASE) ;
    6971HAIKU_CCFLAGS_$(HAIKU_PACKAGING_ARCH)
    70     += -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard ;
     72    += -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard
     73       -DHAIKU_BOARD_LOADER_STACK_BASE=$(HAIKU_BOARD_LOADER_STACK_BASE)
     74       -DHAIKU_BOARD_LOADER_UIBASE=$(HAIKU_BOARD_LOADER_UIBASE) ;
    7175HAIKU_C++FLAGS_$(HAIKU_PACKAGING_ARCH)
    72     += -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard ;
     76    += -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard
     77       -DHAIKU_BOARD_LOADER_STACK_BASE=$(HAIKU_BOARD_LOADER_STACK_BASE)
     78       -DHAIKU_BOARD_LOADER_UIBASE=$(HAIKU_BOARD_LOADER_UIBASE) ;
  • 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..758a1f3 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        HAIKU_BOARD_LOADER_STACK_BASE,
     116        HAIKU_BOARD_LOADER_STACK_BASE + 0xe00000,
    105117        ARM_MMU_L2_FLAG_C,
    106118    },
    107119    {
    108         "RAM_initrd", // stack
    109         SDRAM_BASE + 0x2000000,
    110         SDRAM_BASE + 0x2500000,
     120        "RAM_initrd", // initrd
     121        HAIKU_BOARD_LOADER_UIBASE,
     122        HAIKU_BOARD_LOADER_UIBASE + 0x500000,
    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