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