coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
board_id.c
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
#include "
board_id.h
"
3
#include <
ec/acpi/ec.h
>
4
#include <
stdint.h
>
5
#include <
stddef.h
>
6
7
/*
8
* Get Board info via EC I/O port write/read
9
*/
10
int
get_ec_boardinfo
(
void
)
11
{
12
MAYBE_STATIC_NONZERO
int
ec_info = -1;
13
if
(ec_info < 0) {
14
uint8_t
buffer
[2];
15
uint8_t
index;
16
if
(
send_ec_command
(
EC_FAB_ID_CMD
) == 0) {
17
for
(index = 0; index <
sizeof
(
buffer
); index++)
18
buffer
[index] =
recv_ec_data
();
19
ec_info = (
buffer
[1] << 8) |
buffer
[0];
20
}
21
}
22
return
ec_info;
23
}
24
25
/* Get spd index */
26
int
get_spd_index
(
u8
*
spd_index
)
27
{
28
int
ec_info =
get_ec_boardinfo
();
29
if
(ec_info >= 0) {
30
*
spd_index
= ((
uint16_t
)ec_info >> 5) & 0x7;
31
return
0;
32
}
33
return
-1;
34
}
35
36
/* Get Board Id */
37
int
get_board_id
(
void
)
38
{
39
int
ec_info =
get_ec_boardinfo
();
40
if
(ec_info >= 0)
41
return
((
uint16_t
)ec_info >> 8) & 0xff;
42
43
return
-1;
44
}
get_board_id
int get_board_id(void)
Definition:
board_id.c:20
EC_FAB_ID_CMD
#define EC_FAB_ID_CMD
Definition:
board_id.h:7
send_ec_command
int send_ec_command(u8 command)
Definition:
ec.c:13
recv_ec_data
u8 recv_ec_data(void)
Definition:
ec.c:65
ec.h
get_ec_boardinfo
int get_ec_boardinfo(void)
Definition:
board_id.c:10
get_spd_index
int get_spd_index(u8 *spd_index)
Definition:
board_id.c:26
spd_index
static const int spd_index[32]
Definition:
memory.c:10
buffer
u8 buffer[C2P_BUFFER_MAXSIZE]
Definition:
psp_smm.c:18
stddef.h
MAYBE_STATIC_NONZERO
#define MAYBE_STATIC_NONZERO
Definition:
stddef.h:38
stdint.h
uint16_t
unsigned short uint16_t
Definition:
stdint.h:11
u8
uint8_t u8
Definition:
stdint.h:45
uint8_t
unsigned char uint8_t
Definition:
stdint.h:8
board_id.h
src
mainboard
intel
kblrvp
board_id.c
Generated by
1.9.1