xref: /aosp_15_r20/system/libufdt/ufdt_prop_dict.h (revision 13e8728f0cffde9369df671f7b293a048a99c7ed)
1*13e8728fSAndroid Build Coastguard Worker /*
2*13e8728fSAndroid Build Coastguard Worker  * Copyright (C) 2016 The Android Open Source Project
3*13e8728fSAndroid Build Coastguard Worker  *
4*13e8728fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*13e8728fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*13e8728fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*13e8728fSAndroid Build Coastguard Worker  *
8*13e8728fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*13e8728fSAndroid Build Coastguard Worker  *
10*13e8728fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*13e8728fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*13e8728fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*13e8728fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*13e8728fSAndroid Build Coastguard Worker  * limitations under the License.
15*13e8728fSAndroid Build Coastguard Worker  */
16*13e8728fSAndroid Build Coastguard Worker 
17*13e8728fSAndroid Build Coastguard Worker #ifndef UFDT_PROP_DICT_H
18*13e8728fSAndroid Build Coastguard Worker #define UFDT_PROP_DICT_H
19*13e8728fSAndroid Build Coastguard Worker 
20*13e8728fSAndroid Build Coastguard Worker struct fdt_property;
21*13e8728fSAndroid Build Coastguard Worker 
22*13e8728fSAndroid Build Coastguard Worker struct ufdt_prop_dict {
23*13e8728fSAndroid Build Coastguard Worker   int mem_size;
24*13e8728fSAndroid Build Coastguard Worker   int num_used;
25*13e8728fSAndroid Build Coastguard Worker   void *fdtp;
26*13e8728fSAndroid Build Coastguard Worker   const struct fdt_property **props;
27*13e8728fSAndroid Build Coastguard Worker };
28*13e8728fSAndroid Build Coastguard Worker 
29*13e8728fSAndroid Build Coastguard Worker /*
30*13e8728fSAndroid Build Coastguard Worker  * Allocates some new spaces and creates a new ufdt_prop_dict.
31*13e8728fSAndroid Build Coastguard Worker  *
32*13e8728fSAndroid Build Coastguard Worker  * @return: a pointer to the newly created ufdt_prop_dict or
33*13e8728fSAndroid Build Coastguard Worker  *          NULL if dto_malloc failed
34*13e8728fSAndroid Build Coastguard Worker  */
35*13e8728fSAndroid Build Coastguard Worker int ufdt_prop_dict_construct(struct ufdt_prop_dict *dict, void *fdtp);
36*13e8728fSAndroid Build Coastguard Worker 
37*13e8728fSAndroid Build Coastguard Worker /*
38*13e8728fSAndroid Build Coastguard Worker  * Frees all space dto_malloced, not including ufdt_nodes in the table.
39*13e8728fSAndroid Build Coastguard Worker  */
40*13e8728fSAndroid Build Coastguard Worker void ufdt_prop_dict_destruct(struct ufdt_prop_dict *dict);
41*13e8728fSAndroid Build Coastguard Worker 
42*13e8728fSAndroid Build Coastguard Worker /*
43*13e8728fSAndroid Build Coastguard Worker  * Adds a fdt_property (as pointer) to the ufdt_prop_dict.
44*13e8728fSAndroid Build Coastguard Worker  * @return: 0 if success
45*13e8728fSAndroid Build Coastguard Worker  *          < 0 otherwise
46*13e8728fSAndroid Build Coastguard Worker  *
47*13e8728fSAndroid Build Coastguard Worker  * @Time: O(length of node->name)
48*13e8728fSAndroid Build Coastguard Worker  */
49*13e8728fSAndroid Build Coastguard Worker int ufdt_prop_dict_add(struct ufdt_prop_dict *dict,
50*13e8728fSAndroid Build Coastguard Worker                        const struct fdt_property *prop);
51*13e8728fSAndroid Build Coastguard Worker 
52*13e8728fSAndroid Build Coastguard Worker /*
53*13e8728fSAndroid Build Coastguard Worker  * Returns the pointer to the fdt_property with name
54*13e8728fSAndroid Build Coastguard Worker  *
55*13e8728fSAndroid Build Coastguard Worker  * @return: a pointer to the node or
56*13e8728fSAndroid Build Coastguard Worker  *          NULL if no such node in ufdt_prop_dict with same name.
57*13e8728fSAndroid Build Coastguard Worker  *
58*13e8728fSAndroid Build Coastguard Worker  * @Time: O(len = |name|)
59*13e8728fSAndroid Build Coastguard Worker  */
60*13e8728fSAndroid Build Coastguard Worker const struct fdt_property *ufdt_prop_dict_find(const struct ufdt_prop_dict *dict,
61*13e8728fSAndroid Build Coastguard Worker                                                const char *name);
62*13e8728fSAndroid Build Coastguard Worker 
63*13e8728fSAndroid Build Coastguard Worker #endif
64