userspace: update k_object API to support immutable objects
The k_object API associates mutable state structures with known kernel objects to support userspace. The kernel objects themselves are not modified by the API, and in some cases (e.g. device structures) may be const-qualified. Update the API so that pointers to these const kernel objects can be passed without casting away the const qualifier. Fixes #27399 Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
aac9e2c5e3
commit
2fcf76219e
5 changed files with 42 additions and 35 deletions
|
@ -227,7 +227,7 @@ struct z_object_assignment {
|
|||
*
|
||||
* @param obj Address of the kernel object
|
||||
*/
|
||||
void z_object_init(void *obj);
|
||||
void z_object_init(const void *obj);
|
||||
#else
|
||||
/* LCOV_EXCL_START */
|
||||
#define K_THREAD_ACCESS_GRANT(thread, ...)
|
||||
|
@ -235,7 +235,7 @@ void z_object_init(void *obj);
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
static inline void z_object_init(void *obj)
|
||||
static inline void z_object_init(const void *obj)
|
||||
{
|
||||
ARG_UNUSED(obj);
|
||||
}
|
||||
|
@ -243,8 +243,8 @@ static inline void z_object_init(void *obj)
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
static inline void z_impl_k_object_access_grant(void *object,
|
||||
struct k_thread *thread)
|
||||
static inline void z_impl_k_object_access_grant(const void *object,
|
||||
struct k_thread *thread)
|
||||
{
|
||||
ARG_UNUSED(object);
|
||||
ARG_UNUSED(thread);
|
||||
|
@ -253,7 +253,7 @@ static inline void z_impl_k_object_access_grant(void *object,
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
static inline void k_object_access_revoke(void *object,
|
||||
static inline void k_object_access_revoke(const void *object,
|
||||
struct k_thread *thread)
|
||||
{
|
||||
ARG_UNUSED(object);
|
||||
|
@ -263,12 +263,12 @@ static inline void k_object_access_revoke(void *object,
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
static inline void z_impl_k_object_release(void *object)
|
||||
static inline void z_impl_k_object_release(const void *object)
|
||||
{
|
||||
ARG_UNUSED(object);
|
||||
}
|
||||
|
||||
static inline void k_object_access_all_grant(void *object)
|
||||
static inline void k_object_access_all_grant(const void *object)
|
||||
{
|
||||
ARG_UNUSED(object);
|
||||
}
|
||||
|
@ -285,7 +285,8 @@ static inline void k_object_access_all_grant(void *object)
|
|||
* @param object Address of kernel object
|
||||
* @param thread Thread to grant access to the object
|
||||
*/
|
||||
__syscall void k_object_access_grant(void *object, struct k_thread *thread);
|
||||
__syscall void k_object_access_grant(const void *object,
|
||||
struct k_thread *thread);
|
||||
|
||||
/**
|
||||
* Revoke a thread's access to a kernel object
|
||||
|
@ -297,7 +298,7 @@ __syscall void k_object_access_grant(void *object, struct k_thread *thread);
|
|||
* @param object Address of kernel object
|
||||
* @param thread Thread to remove access to the object
|
||||
*/
|
||||
void k_object_access_revoke(void *object, struct k_thread *thread);
|
||||
void k_object_access_revoke(const void *object, struct k_thread *thread);
|
||||
|
||||
/**
|
||||
* @brief Release an object
|
||||
|
@ -308,7 +309,7 @@ void k_object_access_revoke(void *object, struct k_thread *thread);
|
|||
* @param object The object to be released
|
||||
*
|
||||
*/
|
||||
__syscall void k_object_release(void *object);
|
||||
__syscall void k_object_release(const void *object);
|
||||
|
||||
/**
|
||||
* Grant all present and future threads access to an object
|
||||
|
@ -327,7 +328,7 @@ __syscall void k_object_release(void *object);
|
|||
*
|
||||
* @param object Address of kernel object
|
||||
*/
|
||||
void k_object_access_all_grant(void *object);
|
||||
void k_object_access_all_grant(const void *object);
|
||||
|
||||
/**
|
||||
* Allocate a kernel object of a designated type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue