1 // © 2021 Qualcomm Innovation Center, Inc. All rights reserved.
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 // Get a pointer to the thread's cspace.
6 // This does not take a reference to the cspace since it is not valid to change
7 // the cspace of a running thread.
8 cspace_t *
9 cspace_get_self(void);
10 
11 // Lookup an object from a cap in a cspace. The object must be of the specified
12 // type. If active_only is true, the lookup will check the object state, and
13 // fail if it is not OBJECT_STATE_ACTIVE; checking the object state is the
14 // caller's responsibility otherwise. If successful, an additional reference to
15 // the object will be obtained.
16 object_ptr_result_t
17 cspace_lookup_object(cspace_t *cspace, cap_id_t cap_id, object_type_t type,
18 		     cap_rights_t rights, bool active_only);
19 
20 // Lookup an object from a cap in a cspace. The object may be of any type, and
21 // in any state. It is the caller's responsibility to provide locking of the
22 // object header and to check the object state if required. If successful, an
23 // additional reference to the object will be obtained.
24 object_ptr_result_t
25 cspace_lookup_object_any(cspace_t *cspace, cap_id_t cap_id,
26 			 cap_rights_generic_t rights, object_type_t *type);
27 
28 // Create the master cap for an object. The cspace will adopt the reference
29 // count of the object that was set when initialized after allocation.
30 cap_id_result_t
31 cspace_create_master_cap(cspace_t *cspace, object_ptr_t object,
32 			 object_type_t type);
33 
34 cap_id_result_t
35 cspace_copy_cap(cspace_t *target_cspace, cspace_t *parent_cspace,
36 		cap_id_t parent_id, cap_rights_t rights_mask);
37 
38 error_t
39 cspace_delete_cap(cspace_t *cspace, cap_id_t cap_id);
40 
41 error_t
42 cspace_revoke_caps(cspace_t *cspace, cap_id_t master_cap_id);
43 
44 // Configure the cspace.
45 // The object's header lock must be held and object state must be
46 // OBJECT_STATE_INIT.
47 error_t
48 cspace_configure(cspace_t *cspace, count_t max_caps);
49 
50 error_t
51 cspace_attach_thread(cspace_t *cspace, thread_t *thread);
52