Annotation of sys/dev/acpi/acpivar.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: acpivar.h,v 1.36 2007/05/31 17:49:16 gwk Exp $ */
! 2: /*
! 3: * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
! 4: *
! 5: * Permission to use, copy, modify, and distribute this software for any
! 6: * purpose with or without fee is hereby granted, provided that the above
! 7: * copyright notice and this permission notice appear in all copies.
! 8: *
! 9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
! 10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
! 11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
! 12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
! 13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
! 14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
! 15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
! 16: */
! 17:
! 18: #ifndef _DEV_ACPI_ACPIVAR_H_
! 19: #define _DEV_ACPI_ACPIVAR_H_
! 20:
! 21: #include <sys/timeout.h>
! 22: #include <sys/rwlock.h>
! 23:
! 24: /* #define ACPI_DEBUG */
! 25: #ifdef ACPI_DEBUG
! 26: extern int acpi_debug;
! 27: #define dprintf(x...) do { if (acpi_debug) printf(x); } while (0)
! 28: #define dnprintf(n,x...) do { if (acpi_debug > (n)) printf(x); } while (0)
! 29: #else
! 30: #define dprintf(x...)
! 31: #define dnprintf(n,x...)
! 32: #endif
! 33:
! 34: extern int acpi_hasprocfvs;
! 35:
! 36: struct klist;
! 37: struct acpiec_softc;
! 38:
! 39: struct acpi_attach_args {
! 40: char *aaa_name;
! 41: bus_space_tag_t aaa_iot;
! 42: bus_space_tag_t aaa_memt;
! 43: void *aaa_table;
! 44: paddr_t aaa_pbase; /* Physical base address of ACPI tables */
! 45: struct aml_node *aaa_node;
! 46: const char *aaa_dev;
! 47: };
! 48:
! 49: struct acpi_mem_map {
! 50: vaddr_t baseva;
! 51: u_int8_t *va;
! 52: size_t vsize;
! 53: paddr_t pa;
! 54: };
! 55:
! 56: struct acpi_q {
! 57: SIMPLEQ_ENTRY(acpi_q) q_next;
! 58: void *q_table;
! 59: u_int8_t q_data[0];
! 60: };
! 61:
! 62: typedef SIMPLEQ_HEAD(, acpi_q) acpi_qhead_t;
! 63:
! 64: #define ACPIREG_PM1A_STS 0x00
! 65: #define ACPIREG_PM1A_EN 0x01
! 66: #define ACPIREG_PM1A_CNT 0x02
! 67: #define ACPIREG_PM1B_STS 0x03
! 68: #define ACPIREG_PM1B_EN 0x04
! 69: #define ACPIREG_PM1B_CNT 0x05
! 70: #define ACPIREG_PM2_CNT 0x06
! 71: #define ACPIREG_PM_TMR 0x07
! 72: #define ACPIREG_GPE0_STS 0x08
! 73: #define ACPIREG_GPE0_EN 0x09
! 74: #define ACPIREG_GPE1_STS 0x0A
! 75: #define ACPIREG_GPE1_EN 0x0B
! 76: #define ACPIREG_SMICMD 0x0C
! 77: #define ACPIREG_MAXREG 0x0D
! 78:
! 79: /* Special registers */
! 80: #define ACPIREG_PM1_STS 0x0E
! 81: #define ACPIREG_PM1_EN 0x0F
! 82: #define ACPIREG_PM1_CNT 0x10
! 83: #define ACPIREG_GPE_STS 0x11
! 84: #define ACPIREG_GPE_EN 0x12
! 85:
! 86: struct acpi_parsestate
! 87: {
! 88: u_int8_t *start;
! 89: u_int8_t *end;
! 90: u_int8_t *pos;
! 91: };
! 92:
! 93: struct acpi_reg_map {
! 94: bus_space_handle_t ioh;
! 95: int addr;
! 96: int size;
! 97: const char *name;
! 98: };
! 99:
! 100: struct acpi_thread {
! 101: struct acpi_softc *sc;
! 102: volatile int running;
! 103: };
! 104:
! 105: struct acpi_mutex {
! 106: struct rwlock amt_lock;
! 107: #define ACPI_MTX_MAXNAME 5
! 108: char amt_name[ACPI_MTX_MAXNAME + 3]; /* only 4 used */
! 109: int amt_ref_count;
! 110: int amt_timeout;
! 111: int amt_synclevel;
! 112: };
! 113:
! 114: struct gpe_block {
! 115: int (*handler)(struct acpi_softc *, int, void *);
! 116: void *arg;
! 117: int active;
! 118: };
! 119:
! 120: struct acpi_ac {
! 121: struct acpiac_softc *aac_softc;
! 122: SLIST_ENTRY(acpi_ac) aac_link;
! 123: };
! 124:
! 125: SLIST_HEAD(acpi_ac_head, acpi_ac);
! 126:
! 127: struct acpi_bat {
! 128: struct acpibat_softc *aba_softc;
! 129: SLIST_ENTRY(acpi_bat) aba_link;
! 130: };
! 131:
! 132: SLIST_HEAD(acpi_bat_head, acpi_bat);
! 133:
! 134: struct acpi_softc {
! 135: struct device sc_dev;
! 136:
! 137: bus_space_tag_t sc_iot;
! 138: bus_space_tag_t sc_memt;
! 139: #if 0
! 140: bus_space_tag_t sc_pcit;
! 141: bus_space_tag_t sc_smbust;
! 142: #endif
! 143:
! 144: /*
! 145: * First-level ACPI tables
! 146: */
! 147: struct acpi_fadt *sc_fadt;
! 148: acpi_qhead_t sc_tables;
! 149:
! 150: /*
! 151: * Second-level information from FADT
! 152: */
! 153: struct acpi_facs *sc_facs; /* Shared with firmware! */
! 154:
! 155: struct klist *sc_note;
! 156: struct acpi_reg_map sc_pmregs[ACPIREG_MAXREG];
! 157: bus_space_handle_t sc_ioh_pm1a_evt;
! 158:
! 159: void *sc_interrupt;
! 160: #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
! 161: void *sc_softih;
! 162: #else
! 163: struct timeout sc_timeout;
! 164: #endif
! 165:
! 166: int sc_powerbtn;
! 167: int sc_sleepbtn;
! 168:
! 169: struct {
! 170: int slp_typa;
! 171: int slp_typb;
! 172: } sc_sleeptype[6];
! 173: int sc_maxgpe;
! 174: int sc_lastgpe;
! 175:
! 176: struct gpe_block *gpe_table;
! 177:
! 178: int sc_wakeup;
! 179: u_int32_t sc_gpe_sts;
! 180: u_int32_t sc_gpe_en;
! 181: struct acpi_thread *sc_thread;
! 182:
! 183: struct aml_node *sc_tts;
! 184: struct aml_node *sc_pts;
! 185: struct aml_node *sc_bfs;
! 186: struct aml_node *sc_gts;
! 187: struct aml_node *sc_wak;
! 188: int sc_state;
! 189: struct acpiec_softc *sc_ec; /* XXX assume single EC */
! 190:
! 191: struct acpi_ac_head sc_ac;
! 192: struct acpi_bat_head sc_bat;
! 193:
! 194: struct timeout sc_dev_timeout;
! 195: int sc_poll;
! 196: };
! 197:
! 198: #define GPE_NONE 0x00
! 199: #define GPE_LEVEL 0x01
! 200: #define GPE_EDGE 0x02
! 201:
! 202: struct acpi_table {
! 203: int offset;
! 204: size_t size;
! 205: void *table;
! 206: };
! 207:
! 208: #define ACPI_IOC_GETFACS _IOR('A', 0, struct acpi_facs)
! 209: #define ACPI_IOC_GETTABLE _IOWR('A', 1, struct acpi_table)
! 210: #define ACPI_IOC_SETSLEEPSTATE _IOW('A', 2, int)
! 211:
! 212: #define ACPI_EV_PWRBTN 0x0001 /* Power button was pushed */
! 213: #define ACPI_EV_SLPBTN 0x0002 /* Sleep button was pushed */
! 214:
! 215: #define ACPI_EVENT_MASK 0x0003
! 216:
! 217: #define ACPI_EVENT_COMPOSE(t,i) (((i) & 0x7fff) << 16 | ((t) & ACPI_EVENT_MASK))
! 218: #define ACPI_EVENT_TYPE(e) ((e) & ACPI_EVENT_MASK)
! 219: #define ACPI_EVENT_INDEX(e) ((e) >> 16)
! 220:
! 221: #if defined(_KERNEL)
! 222: struct acpi_gas;
! 223: int acpi_map_address(struct acpi_softc *, struct acpi_gas *, bus_addr_t, bus_size_t,
! 224: bus_space_handle_t *, bus_space_tag_t *);
! 225:
! 226: int acpi_map(paddr_t, size_t, struct acpi_mem_map *);
! 227: void acpi_unmap(struct acpi_mem_map *);
! 228: int acpi_probe(struct device *, struct cfdata *, struct acpi_attach_args *);
! 229: u_int acpi_checksum(const void *, size_t);
! 230: void acpi_attach_machdep(struct acpi_softc *);
! 231: int acpi_interrupt(void *);
! 232: void acpi_enter_sleep_state(struct acpi_softc *, int);
! 233: void acpi_powerdown(void);
! 234: void acpi_resume(struct acpi_softc *);
! 235:
! 236: #define ACPI_IOREAD 0
! 237: #define ACPI_IOWRITE 1
! 238:
! 239: void acpi_delay(struct acpi_softc *, int64_t);
! 240: int acpi_gasio(struct acpi_softc *, int, int, uint64_t, int, int, void *);
! 241:
! 242: int acpi_set_gpehandler(struct acpi_softc *, int, int (*)(struct acpi_softc *, int, void *), void *, const char *);
! 243: void acpi_enable_gpe(struct acpi_softc *, u_int32_t);
! 244:
! 245: int acpiec_intr(struct acpiec_softc *);
! 246: void acpiec_read(struct acpiec_softc *, u_int8_t, int, u_int8_t *);
! 247: void acpiec_write(struct acpiec_softc *, u_int8_t, int, u_int8_t *);
! 248: void acpiec_handle_events(struct acpiec_softc *);
! 249:
! 250: int acpi_read_pmreg(struct acpi_softc *, int, int);
! 251: void acpi_write_pmreg(struct acpi_softc *, int, int, int);
! 252:
! 253: void acpi_poll(void *);
! 254:
! 255: #endif
! 256:
! 257: #endif /* !_DEV_ACPI_ACPIVAR_H_ */
CVSweb