coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
romstage.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/cache.h>
4 #include <arch/exception.h>
5 #include <cbmem.h>
6 #include <console/console.h>
7 #include <reset.h>
8 #include <program_loading.h>
9 #include <soc/addressmap.h>
10 #include <soc/cache.h>
11 #include <soc/clk_rst.h>
12 #include <soc/clock.h>
13 #include <soc/display.h>
14 #include <soc/early_configs.h>
15 #include <soc/nvidia/tegra/i2c.h>
17 #include <soc/power.h>
18 #include <soc/sdram.h>
19 #include <symbols.h>
20 #include <timestamp.h>
21 
22 #include "sdram_configs.h"
23 
24 static void __attribute__((noinline)) romstage(void)
25 {
26  timestamp_init(0);
28 
29  console_init();
31 
33 
34  /* used for MMU and CBMEM setup, in MB */
35  u32 dram_start_mb = (uintptr_t)_dram/MiB;
36  u32 dram_end_mb = sdram_max_addressable_mb();
37  u32 dram_size_mb = dram_end_mb - dram_start_mb;
38 
40  mmu_init();
41  /* Device memory below DRAM is uncached. */
42  mmu_config_range(0, dram_start_mb, DCACHE_OFF);
43  /* SRAM is cached. MMU code will round size up to page size. */
47  /* DRAM is cached. */
48  mmu_config_range(dram_start_mb, dram_size_mb, DCACHE_WRITEBACK);
49  /* A window for DMA is uncached. */
50  mmu_config_range((uintptr_t)_dma_coherent/MiB,
52  /* The space above DRAM is uncached. */
53  if (dram_end_mb < 4096)
54  mmu_config_range(dram_end_mb, 4096 - dram_end_mb, DCACHE_OFF);
55  mmu_disable_range(0, 1);
57 
58  /*
59  * A watchdog reset only resets part of the system so it ends up in
60  * a funny state. If that happens, we need to reset the whole machine.
61  */
63  printk(BIOS_INFO, "Watchdog reset detected, rebooting.\n");
64  board_reset();
65  }
66 
67  /* FIXME: this may require coordination with moving timestamps */
69 
70  /* This was already called from verstage in vboot context. */
71  if (!CONFIG(VBOOT))
73 
74  run_ramstage();
75 }
76 
77 /* Stub to force arm_init_caches to the top, before any stack/memory accesses */
78 void main(void)
79 {
80  asm volatile ("bl arm_init_caches"
81  ::: "r0","r1","r2","r3","r4","r5","ip");
82  romstage();
83 }
void main(void)
Definition: romstage.c:13
void dcache_mmu_enable(void)
Definition: cache.c:53
void mmu_config_range(u32 start_mb, u32 size_mb, enum dcache_policy policy)
Definition: mmu.c:221
void mmu_init(void)
Definition: mmu.c:242
void mmu_disable_range(u32 start_mb, u32 size_mb)
Definition: mmu.c:211
@ DCACHE_WRITEBACK
Definition: cache.h:364
@ DCACHE_OFF
Definition: cache.h:363
void exception_init(void)
Definition: exception.c:120
const struct sdram_info * get_sdram_config(void)
Definition: sdram_configs.c:85
#define MiB
Definition: helpers.h:76
#define DIV_ROUND_UP(x, y)
Definition: helpers.h:60
void sdram_init(void)
Definition: sdram.c:16
void cbmem_initialize_empty(void)
Definition: imd_cbmem.c:45
#define printk(level,...)
Definition: stdlib.h:16
int dma_coherent(void *ptr)
@ CONFIG
Definition: dsi_common.h:201
__noreturn void board_reset(void)
Definition: reset.c:8
u8 _dram[]
#define REGION_SIZE(name)
Definition: symbols.h:10
void console_init(void)
Definition: init.c:49
void timestamp_add_now(enum timestamp_id id)
Definition: timestamp.c:141
void timestamp_init(uint64_t base)
Definition: timestamp.c:146
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
static void romstage(void)
Definition: romstage.c:24
int power_reset_status(void)
Definition: power.c:74
@ POWER_RESET_WATCHDOG
Definition: power.h:14
uintptr_t sdram_max_addressable_mb(void)
Definition: sdram.c:630
void early_mainboard_init(void)
Definition: early_configs.c:80
void run_ramstage(void)
Definition: prog_loaders.c:85
void configure_l2_cache(void)
Definition: cache.c:45
uint32_t u32
Definition: stdint.h:51
unsigned long uintptr_t
Definition: stdint.h:21
@ TS_ROMSTAGE_START