1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSScoreMemory |
---|
7 | * |
---|
8 | * @ingroup RTEMSBSPsSharedStartup |
---|
9 | * |
---|
10 | * @brief This source file contains the default implementation of |
---|
11 | * _Memory_Get(). |
---|
12 | */ |
---|
13 | |
---|
14 | /* |
---|
15 | * Copyright (C) 2011, 2019 embedded brains GmbH (http://www.embedded-brains.de) |
---|
16 | * |
---|
17 | * Copyright (C) 1989, 2009 On-Line Applications Research Corporation (OAR) |
---|
18 | * |
---|
19 | * Redistribution and use in source and binary forms, with or without |
---|
20 | * modification, are permitted provided that the following conditions |
---|
21 | * are met: |
---|
22 | * 1. Redistributions of source code must retain the above copyright |
---|
23 | * notice, this list of conditions and the following disclaimer. |
---|
24 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
25 | * notice, this list of conditions and the following disclaimer in the |
---|
26 | * documentation and/or other materials provided with the distribution. |
---|
27 | * |
---|
28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
38 | * POSSIBILITY OF SUCH DAMAGE. |
---|
39 | */ |
---|
40 | |
---|
41 | #include <bsp.h> |
---|
42 | #include <bsp/bootcard.h> |
---|
43 | |
---|
44 | #if defined(HAS_UBOOT) && !defined(BSP_DISABLE_UBOOT_WORK_AREA_CONFIG) |
---|
45 | #define USE_UBOOT |
---|
46 | #endif |
---|
47 | |
---|
48 | /* |
---|
49 | * These are provided by the linkcmds for ALL of the BSPs which use this file. |
---|
50 | */ |
---|
51 | extern char WorkAreaBase[]; |
---|
52 | |
---|
53 | /* |
---|
54 | * We may get the size information from U-Boot or the linker scripts. |
---|
55 | */ |
---|
56 | #ifdef USE_UBOOT |
---|
57 | #include <bsp/u-boot.h> |
---|
58 | #include <rtems/sysinit.h> |
---|
59 | |
---|
60 | static Memory_Area _Memory_Areas[ 1 ]; |
---|
61 | |
---|
62 | static void bsp_memory_initialize( void ) |
---|
63 | { |
---|
64 | char *end; |
---|
65 | |
---|
66 | end = (char *) bsp_uboot_board_info.bi_memstart |
---|
67 | + bsp_uboot_board_info.bi_memsize; |
---|
68 | _Memory_Initialize( &_Memory_Areas[ 0 ], WorkAreaBase, end ); |
---|
69 | } |
---|
70 | |
---|
71 | RTEMS_SYSINIT_ITEM( |
---|
72 | bsp_memory_initialize, |
---|
73 | RTEMS_SYSINIT_MEMORY, |
---|
74 | RTEMS_SYSINIT_ORDER_MIDDLE |
---|
75 | ); |
---|
76 | #else /* !USE_UBOOT */ |
---|
77 | extern char RamEnd[]; |
---|
78 | |
---|
79 | static Memory_Area _Memory_Areas[] = { |
---|
80 | MEMORY_INITIALIZER(WorkAreaBase, RamEnd) |
---|
81 | }; |
---|
82 | #endif /* USE_UBOOT */ |
---|
83 | |
---|
84 | static const Memory_Information _Memory_Information = |
---|
85 | MEMORY_INFORMATION_INITIALIZER( _Memory_Areas ); |
---|
86 | |
---|
87 | const Memory_Information *_Memory_Get( void ) |
---|
88 | { |
---|
89 | return &_Memory_Information; |
---|
90 | } |
---|