blob: 23f6471689a1e3fce0a8d2c126702af4c09a6373 [file] [log] [blame]
Paul Burtonc1081a42014-06-14 00:08:02 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Imagination Technologies
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Paul Burtonc1081a42014-06-14 00:08:02 +010015 */
16
Vadim Bendebury52a88792014-11-05 17:50:09 -080017#include <arch/cpu.h>
Andrew Brestickerb8936ad2015-02-05 13:40:49 -080018#include <arch/mmu.h>
19#include <assert.h>
Ionela Voinescu1d4c3052015-06-07 23:22:34 +010020#include <stdint.h>
Andrew Brestickerb8936ad2015-02-05 13:40:49 -080021#include <symbols.h>
Vadim Bendebury52a88792014-11-05 17:50:09 -080022
Paul Burtonc1081a42014-06-14 00:08:02 +010023static void bootblock_cpu_init(void)
24{
Vadim Bendebury52a88792014-11-05 17:50:09 -080025 uint32_t cause;
26
27 /*
28 * Make sure the count register is counting by clearing the "Disable
29 * Counter" bit, in case it is set.
30 */
31 cause = read_c0_cause();
32 if (cause & C0_CAUSE_DC)
33 write_c0_cause(cause & ~(C0_CAUSE_DC));
34
35 /* And make sure that it starts from zero. */
36 write_c0_count(0);
Paul Burtonc1081a42014-06-14 00:08:02 +010037}
Andrew Brestickerb8936ad2015-02-05 13:40:49 -080038
39static void bootblock_mmu_init(void)
40{
41 uint32_t null_guard_size = 1 * MiB;
42 uint32_t dram_base, dram_size;
43
44 write_c0_wired(0);
45
46 dram_base = (uint32_t)_dram;
47 dram_size = CONFIG_DRAM_SIZE_MB * MiB;
48
49 /*
50 * To be able to catch NULL pointer dereference attempts, lets not map
51 * memory close to zero.
52 */
53 if (dram_base < null_guard_size) {
54 dram_base += null_guard_size;
55 dram_size -= null_guard_size;
56 }
Ionela Voinescue7a336a2015-07-24 15:00:20 +010057 assert(!identity_map((uint32_t)_sram, _sram_size,
58 C0_ENTRYLO_COHERENCY_WB));
59 assert(!identity_map(dram_base, dram_size, C0_ENTRYLO_COHERENCY_WB));
Ionela Voinescu56e64592015-12-17 19:16:01 +000060 assert(!identity_map((uint32_t)_soc_registers, _soc_registers_size,
61 C0_ENTRYLO_COHERENCY_UC));
Andrew Brestickerb8936ad2015-02-05 13:40:49 -080062}