coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
biosram.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/acpimmio.h>
4 #include <amdblocks/biosram.h>
5 #include <device/mmio.h>
6 #include <stdint.h>
7 
8 /* BiosRam Ranges at 0xfed80500 or I/O 0xcd4/0xcd5 */
9 #define BIOSRAM_AP_ENTRY 0xe8 /* 8 bytes */
10 #define BIOSRAM_CBMEM_TOP 0xf0 /* 4 bytes */
11 #define BIOSRAM_UMA_SIZE 0xf4 /* 4 bytes */
12 #define BIOSRAM_UMA_BASE 0xf8 /* 8 bytes */
13 
15 {
16  return read8(acpimmio_biosram + reg);
17 }
18 
20 {
22 }
23 
24 static uint16_t biosram_read16(uint8_t reg) /* Must be 1 byte at a time */
25 {
26  return (biosram_read8(reg + sizeof(uint8_t)) << 8 | biosram_read8(reg));
27 }
28 
30 {
31  biosram_write8(reg, value & 0xff);
32  value >>= 8;
33  biosram_write8(reg + sizeof(uint8_t), value & 0xff);
34 }
35 
37 {
38  uint32_t value = biosram_read16(reg + sizeof(uint16_t)) << 16;
39  return value | biosram_read16(reg);
40 }
41 
43 {
44  biosram_write16(reg, value & 0xffff);
45  value >>= 16;
46  biosram_write16(reg + sizeof(uint16_t), value & 0xffff);
47 }
48 
49 /* Access to BIOSRAM is only allowed through the abstractions below. */
50 
51 void *get_ap_entry_ptr(void)
52 {
53  return (void *)biosram_read32(BIOSRAM_AP_ENTRY);
54 }
55 
56 void set_ap_entry_ptr(void *entry)
57 {
59 }
60 
62 {
64 }
65 
67 {
69 }
70 
72 {
74 }
75 
77 {
80 }
81 
83 {
85 }
86 
88 {
89  uint64_t base;
91  base |= ((uint64_t)(biosram_read32(BIOSRAM_UMA_BASE + 4)) << 32);
92  return base;
93 }
uint8_t *MAYBE_CONST acpimmio_biosram
pte_t value
Definition: mmu.c:91
static void write8(void *addr, uint8_t val)
Definition: mmio.h:30
static uint8_t read8(const void *addr)
Definition: mmio.h:12
void save_uma_base(uint64_t base)
Definition: biosram.c:76
#define BIOSRAM_UMA_BASE
Definition: biosram.c:12
#define BIOSRAM_CBMEM_TOP
Definition: biosram.c:10
uintptr_t restore_top_of_low_cacheable(void)
Definition: biosram.c:66
void backup_top_of_low_cacheable(uintptr_t ramtop)
Definition: biosram.c:61
static void biosram_write16(uint8_t reg, uint16_t value)
Definition: biosram.c:29
uint64_t get_uma_base(void)
Definition: biosram.c:87
static void biosram_write32(uint8_t reg, uint32_t value)
Definition: biosram.c:42
static uint8_t biosram_read8(uint8_t reg)
Definition: biosram.c:14
static void biosram_write8(uint8_t reg, uint8_t value)
Definition: biosram.c:19
#define BIOSRAM_AP_ENTRY
Definition: biosram.c:9
static uint16_t biosram_read16(uint8_t reg)
Definition: biosram.c:24
#define BIOSRAM_UMA_SIZE
Definition: biosram.c:11
void set_ap_entry_ptr(void *entry)
Definition: biosram.c:56
void * get_ap_entry_ptr(void)
Definition: biosram.c:51
void save_uma_size(uint32_t size)
Definition: biosram.c:71
static uint32_t biosram_read32(uint8_t reg)
Definition: biosram.c:36
uint32_t get_uma_size(void)
Definition: biosram.c:82
uintptr_t base
Definition: uart.c:17
unsigned short uint16_t
Definition: stdint.h:11
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
unsigned char uint8_t
Definition: stdint.h:8