Changeset c296687 in rtems


Ignore:
Timestamp:
Dec 10, 2009, 6:44:10 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
ba3e987e
Parents:
4439616
Message:

2009-12-10 Joel Sherrill <joel.sherrill@…>

  • include/bsp.h, startup/bspgetworkarea.c: Rework bsp_size_memory() to ensure that multiboot information regarding memory size is used as the primary source. This was broken in the move to supporting a unified workspace. It worked this way in 4.9 so this was a regression.
Location:
c/src/lib/libbsp/i386/pc386
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/pc386/ChangeLog

    r4439616 rc296687  
     12009-12-10      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * include/bsp.h, startup/bspgetworkarea.c: Rework bsp_size_memory() to
     4        ensure that multiboot information regarding memory size is used as
     5        the primary source. This was broken in the move to supporting a
     6        unified workspace. It worked this way in 4.9 so this was a
     7        regression.
     8
    192009-12-09      Joel Sherrill <joel.sherrill@oarcorp.com>
    210
  • c/src/lib/libbsp/i386/pc386/include/bsp.h

    r4439616 rc296687  
    163163extern segment_descriptors Global_descriptor_table   [GDT_SIZE];
    164164
    165 extern uint32_t                  rtemsFreeMemStart;
    166   /* Address of start of free memory - should be used when creating new
    167      partitions or regions and updated afterwards. */
    168 
    169165/*-------------------------------------------------------------------------+
    170166| Function Prototypes.
  • c/src/lib/libbsp/i386/pc386/startup/bspgetworkarea.c

    r4439616 rc296687  
    4242
    4343/*
     44 *  This is the first address of the memory we can use for the RTEMS
     45 *  Work Area.
     46 */
     47static uintptr_t rtemsWorkAreaStart;
     48
     49/*
    4450 * Board's memory size easily be overridden by application.
    4551 */
    46 uint32_t bsp_mem_size = 0;
     52static uint32_t bsp_mem_size = 0;
    4753
    4854/* Size of stack used during initialization. Defined in 'start.s'.  */
    4955extern uint32_t _stack_size;
    5056
    51 /* Address of start of free memory. */
    52 uintptr_t rtemsFreeMemStart;
    53 
    54 
    5557void bsp_size_memory(void)
    5658{
    5759  uintptr_t topAddr;
    58   uintptr_t lowest;
    59   uint32_t  val;
    60   int       i;
    6160
    62   /* set the value of start of free memory. */
    63   rtemsFreeMemStart = (uint32_t)WorkAreaBase + _stack_size;
     61  /* Set the value of start of free memory. */
     62  rtemsWorkAreaStart = (uint32_t)WorkAreaBase + _stack_size;
    6463
    65   /* Place RTEMS workspace at beginning of free memory. */
    66 
    67   if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
    68     rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
    69 
    70   /* find the lowest 1M boundary to probe */
    71   lowest = ((rtemsFreeMemStart + (1<<20)) >> 20) + 1;
    72   if ( lowest  < 2 )
    73       lowest = 2;
     64  /* Align the RTEMS Work Area at beginning of free memory. */
     65  if (rtemsWorkAreaStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
     66    rtemsWorkAreaStart = (rtemsWorkAreaStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
    7467
    7568  /* The memory detection algorithm is very crude; try
     
    7972       (_boot_multiboot_info.flags & 1) &&
    8073       _boot_multiboot_info.mem_upper ) {
    81     bsp_mem_size = _boot_multiboot_info.mem_upper * 1024;
     74    topAddr = _boot_multiboot_info.mem_upper * 1024;
    8275    #ifdef BSP_GET_WORK_AREA_DEBUG
    83       printk( "Multiboot info says we have 0x%08x\n", bsp_mem_size );
     76      printk( "Multiboot info says we have 0x%08x\n", topAddr );
    8477    #endif
    85   }
     78  } else if ( (uintptr_t) RamSize == (uintptr_t) 0xFFFFFFFF ) {
     79    uintptr_t lowest;
     80    uint32_t  val;
     81    int       i;
    8682
    87   if ( (uintptr_t) RamSize == (uintptr_t) 0xFFFFFFFF ) {
    8883    /*
    8984     * We have to dynamically size memory. Memory size can be anything
    90      * between no less than 2M and 2048M.
    91      * let us first write
     85     * between no less than 2M and 2048M.  If we can write a value to
     86     * an address and read the same value back, then the memory is there.
     87     *
     88     * WARNING: This can detect memory which should be reserved for
     89     *          graphics controllers which share the CPU's RAM.
    9290     */
     91
     92    /* find the lowest 1M boundary to probe */
     93    lowest = ((rtemsWorkAreaStart + (1<<20)) >> 20) + 1;
     94    if ( lowest  < 2 )
     95      lowest = 2;
     96
    9397    for (i=2048; i>=lowest; i--) {
    9498      topAddr = i*1024*1024 - 4;
     
    104108    }
    105109
    106     topAddr = (i-1)*1024*1024 - 4;
     110    topAddr = (i-1)*1024*1024;
    107111    #ifdef BSP_GET_WORK_AREA_DEBUG
    108112      printk( "Dynamically sized to 0x%08x\n", topAddr );
     
    117121  bsp_mem_size = topAddr;
    118122}
     123
    119124/*
    120125 *  This method returns the base address and size of the area which
     
    129134)
    130135{
    131   *work_area_start = (void *) rtemsFreeMemStart;
    132   *work_area_size  = (uintptr_t) bsp_mem_size - (uintptr_t) rtemsFreeMemStart;
     136  *work_area_start = (void *) rtemsWorkAreaStart;
     137  *work_area_size  = (uintptr_t) bsp_mem_size - (uintptr_t) rtemsWorkAreaStart;
    133138  *heap_start      = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
    134139  *heap_size       = (uintptr_t) HeapSize;
     
    136141  #ifdef BSP_GET_WORK_AREA_DEBUG
    137142    printk( "bsp_mem_size = 0x%08x\n", bsp_mem_size );
    138     printk( "rtemsFreeMemStart = 0x%08x\n", rtemsFreeMemStart );
     143    printk( "rtemsWorkAreaStart = 0x%08x\n", rtemsWorkAreaStart );
    139144    printk( "WorkArea Base = %p\n", *work_area_start );
    140145    printk( "WorkArea Size = 0x%08x\n", *work_area_size );
Note: See TracChangeset for help on using the changeset viewer.