acpiioctl() can be left without ACPI_UNLOCK(), leading to
[dragonfly.git] / sys / sys / pciio.h
1 /*-
2  * Copyright (c) 1997, Stefan Esser <se@FreeBSD.ORG>
3  * Copyright (c) 1997, 1998, 1999, Kenneth D. Merry <ken@FreeBSD.ORG>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice unmodified, this list of conditions, and the following
11  *    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.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  *      $FreeBSD: src/sys/sys/pciio.h,v 1.5 1999/12/08 17:44:04 ken Exp $
28  *      $DragonFly: src/sys/sys/pciio.h,v 1.3 2006/05/20 02:42:13 dillon Exp $
29  *
30  */
31
32 #ifndef _SYS_PCIIO_H_
33 #define _SYS_PCIIO_H_
34
35 #ifndef _SYS_TYPES_H_
36 #include <sys/types.h>
37 #endif
38 #ifndef _SYS_IOCCOM_H_
39 #include <sys/ioccom.h>
40 #endif
41
42 #define PCI_MAXNAMELEN  16
43
44 typedef enum {
45         PCI_GETCONF_LAST_DEVICE,
46         PCI_GETCONF_LIST_CHANGED,
47         PCI_GETCONF_MORE_DEVS,
48         PCI_GETCONF_ERROR
49 } pci_getconf_status;
50
51 typedef enum {
52         PCI_GETCONF_NO_MATCH            = 0x00,
53         PCI_GETCONF_MATCH_BUS           = 0x01,
54         PCI_GETCONF_MATCH_DEV           = 0x02,
55         PCI_GETCONF_MATCH_FUNC          = 0x04,
56         PCI_GETCONF_MATCH_NAME          = 0x08,
57         PCI_GETCONF_MATCH_UNIT          = 0x10,
58         PCI_GETCONF_MATCH_VENDOR        = 0x20,
59         PCI_GETCONF_MATCH_DEVICE        = 0x40,
60         PCI_GETCONF_MATCH_CLASS         = 0x80
61 } pci_getconf_flags;
62
63 struct pcisel {
64         u_int8_t        pc_bus;         /* bus number */
65         u_int8_t        pc_dev;         /* device on this bus */
66         u_int8_t        pc_func;        /* function on this device */
67 };
68
69 struct  pci_conf {
70         struct pcisel   pc_sel;         /* bus+slot+function */
71         u_int8_t        pc_hdr;         /* PCI header type */
72         u_int16_t       pc_subvendor;   /* card vendor ID */
73         u_int16_t       pc_subdevice;   /* card device ID, assigned by 
74                                            card vendor */
75         u_int16_t       pc_vendor;      /* chip vendor ID */
76         u_int16_t       pc_device;      /* chip device ID, assigned by 
77                                            chip vendor */
78         u_int8_t        pc_class;       /* chip PCI class */
79         u_int8_t        pc_subclass;    /* chip PCI subclass */
80         u_int8_t        pc_progif;      /* chip PCI programming interface */
81         u_int8_t        pc_revid;       /* chip revision ID */
82         char            pd_name[PCI_MAXNAMELEN + 1];  /* device name */
83         u_long          pd_unit;        /* device unit number */
84 };
85
86 struct pci_match_conf {
87         struct pcisel           pc_sel;         /* bus+slot+function */
88         char                    pd_name[PCI_MAXNAMELEN + 1];  /* device name */
89         u_long                  pd_unit;        /* Unit number */
90         u_int16_t               pc_vendor;      /* PCI Vendor ID */
91         u_int16_t               pc_device;      /* PCI Device ID */
92         u_int8_t                pc_class;       /* PCI class */
93         pci_getconf_flags       flags;          /* Matching expression */
94 };
95
96 struct  pci_conf_io {
97         u_int32_t               pat_buf_len;    /* pattern buffer length */
98         u_int32_t               num_patterns;   /* number of patterns */
99         struct pci_match_conf   *patterns;      /* pattern buffer */
100         u_int32_t               match_buf_len;  /* match buffer length */
101         u_int32_t               num_matches;    /* number of matches returned */
102         struct pci_conf         *matches;       /* match buffer */
103         u_int32_t               offset;         /* offset into device list */
104         u_int32_t               generation;     /* device list generation */
105         pci_getconf_status      status;         /* request status */
106 };
107
108 struct pci_io {
109         struct pcisel   pi_sel;         /* device to operate on */
110         int             pi_reg;         /* configuration register to examine */
111         int             pi_width;       /* width (in bytes) of read or write */
112         u_int32_t       pi_data;        /* data to write or result of read */
113 };
114         
115
116 #define PCIOCGETCONF    _IOWR('p', 1, struct pci_conf_io)
117 #define PCIOCREAD       _IOWR('p', 2, struct pci_io)
118 #define PCIOCWRITE      _IOWR('p', 3, struct pci_io)
119 #define PCIOCATTACHED   _IOWR('p', 4, struct pci_io)
120
121 #endif /* !_SYS_PCIIO_H_ */