Paul Burton | c1081a4 | 2014-06-14 00:08:02 +0100 | [diff] [blame] | 1 | /* |
| 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 Burton | c1081a4 | 2014-06-14 00:08:02 +0100 | [diff] [blame] | 15 | */ |
| 16 | |
Vadim Bendebury | 52a8879 | 2014-11-05 17:50:09 -0800 | [diff] [blame] | 17 | #include <arch/cpu.h> |
Andrew Bresticker | b8936ad | 2015-02-05 13:40:49 -0800 | [diff] [blame] | 18 | #include <arch/mmu.h> |
| 19 | #include <assert.h> |
Ionela Voinescu | 1d4c305 | 2015-06-07 23:22:34 +0100 | [diff] [blame] | 20 | #include <stdint.h> |
Andrew Bresticker | b8936ad | 2015-02-05 13:40:49 -0800 | [diff] [blame] | 21 | #include <symbols.h> |
Vadim Bendebury | 52a8879 | 2014-11-05 17:50:09 -0800 | [diff] [blame] | 22 | |
Paul Burton | c1081a4 | 2014-06-14 00:08:02 +0100 | [diff] [blame] | 23 | static void bootblock_cpu_init(void) |
| 24 | { |
Vadim Bendebury | 52a8879 | 2014-11-05 17:50:09 -0800 | [diff] [blame] | 25 | 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 Burton | c1081a4 | 2014-06-14 00:08:02 +0100 | [diff] [blame] | 37 | } |
Andrew Bresticker | b8936ad | 2015-02-05 13:40:49 -0800 | [diff] [blame] | 38 | |
| 39 | static 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 | } |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 57 | assert(!identity_map((uint32_t)_sram, REGION_SIZE(sram), |
Ionela Voinescu | e7a336a | 2015-07-24 15:00:20 +0100 | [diff] [blame] | 58 | C0_ENTRYLO_COHERENCY_WB)); |
| 59 | assert(!identity_map(dram_base, dram_size, C0_ENTRYLO_COHERENCY_WB)); |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 60 | assert(!identity_map((uint32_t)_soc_registers, |
| 61 | REGION_SIZE(soc_registers), C0_ENTRYLO_COHERENCY_UC)); |
Andrew Bresticker | b8936ad | 2015-02-05 13:40:49 -0800 | [diff] [blame] | 62 | } |