root/dev/acpi/dsdt.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


    1 /* $OpenBSD: dsdt.h,v 1.28 2007/04/11 02:51:11 jordan Exp $ */
    2 /*
    3  * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
    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_DSDT_H__
   19 #define __DEV_ACPI_DSDT_H__
   20 
   21 struct aml_vallist {
   22         struct aml_value *obj;
   23         int nobj;
   24         struct aml_vallist *next;
   25 };
   26 
   27 struct aml_scope {
   28         struct acpi_softc  *sc;
   29         uint8_t            *pos;
   30         uint8_t            *end;
   31         struct aml_node    *node;
   32         struct aml_vallist *tmpvals;
   33         struct aml_scope   *parent;
   34         struct aml_value   *locals;
   35         struct aml_value   *args;
   36         int                 nargs;
   37 };
   38 
   39 
   40 struct aml_opcode {
   41         u_int32_t               opcode;
   42         const char              *mnem;
   43         const char              *args;
   44         struct aml_value        *(*handler)(struct aml_scope *, int,
   45                                     struct aml_value*);
   46 };
   47 
   48 const char              *aml_eisaid(u_int32_t);
   49 const char              *aml_args(int);
   50 const char              *aml_mnem(int, uint8_t *);
   51 int64_t                 aml_val2int(struct aml_value *);
   52 struct aml_node         *aml_searchname(struct aml_node *, const void *);
   53 struct aml_node         *aml_createname(struct aml_node *, const void *,
   54                             struct aml_value *);
   55 
   56 struct aml_value        *aml_allocint(uint64_t);
   57 struct aml_value        *aml_allocstr(const char *);
   58 struct aml_value        *aml_allocvalue(int, int64_t, const void *);
   59 void                    aml_freevalue(struct aml_value *);
   60 void                    aml_notify(struct aml_node *, int);
   61 void                    aml_notify_dev(const char *, int);
   62 void                    aml_showvalue(struct aml_value *, int);
   63 void                    aml_walkroot(void);
   64 void                    aml_walktree(struct aml_node *);
   65 
   66 int                     aml_find_node(struct aml_node *, const char *,
   67                             void (*)(struct aml_node *, void *), void *);
   68 int                     acpi_parse_aml(struct acpi_softc *, u_int8_t *,
   69                             u_int32_t);
   70 int                     aml_eval_object(struct acpi_softc *, struct aml_node *,
   71                             struct aml_value *, int, struct aml_value *);
   72 void                    aml_register_notify(struct aml_node *, const char *,
   73                             int (*)(struct aml_node *, int, void *), void *,
   74                             int);
   75 
   76 u_int64_t               aml_getpciaddr(struct acpi_softc *, struct aml_node *);
   77 
   78 int                     aml_evalnode(struct acpi_softc *, struct aml_node *,
   79                             int , struct aml_value *, struct aml_value *);
   80 int                     aml_evalname(struct acpi_softc *, struct aml_node *,
   81                             const char *, int, struct aml_value *,
   82                             struct aml_value *);
   83 
   84 void                    aml_fixup_dsdt(u_int8_t *, u_int8_t *, int);
   85 void                    aml_create_defaultobjects(void);
   86 
   87 int                     acpi_mutex_acquire(struct aml_value *, int);
   88 void                    acpi_mutex_release(struct aml_value *);
   89 
   90 const char              *aml_nodename(struct aml_node *);
   91 
   92 #define SR_IRQ                  0x04
   93 #define SR_DMA                  0x05
   94 #define SR_STARTDEP             0x06
   95 #define SR_ENDDEP               0x07
   96 #define SR_IOPORT               0x08
   97 #define SR_FIXEDPORT            0x09
   98 #define SR_ENDTAG               0x0F
   99 
  100 #define LR_24BIT                0x81
  101 #define LR_GENREGISTER          0x82
  102 #define LR_32BIT                0x85
  103 #define LR_32BITFIXED           0x86
  104 #define LR_DWORD                0x87
  105 #define LR_WORD                 0x88
  106 #define LR_EXTIRQ               0x89
  107 #define LR_QWORD                0x8A
  108 
  109 #define __amlflagbit(v,s,l)
  110 union acpi_resource {
  111         struct {
  112                 uint8_t  typecode;
  113                 uint16_t length;
  114         }  __packed hdr;
  115 
  116         /* Small resource structures
  117          * format of typecode is: tttttlll, t = type, l = length
  118          */
  119         struct {
  120                 uint8_t  typecode;
  121                 uint16_t irq_mask;
  122                 uint8_t  irq_flags;
  123         }  __packed sr_irq;
  124         struct {
  125                 uint8_t  typecode;
  126                 uint8_t  channel;
  127                 uint8_t  flags;
  128         }  __packed sr_dma;
  129         struct {
  130                 uint8_t  typecode;
  131                 uint8_t  flags;
  132                 uint16_t _min;
  133                 uint16_t _max;
  134                 uint8_t  _aln;
  135                 uint8_t  _len;
  136         }  __packed sr_ioport;
  137         struct {
  138                 uint8_t  typecode;
  139                 uint16_t _bas;
  140                 uint8_t  _len;
  141         }  __packed sr_fioport;
  142 
  143         /* Large resource structures */
  144         struct {
  145                 uint8_t  typecode;
  146                 uint16_t length;
  147                 uint8_t  _info;
  148                 uint16_t _min;
  149                 uint16_t _max;
  150                 uint16_t _aln;
  151                 uint16_t _len;
  152         }  __packed lr_m24;
  153         struct {
  154                 uint8_t  typecode;
  155                 uint16_t length;
  156                 uint8_t  _info;
  157                 uint32_t _min;
  158                 uint32_t _max;
  159                 uint32_t _aln;
  160                 uint32_t _len;
  161         }  __packed lr_m32;
  162         struct {
  163                 uint8_t  typecode;
  164                 uint16_t length;
  165                 uint8_t  flags;
  166                 uint8_t  irq_count;
  167                 uint32_t irq[1];
  168         } __packed lr_extirq;
  169         struct {
  170                 uint8_t         typecode;
  171                 uint16_t        length;
  172                 uint8_t         type;
  173                 uint8_t         flags;
  174                 uint8_t         tflags;
  175                 uint16_t        _gra;
  176                 uint16_t        _min;
  177                 uint16_t        _max;
  178                 uint16_t        _tra;
  179                 uint16_t        _len;
  180                 uint8_t         src_index;
  181                 char            src[1];
  182         } __packed lr_word;
  183         struct {
  184                 uint8_t         typecode;
  185                 uint16_t        length;
  186                 uint8_t         type;
  187                 uint8_t         flags;
  188                 uint8_t         tflags;
  189                 uint32_t        _gra;
  190                 uint32_t        _min;
  191                 uint32_t        _max;
  192                 uint32_t        _tra;
  193                 uint32_t        _len;
  194                 uint8_t         src_index;
  195                 char            src[1];
  196         } __packed lr_dword;
  197         struct {
  198                 uint8_t         typecode;
  199                 uint16_t        length;
  200                 uint8_t         type;
  201                 uint8_t         flags;
  202                 uint8_t         tflags;
  203                 uint64_t        _gra;
  204                 uint64_t        _min;
  205                 uint64_t        _max;
  206                 uint64_t        _tra;
  207                 uint64_t        _len;
  208                 uint8_t         src_index;
  209                 char            src[1];
  210         } __packed lr_qword;
  211         uint8_t          pad[64];
  212 } __packed;
  213 
  214 #define AML_CRSTYPE(x)  ((x)->hdr.typecode & 0x80 ? \
  215                             (x)->hdr.typecode : (x)->hdr.typecode >> 3)
  216 #define AML_CRSLEN(x)   ((x)->hdr.typecode & 0x80 ? \
  217                             3+(x)->hdr.length : 1+((x)->hdr.typecode & 0x7))
  218 
  219 int                     aml_print_resource(union acpi_resource *, void *);
  220 int                     aml_parse_resource(int, uint8_t *,
  221                             int (*)(union acpi_resource *, void *), void *);
  222 
  223 #define ACPI_E_NOERROR   0x00
  224 #define ACPI_E_BADVALUE  0x01
  225 
  226 #define AML_MAX_ARG      7
  227 #define AML_MAX_LOCAL    8
  228 
  229 /* XXX: endian macros */
  230 #define aml_letohost16(x) letoh16(x)
  231 #define aml_letohost32(x) letoh32(x)
  232 #define aml_letohost64(x) letoh64(x)
  233 
  234 #define AML_WALK_PRE 0x00
  235 #define AML_WALK_POST 0x01
  236 
  237 void                    aml_walknodes(struct aml_node *, int,
  238                             int (*)(struct aml_node *, void *), void *);
  239 
  240 void                    aml_postparse(void);
  241 void                    acpi_poll_notify(void);
  242 
  243 void                    aml_hashopcodes(void);
  244 
  245 void    aml_foreachpkg(struct aml_value *, int,
  246             void (*fn)(struct aml_value *, void *), void *);
  247 
  248 #endif /* __DEV_ACPI_DSDT_H__ */

/* [<][>][^][v][top][bottom][index][help] */