coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ddr_common.c
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
3
#include <
device/dram/common.h
>
4
#include <types.h>
5
6
/**
7
* \brief Calculate the CRC of a DDR SPD data
8
*
9
* @param spd pointer to raw SPD data
10
* @param len length of data in SPD
11
*
12
* @return the CRC of the SPD data
13
*/
14
u16
ddr_crc16
(
const
u8
*ptr,
int
n_crc)
15
{
16
int
i;
17
u16
crc = 0;
18
19
while
(--n_crc >= 0) {
20
crc = crc ^ ((int)*ptr++ << 8);
21
for
(i = 0; i < 8; ++i)
22
if
(crc & 0x8000)
23
crc = (crc << 1) ^ 0x1021;
24
else
25
crc = crc << 1;
26
}
27
28
return
crc;
29
}
ddr_crc16
u16 ddr_crc16(const u8 *ptr, int n_crc)
Calculate the CRC of a DDR SPD data.
Definition:
ddr_common.c:14
common.h
u16
uint16_t u16
Definition:
stdint.h:48
u8
uint8_t u8
Definition:
stdint.h:45
src
device
dram
ddr_common.c
Generated by
1.9.1