coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ramdetect.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <types.h>
4 #include <device/mmio.h>
5 #include <ramdetect.h>
6 #include <arch/exception.h>
7 #include <arch/transition.h>
8 
9 static enum {
13 
14 static int abort_checker(struct exc_state *state, uint64_t vector_id)
15 {
16  if (raw_read_esr_el3() >> 26 != 0x25)
17  return EXC_RET_IGNORED; /* Not a data abort. */
18 
20  state->elx.elr += sizeof(uint32_t); /* Jump over faulting instruction. */
21  raw_write_elr_el3(state->elx.elr);
22  return EXC_RET_HANDLED;
23 }
24 
25 static struct exception_handler sync_el0 = {.handler = &abort_checker};
26 
27 int probe_mb(const uintptr_t dram_start, const uintptr_t size)
28 {
29  uintptr_t addr = dram_start + (size * MiB) - sizeof(uint32_t);
30  void *ptr = (void *)addr;
31 
34  read32(ptr);
37 }
static struct exception_handler sync_el0
Definition: ramdetect.c:25
static enum @9 abort_state
int probe_mb(const uintptr_t dram_start, const uintptr_t size)
Definition: ramdetect.c:27
@ ABORT_CHECKER_TRIGGERED
Definition: ramdetect.c:11
@ ABORT_CHECKER_NOT_TRIGGERED
Definition: ramdetect.c:10
static int abort_checker(struct exc_state *state, uint64_t vector_id)
Definition: ramdetect.c:14
static uint32_t read32(const void *addr)
Definition: mmio.h:22
int exception_handler_register(uint64_t vid, struct exception_handler *h)
Definition: exception.c:68
int exception_handler_unregister(uint64_t vid, struct exception_handler *h)
Definition: exception.c:80
@ EXC_RET_IGNORED
Definition: exception.h:19
@ EXC_RET_HANDLED
Definition: exception.h:21
#define MiB
Definition: helpers.h:76
static u32 addr
Definition: cirrus.c:14
state
Definition: raminit.c:1787
unsigned int uint32_t
Definition: stdint.h:14
unsigned long uintptr_t
Definition: stdint.h:21
unsigned long long uint64_t
Definition: stdint.h:17
int(* handler)(struct exc_state *state, uint64_t vector_id)
Definition: exception.h:26
#define EXC_VID_CUR_SP_EL0_SYNC
Definition: transition.h:28