Jon Medhurst | bb1fe20 | 2014-01-24 15:41:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * Redistributions of source code must retain the above copyright notice, this |
| 8 | * list of conditions and the following disclaimer. |
| 9 | * |
| 10 | * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * Neither the name of ARM nor the names of its contributors may be used |
| 15 | * to endorse or promote products derived from this software without specific |
| 16 | * prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | * POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | |
Sandrine Bailleux | 82a6e1a | 2014-04-03 13:48:04 +0100 | [diff] [blame] | 31 | #ifndef __XLAT_TABLES_H__ |
| 32 | #define __XLAT_TABLES_H__ |
| 33 | |
Achin Gupta | e998254 | 2014-06-26 08:59:07 +0100 | [diff] [blame] | 34 | |
| 35 | /* |
| 36 | * Flags to override default values used to program system registers while |
| 37 | * enabling the MMU. |
| 38 | */ |
| 39 | #define DISABLE_DCACHE (1 << 0) |
| 40 | |
| 41 | #ifndef __ASSEMBLY__ |
Jon Medhurst | bb1fe20 | 2014-01-24 15:41:33 +0000 | [diff] [blame] | 42 | #include <stdint.h> |
| 43 | |
| 44 | /* |
| 45 | * Flags for building up memory mapping attributes. |
| 46 | * These are organised so that a clear bit gives a more restrictive mapping |
| 47 | * that a set bit, that way a bitwise-and two sets of attributes will never give |
| 48 | * an attribute which has greater access rights that any of the original |
| 49 | * attributes. |
| 50 | */ |
| 51 | typedef enum { |
| 52 | MT_DEVICE = 0 << 0, |
| 53 | MT_MEMORY = 1 << 0, |
| 54 | |
| 55 | MT_RO = 0 << 1, |
| 56 | MT_RW = 1 << 1, |
| 57 | |
| 58 | MT_SECURE = 0 << 2, |
| 59 | MT_NS = 1 << 2 |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 60 | } mmap_attr_t; |
Jon Medhurst | bb1fe20 | 2014-01-24 15:41:33 +0000 | [diff] [blame] | 61 | |
| 62 | /* |
| 63 | * Structure for specifying a single region of memory. |
| 64 | */ |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 65 | typedef struct mmap_region { |
Lin Ma | 1359236 | 2014-06-02 11:45:36 -0700 | [diff] [blame] | 66 | unsigned long base_pa; |
| 67 | unsigned long base_va; |
Jon Medhurst | bb1fe20 | 2014-01-24 15:41:33 +0000 | [diff] [blame] | 68 | unsigned long size; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 69 | mmap_attr_t attr; |
| 70 | } mmap_region_t; |
Jon Medhurst | bb1fe20 | 2014-01-24 15:41:33 +0000 | [diff] [blame] | 71 | |
Lin Ma | 1359236 | 2014-06-02 11:45:36 -0700 | [diff] [blame] | 72 | void mmap_add_region(unsigned long base_pa, unsigned long base_va, |
| 73 | unsigned long size, unsigned attr); |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 74 | void mmap_add(const mmap_region_t *mm); |
Jon Medhurst | bb1fe20 | 2014-01-24 15:41:33 +0000 | [diff] [blame] | 75 | |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 76 | void init_xlat_tables(void); |
Jon Medhurst | bb1fe20 | 2014-01-24 15:41:33 +0000 | [diff] [blame] | 77 | |
Achin Gupta | e998254 | 2014-06-26 08:59:07 +0100 | [diff] [blame] | 78 | void enable_mmu_el1(uint32_t flags); |
| 79 | void enable_mmu_el3(uint32_t flags); |
Sandrine Bailleux | 82a6e1a | 2014-04-03 13:48:04 +0100 | [diff] [blame] | 80 | |
Achin Gupta | e998254 | 2014-06-26 08:59:07 +0100 | [diff] [blame] | 81 | #endif /*__ASSEMBLY__*/ |
Sandrine Bailleux | 82a6e1a | 2014-04-03 13:48:04 +0100 | [diff] [blame] | 82 | #endif /* __XLAT_TABLES_H__ */ |