4 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * Id: aml_common.h,v 1.4 2000/08/08 14:12:05 iwasaki Exp
29 * $FreeBSD: src/usr.sbin/acpi/amldb/aml/aml_common.h,v 1.4 2000/10/02 08:58:47 iwasaki Exp $
32 #ifndef _AML_COMMON_H_
33 #define _AML_COMMON_H_
39 #define AML_SYSABORT() do { \
40 printf("aml: fatal errer at %s:%d\n", __FILE__, __LINE__); \
41 panic("panic in AML interpreter!"); \
43 #define AML_SYSASSERT(x) do { \
48 #define AML_SYSERRX(eval, fmt, args...) do { \
51 #define AML_DEBUGGER(x, y) /* no debugger in kernel */
52 #define AML_STALL(micro) OsdSleepUsec(micro)
53 #define AML_SLEEP(sec, milli) OsdSleep(sec, milli)
55 #define AML_SYSASSERT(x) assert(x)
56 #define AML_SYSABORT() abort()
57 #define AML_SYSERRX(eval, fmt, args...) errx(eval, fmt, args)
58 #define AML_DEBUGGER(x, y) aml_dbgr(x, y)
59 #define AML_STALL(micro) /* not required in userland */
60 #define AML_SLEEP(sec, milli) /* not required in userland */
68 #define AML_DEBUGPRINT(args...) do { \
74 void aml_showobject(union aml_object
*);
75 void aml_showtree(struct aml_name
*, int);
76 int aml_print_curname(struct aml_name
*);
77 void aml_print_namestring(u_int8_t
*);
78 void aml_print_indent(int);
81 * Reigion I/O Stuff for both kernel/userland.
87 /* bit 0 -3: AccessType */
88 #define AML_FIELDFLAGS_ACCESS_ANYACC 0x00
89 #define AML_FIELDFLAGS_ACCESS_BYTEACC 0x01
90 #define AML_FIELDFLAGS_ACCESS_WORDACC 0x02
91 #define AML_FIELDFLAGS_ACCESS_DWORDACC 0x03
92 #define AML_FIELDFLAGS_ACCESS_BLOCKACC 0x04
93 #define AML_FIELDFLAGS_ACCESS_SMBSENDRECVACC 0x05
94 #define AML_FIELDFLAGS_ACCESS_SMBQUICKACC 0x06
95 #define AML_FIELDFLAGS_ACCESSTYPE(flags) (flags & 0x0f)
97 #define AML_FIELDFLAGS_LOCK_NOLOCK 0x00
98 #define AML_FIELDFLAGS_LOCK_LOCK 0x10
99 #define AML_FIELDFLAGS_LOCKRULE(flags) (flags & 0x10)
100 /* bit 5 - 6: UpdateRule */
101 #define AML_FIELDFLAGS_UPDATE_PRESERVE 0x00
102 #define AML_FIELDFLAGS_UPDATE_WRITEASONES 0x20
103 #define AML_FIELDFLAGS_UPDATE_WRITEASZEROS 0x40
104 #define AML_FIELDFLAGS_UPDATERULE(flags) (flags & 0x60)
105 /* bit 7: reserved (must be 0) */
107 #define AML_REGION_INPUT 0
108 #define AML_REGION_OUTPUT 1
110 #define AML_REGION_SYSMEM 0
111 #define AML_REGION_SYSIO 1
112 #define AML_REGION_PCICFG 2
113 #define AML_REGION_EMBCTL 3
114 #define AML_REGION_SMBUS 4
116 struct aml_region_handle
{
117 /* These are copies of values used on initialization */
118 struct aml_environ
*env
;
125 /* following is determined on initialization */
126 vm_offset_t addr
, bytelen
;
127 u_int32_t unit
; /* access unit in bytes */
129 /* region type dependant */
130 vm_offset_t vaddr
; /* SystemMemory */
131 u_int32_t pci_bus
, pci_devfunc
; /* PCI_Config */
134 u_int32_t
aml_adjust_readvalue(u_int32_t
, u_int32_t
, u_int32_t
,
136 u_int32_t
aml_adjust_updatevalue(u_int32_t
, u_int32_t
, u_int32_t
,
137 u_int32_t
, u_int32_t
);
139 u_int32_t
aml_bufferfield_read(u_int8_t
*, u_int32_t
, u_int32_t
);
140 int aml_bufferfield_write(u_int32_t
, u_int8_t
*,
141 u_int32_t
, u_int32_t
);
143 int aml_region_handle_alloc(struct aml_environ
*, int, u_int32_t
,
144 u_int32_t
, u_int32_t
, u_int32_t
,
145 struct aml_region_handle
*);
146 void aml_region_handle_free(struct aml_region_handle
*);
148 int aml_region_io(struct aml_environ
*, int, int,
149 u_int32_t
, u_int32_t
*, u_int32_t
,
150 u_int32_t
, u_int32_t
);
151 int aml_region_read_simple(struct aml_region_handle
*, vm_offset_t
,
153 int aml_region_write_simple(struct aml_region_handle
*, vm_offset_t
,
155 u_int32_t
aml_region_prompt_read(struct aml_region_handle
*,
157 u_int32_t
aml_region_prompt_write(struct aml_region_handle
*,
159 int aml_region_prompt_update_value(u_int32_t
, u_int32_t
,
160 struct aml_region_handle
*);
161 void aml_dbgr(struct aml_environ
*, struct aml_environ
*);
162 #endif /* !_AML_COMMON_H_ */