Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
91a78198
Commit
91a78198
authored
Apr 07, 2020
by
Sandrine Bailleux
Committed by
TrustedFirmware Code Review
Apr 07, 2020
Browse files
Merge "coreboot: Add memory range parsing" into integration
parents
9dfe46c2
579d1e90
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/lib/coreboot.h
View file @
91a78198
/*
/*
* Copyright (c) 2017-20
18
, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2017-20
20
, ARM Limited and Contributors. All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
* SPDX-License-Identifier: BSD-3-Clause
*/
*/
...
@@ -19,6 +19,27 @@ typedef struct {
...
@@ -19,6 +19,27 @@ typedef struct {
}
coreboot_serial_t
;
}
coreboot_serial_t
;
extern
coreboot_serial_t
coreboot_serial
;
extern
coreboot_serial_t
coreboot_serial
;
#define COREBOOT_MAX_MEMRANGES 32
/* libpayload also uses this limit */
typedef
struct
__packed
{
uint64_t
start
;
uint64_t
size
;
uint32_t
type
;
}
coreboot_memrange_t
;
extern
coreboot_memrange_t
coreboot_memranges
[
COREBOOT_MAX_MEMRANGES
];
typedef
enum
{
CB_MEM_NONE
=
0
,
/* coreboot will never report this */
CB_MEM_RAM
=
1
,
CB_MEM_RESERVED
=
2
,
CB_MEM_ACPI
=
3
,
CB_MEM_NVS
=
4
,
CB_MEM_UNUSABLE
=
5
,
CB_MEM_VENDOR_RSVD
=
6
,
CB_MEM_TABLE
=
16
,
}
coreboot_memory_t
;
coreboot_memory_t
coreboot_get_memory_type
(
uintptr_t
address
);
void
coreboot_table_setup
(
void
*
base
);
void
coreboot_table_setup
(
void
*
base
);
#endif
/* COREBOOT_H */
#endif
/* COREBOOT_H */
lib/coreboot/coreboot_table.c
View file @
91a78198
/*
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2017
-2020
, ARM Limited and Contributors. All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
* SPDX-License-Identifier: BSD-3-Clause
*/
*/
...
@@ -29,6 +29,7 @@ typedef struct {
...
@@ -29,6 +29,7 @@ typedef struct {
}
cb_header_t
;
}
cb_header_t
;
typedef
enum
{
typedef
enum
{
CB_TAG_MEMORY
=
0x1
,
CB_TAG_SERIAL
=
0xf
,
CB_TAG_SERIAL
=
0xf
,
CB_TAG_CBMEM_CONSOLE
=
0x17
,
CB_TAG_CBMEM_CONSOLE
=
0x17
,
}
cb_tag_t
;
}
cb_tag_t
;
...
@@ -37,11 +38,13 @@ typedef struct {
...
@@ -37,11 +38,13 @@ typedef struct {
uint32_t
tag
;
uint32_t
tag
;
uint32_t
size
;
uint32_t
size
;
union
{
union
{
coreboot_memrange_t
memranges
[
COREBOOT_MAX_MEMRANGES
];
coreboot_serial_t
serial
;
coreboot_serial_t
serial
;
uint64_t
uint64
;
uint64_t
uint64
;
};
};
}
cb_entry_t
;
}
cb_entry_t
;
coreboot_memrange_t
coreboot_memranges
[
COREBOOT_MAX_MEMRANGES
];
coreboot_serial_t
coreboot_serial
;
coreboot_serial_t
coreboot_serial
;
/*
/*
...
@@ -86,6 +89,23 @@ static void setup_cbmem_console(uintptr_t baseaddr)
...
@@ -86,6 +89,23 @@ static void setup_cbmem_console(uintptr_t baseaddr)
CONSOLE_FLAG_CRASH
);
CONSOLE_FLAG_CRASH
);
}
}
coreboot_memory_t
coreboot_get_memory_type
(
uintptr_t
address
)
{
int
i
;
for
(
i
=
0
;
i
<
COREBOOT_MAX_MEMRANGES
;
i
++
)
{
coreboot_memrange_t
*
range
=
&
coreboot_memranges
[
i
];
if
(
range
->
type
==
CB_MEM_NONE
)
break
;
/* end of table reached */
if
(
address
>=
range
->
start
&&
address
-
range
->
start
<
range
->
size
)
return
range
->
type
;
}
return
CB_MEM_NONE
;
}
void
coreboot_table_setup
(
void
*
base
)
void
coreboot_table_setup
(
void
*
base
)
{
{
cb_header_t
*
header
=
base
;
cb_header_t
*
header
=
base
;
...
@@ -99,6 +119,7 @@ void coreboot_table_setup(void *base)
...
@@ -99,6 +119,7 @@ void coreboot_table_setup(void *base)
ptr
=
base
+
header
->
header_bytes
;
ptr
=
base
+
header
->
header_bytes
;
for
(
i
=
0
;
i
<
header
->
table_entries
;
i
++
)
{
for
(
i
=
0
;
i
<
header
->
table_entries
;
i
++
)
{
size_t
size
;
cb_entry_t
*
entry
=
ptr
;
cb_entry_t
*
entry
=
ptr
;
if
(
ptr
-
base
>=
header
->
header_bytes
+
header
->
table_bytes
)
{
if
(
ptr
-
base
>=
header
->
header_bytes
+
header
->
table_bytes
)
{
...
@@ -107,6 +128,15 @@ void coreboot_table_setup(void *base)
...
@@ -107,6 +128,15 @@ void coreboot_table_setup(void *base)
}
}
switch
(
read_le32
(
&
entry
->
tag
))
{
switch
(
read_le32
(
&
entry
->
tag
))
{
case
CB_TAG_MEMORY
:
size
=
read_le32
(
&
entry
->
size
)
-
offsetof
(
cb_entry_t
,
memranges
);
if
(
size
>
sizeof
(
coreboot_memranges
))
{
ERROR
(
"Need to truncate coreboot memranges!
\n
"
);
size
=
sizeof
(
coreboot_memranges
);
}
memcpy
(
&
coreboot_memranges
,
&
entry
->
memranges
,
size
);
break
;
case
CB_TAG_SERIAL
:
case
CB_TAG_SERIAL
:
memcpy
(
&
coreboot_serial
,
&
entry
->
serial
,
memcpy
(
&
coreboot_serial
,
&
entry
->
serial
,
sizeof
(
coreboot_serial
));
sizeof
(
coreboot_serial
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment