xref: /netbsd-src/sys/arch/i386/pnpbios/pnpbiosvar.h (revision 4cbd24b23f7b9efac0cd70749df49d28974c7799)
1 /* $NetBSD: pnpbiosvar.h,v 1.12 2011/06/30 20:09:31 wiz Exp $ */
2 /*
3  * Copyright (c) 1999
4  * 	Matthias Drochner.  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, this list of conditions, and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #include <sys/device.h>		/* for device_t */
29 
30 struct pnpbios_attach_args {
31 	isa_chipset_tag_t paa_ic;
32 };
33 
34 int pnpbios_probe(void);
35 
36 struct pnp_compatid {
37 	char idstr[8];
38 	struct pnp_compatid *next;
39 };
40 
41 struct pnp_mem {
42 	SIMPLEQ_ENTRY(pnp_mem) next;
43 	uint32_t minbase, maxbase, align, len;
44 	int flags;
45 };
46 struct pnp_io {
47 	SIMPLEQ_ENTRY(pnp_io) next;
48 	uint16_t minbase, maxbase, align, len;
49 	int flags;
50 };
51 struct pnp_irq {
52 	SIMPLEQ_ENTRY(pnp_irq) next;
53 	uint16_t mask;
54 	int flags;
55 };
56 struct pnp_dma {
57 	SIMPLEQ_ENTRY(pnp_dma) next;
58 	uint8_t mask;
59 	int flags;
60 };
61 
62 #define PNP_MAXMEM 4
63 #define PNP_MAXIOPORT 8
64 #define PNP_MAXIRQ 2
65 #define PNP_MAXDMA 2
66 
67 struct pnpresources {
68 	int nummem, numio, numirq, numdma;
69 	SIMPLEQ_HEAD(, pnp_mem) mem;
70 	SIMPLEQ_HEAD(, pnp_io) io;
71 	SIMPLEQ_HEAD(, pnp_irq) irq;
72 	SIMPLEQ_HEAD(, pnp_dma) dma;
73 	struct pnpresources *dependent_link;
74 	struct pnp_compatid *compatids;
75 	char *longname;
76 };
77 
78 typedef void *pnpbios_tag_t; /* driver private */
79 
80 struct pnpbiosdev_attach_args {
81 	pnpbios_tag_t pbt;
82 	isa_chipset_tag_t ic;
83 	int idx;
84 	struct pnpresources *resc;
85 	char *idstr;
86 	char *primid;
87 };
88 
89 int pnpbios_io_map(pnpbios_tag_t, struct pnpresources *, int,
90 			bus_space_tag_t *, bus_space_handle_t *);
91 void pnpbios_io_unmap(pnpbios_tag_t, struct pnpresources *, int,
92 			bus_space_tag_t, bus_space_handle_t);
93 void *pnpbios_intr_establish(pnpbios_tag_t, struct pnpresources *, int,
94 				  int, int (*)(void *), void *);
95 
96 int pnpbios_getiobase(pnpbios_tag_t, struct pnpresources *, int,
97 			   bus_space_tag_t *, int *);
98 int pnpbios_getiosize(pnpbios_tag_t, struct pnpresources *, int, int *);
99 int pnpbios_getirqnum(pnpbios_tag_t, struct pnpresources *, int, int *, int *);
100 int pnpbios_getdmachan(pnpbios_tag_t, struct pnpresources *, int, int *);
101 void pnpbios_print_devres(device_t, struct pnpbiosdev_attach_args *);
102