[c64d5f0d] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @ingroup arm_start |
---|
| 5 | * |
---|
| 6 | * @brief Raspberry pi workarea initialization. |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | * COPYRIGHT (c) 1989-2008. |
---|
| 11 | * On-Line Applications Research Corporation (OAR). |
---|
| 12 | * |
---|
| 13 | * Copyright (c) 2011-2012 embedded brains GmbH. |
---|
| 14 | * |
---|
| 15 | * The license and distribution terms for this file may be |
---|
| 16 | * found in the file LICENSE in this distribution or at |
---|
| 17 | * http://www.rtems.org/license/LICENSE. |
---|
| 18 | * |
---|
| 19 | * Copyright (c) 2015 YANG Qiao |
---|
| 20 | * |
---|
| 21 | * Code is based on c/src/lib/libbsp/shared/bspgetworkarea.c |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | #include <string.h> |
---|
| 25 | #include <bsp.h> |
---|
| 26 | #include <bsp/bootcard.h> |
---|
| 27 | #include <bsp/vc.h> |
---|
| 28 | #ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN |
---|
| 29 | #include <rtems/config.h> |
---|
| 30 | #endif |
---|
| 31 | |
---|
| 32 | #if defined(HAS_UBOOT) && !defined(BSP_DISABLE_UBOOT_WORK_AREA_CONFIG) |
---|
| 33 | #define USE_UBOOT |
---|
| 34 | #endif |
---|
| 35 | |
---|
| 36 | /* |
---|
| 37 | * These are provided by the linkcmds for ALL of the BSPs which use this file. |
---|
| 38 | */ |
---|
| 39 | extern char WorkAreaBase[]; |
---|
| 40 | |
---|
| 41 | /* |
---|
| 42 | * We may get the size information from U-Boot or the linker scripts. |
---|
| 43 | */ |
---|
| 44 | #ifdef USE_UBOOT |
---|
| 45 | #include <bsp/u-boot.h> |
---|
| 46 | #else |
---|
| 47 | extern char RamBase[]; |
---|
| 48 | extern char RamSize[]; |
---|
| 49 | #endif |
---|
| 50 | |
---|
| 51 | void bsp_work_area_initialize(void) |
---|
| 52 | { |
---|
| 53 | uintptr_t work_base = (uintptr_t) WorkAreaBase; |
---|
| 54 | uintptr_t ram_end; |
---|
| 55 | bcm2835_get_vc_memory_entries vc_entry; |
---|
| 56 | /* |
---|
| 57 | * bcm2835_get_arm_memory_entries arm_entry; |
---|
| 58 | * is another alternative how to obtain usable memory size |
---|
| 59 | */ |
---|
| 60 | |
---|
| 61 | #ifdef USE_UBOOT |
---|
| 62 | ram_end = (uintptr_t) bsp_uboot_board_info.bi_memstart + |
---|
| 63 | bsp_uboot_board_info.bi_memsize; |
---|
| 64 | #else |
---|
| 65 | ram_end = (uintptr_t)RamBase + (uintptr_t)RamSize; |
---|
| 66 | #endif |
---|
| 67 | |
---|
| 68 | #ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN |
---|
| 69 | work_base += rtems_configuration_get_interrupt_stack_size(); |
---|
| 70 | #endif |
---|
| 71 | |
---|
| 72 | memset( &vc_entry, 0, sizeof(vc_entry) ); |
---|
[3d3ad4dc] | 73 | if (bcm2835_mailbox_get_vc_memory( &vc_entry ) >= 0) { |
---|
| 74 | if (vc_entry.base > 10 * 1024 *1024) |
---|
| 75 | ram_end = ram_end > vc_entry.base? vc_entry.base: ram_end; |
---|
| 76 | } |
---|
[c64d5f0d] | 77 | bsp_work_area_initialize_default( (void *) work_base, ram_end - work_base ); |
---|
| 78 | } |
---|