XenevaOS
Loading...
Searching...
No Matches
synchronize.h
Go to the documentation of this file.
1//
2// synchronize.h
3//
4// USPi - An USB driver for Raspberry Pi written in C
5// Copyright (C) 2014-2018 R. Stange <rsta2@o2online.de>
6//
7// This program is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19//
20#ifndef _uspi_synchronize_h
21#define _uspi_synchronize_h
22
23#include "uspi/macros.h"
24#include "uspi/types.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31//
32// Interrupt synchronization
33//
34void uspi_EnterCritical (void); // disable interrupts (nested calls possible)
35void uspi_LeaveCritical (void); // enable interrupts (nested calls possible)
36
37#ifndef AARCH64
38
39#if RASPPI == 1
40
41//
42// Cache control
43//
44#define InvalidateInstructionCache() \
45 __asm volatile ("mcr p15, 0, %0, c7, c5, 0" : : "r" (0) : "memory")
46#define FlushPrefetchBuffer() __asm volatile ("mcr p15, 0, %0, c7, c5, 4" : : "r" (0) : "memory")
47#define FlushBranchTargetCache() \
48 __asm volatile ("mcr p15, 0, %0, c7, c5, 6" : : "r" (0) : "memory")
49#define InvalidateDataCache() __asm volatile ("mcr p15, 0, %0, c7, c6, 0" : : "r" (0) : "memory")
50#define CleanDataCache() __asm volatile ("mcr p15, 0, %0, c7, c10, 0" : : "r" (0) : "memory")
51
53
54//
55// Barriers
56//
57#define DataSyncBarrier() __asm volatile ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory")
58#define DataMemBarrier() __asm volatile ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory")
59
60#define InstructionSyncBarrier() FlushPrefetchBuffer()
61#define InstructionMemBarrier() FlushPrefetchBuffer()
62
63#else // #if RASPPI == 1
64
65//
66// Cache control
67//
68#define InvalidateInstructionCache() //\
69 //__asm volatile ("mcr p15, 0, %0, c7, c5, 0" : : "r" (0) : "memory")
70#define FlushPrefetchBuffer() isb_flush() //__asm volatile ("isb" ::: "memory")
71#define FlushBranchTargetCache() //\
72 //__asm volatile ("mcr p15, 0, %0, c7, c5, 6" : : "r" (0) : "memory")
73
74void uspi_CleanAndInvalidateDataCacheRange(u32 nAddress, u32 nLength); // MAXOPT;
75
76//
77// Barriers
78//
79#define DataSyncBarrier() dsb_sy_barrier()// __asm volatile ("dsb" ::: "memory")
80#define DataMemBarrier() dmb_sy() //__asm volatile ("dmb" ::: "memory")
81
82#define InstructionSyncBarrier() isb_flush(); // __asm volatile ("isb" ::: "memory")
83#define InstructionMemBarrier() isb_flush();// __asm volatile ("isb" ::: "memory")
84
85#endif // #if RASPPI == 1
86
87#else // #ifdef AARCH64
88
89//
90// Cache control
91//
93
94//
95// Barriers
96//
97#define DataSyncBarrier() __asm volatile ("dsb sy" ::: "memory")
98#define DataMemBarrier() __asm volatile ("dmb sy" ::: "memory")
99
100#endif // #ifdef AARCH64
101
102#define CompilerBarrier() __asm volatile ("" ::: "memory")
103
104#ifdef __cplusplus
105}
106#endif
107
108#endif
uint64_t u64
Definition kernel.h:23
uint32_t u32
Definition kernel.h:22
#define MAXOPT
Definition macros.h:26
void uspi_EnterCritical(void)
Definition synchronize.c:36
void uspi_LeaveCritical(void)
Definition synchronize.c:56
void uspi_CleanAndInvalidateDataCacheRange(u32 nAddress, u32 nLength)
Definition synchronize.c:123