#ifndef _AML_COMMON_H_
#define _AML_COMMON_H_
#ifdef _KERNEL
#define AML_SYSABORT() do { \
printf("aml: fatal error at %s:%d\n", __FILE__, __LINE__); \
panic("panic in AML interpreter!"); \
} while(0)
#define AML_SYSASSERT(x) do { \
if (!(x)) { \
AML_SYSABORT(); \
} \
} while(0)
#define AML_SYSERRX(eval, fmt, args...) do { \
printf(fmt, args); \
} while(0)
#define AML_DEBUGGER(x, y)
#define AML_STALL(micro) OsdSleepUsec(micro)
#define AML_SLEEP(sec, milli) OsdSleep(sec, milli)
#else
#define AML_SYSASSERT(x) assert(x)
#define AML_SYSABORT() abort()
#define AML_SYSERRX(eval, fmt, args...) errx(eval, fmt, args)
#define AML_DEBUGGER(x, y) aml_dbgr(x, y)
#define AML_STALL(micro)
#define AML_SLEEP(sec, milli)
#endif
union aml_object;
struct aml_name;
extern int aml_debug;
#define AML_DEBUGPRINT(args...) do { \
if (aml_debug) { \
printf(args); \
} \
} while(0)
void aml_showobject(union aml_object *);
void aml_showtree(struct aml_name *, int);
int aml_print_curname(struct aml_name *);
void aml_print_namestring(u_int8_t *);
void aml_print_indent(int);
#define AML_FIELDFLAGS_ACCESS_ANYACC 0x00
#define AML_FIELDFLAGS_ACCESS_BYTEACC 0x01
#define AML_FIELDFLAGS_ACCESS_WORDACC 0x02
#define AML_FIELDFLAGS_ACCESS_DWORDACC 0x03
#define AML_FIELDFLAGS_ACCESS_BLOCKACC 0x04
#define AML_FIELDFLAGS_ACCESS_SMBSENDRECVACC 0x05
#define AML_FIELDFLAGS_ACCESS_SMBQUICKACC 0x06
#define AML_FIELDFLAGS_ACCESSTYPE(flags) (flags & 0x0f)
#define AML_FIELDFLAGS_LOCK_NOLOCK 0x00
#define AML_FIELDFLAGS_LOCK_LOCK 0x10
#define AML_FIELDFLAGS_LOCKRULE(flags) (flags & 0x10)
#define AML_FIELDFLAGS_UPDATE_PRESERVE 0x00
#define AML_FIELDFLAGS_UPDATE_WRITEASONES 0x20
#define AML_FIELDFLAGS_UPDATE_WRITEASZEROS 0x40
#define AML_FIELDFLAGS_UPDATERULE(flags) (flags & 0x60)
#define AML_REGION_INPUT 0
#define AML_REGION_OUTPUT 1
#define AML_REGION_SYSMEM 0
#define AML_REGION_SYSIO 1
#define AML_REGION_PCICFG 2
#define AML_REGION_EMBCTL 3
#define AML_REGION_SMBUS 4
struct aml_region_handle {
struct aml_environ *env;
int regtype;
u_int32_t flags;
u_int32_t baseaddr;
u_int32_t bitoffset;
u_int32_t bitlen;
vm_offset_t addr, bytelen;
u_int32_t unit;
vm_offset_t vaddr;
u_int32_t pci_bus, pci_devfunc;
};
u_int32_t aml_adjust_readvalue(u_int32_t, u_int32_t, u_int32_t,
u_int32_t);
u_int32_t aml_adjust_updatevalue(u_int32_t, u_int32_t, u_int32_t,
u_int32_t, u_int32_t);
u_int32_t aml_bufferfield_read(u_int8_t *, u_int32_t, u_int32_t);
int aml_bufferfield_write(u_int32_t, u_int8_t *,
u_int32_t, u_int32_t);
int aml_region_handle_alloc(struct aml_environ *, int, u_int32_t,
u_int32_t, u_int32_t, u_int32_t,
struct aml_region_handle *);
void aml_region_handle_free(struct aml_region_handle *);
int aml_region_io(struct aml_environ *, int, int,
u_int32_t, u_int32_t *, u_int32_t,
u_int32_t, u_int32_t);
int aml_region_read_simple(struct aml_region_handle *, vm_offset_t,
u_int32_t *);
int aml_region_write_simple(struct aml_region_handle *, vm_offset_t,
u_int32_t);
u_int32_t aml_region_prompt_read(struct aml_region_handle *,
u_int32_t);
u_int32_t aml_region_prompt_write(struct aml_region_handle *,
u_int32_t);
int aml_region_prompt_update_value(u_int32_t, u_int32_t,
struct aml_region_handle *);
void aml_dbgr(struct aml_environ *, struct aml_environ *);
#endif