1/* $NetBSD$ */ 2 3/*- 4 * Copyright (c) 1999 Takanori Watanabe 5 * Copyright (c) 1999, 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * Id: aml_obj.h,v 1.15 2000/08/09 14:47:43 iwasaki Exp 30 * $FreeBSD: src/usr.sbin/acpi/amldb/aml/aml_obj.h,v 1.1 2000/08/24 09:33:08 takawata Exp $ 31 */ 32 33#ifndef _AML_OBJ_H_ 34#define _AML_OBJ_H_ 35 36#include <sys/queue.h> 37 38struct aml_environ; 39enum aml_objtype { 40 aml_t_namestr = -3, 41 aml_t_regfield, 42 aml_t_objref, 43 aml_t_null = 0, 44 aml_t_num, 45 aml_t_string, 46 aml_t_buffer, 47 aml_t_package, 48 aml_t_device, 49 aml_t_field, 50 aml_t_event, 51 aml_t_method, 52 aml_t_mutex, 53 aml_t_opregion, 54 aml_t_powerres, 55 aml_t_processor, 56 aml_t_therm, 57 aml_t_bufferfield, 58 aml_t_ddbhandle, 59 aml_t_debug 60}; 61 62struct aml_namestr { 63 enum aml_objtype type; /* =aml_t_namestr */ 64 u_int8_t *dp; 65}; 66 67struct aml_opregion { 68 enum aml_objtype type; 69 int space; 70 int offset; 71 int length; 72}; 73 74struct aml_num { 75 enum aml_objtype type; /* =aml_t_num */ 76 int number; 77 int constant; 78}; 79 80struct aml_package { 81 enum aml_objtype type; 82 int elements; 83 union aml_object **objects; 84}; 85 86struct aml_string { 87 enum aml_objtype type; /* =aml_t_string */ 88 int needfree; 89 u_int8_t *string; 90}; 91 92struct aml_buffer { 93 enum aml_objtype type; /* =aml_t_buffer */ 94 int size; 95 u_int8_t *data; /* This should be free when 96 * this object is free. 97 */ 98}; 99 100enum fieldtype { 101 f_t_field, 102 f_t_index, 103 f_t_bank 104}; 105 106struct nfieldd { 107 enum fieldtype ftype; /* f_t_field */ 108 u_int8_t *regname; /* Namestring */ 109}; 110 111struct ifieldd { 112 enum fieldtype ftype; /* f_t_index */ 113 u_int8_t *indexname; 114 u_int8_t *dataname; 115}; 116 117struct bfieldd { 118 enum fieldtype ftype; /* f_t_bank */ 119 u_int8_t *regname; 120 u_int8_t *bankname; 121 u_int32_t bankvalue; 122}; 123 124struct aml_field { 125 enum aml_objtype type; 126 u_int32_t flags; 127 int bitoffset; /* Not Byte offset but bitoffset */ 128 int bitlen; 129 union { 130 enum fieldtype ftype; 131 struct nfieldd fld; 132 struct ifieldd ifld; 133 struct bfieldd bfld; 134 } f; 135}; 136 137struct aml_bufferfield { 138 enum aml_objtype type; /* aml_t_bufferfield */ 139 int bitoffset; 140 int bitlen; 141 u_int8_t *origin; /* This should not be free 142 * when this object is free 143 * (Within Buffer object) 144 */ 145}; 146 147struct aml_method { 148 enum aml_objtype type; 149 int argnum; /* Not argnum but argnum|frag */ 150 u_int8_t *from; 151 u_int8_t *to; 152}; 153 154struct aml_powerres { 155 enum aml_objtype type; 156 int level; 157 int order; 158}; 159 160struct aml_processor { 161 enum aml_objtype type; 162 int id; 163 int addr; 164 int len; 165}; 166 167struct aml_mutex_queue { 168 STAILQ_ENTRY(aml_mutex_queue) entry; 169}; 170 171struct aml_mutex { 172 enum aml_objtype type; 173 int level; 174 volatile void *cookie; /* In kernel, struct proc? */ 175 STAILQ_HEAD(, aml_mutex_queue) queue; 176}; 177 178struct aml_objref { 179 enum aml_objtype type; 180 struct aml_name *nameref; 181 union aml_object *ref; 182 int offset; /* of aml_buffer.data or aml_package.objects. */ 183 /* if negative value, not ready to dereference for element access. */ 184 unsigned deref; /* indicates whether dereffenced or not */ 185 unsigned alias; /* true if this is an alias object reference */ 186}; 187 188struct aml_regfield { 189 enum aml_objtype type; 190 int space; 191 u_int32_t flags; 192 int offset; 193 int bitoffset; 194 int bitlen; 195}; 196 197struct aml_event { 198 enum aml_objtype type; /* aml_t_event */ 199 int inuse; 200}; 201 202union aml_object { 203 enum aml_objtype type; 204 struct aml_num num; 205 struct aml_processor proc; 206 struct aml_powerres pres; 207 struct aml_opregion opregion; 208 struct aml_method meth; 209 struct aml_field field; 210 struct aml_mutex mutex; 211 struct aml_namestr nstr; 212 struct aml_buffer buffer; 213 struct aml_bufferfield bfld; 214 struct aml_package package; 215 struct aml_string str; 216 struct aml_objref objref; 217 struct aml_event event; 218 struct aml_regfield regfield; 219}; 220 221union aml_object *aml_copy_object(struct aml_environ *, 222 union aml_object *); 223union aml_object *aml_alloc_object(enum aml_objtype, 224 union aml_object *); 225void aml_free_objectcontent(union aml_object *); 226void aml_free_object(union aml_object **); 227void aml_realloc_object(union aml_object *, int); 228 229#endif /* !_AML_OBJ_H_ */ 230