-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "refactor(lib/granule): redefine granule structure" into integr…
…ation
- Loading branch information
Showing
20 changed files
with
975 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* SPDX-FileCopyrightText: Copyright TF-RMM Contributors. | ||
*/ | ||
|
||
#ifndef GRANULE_LOCK_H | ||
#define GRANULE_LOCK_H | ||
|
||
#include <granule_types.h> | ||
|
||
static inline void granule_bitlock_acquire(struct granule *g) | ||
{ | ||
/* To avoid misra-c2012-2.7 warnings */ | ||
(void)g; | ||
uint32_t tmp; | ||
uint32_t mask = GRN_LOCK_BIT; | ||
|
||
asm volatile( | ||
"1: ldsetah %w[mask], %w[tmp], %[lock]\n" | ||
" tbz %w[tmp], #%c[bit], 2f\n" | ||
" ldxrh %w[tmp], %[lock]\n" | ||
" tbz %w[tmp], #%c[bit], 1b\n" | ||
" wfe\n" | ||
" b 1b\n" | ||
"2:\n" | ||
: [lock] "+Q" (g->descriptor), | ||
[tmp] "=&r" (tmp) | ||
: [mask] "r" (mask), | ||
[bit] "i" (GRN_LOCK_SHIFT) | ||
: "memory" | ||
); | ||
} | ||
|
||
static inline void granule_bitlock_release(struct granule *g) | ||
{ | ||
/* To avoid misra-c2012-2.7 warnings */ | ||
(void)g; | ||
uint32_t mask = GRN_LOCK_BIT; | ||
|
||
asm volatile( | ||
" stclrlh %w[mask], %[lock]\n" | ||
: [lock] "+Q" (g->descriptor) | ||
: [mask] "r" (mask) | ||
: "memory" | ||
); | ||
} | ||
|
||
#endif /* GRANULE_LOCK_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* SPDX-FileCopyrightText: Copyright TF-RMM Contributors. | ||
*/ | ||
|
||
#ifndef GRANULE_LOCK_H | ||
#define GRANULE_LOCK_H | ||
|
||
#include <assert.h> | ||
#include <granule_types.h> | ||
|
||
static inline void granule_bitlock_acquire(struct granule *g) | ||
{ | ||
/* | ||
* The fake_host architecture is single threaded and we do not expect | ||
* the lock to be already acquired in properly implemented locking | ||
* sequence. | ||
*/ | ||
assert((g->descriptor & GRN_LOCK_BIT) == 0); | ||
g->descriptor |= GRN_LOCK_BIT; | ||
} | ||
|
||
static inline void granule_bitlock_release(struct granule *g) | ||
{ | ||
g->descriptor &= ~GRN_LOCK_BIT; | ||
} | ||
|
||
#endif /* GRANULE_LOCK_H */ |
Oops, something went wrong.