1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef GRAPHIC_LITE_HAL_CPU_H 17 #define GRAPHIC_LITE_HAL_CPU_H 18 19 #include <stdint.h> 20 21 #ifdef __cplusplus 22 #if __cplusplus 23 extern "C" { 24 #endif 25 #endif 26 27 #ifdef _WIN32 28 #define BARRIER() MemoryBarrier() 29 #define MB() BARRIER() 30 #define WMB() BARRIER() 31 #define RMB() BARRIER() 32 #elif defined __linux__ || defined __LITEOS__ || defined __APPLE__ 33 #ifdef __ICCARM__ 34 #define DSB() __asm volatile("dsb" ::: "memory") 35 #define DMB() __asm volatile("dmb" ::: "memory") 36 #define ISB() __asm volatile("isb" ::: "memory") 37 #define BARRIER() __asm volatile("" ::: "memory") 38 #else 39 #define DSB() __asm__ volatile("dsb" ::: "memory") 40 #define DMB() __asm__ volatile("dmb" ::: "memory") 41 #define ISB() __asm__ volatile("isb" ::: "memory") 42 #define BARRIER() __asm__ volatile("" ::: "memory") 43 #endif 44 45 #define MB() DMB() 46 #define WMB() DMB() 47 #define RMB() DMB() 48 #else 49 #define MB() 50 #define WMB() 51 #define RMB() 52 #endif 53 54 uint32_t HalGetCpuCoreNum(); 55 56 #ifdef __cplusplus 57 #if __cplusplus 58 } 59 #endif /* __cplusplus */ 60 #endif /* __cplusplus */ 61 #endif // GRAPHIC_LITE_HAL_CPU_H 62