summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86/pirq_routing.c11
-rw-r--r--src/arch/x86/postcar_loader.c6
-rw-r--r--src/arch/x86/rdrand.c16
-rw-r--r--src/include/random.h6
4 files changed, 20 insertions, 19 deletions
diff --git a/src/arch/x86/pirq_routing.c b/src/arch/x86/pirq_routing.c
index 0a1e75d6e3..72445360ca 100644
--- a/src/arch/x86/pirq_routing.c
+++ b/src/arch/x86/pirq_routing.c
@@ -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)
diff --git a/src/arch/x86/postcar_loader.c b/src/arch/x86/postcar_loader.c
index be4a235bf1..a8a77e0227 100644
--- a/src/arch/x86/postcar_loader.c
+++ b/src/arch/x86/postcar_loader.c
@@ -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,
diff --git a/src/arch/x86/rdrand.c b/src/arch/x86/rdrand.c
index 985aeba6c1..31958dba7f 100644
--- a/src/arch/x86/rdrand.c
+++ b/src/arch/x86/rdrand.c
@@ -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;
}
diff --git a/src/include/random.h b/src/include/random.h
index 589254e89f..5be918fa77 100644
--- a/src/include/random.h
+++ b/src/include/random.h
@@ -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_ */