summaryrefslogtreecommitdiff
path: root/usr.sbin/acpidump/aml/aml_obj.h
blob: c38404184eda8bda19b537dd60748aa32bbda52a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*	$OpenBSD: aml_obj.h,v 1.1 2005/06/02 20:09:39 tholo Exp $	*/
/*-
 * Copyright (c) 1999 Takanori Watanabe
 * Copyright (c) 1999, 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	$Id: aml_obj.h,v 1.1 2005/06/02 20:09:39 tholo Exp $
 *	$FreeBSD: src/usr.sbin/acpi/amldb/aml/aml_obj.h,v 1.1 2000/08/24 09:33:08 takawata Exp $
 */

#ifndef _AML_OBJ_H_
#define _AML_OBJ_H_

#include <sys/queue.h>

struct aml_environ;
enum aml_objtype {
	aml_t_namestr = -3,
	aml_t_regfield,
	aml_t_objref,
	aml_t_null = 0,
	aml_t_num,
	aml_t_string,
	aml_t_buffer,
	aml_t_package,
	aml_t_device,
	aml_t_field,
	aml_t_event,
	aml_t_method,
	aml_t_mutex,
	aml_t_opregion,
	aml_t_powerres,
	aml_t_processor,
	aml_t_therm,
	aml_t_bufferfield,
	aml_t_ddbhandle,
	aml_t_debug
};

struct	aml_namestr {
	enum	aml_objtype type;	/* =aml_t_namestr */
	u_int8_t	*dp;
};

struct	aml_opregion {
	enum	aml_objtype type;
	int	space;
	int	offset;
	int	length;
};

struct	aml_num {
	enum	aml_objtype type;	/* =aml_t_num */
	int	number;
	int	constant;
};

struct	aml_package {
	enum	aml_objtype type;
	int	elements;
	union	aml_object **objects;
};

struct	aml_string {
	enum	aml_objtype type;	/* =aml_t_string */
	int	needfree;
	u_int8_t	*string;
};

struct	aml_buffer {
	enum	aml_objtype type;	/* =aml_t_buffer */
	int	size;
	u_int8_t	*data;		/* This should be free when 
					 * this object is free.
					 */
};

enum	fieldtype {
	f_t_field,
	f_t_index,
	f_t_bank
};

struct	nfieldd {
	enum	fieldtype ftype;	/* f_t_field */
	u_int8_t	*regname;	/* Namestring */
};

struct	ifieldd {
	enum	fieldtype ftype;	/* f_t_index */
	u_int8_t	*indexname;
	u_int8_t	*dataname;
};

struct	bfieldd {
	enum	fieldtype ftype;	/* f_t_bank */
	u_int8_t	*regname;
	u_int8_t	*bankname;
	u_int32_t	bankvalue;
};

struct	aml_field {
	enum	aml_objtype type;
	u_int32_t	flags;
	int	bitoffset;		/* Not Byte offset but bitoffset */
	int	bitlen;
	union {
		enum	fieldtype ftype;
		struct	nfieldd fld;
		struct	ifieldd ifld;
		struct	bfieldd bfld;
	}     f;
};

struct	aml_bufferfield {
	enum	aml_objtype type;	/* aml_t_bufferfield */
	int	bitoffset;
	int	bitlen;
	u_int8_t	*origin;	/* This should not be free
					 * when this object is free
					 * (Within Buffer object)
					 */
};

struct	aml_method {
	enum	aml_objtype type;
	int	argnum;		/* Not argnum but argnum|frag */
	u_int8_t	*from;
	u_int8_t	*to;
};

struct aml_powerres {
	enum	aml_objtype type;
	int	level;
	int	order;
};

struct	aml_processor {
	enum	aml_objtype type;
	int	id;
	int	addr;
	int	len;
};

struct	aml_mutex_queue {
#if 0
	STAILQ_ENTRY(aml_mutex_queue) entry;
#endif
};

struct	aml_mutex {
	enum	aml_objtype type;
	int	level;
	volatile	void *cookie;	/* In kernel, struct proc? */
#if 0
	STAILQ_HEAD(, aml_mutex_queue) queue;
#endif
};

struct	aml_objref {
	enum	aml_objtype type;
	struct	aml_name *nameref;
	union	aml_object *ref;
	int	offset;		/* of aml_buffer.data or aml_package.objects. */
	/* if negative value, not ready to dereference for element access. */
	unsigned	deref;	/* indicates whether dereffenced or not */
	unsigned	alias;	/* true if this is an alias object reference */
};

struct	aml_regfield {
	enum	aml_objtype type;
	int	space;
	u_int32_t	flags;
	int	offset;
	int	bitoffset;
	int	bitlen;
};

struct	aml_event {
	enum	aml_objtype type;	/* aml_t_event */
	int	inuse;
};

union	aml_object {
	enum	aml_objtype type;
	struct	aml_num num;
	struct	aml_processor proc;
	struct	aml_powerres pres;
	struct	aml_opregion opregion;
	struct	aml_method meth;
	struct	aml_field field;
	struct	aml_mutex mutex;
	struct	aml_namestr nstr;
	struct	aml_buffer buffer;
	struct	aml_bufferfield bfld;
	struct	aml_package package;
	struct	aml_string str;
	struct	aml_objref objref;
	struct	aml_event event;
	struct	aml_regfield regfield;
};

union aml_object	*aml_copy_object(struct aml_environ *,
					  union aml_object *);
union aml_object	*aml_alloc_object(enum aml_objtype,
					   union aml_object *);
void			 aml_free_objectcontent(union aml_object *);
void			 aml_free_object(union aml_object **);
void			 aml_realloc_object(union aml_object *, int);

#endif /* !_AML_OBJ_H_ */