userspace: add _k_object_recycle()
This is used to reset the permissions on an object while also initializing it. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
4a39b9ea64
commit
83fda7c68f
2 changed files with 30 additions and 0 deletions
|
@ -125,6 +125,25 @@ extern void _thread_perms_all_clear(struct k_thread *thread);
|
|||
*/
|
||||
void _k_object_uninit(void *obj);
|
||||
|
||||
/**
|
||||
* Initialize and reset permissions to only access by the caller
|
||||
*
|
||||
* Intended for scenarios where objects are fetched from slab pools
|
||||
* and may have had different permissions set during prior usage.
|
||||
*
|
||||
* This is only intended for pools of objects, where such objects are
|
||||
* acquired and released to the pool. If an object has already been used,
|
||||
* we do not want stale permission information hanging around, the object
|
||||
* should only have permissions on the caller. Objects which are not
|
||||
* managed by a pool-like mechanism should not use this API.
|
||||
*
|
||||
* The object will be marked as initialized and the calling thread
|
||||
* granted access to it.
|
||||
*
|
||||
* @param object Address of the kernel object
|
||||
*/
|
||||
void _k_object_recycle(void *obj);
|
||||
|
||||
/**
|
||||
* @brief Obtain the size of a C string passed from user mode
|
||||
*
|
||||
|
|
|
@ -546,6 +546,17 @@ void _k_object_init(void *object)
|
|||
ko->flags |= K_OBJ_FLAG_INITIALIZED;
|
||||
}
|
||||
|
||||
void _k_object_recycle(void *object)
|
||||
{
|
||||
struct _k_object *ko = _k_object_find(object);
|
||||
|
||||
if (ko) {
|
||||
memset(ko->perms, 0, sizeof(ko->perms));
|
||||
_thread_perms_set(ko, k_current_get());
|
||||
ko->flags |= K_OBJ_FLAG_INITIALIZED;
|
||||
}
|
||||
}
|
||||
|
||||
void _k_object_uninit(void *object)
|
||||
{
|
||||
struct _k_object *ko;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue