arch/x86: Use 'enum cb_err'

Change-Id: I38e4b8c6adfaaa45377b2fbe0644285d21841cd1
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/68369
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
This commit is contained in:
Elyes Haouas 2022-11-08 14:38:41 +01:00 committed by Felix Singer
parent 70191da272
commit 9523e3b790
4 changed files with 20 additions and 19 deletions

View File

@ -1,10 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include <console/console.h>
#include <arch/pirq_routing.h>
#include <commonlib/helpers.h>
#include <string.h>
#include <console/console.h>
#include <device/pci.h>
#include <string.h>
#include <types.h>
static void check_pirq_routing_table(struct irq_routing_table *rt)
{
@ -59,7 +60,7 @@ static void check_pirq_routing_table(struct irq_routing_table *rt)
printk(BIOS_INFO, "done.\n");
}
static int verify_copy_pirq_routing_table(unsigned long addr,
static enum cb_err verify_copy_pirq_routing_table(unsigned long addr,
const struct irq_routing_table *routing_table)
{
int i;
@ -73,14 +74,14 @@ static int verify_copy_pirq_routing_table(unsigned long addr,
for (i = 0; i < routing_table->size; i++) {
if (*(rt_curr + i) != *(rt_orig + i)) {
printk(BIOS_INFO, "failed\n");
return -1;
return CB_ERR;
}
}
printk(BIOS_INFO, "done\n");
check_pirq_routing_table((struct irq_routing_table *)addr);
return 0;
return CB_SUCCESS;
}
static u8 pirq_get_next_free_irq(u8 *pirq, u16 bitmap)

View File

@ -20,7 +20,7 @@ static size_t var_mtrr_ctx_size(void)
return sizeof(struct var_mtrr_context) + mtrr_count * 2 * sizeof(msr_t);
}
static int postcar_frame_init(struct postcar_frame *pcf)
static enum cb_err postcar_frame_init(struct postcar_frame *pcf)
{
memset(pcf, 0, sizeof(*pcf));
@ -29,13 +29,13 @@ static int postcar_frame_init(struct postcar_frame *pcf)
ctx = cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK, var_mtrr_ctx_size());
if (ctx == NULL) {
printk(BIOS_ERR, "Couldn't add var_mtrr_ctx setup in cbmem.\n");
return -1;
return CB_ERR;
}
pcf->mtrr = ctx;
var_mtrr_context_init(pcf->mtrr);
return 0;
return CB_SUCCESS;
}
void postcar_frame_add_mtrr(struct postcar_frame *pcf,

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <random.h>
#include <stdint.h>
#include <types.h>
/*
* Intel recommends that applications attempt 10 retries in a tight loop
@ -41,19 +41,19 @@ static inline uint8_t rdrand_64(uint64_t *rand)
}
#endif
int get_random_number_32(uint32_t *rand)
enum cb_err get_random_number_32(uint32_t *rand)
{
int i;
/* Perform a loop call until RDRAND succeeds or returns failure. */
for (i = 0; i < RDRAND_RETRY_LOOPS; i++) {
if (rdrand_32(rand))
return 0;
return CB_SUCCESS;
}
return -1;
return CB_ERR;
}
int get_random_number_64(uint64_t *rand)
enum cb_err get_random_number_64(uint64_t *rand)
{
int i;
uint32_t rand_high, rand_low;
@ -62,13 +62,13 @@ int get_random_number_64(uint64_t *rand)
for (i = 0; i < RDRAND_RETRY_LOOPS; i++) {
#if ENV_X86_64
if (rdrand_64(rand))
return 0;
return CB_SUCCESS;
#endif
if (rdrand_32(&rand_high) && rdrand_32(&rand_low)) {
*rand = ((uint64_t)rand_high << 32) |
(uint64_t)rand_low;
return 0;
return CB_SUCCESS;
}
}
return -1;
return CB_ERR;
}

View File

@ -2,13 +2,13 @@
#ifndef _RANDOM_H_
#define _RANDOM_H_
#include <stdint.h>
#include <types.h>
/*
* Generates a 32/64 bit random number respectively.
* return 0 on success and -1 on error.
*/
int get_random_number_32(uint32_t *rand);
int get_random_number_64(uint64_t *rand);
enum cb_err get_random_number_32(uint32_t *rand);
enum cb_err get_random_number_64(uint64_t *rand);
#endif /* _RANDOM_H_ */