Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bit_ffs_from() + fix typo in notif inline comment #6009

Merged
merged 2 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/arch/arm/include/sm/optee_smc.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@
* a0 OPTEE_SMC_RETURN_OK
* a1 value
* a2 Bit[0]: OPTEE_SMC_ASYNC_NOTIF_VALUE_VALID if the value in a1 is
* valid, else 0 if no values where pending
* valid, else 0 if no values were pending
* a2 Bit[1]: OPTEE_SMC_ASYNC_NOTIF_VALUE_PENDING if another value is
* pending, else 0.
* Bit[31:2]: MBZ
Expand Down
32 changes: 22 additions & 10 deletions lib/libutils/ext/include/bitstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,34 @@ typedef unsigned char bitstr_t;
} while (0)

/* find first bit set in name */
#define bit_ffs(name, nbits, value) do { \
register bitstr_t *_name = (name); \
register int _byte, _nbits = (nbits); \
register int _stopbyte = _bit_byte(_nbits - 1), _value = -1; \
if (_nbits > 0) \
for (_byte = 0; _byte <= _stopbyte; ++_byte) \
if (_name[_byte]) { \
bitstr_t _lb; \
#define bit_ffs_from(name, nbits, startbit, value) do { \
bitstr_t *_name = (name); \
int _byte = 0; \
int _nbits = (nbits); \
int _startbyte = _bit_byte(startbit); \
int _stopbyte = _bit_byte(_nbits - 1), _value = -1; \
bitstr_t _test_bit_mask = 0xff << ((startbit) % 8); \
\
if (_nbits > 0) { \
for (_byte = _startbyte; _byte <= _stopbyte; ++_byte) { \
if (_name[_byte] & _test_bit_mask) { \
bitstr_t _lb = 0; \
\
_value = _byte << 3; \
for (_lb = _name[_byte]; !(_lb&0x1); \
++_value, _lb >>= 1); \
for (_lb = _name[_byte] & _test_bit_mask; \
!(_lb&0x1); ++_value, _lb >>= 1) \
; \
break; \
} \
_test_bit_mask = 0xff; \
} \
} \
if (_value >= nbits) \
_value = -1; \
*(value) = _value; \
} while (0)

#define bit_ffs(name, nbits, value) \
bit_ffs_from((name), (nbits), 0, (value))

#endif /* !_SYS_BITSTRING_H_ */
2 changes: 1 addition & 1 deletion mk/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ ifeq (y-y,$(CFG_WITH_PAGER)-$(CFG_MEMTAG))
$(error CFG_WITH_PAGER and CFG_MEMTAG are not compatible)
endif

# CFG_CORE_ASYNC_NOTIF is defined by the platform to enable enables support
# CFG_CORE_ASYNC_NOTIF is defined by the platform to enable support
# for sending asynchronous notifications to normal world. Note that an
# interrupt ID must be configurged by the platform too. Currently is only
# CFG_CORE_ASYNC_NOTIF_GIC_INTID defined.
Expand Down