Changeset a4d7e4ce in rtems


Ignore:
Timestamp:
Aug 6, 2019, 10:00:56 AM (2 weeks ago)
Author:
Chris Johns <chrisj@…>
Branches:
master
Children:
df256505
Parents:
9cb19ded
git-author:
Chris Johns <chrisj@…> (08/06/19 10:00:56)
git-committer:
Chris Johns <chrisj@…> (08/11/19 22:49:33)
Message:

arm/raspberry: Set the workspace based on the mailbox version.

  • Update the linkcmd file to support configure settings
  • Set the workspace size based on the revision value
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • bsps/arm/raspberrypi/start/bspgetworkarea.c

    r9cb19ded ra4d7e4ce  
    4848void bsp_work_area_initialize(void)
    4949{
    50   uintptr_t work_base = (uintptr_t) WorkAreaBase;
    51   uintptr_t ram_end;
    52   bcm2835_get_vc_memory_entries vc_entry;
     50  uintptr_t                      work_base;
     51  uintptr_t                      ram_end;
     52  bcm2835_get_board_spec_entries spec = { 0 };
     53
     54  work_base = (uintptr_t) WorkAreaBase;
     55
    5356  /*
    54    * bcm2835_get_arm_memory_entries arm_entry;
    55    * is another alternative how to obtain usable memory size
     57   * Get the board revision and use it to determine the size of the
     58   * SDRAM. Get the VC memory entry to determine the size of the VC
     59   * memory needed.
    5660   */
    5761
     
    6367  #endif
    6468
    65   memset( &vc_entry, 0, sizeof(vc_entry) );
    66   if (bcm2835_mailbox_get_vc_memory( &vc_entry ) >= 0) {
    67     if (vc_entry.base > 10 * 1024 *1024)
    68       ram_end = ram_end > vc_entry.base? vc_entry.base: ram_end;
     69  if (bcm2835_mailbox_get_board_revision( &spec ) >= 0) {
     70    uint32_t mem = (spec.spec >> (4 + 4 + 8 + 4)) & 0xf;
     71    if (mem < 5) {
     72      bcm2835_get_vc_memory_entries vc = { 0 };
     73      const uint32_t rpi_mem[5] = {
     74        256 * 1024,
     75        512 * 1024,
     76        1 * 1024,
     77        2 * 1024,
     78        4 * 1024
     79      };
     80      ram_end = work_base + rpi_mem[mem];
     81      if (bcm2835_mailbox_get_vc_memory( &vc ) >= 0)
     82        ram_end -= vc.size;
     83    }
    6984  }
     85
    7086  bsp_work_area_initialize_default( (void *) work_base, ram_end - work_base );
    7187}
  • bsps/arm/raspberrypi/start/bspstart.c

    r9cb19ded ra4d7e4ce  
    2323#include <bsp/stackalloc.h>
    2424#include <bsp/raspberrypi.h>
     25#include <bsp/vc.h>
     26
     27static const struct {
     28    uint32_t code;
     29    const char* label;
     30} rpi_codes[] =
     31{
     32    { 0x900021, "A+ 1.1 (512MB)" },
     33    { 0x900032, "B+ 1.2 (512MB)" },
     34    { 0x900092, "Zero 1.2 (512MB)" },
     35    { 0x900093, "Zero 1.3 (512MB)" },
     36    { 0x9000c1, "Zero W 1.1 (512MB)" },
     37    { 0x9020e0, "3A+ 1.0 (512MB)" },
     38    { 0x920092, "Zero 1.2 (512MB)" },
     39    { 0x920093, "Zero 1.3 (512MB)" },
     40    { 0x900061, "CM 1.1 (512MB)" },
     41    { 0xa01040, "2B 1.0 (1GB)" },
     42    { 0xa01041, "2B 1.1 (1GB)" },
     43    { 0xa02082, "3B 1.2 (1GB)" },
     44    { 0xa020a0, "CM3 1.0 (1GB)" },
     45    { 0xa020d3, "3B+ 1.3 (1GB)" },
     46    { 0xa21041, "2B 1.1 (1GB)" },
     47    { 0xa22042, "2B 1,2 (with BCM2837) (1GB)" },
     48    { 0xa22082, "3B 1.2 (1GB)" },
     49    { 0xa220a0, "CM3 1.0 (1GB)" },
     50    { 0xa32082, "3B 1.2 (1GB)" },
     51    { 0xa52082, "3B 1.2 (1GB)" },
     52    { 0xa22083, "3B 1.3 (1GB)" },
     53    { 0xa02100, "CM3+ 1.0 (1GB)" },
     54    { 0xa03111, "4B 1.1 (1GB)" },
     55    { 0xb03111, "4B 1.1 (2GB)" },
     56    { 0xc03111, "4B 1.1 (4GB)" },
     57};
     58
     59static const char* rpi_types[] = {
     60    "A",
     61    "B",
     62    "A+",
     63    "B+",
     64    "2B",
     65    "Alpha (early prototype)",
     66    "CM1",
     67    "3B",
     68    "Zero",
     69    "CM3",
     70    "Zero W",
     71    "3B+",
     72    "3A+",
     73    "Internal use only",
     74    "CM3+",
     75    "4B",
     76};
     77
     78static const char* rpi_mem[] =
     79{
     80    "256MB",
     81    "512MB",
     82    "1GB",
     83    "2GB",
     84    "4GB"
     85};
     86
     87#define NUMOF(_s) (sizeof(_s) / sizeof(_s[0]))
    2588
    2689void bsp_start(void)
    2790{
     91    bcm2835_get_board_spec_entries spec = { 0 };
     92
     93    printk("\nRTEMS RPi ");
     94    if (bcm2835_mailbox_get_board_revision( &spec ) >= 0) {
     95        size_t i;
     96        for (i = 0; i < NUMOF(rpi_codes); ++i) {
     97            if (rpi_codes[i].code == spec.spec) {
     98                printk("%s [%08x]", rpi_codes[i].label, spec.spec);
     99                break;
     100            }
     101        }
     102        if (i >= NUMOF(rpi_codes)) {
     103            uint32_t type = (spec.spec >> 4) & 0xff;
     104            uint32_t mem = (spec.spec >> (4 + 4 + 8 + 4)) & 0xf;
     105            printk(" unknown code [%08x] ", spec.spec);
     106            if (type < NUMOF(rpi_types))
     107                printk(rpi_types[type]);
     108            else
     109                printk("type: %02x", type);
     110            if (mem < NUMOF(rpi_mem))
     111                printk(" %s", rpi_mem[mem]);
     112            else
     113                printk(" mem: %x", mem);
     114        }
     115        printk("\n");
     116    }
     117    else {
     118        printk(": ERROR reading mailbox\n");
     119    }
     120
    28121    bsp_interrupt_initialize();
    29122}
  • bsps/arm/raspberrypi/start/linkcmds.in

    r9cb19ded ra4d7e4ce  
    1616
    1717MEMORY {
    18         RAM_MMU        (AIW) : ORIGIN = 0x00100000, LENGTH = 16k
    19         RAM            (AIW) : ORIGIN = 0x00200000, LENGTH = 128M - 2M
     18  RAM_MMU (AIW) : ORIGIN = 0x00100000, LENGTH = @RPI_RAM_MMU_LENGTH@
     19  RAM     (AIW) : ORIGIN = 0x00200000, LENGTH = @RPI_RAM_LENGTH_AVAILABLE@ - @RPI_RAM_NOCACHE_LENGTH@
    2020}
    2121
    22 REGION_ALIAS ("REGION_START", RAM);
    23 REGION_ALIAS ("REGION_VECTOR", RAM);
    24 REGION_ALIAS ("REGION_TEXT", RAM);
    25 REGION_ALIAS ("REGION_TEXT_LOAD", RAM);
    26 REGION_ALIAS ("REGION_RODATA", RAM);
    27 REGION_ALIAS ("REGION_RODATA_LOAD", RAM);
    28 REGION_ALIAS ("REGION_DATA", RAM);
    29 REGION_ALIAS ("REGION_DATA_LOAD", RAM);
    30 REGION_ALIAS ("REGION_FAST_TEXT", RAM);
     22REGION_ALIAS ("REGION_START",          RAM);
     23REGION_ALIAS ("REGION_VECTOR",         RAM);
     24REGION_ALIAS ("REGION_TEXT",           RAM);
     25REGION_ALIAS ("REGION_TEXT_LOAD",      RAM);
     26REGION_ALIAS ("REGION_RODATA",         RAM);
     27REGION_ALIAS ("REGION_RODATA_LOAD",    RAM);
     28REGION_ALIAS ("REGION_DATA",           RAM);
     29REGION_ALIAS ("REGION_DATA_LOAD",      RAM);
     30REGION_ALIAS ("REGION_FAST_TEXT",      RAM);
    3131REGION_ALIAS ("REGION_FAST_TEXT_LOAD", RAM);
    32 REGION_ALIAS ("REGION_FAST_DATA", RAM);
     32REGION_ALIAS ("REGION_FAST_DATA",      RAM);
    3333REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM);
    34 REGION_ALIAS ("REGION_BSS", RAM);
    35 REGION_ALIAS ("REGION_WORK", RAM);
    36 REGION_ALIAS ("REGION_STACK", RAM);
    37 REGION_ALIAS ("REGION_NOCACHE", RAM);
    38 REGION_ALIAS ("REGION_NOCACHE_LOAD", RAM);
     34REGION_ALIAS ("REGION_BSS",            RAM);
     35REGION_ALIAS ("REGION_WORK",           RAM);
     36REGION_ALIAS ("REGION_STACK",          RAM);
     37REGION_ALIAS ("REGION_NOCACHE",        RAM);
     38REGION_ALIAS ("REGION_NOCACHE_LOAD",   RAM);
    3939
    4040bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
  • c/src/lib/libbsp/arm/raspberrypi/configure.ac

    r9cb19ded ra4d7e4ce  
    1111RTEMS_SOURCE_TOP
    1212RTEMS_BUILD_TOP
    13 RTEMS_BSP_LINKCMDS
    1413
    1514RTEMS_CANONICAL_TARGET_CPU
    1615AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.12.2])
    1716RTEMS_BSP_CONFIGURE
    18 
    19 
    2017
    2118RTEMS_BSPOPTS_SET([BSP_START_RESET_VECTOR],[*],[])
     
    3835AM_CONDITIONAL(RTEMS_RPI2,[test "$BSP_IS_RPI2" = "1"])
    3936
     37RPI_RAM_MMU_LENGTH="16k"
     38RPI_RAM_LENGTH_AVAILABLE="256M"
     39RPI_RAM_NOCACHE_LENGTH="2M"
     40
     41AC_DEFUN([RPI_LINKCMD],[
     42AC_ARG_VAR([$1],[$2; default $3])dnl
     43[$1]=[$]{[$1]:-[$3]}
     44])
     45
     46RPI_LINKCMD([RPI_RAM_MMU_LENGTH],[MMU region length],[${BSP_RPI_RAM_MMU_LENGTH}])
     47RPI_LINKCMD([RPI_RAM_LENGTH_AVAILABLE],[RAM region length],[${BSP_RPI_RAM_LENGTH_AVAILABLE}])
     48RPI_LINKCMD([RPI_RAM_NOCACHE_LENGTH],[No-cache region length],[${BSP_RPI_RAM_NOCACHE_LENGTH}])
     49
    4050RTEMS_BSP_CLEANUP_OPTIONS
    4151
    42 AC_CONFIG_FILES([Makefile])
     52AC_CONFIG_FILES([
     53Makefile
     54linkcmds:../../../../../../bsps/arm/raspberrypi/start/linkcmds.in])
    4355AC_OUTPUT
Note: See TracChangeset for help on using the changeset viewer.