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 */ /* SPDX-License-Identifier: GPL-2.0-or-later */
#include <console/console.h>
#include <arch/pirq_routing.h> #include <arch/pirq_routing.h>
#include <commonlib/helpers.h> #include <commonlib/helpers.h>
#include <string.h> #include <console/console.h>
#include <device/pci.h> #include <device/pci.h>
#include <string.h>
#include <types.h>
static void check_pirq_routing_table(struct irq_routing_table *rt) 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"); 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) const struct irq_routing_table *routing_table)
{ {
int i; int i;
@@ -73,14 +74,14 @@ static int verify_copy_pirq_routing_table(unsigned long addr,
for (i = 0; i < routing_table->size; i++) { for (i = 0; i < routing_table->size; i++) {
if (*(rt_curr + i) != *(rt_orig + i)) { if (*(rt_curr + i) != *(rt_orig + i)) {
printk(BIOS_INFO, "failed\n"); printk(BIOS_INFO, "failed\n");
return -1; return CB_ERR;
} }
} }
printk(BIOS_INFO, "done\n"); printk(BIOS_INFO, "done\n");
check_pirq_routing_table((struct irq_routing_table *)addr); 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) 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); 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)); 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()); ctx = cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK, var_mtrr_ctx_size());
if (ctx == NULL) { if (ctx == NULL) {
printk(BIOS_ERR, "Couldn't add var_mtrr_ctx setup in cbmem.\n"); printk(BIOS_ERR, "Couldn't add var_mtrr_ctx setup in cbmem.\n");
return -1; return CB_ERR;
} }
pcf->mtrr = ctx; pcf->mtrr = ctx;
var_mtrr_context_init(pcf->mtrr); var_mtrr_context_init(pcf->mtrr);
return 0; return CB_SUCCESS;
} }
void postcar_frame_add_mtrr(struct postcar_frame *pcf, void postcar_frame_add_mtrr(struct postcar_frame *pcf,

View File

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

View File

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