drivers/pc80/rtc: Remove duplicate cmos_chksum_valid()
Change-Id: I5a4b86921876c24cd1d310b674119b960c3d2fd6 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/38194 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
3838701c84
commit
2a0e3b25ea
|
@ -1,6 +1,7 @@
|
||||||
ifeq ($(CONFIG_ARCH_X86),y)
|
ifeq ($(CONFIG_ARCH_X86),y)
|
||||||
|
|
||||||
bootblock-$(CONFIG_DRIVERS_MC146818) += mc146818rtc_boot.c
|
all-$(CONFIG_DRIVERS_MC146818) += mc146818rtc_boot.c
|
||||||
|
|
||||||
bootblock-$(CONFIG_DRIVERS_MC146818) += mc146818rtc.c
|
bootblock-$(CONFIG_DRIVERS_MC146818) += mc146818rtc.c
|
||||||
postcar-$(CONFIG_DRIVERS_MC146818) += mc146818rtc.c
|
postcar-$(CONFIG_DRIVERS_MC146818) += mc146818rtc.c
|
||||||
romstage-$(CONFIG_DRIVERS_MC146818) += mc146818rtc.c
|
romstage-$(CONFIG_DRIVERS_MC146818) += mc146818rtc.c
|
||||||
|
|
|
@ -53,7 +53,7 @@ static void cmos_reset_date(void)
|
||||||
rtc_set(&time);
|
rtc_set(&time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cmos_checksum_valid(int range_start, int range_end, int cks_loc)
|
int cmos_checksum_valid(int range_start, int range_end, int cks_loc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
u16 sum, old_sum;
|
u16 sum, old_sum;
|
||||||
|
@ -69,7 +69,7 @@ static int cmos_checksum_valid(int range_start, int range_end, int cks_loc)
|
||||||
return sum == old_sum;
|
return sum == old_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmos_set_checksum(int range_start, int range_end, int cks_loc)
|
void cmos_set_checksum(int range_start, int range_end, int cks_loc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
u16 sum;
|
u16 sum;
|
||||||
|
@ -149,8 +149,7 @@ static bool __cmos_init(bool invalid)
|
||||||
|
|
||||||
if (CONFIG(USE_OPTION_TABLE)) {
|
if (CONFIG(USE_OPTION_TABLE)) {
|
||||||
/* See if there is a LB CMOS checksum error */
|
/* See if there is a LB CMOS checksum error */
|
||||||
checksum_invalid = !cmos_checksum_valid(LB_CKS_RANGE_START,
|
checksum_invalid = !cmos_lb_cks_valid();
|
||||||
LB_CKS_RANGE_END, LB_CKS_LOC);
|
|
||||||
if (checksum_invalid)
|
if (checksum_invalid)
|
||||||
printk(BIOS_DEBUG, "RTC: coreboot checksum invalid\n");
|
printk(BIOS_DEBUG, "RTC: coreboot checksum invalid\n");
|
||||||
|
|
||||||
|
|
|
@ -19,27 +19,14 @@
|
||||||
#if CONFIG(USE_OPTION_TABLE)
|
#if CONFIG(USE_OPTION_TABLE)
|
||||||
#include <option_table.h>
|
#include <option_table.h>
|
||||||
|
|
||||||
int cmos_chksum_valid(void)
|
int cmos_lb_cks_valid(void)
|
||||||
{
|
{
|
||||||
unsigned char addr;
|
return cmos_checksum_valid(LB_CKS_RANGE_START, LB_CKS_RANGE_END, LB_CKS_LOC);
|
||||||
u16 sum, old_sum;
|
|
||||||
|
|
||||||
sum = 0;
|
|
||||||
/* Compute the cmos checksum */
|
|
||||||
for (addr = LB_CKS_RANGE_START; addr <= LB_CKS_RANGE_END; addr++)
|
|
||||||
sum += cmos_read(addr);
|
|
||||||
|
|
||||||
/* Read the stored checksum */
|
|
||||||
old_sum = cmos_read(LB_CKS_LOC) << 8;
|
|
||||||
old_sum |= cmos_read(LB_CKS_LOC + 1);
|
|
||||||
|
|
||||||
return sum == old_sum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sanitize_cmos(void)
|
void sanitize_cmos(void)
|
||||||
{
|
{
|
||||||
if (cmos_error() || !cmos_chksum_valid() ||
|
if (cmos_error() || !cmos_lb_cks_valid() || CONFIG(STATIC_OPTION_TABLE)) {
|
||||||
CONFIG(STATIC_OPTION_TABLE)) {
|
|
||||||
size_t length = 128;
|
size_t length = 128;
|
||||||
const unsigned char *cmos_default =
|
const unsigned char *cmos_default =
|
||||||
cbfs_boot_map_with_leak("cmos.default",
|
cbfs_boot_map_with_leak("cmos.default",
|
||||||
|
@ -83,7 +70,7 @@ int do_normal_boot(void)
|
||||||
{
|
{
|
||||||
unsigned char byte;
|
unsigned char byte;
|
||||||
|
|
||||||
if (!CONFIG(USE_OPTION_TABLE) || cmos_error() || !cmos_chksum_valid()) {
|
if (!CONFIG(USE_OPTION_TABLE) || cmos_error() || !cmos_lb_cks_valid()) {
|
||||||
/* Invalid CMOS checksum detected!
|
/* Invalid CMOS checksum detected!
|
||||||
* Force fallback boot...
|
* Force fallback boot...
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -176,7 +176,10 @@ static inline void cmos_write32(u32 value, u8 offset)
|
||||||
void cmos_init(bool invalid);
|
void cmos_init(bool invalid);
|
||||||
void cmos_check_update_date(void);
|
void cmos_check_update_date(void);
|
||||||
int cmos_error(void);
|
int cmos_error(void);
|
||||||
int cmos_chksum_valid(void);
|
int cmos_lb_cks_valid(void);
|
||||||
|
|
||||||
|
int cmos_checksum_valid(int range_start, int range_end, int cks_loc);
|
||||||
|
void cmos_set_checksum(int range_start, int range_end, int cks_loc);
|
||||||
|
|
||||||
enum cb_err set_option(const char *name, void *val);
|
enum cb_err set_option(const char *name, void *val);
|
||||||
enum cb_err get_option(void *dest, const char *name);
|
enum cb_err get_option(void *dest, const char *name);
|
||||||
|
|
Loading…
Reference in New Issue