source: rtems/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c @ 3d3ad4dc

5
Last change on this file since 3d3ad4dc was 3d3ad4dc, checked in by Pavel Pisa <pisa@…>, on 07/31/16 at 09:33:06

arm/raspberrypi: VideoCore? access corrections in cache operation and more error checking.

The first, mistake in buffer size computation for cache flush
and invalidate has been corrected.

GCC attribute( ( aligned( 64 ) ) ) should work and works for local
variables. Code ensures right stack alignment. But attribute has
to be moved to type declaration to ensure that structure size is affected
by attribute. But even this seems to not work reliably for some reason.
May it be, the stack area between frame start and end of local variable buffer
accessed during context switch or some stack prefetch during resturn
such way that some cache lines belonging to buffer are filled to cache.
Extending buffer by one more cache line padding helps there.

In the longer term perspective, buffer should be moved to some static
area or cache aligned dynamic memory allocated. Concurrent calls
to the VideoCore? operations and access serialization should be added
too but problem is that some calls are required during workspace and MMU
setup so variant without need of mutex would be required as well.

Framebuffer setup code and other VideoCore? calls check more
precisely for errors and do not proceed forward with incorrect
data now.

Signed-off-by: Pavel Pisa <pisa@…>

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[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 */
39extern 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
51void 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}
Note: See TracBrowser for help on using the repository browser.