developer | 880fb17 | 2022-09-05 19:08:59 +0800 | [diff] [blame] | 1 | /* |
Chungying Lu | 59c1c2b | 2023-04-25 15:39:10 +0800 | [diff] [blame] | 2 | * Copyright (c) 2022-2023, ARM Limited and Contributors. All rights reserved. |
developer | 880fb17 | 2022-09-05 19:08:59 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef EMI_MPU_H |
| 8 | #define EMI_MPU_H |
| 9 | |
| 10 | #include <emi_mpu_priv.h> |
| 11 | #include <platform_def.h> |
| 12 | |
| 13 | #define NO_PROTECTION (0) |
| 14 | #define SEC_RW (1) |
| 15 | #define SEC_RW_NSEC_R (2) |
| 16 | #define SEC_RW_NSEC_W (3) |
| 17 | #define SEC_R_NSEC_R (4) |
| 18 | #define FORBIDDEN (5) |
| 19 | #define SEC_R_NSEC_RW (6) |
| 20 | |
| 21 | #define LOCK (1) |
| 22 | #define UNLOCK (0) |
| 23 | |
| 24 | #if (EMI_MPU_DGROUP_NUM == 1) |
| 25 | #define SET_ACCESS_PERMISSION(apc_ary, lock, d7, d6, d5, d4, d3, d2, d1, d0) \ |
| 26 | do { \ |
| 27 | apc_ary[1] = 0; \ |
| 28 | apc_ary[0] = \ |
| 29 | (((unsigned int) d7) << 21) | (((unsigned int) d6) << 18) | \ |
| 30 | (((unsigned int) d5) << 15) | (((unsigned int) d4) << 12) | \ |
| 31 | (((unsigned int) d3) << 9) | (((unsigned int) d2) << 6) | \ |
| 32 | (((unsigned int) d1) << 3) | ((unsigned int) d0) | \ |
| 33 | ((unsigned int) lock << 31); \ |
| 34 | } while (0) |
| 35 | #elif (EMI_MPU_DGROUP_NUM == 2) |
| 36 | #define SET_ACCESS_PERMISSION(apc_ary, lock, d15, d14, d13, d12, d11, d10, \ |
| 37 | d9, d8, d7, d6, d5, d4, d3, d2, d1, d0) \ |
| 38 | do { \ |
| 39 | apc_ary[1] = \ |
| 40 | (((unsigned int) d15) << 21) | (((unsigned int) d14) << 18) | \ |
| 41 | (((unsigned int) d13) << 15) | (((unsigned int) d12) << 12) | \ |
| 42 | (((unsigned int) d11) << 9) | (((unsigned int) d10) << 6) | \ |
| 43 | (((unsigned int) d9) << 3) | ((unsigned int) d8); \ |
| 44 | apc_ary[0] = \ |
| 45 | (((unsigned int) d7) << 21) | (((unsigned int) d6) << 18) | \ |
| 46 | (((unsigned int) d5) << 15) | (((unsigned int) d4) << 12) | \ |
| 47 | (((unsigned int) d3) << 9) | (((unsigned int) d2) << 6) | \ |
| 48 | (((unsigned int) d1) << 3) | ((unsigned int) d0) | \ |
| 49 | ((unsigned int) lock << 31); \ |
| 50 | } while (0) |
| 51 | #endif |
| 52 | |
| 53 | struct emi_region_info_t { |
| 54 | unsigned long long start; |
| 55 | unsigned long long end; |
| 56 | unsigned int region; |
| 57 | unsigned int apc[EMI_MPU_DGROUP_NUM]; |
| 58 | }; |
| 59 | |
| 60 | int emi_mpu_init(void); |
| 61 | int emi_mpu_set_protection(struct emi_region_info_t *region_info); |
| 62 | void set_emi_mpu_regions(void); |
Chungying Lu | 59c1c2b | 2023-04-25 15:39:10 +0800 | [diff] [blame] | 63 | int set_apu_emi_mpu_region(void); |
developer | 880fb17 | 2022-09-05 19:08:59 +0800 | [diff] [blame] | 64 | |
| 65 | #endif |