xref: /aosp_15_r20/external/libdrm/radeon/bof.h (revision 7688df22e49036ff52a766b7101da3a49edadb8c)
1*7688df22SAndroid Build Coastguard Worker /*
2*7688df22SAndroid Build Coastguard Worker  * Copyright 2010 Jerome Glisse <[email protected]>
3*7688df22SAndroid Build Coastguard Worker  *
4*7688df22SAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining a
5*7688df22SAndroid Build Coastguard Worker  * copy of this software and associated documentation files (the "Software"),
6*7688df22SAndroid Build Coastguard Worker  * to deal in the Software without restriction, including without limitation
7*7688df22SAndroid Build Coastguard Worker  * on the rights to use, copy, modify, merge, publish, distribute, sub
8*7688df22SAndroid Build Coastguard Worker  * license, and/or sell copies of the Software, and to permit persons to whom
9*7688df22SAndroid Build Coastguard Worker  * the Software is furnished to do so, subject to the following conditions:
10*7688df22SAndroid Build Coastguard Worker  *
11*7688df22SAndroid Build Coastguard Worker  * The above copyright notice and this permission notice (including the next
12*7688df22SAndroid Build Coastguard Worker  * paragraph) shall be included in all copies or substantial portions of the
13*7688df22SAndroid Build Coastguard Worker  * Software.
14*7688df22SAndroid Build Coastguard Worker  *
15*7688df22SAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*7688df22SAndroid Build Coastguard Worker  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*7688df22SAndroid Build Coastguard Worker  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18*7688df22SAndroid Build Coastguard Worker  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19*7688df22SAndroid Build Coastguard Worker  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20*7688df22SAndroid Build Coastguard Worker  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21*7688df22SAndroid Build Coastguard Worker  * USE OR OTHER DEALINGS IN THE SOFTWARE.
22*7688df22SAndroid Build Coastguard Worker  *
23*7688df22SAndroid Build Coastguard Worker  * Authors:
24*7688df22SAndroid Build Coastguard Worker  *      Jerome Glisse
25*7688df22SAndroid Build Coastguard Worker  */
26*7688df22SAndroid Build Coastguard Worker #ifndef BOF_H
27*7688df22SAndroid Build Coastguard Worker #define BOF_H
28*7688df22SAndroid Build Coastguard Worker 
29*7688df22SAndroid Build Coastguard Worker #include <stdio.h>
30*7688df22SAndroid Build Coastguard Worker #include <stdint.h>
31*7688df22SAndroid Build Coastguard Worker 
32*7688df22SAndroid Build Coastguard Worker #define BOF_TYPE_STRING		0
33*7688df22SAndroid Build Coastguard Worker #define BOF_TYPE_NULL		1
34*7688df22SAndroid Build Coastguard Worker #define BOF_TYPE_BLOB		2
35*7688df22SAndroid Build Coastguard Worker #define BOF_TYPE_OBJECT		3
36*7688df22SAndroid Build Coastguard Worker #define BOF_TYPE_ARRAY		4
37*7688df22SAndroid Build Coastguard Worker #define BOF_TYPE_INT32		5
38*7688df22SAndroid Build Coastguard Worker 
39*7688df22SAndroid Build Coastguard Worker struct bof;
40*7688df22SAndroid Build Coastguard Worker 
41*7688df22SAndroid Build Coastguard Worker typedef struct bof {
42*7688df22SAndroid Build Coastguard Worker 	struct bof	**array;
43*7688df22SAndroid Build Coastguard Worker 	unsigned	centry;
44*7688df22SAndroid Build Coastguard Worker 	unsigned	nentry;
45*7688df22SAndroid Build Coastguard Worker 	unsigned	refcount;
46*7688df22SAndroid Build Coastguard Worker 	FILE		*file;
47*7688df22SAndroid Build Coastguard Worker 	uint32_t	type;
48*7688df22SAndroid Build Coastguard Worker 	uint32_t	size;
49*7688df22SAndroid Build Coastguard Worker 	uint32_t	array_size;
50*7688df22SAndroid Build Coastguard Worker 	void		*value;
51*7688df22SAndroid Build Coastguard Worker 	long		offset;
52*7688df22SAndroid Build Coastguard Worker } bof_t;
53*7688df22SAndroid Build Coastguard Worker 
54*7688df22SAndroid Build Coastguard Worker extern int bof_file_flush(bof_t *root);
55*7688df22SAndroid Build Coastguard Worker extern bof_t *bof_file_new(const char *filename);
56*7688df22SAndroid Build Coastguard Worker extern int bof_object_dump(bof_t *object, const char *filename);
57*7688df22SAndroid Build Coastguard Worker 
58*7688df22SAndroid Build Coastguard Worker /* object */
59*7688df22SAndroid Build Coastguard Worker extern bof_t *bof_object(void);
60*7688df22SAndroid Build Coastguard Worker extern bof_t *bof_object_get(bof_t *object, const char *keyname);
61*7688df22SAndroid Build Coastguard Worker extern int bof_object_set(bof_t *object, const char *keyname, bof_t *value);
62*7688df22SAndroid Build Coastguard Worker /* array */
63*7688df22SAndroid Build Coastguard Worker extern bof_t *bof_array(void);
64*7688df22SAndroid Build Coastguard Worker extern int bof_array_append(bof_t *array, bof_t *value);
65*7688df22SAndroid Build Coastguard Worker extern bof_t *bof_array_get(bof_t *bof, unsigned i);
66*7688df22SAndroid Build Coastguard Worker extern unsigned bof_array_size(bof_t *bof);
67*7688df22SAndroid Build Coastguard Worker /* blob */
68*7688df22SAndroid Build Coastguard Worker extern bof_t *bof_blob(unsigned size, void *value);
69*7688df22SAndroid Build Coastguard Worker extern unsigned bof_blob_size(bof_t *bof);
70*7688df22SAndroid Build Coastguard Worker extern void *bof_blob_value(bof_t *bof);
71*7688df22SAndroid Build Coastguard Worker /* string */
72*7688df22SAndroid Build Coastguard Worker extern bof_t *bof_string(const char *value);
73*7688df22SAndroid Build Coastguard Worker /* int32 */
74*7688df22SAndroid Build Coastguard Worker extern bof_t *bof_int32(int32_t value);
75*7688df22SAndroid Build Coastguard Worker extern int32_t bof_int32_value(bof_t *bof);
76*7688df22SAndroid Build Coastguard Worker /* common functions */
77*7688df22SAndroid Build Coastguard Worker extern void bof_decref(bof_t *bof);
78*7688df22SAndroid Build Coastguard Worker extern void bof_incref(bof_t *bof);
79*7688df22SAndroid Build Coastguard Worker extern bof_t *bof_load_file(const char *filename);
80*7688df22SAndroid Build Coastguard Worker extern int bof_dump_file(bof_t *bof, const char *filename);
81*7688df22SAndroid Build Coastguard Worker extern void bof_print(bof_t *bof);
82*7688df22SAndroid Build Coastguard Worker 
bof_is_object(bof_t * bof)83*7688df22SAndroid Build Coastguard Worker static inline int bof_is_object(bof_t *bof){return (bof->type == BOF_TYPE_OBJECT);}
bof_is_blob(bof_t * bof)84*7688df22SAndroid Build Coastguard Worker static inline int bof_is_blob(bof_t *bof){return (bof->type == BOF_TYPE_BLOB);}
bof_is_null(bof_t * bof)85*7688df22SAndroid Build Coastguard Worker static inline int bof_is_null(bof_t *bof){return (bof->type == BOF_TYPE_NULL);}
bof_is_int32(bof_t * bof)86*7688df22SAndroid Build Coastguard Worker static inline int bof_is_int32(bof_t *bof){return (bof->type == BOF_TYPE_INT32);}
bof_is_array(bof_t * bof)87*7688df22SAndroid Build Coastguard Worker static inline int bof_is_array(bof_t *bof){return (bof->type == BOF_TYPE_ARRAY);}
bof_is_string(bof_t * bof)88*7688df22SAndroid Build Coastguard Worker static inline int bof_is_string(bof_t *bof){return (bof->type == BOF_TYPE_STRING);}
89*7688df22SAndroid Build Coastguard Worker 
90*7688df22SAndroid Build Coastguard Worker #endif
91