Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google LLC |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Andrew Scull | fbc938a | 2018-08-20 14:09:28 +0100 | [diff] [blame] | 17 | #pragma once |
Wedson Almeida Filho | fed6902 | 2018-07-11 15:39:12 +0100 | [diff] [blame] | 18 | |
| 19 | #include <stdbool.h> |
| 20 | #include <stddef.h> |
Wedson Almeida Filho | fed6902 | 2018-07-11 15:39:12 +0100 | [diff] [blame] | 21 | |
Andrew Scull | 18c78fc | 2018-08-20 12:57:41 +0100 | [diff] [blame] | 22 | #include "hf/addr.h" |
Wedson Almeida Filho | fed6902 | 2018-07-11 15:39:12 +0100 | [diff] [blame] | 23 | |
Andrew Walbran | c3910f7 | 2018-11-27 14:24:36 +0000 | [diff] [blame] | 24 | /** A page table entry. */ |
Andrew Scull | 8087132 | 2018-08-06 12:04:09 +0100 | [diff] [blame] | 25 | typedef uint64_t pte_t; |
| 26 | |
| 27 | #define PAGE_LEVEL_BITS 9 |
| 28 | |
Andrew Walbran | 2513374 | 2018-09-28 16:28:02 +0100 | [diff] [blame] | 29 | /* |
Andrew Scull | 459d3b5 | 2018-12-07 16:37:12 +0000 | [diff] [blame^] | 30 | * TODO: move the arch_mm_* declarations to a shared header. That header can |
| 31 | * also check that the specific implementation defines everything it needs to |
| 32 | * too. |
Andrew Walbran | 2513374 | 2018-09-28 16:28:02 +0100 | [diff] [blame] | 33 | */ |
Andrew Scull | 459d3b5 | 2018-12-07 16:37:12 +0000 | [diff] [blame^] | 34 | pte_t arch_mm_absent_pte(int level); |
| 35 | pte_t arch_mm_table_pte(int level, paddr_t pa); |
| 36 | pte_t arch_mm_block_pte(int level, paddr_t pa, uint64_t attrs); |
| 37 | bool arch_mm_is_block_allowed(int level); |
| 38 | bool arch_mm_pte_is_present(pte_t pte, int level); |
| 39 | bool arch_mm_pte_is_table(pte_t pte, int level); |
| 40 | bool arch_mm_pte_is_block(pte_t pte, int level); |
| 41 | paddr_t arch_mm_clear_pa(paddr_t pa); |
| 42 | paddr_t arch_mm_block_from_pte(pte_t pte); |
| 43 | paddr_t arch_mm_table_from_pte(pte_t pte); |
| 44 | uint64_t arch_mm_pte_attrs(pte_t pte); |
Andrew Walbran | 2400ed2 | 2018-09-27 14:45:58 +0100 | [diff] [blame] | 45 | uint64_t arch_mm_combine_table_entry_attrs(uint64_t table_attrs, |
| 46 | uint64_t block_attrs); |
Andrew Scull | 459d3b5 | 2018-12-07 16:37:12 +0000 | [diff] [blame^] | 47 | void arch_mm_invalidate_stage1_range(vaddr_t va_begin, vaddr_t va_end); |
| 48 | void arch_mm_invalidate_stage2_range(ipaddr_t va_begin, ipaddr_t va_end); |
| 49 | void arch_mm_write_back_dcache(void *base, size_t size); |
| 50 | uint8_t arch_mm_max_level(int mode); |
| 51 | uint8_t arch_mm_root_table_count(int mode); |
| 52 | uint64_t arch_mm_mode_to_attrs(int mode); |
| 53 | bool arch_mm_init(paddr_t table, bool first); |