Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008 Travis Geiselbrecht |
| 3 | * |
Channagoud Kadabi | 0e54f14 | 2015-07-07 15:05:38 -0700 | [diff] [blame] | 4 | * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. |
Channagoud Kadabi | 5fd4efa | 2013-04-23 14:30:17 -0700 | [diff] [blame] | 5 | * |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 6 | * Permission is hereby granted, free of charge, to any person obtaining |
| 7 | * a copy of this software and associated documentation files |
| 8 | * (the "Software"), to deal in the Software without restriction, |
| 9 | * including without limitation the rights to use, copy, modify, merge, |
| 10 | * publish, distribute, sublicense, and/or sell copies of the Software, |
| 11 | * and to permit persons to whom the Software is furnished to do so, |
| 12 | * subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be |
| 15 | * included in all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | */ |
| 25 | #ifndef __ARCH_CPU_H |
| 26 | #define __ARCH_CPU_H |
| 27 | |
| 28 | /* arm specific stuff */ |
| 29 | #define PAGE_SIZE 4096 |
| 30 | |
Amol Jadi | 9ef9b73 | 2011-05-23 16:00:17 -0700 | [diff] [blame] | 31 | #if defined(ARM_CPU_ARM1136) |
| 32 | #define CACHE_LINE 32 |
| 33 | #elif defined(ARM_CPU_CORE_A5) |
| 34 | #define CACHE_LINE 32 |
| 35 | #elif defined(ARM_CPU_CORE_SCORPION) |
| 36 | #define CACHE_LINE 32 |
David Ng | 296fc0c | 2013-01-17 12:04:58 -0800 | [diff] [blame] | 37 | #elif defined(ARM_CPU_CORE_KRAIT) || defined(ARM_CPU_CORE_A7) |
Amol Jadi | 9ef9b73 | 2011-05-23 16:00:17 -0700 | [diff] [blame] | 38 | #define CACHE_LINE 64 |
Channagoud Kadabi | 0e54f14 | 2015-07-07 15:05:38 -0700 | [diff] [blame] | 39 | #elif defined(ARM_CPU_CORE_KRYO) |
| 40 | #define CACHE_LINE 128 |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 41 | #else |
Amol Jadi | 9ef9b73 | 2011-05-23 16:00:17 -0700 | [diff] [blame] | 42 | #error unknown cpu |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 43 | #endif |
| 44 | |
Channagoud Kadabi | 5fd4efa | 2013-04-23 14:30:17 -0700 | [diff] [blame] | 45 | #define IS_CACHE_LINE_ALIGNED(addr) !((uint32_t) (addr) & (CACHE_LINE - 1)) |
Channagoud Kadabi | c9f8da6 | 2013-08-05 15:27:13 -0700 | [diff] [blame] | 46 | |
| 47 | #if ARM_ISA_ARMV7 |
| 48 | #define dsb() __asm__ volatile ("dsb" : : : "memory"); |
Channagoud Kadabi | 87fbe8d | 2014-04-08 14:14:23 -0700 | [diff] [blame] | 49 | #define dmb() __asm__ volatile ("dmb" : : : "memory"); |
Channagoud Kadabi | bca5254 | 2014-01-30 14:35:39 -0800 | [diff] [blame] | 50 | #define isb() __asm__ volatile ("isb" : : : "memory"); |
Channagoud Kadabi | c9f8da6 | 2013-08-05 15:27:13 -0700 | [diff] [blame] | 51 | #elif ARM_ISA_ARMV6 |
| 52 | #define dsb() __asm__ volatile ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0): "memory"); |
Channagoud Kadabi | 87fbe8d | 2014-04-08 14:14:23 -0700 | [diff] [blame] | 53 | #define dmb() __asm__ volatile ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0): "memory"); |
Channagoud Kadabi | bca5254 | 2014-01-30 14:35:39 -0800 | [diff] [blame] | 54 | #define isb() __asm__ volatile ("mcr p15, 0, %0, c7, c5, 4" : : "r" (0): "memory"); |
Channagoud Kadabi | c9f8da6 | 2013-08-05 15:27:13 -0700 | [diff] [blame] | 55 | #endif |
| 56 | |
Deepa Dinamani | 65df150 | 2013-07-29 13:23:04 -0700 | [diff] [blame] | 57 | #define GET_CAHE_LINE_START_ADDR(addr) ROUNDDOWN(addr, CACHE_LINE) |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 58 | |
Deepa Dinamani | 65df150 | 2013-07-29 13:23:04 -0700 | [diff] [blame] | 59 | #endif |