xref: /netbsd-src/sys/arch/x86/include/isa_machdep.h (revision 4075f0e731bb08ef66ff49d419ee769313adb9f1)
1*4075f0e7Sandvar /*	$NetBSD: isa_machdep.h,v 1.13 2021/12/12 11:10:04 andvar Exp $	*/
220e439b5Sfvdl 
320e439b5Sfvdl /*-
420e439b5Sfvdl  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
520e439b5Sfvdl  * All rights reserved.
620e439b5Sfvdl  *
720e439b5Sfvdl  * This code is derived from software contributed to The NetBSD Foundation
820e439b5Sfvdl  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
920e439b5Sfvdl  * NASA Ames Research Center.
1020e439b5Sfvdl  *
1120e439b5Sfvdl  * Redistribution and use in source and binary forms, with or without
1220e439b5Sfvdl  * modification, are permitted provided that the following conditions
1320e439b5Sfvdl  * are met:
1420e439b5Sfvdl  * 1. Redistributions of source code must retain the above copyright
1520e439b5Sfvdl  *    notice, this list of conditions and the following disclaimer.
1620e439b5Sfvdl  * 2. Redistributions in binary form must reproduce the above copyright
1720e439b5Sfvdl  *    notice, this list of conditions and the following disclaimer in the
1820e439b5Sfvdl  *    documentation and/or other materials provided with the distribution.
1920e439b5Sfvdl  *
2020e439b5Sfvdl  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2120e439b5Sfvdl  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2220e439b5Sfvdl  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2320e439b5Sfvdl  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2420e439b5Sfvdl  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2520e439b5Sfvdl  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2620e439b5Sfvdl  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2720e439b5Sfvdl  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2820e439b5Sfvdl  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2920e439b5Sfvdl  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3020e439b5Sfvdl  * POSSIBILITY OF SUCH DAMAGE.
3120e439b5Sfvdl  */
3220e439b5Sfvdl 
3320e439b5Sfvdl /*-
3420e439b5Sfvdl  * Copyright (c) 1990 The Regents of the University of California.
3520e439b5Sfvdl  * All rights reserved.
3620e439b5Sfvdl  *
3720e439b5Sfvdl  * This code is derived from software contributed to Berkeley by
3820e439b5Sfvdl  * William Jolitz.
3920e439b5Sfvdl  *
4020e439b5Sfvdl  * Redistribution and use in source and binary forms, with or without
4120e439b5Sfvdl  * modification, are permitted provided that the following conditions
4220e439b5Sfvdl  * are met:
4320e439b5Sfvdl  * 1. Redistributions of source code must retain the above copyright
4420e439b5Sfvdl  *    notice, this list of conditions and the following disclaimer.
4520e439b5Sfvdl  * 2. Redistributions in binary form must reproduce the above copyright
4620e439b5Sfvdl  *    notice, this list of conditions and the following disclaimer in the
4720e439b5Sfvdl  *    documentation and/or other materials provided with the distribution.
48aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
4920e439b5Sfvdl  *    may be used to endorse or promote products derived from this software
5020e439b5Sfvdl  *    without specific prior written permission.
5120e439b5Sfvdl  *
5220e439b5Sfvdl  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5320e439b5Sfvdl  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5420e439b5Sfvdl  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5520e439b5Sfvdl  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5620e439b5Sfvdl  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5720e439b5Sfvdl  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5820e439b5Sfvdl  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5920e439b5Sfvdl  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6020e439b5Sfvdl  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6120e439b5Sfvdl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6220e439b5Sfvdl  * SUCH DAMAGE.
6320e439b5Sfvdl  *
6420e439b5Sfvdl  *	@(#)isa.h	5.7 (Berkeley) 5/9/91
6520e439b5Sfvdl  */
6620e439b5Sfvdl 
6720e439b5Sfvdl /*
6820e439b5Sfvdl  * Various pieces of the i386 port want to include this file without
6920e439b5Sfvdl  * or in spite of using isavar.h, and should be fixed.
7020e439b5Sfvdl  */
7120e439b5Sfvdl 
72f141fad5Syamt #ifndef _X86_ISA_MACHDEP_H_			/* XXX */
73f141fad5Syamt #define _X86_ISA_MACHDEP_H_			/* XXX */
7420e439b5Sfvdl 
75391925c7Sdyoung #include <sys/bus.h>
769fd1ce14Sdyoung #include <sys/device.h>
7720e439b5Sfvdl #include <dev/isa/isadmavar.h>
7820e439b5Sfvdl 
7920e439b5Sfvdl /*
8020e439b5Sfvdl  * XXX THIS FILE IS A MESS.  copyright: berkeley's probably.
8120e439b5Sfvdl  * contents from isavar.h and isareg.h, mostly the latter.
8220e439b5Sfvdl  * perhaps charles's?
8320e439b5Sfvdl  *
8420e439b5Sfvdl  * copyright from berkeley's isa.h which is now dev/isa/isareg.h.
8520e439b5Sfvdl  */
8620e439b5Sfvdl 
8720e439b5Sfvdl /*
8820e439b5Sfvdl  * Types provided to machine-independent ISA code.
8920e439b5Sfvdl  */
9020e439b5Sfvdl struct x86_isa_chipset {
9120e439b5Sfvdl 	struct isa_dma_state ic_dmastate;
9220e439b5Sfvdl };
9320e439b5Sfvdl 
9420e439b5Sfvdl typedef struct x86_isa_chipset *isa_chipset_tag_t;
9520e439b5Sfvdl 
9620e439b5Sfvdl struct isabus_attach_args;	/* XXX */
9720e439b5Sfvdl 
9820e439b5Sfvdl /*
9920e439b5Sfvdl  * Functions provided to machine-independent ISA code.
10020e439b5Sfvdl  */
101c82e679eScegger void	isa_attach_hook(device_t, device_t,
10220e439b5Sfvdl 	    struct isabus_attach_args *);
103a1ac1a18Sdyoung void	isa_detach_hook(isa_chipset_tag_t, device_t);
10420e439b5Sfvdl int	isa_intr_alloc(isa_chipset_tag_t, int, int, int *);
10520e439b5Sfvdl const struct evcnt *isa_intr_evcnt(isa_chipset_tag_t ic, int irq);
10620e439b5Sfvdl void	*isa_intr_establish(isa_chipset_tag_t ic, int irq, int type,
10720e439b5Sfvdl 	    int level, int (*ih_fun)(void *), void *ih_arg);
10889f2f7eaSjdolecek void	*isa_intr_establish_xname(isa_chipset_tag_t ic, int irq, int type,
10989f2f7eaSjdolecek 	    int level, int (*ih_fun)(void *), void *ih_arg, const char *xname);
11020e439b5Sfvdl void	isa_intr_disestablish(isa_chipset_tag_t ic, void *handler);
11120e439b5Sfvdl int	isa_mem_alloc(bus_space_tag_t, bus_size_t, bus_size_t,
11220e439b5Sfvdl 	    bus_addr_t, int, bus_addr_t *, bus_space_handle_t *);
11320e439b5Sfvdl void	isa_mem_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
11420e439b5Sfvdl 
11547b66b70Sdyoung #define	isa_dmadestroy(ic)						\
11647b66b70Sdyoung 	_isa_dmadestroy(&(ic)->ic_dmastate)
11720e439b5Sfvdl #define	isa_dmainit(ic, bst, dmat, d)					\
11820e439b5Sfvdl 	_isa_dmainit(&(ic)->ic_dmastate, (bst), (dmat), (d))
11920e439b5Sfvdl #define	isa_dmacascade(ic, c)						\
12020e439b5Sfvdl 	_isa_dmacascade(&(ic)->ic_dmastate, (c))
12120e439b5Sfvdl #define	isa_dmamaxsize(ic, c)						\
12220e439b5Sfvdl 	_isa_dmamaxsize(&(ic)->ic_dmastate, (c))
12320e439b5Sfvdl #define	isa_dmamap_create(ic, c, s, f)					\
12420e439b5Sfvdl 	_isa_dmamap_create(&(ic)->ic_dmastate, (c), (s), (f))
12520e439b5Sfvdl #define	isa_dmamap_destroy(ic, c)					\
12620e439b5Sfvdl 	_isa_dmamap_destroy(&(ic)->ic_dmastate, (c))
12720e439b5Sfvdl #define	isa_dmastart(ic, c, a, n, p, f, bf)				\
12820e439b5Sfvdl 	_isa_dmastart(&(ic)->ic_dmastate, (c), (a), (n), (p), (f), (bf))
12920e439b5Sfvdl #define	isa_dmaabort(ic, c)						\
13020e439b5Sfvdl 	_isa_dmaabort(&(ic)->ic_dmastate, (c))
13120e439b5Sfvdl #define	isa_dmacount(ic, c)						\
13220e439b5Sfvdl 	_isa_dmacount(&(ic)->ic_dmastate, (c))
13320e439b5Sfvdl #define	isa_dmafinished(ic, c)						\
13420e439b5Sfvdl 	_isa_dmafinished(&(ic)->ic_dmastate, (c))
13520e439b5Sfvdl #define	isa_dmadone(ic, c)						\
13620e439b5Sfvdl 	_isa_dmadone(&(ic)->ic_dmastate, (c))
13720e439b5Sfvdl #define	isa_dmafreeze(ic)						\
13820e439b5Sfvdl 	_isa_dmafreeze(&(ic)->ic_dmastate)
13920e439b5Sfvdl #define	isa_dmathaw(ic)							\
14020e439b5Sfvdl 	_isa_dmathaw(&(ic)->ic_dmastate)
14120e439b5Sfvdl #define	isa_dmamem_alloc(ic, c, s, ap, f)				\
14220e439b5Sfvdl 	_isa_dmamem_alloc(&(ic)->ic_dmastate, (c), (s), (ap), (f))
14320e439b5Sfvdl #define	isa_dmamem_free(ic, c, a, s)					\
14420e439b5Sfvdl 	_isa_dmamem_free(&(ic)->ic_dmastate, (c), (a), (s))
14520e439b5Sfvdl #define	isa_dmamem_map(ic, c, a, s, kp, f)				\
14620e439b5Sfvdl 	_isa_dmamem_map(&(ic)->ic_dmastate, (c), (a), (s), (kp), (f))
14720e439b5Sfvdl #define	isa_dmamem_unmap(ic, c, k, s)					\
14820e439b5Sfvdl 	_isa_dmamem_unmap(&(ic)->ic_dmastate, (c), (k), (s))
14920e439b5Sfvdl #define	isa_dmamem_mmap(ic, c, a, s, o, p, f)				\
15020e439b5Sfvdl 	_isa_dmamem_mmap(&(ic)->ic_dmastate, (c), (a), (s), (o), (p), (f))
151d88cf589Sfvdl #define isa_drq_alloc(ic, c)						\
152d88cf589Sfvdl 	_isa_drq_alloc(&(ic)->ic_dmastate, c)
153d88cf589Sfvdl #define isa_drq_free(ic, c)						\
154d88cf589Sfvdl 	_isa_drq_free(&(ic)->ic_dmastate, c)
15520e439b5Sfvdl #define	isa_drq_isfree(ic, c)						\
15620e439b5Sfvdl 	_isa_drq_isfree(&(ic)->ic_dmastate, (c))
15720e439b5Sfvdl #define	isa_malloc(ic, c, s, p, f)					\
15820e439b5Sfvdl 	_isa_malloc(&(ic)->ic_dmastate, (c), (s), (p), (f))
15920e439b5Sfvdl #define	isa_free(a, p)							\
16020e439b5Sfvdl 	_isa_free((a), (p))
16120e439b5Sfvdl #define	isa_mappage(m, o, p)						\
16220e439b5Sfvdl 	_isa_mappage((m), (o), (p))
16320e439b5Sfvdl 
16420e439b5Sfvdl /*
16520e439b5Sfvdl  * for ACPI code
16620e439b5Sfvdl  */
16720e439b5Sfvdl 
16820e439b5Sfvdl void	isa_reinit_irq(void);
16920e439b5Sfvdl 
17020e439b5Sfvdl /*
17120e439b5Sfvdl  * ALL OF THE FOLLOWING ARE MACHINE-DEPENDENT, AND SHOULD NOT BE USED
17220e439b5Sfvdl  * BY PORTABLE CODE.
17320e439b5Sfvdl  */
17420e439b5Sfvdl 
17520e439b5Sfvdl extern struct x86_bus_dma_tag isa_bus_dma_tag;
17620e439b5Sfvdl 
17720e439b5Sfvdl /*
17820e439b5Sfvdl  * XXX Various seemingly PC-specific constants, some of which may be
17920e439b5Sfvdl  * unnecessary anyway.
18020e439b5Sfvdl  */
18120e439b5Sfvdl 
18220e439b5Sfvdl /*
18320e439b5Sfvdl  * RAM Physical Address Space (ignoring the above mentioned "hole")
18420e439b5Sfvdl  */
18520e439b5Sfvdl #define	RAM_BEGIN	0x0000000	/* Start of RAM Memory */
18620e439b5Sfvdl #define	RAM_END		0x1000000	/* End of RAM Memory */
18720e439b5Sfvdl #define	RAM_SIZE	(RAM_END - RAM_BEGIN)
18820e439b5Sfvdl 
18920e439b5Sfvdl /*
19020e439b5Sfvdl  * Oddball Physical Memory Addresses
19120e439b5Sfvdl  */
19220e439b5Sfvdl #define	COMPAQ_RAMRELOC	0x80c00000	/* Compaq RAM relocation/diag */
19320e439b5Sfvdl #define	COMPAQ_RAMSETUP	0x80c00002	/* Compaq RAM setup */
19420e439b5Sfvdl #define	WEITEK_FPU	0xC0000000	/* WTL 2167 */
19520e439b5Sfvdl #define	CYRIX_EMC	0xC0000000	/* Cyrix EMC */
19620e439b5Sfvdl 
19720e439b5Sfvdl /*
19820e439b5Sfvdl  * stuff that used to be in pccons.c
19920e439b5Sfvdl  */
20020e439b5Sfvdl #define	MONO_BASE	0x3B4
20120e439b5Sfvdl #define	MONO_BUF	0xB0000
20220e439b5Sfvdl #define	CGA_BASE	0x3D4
20320e439b5Sfvdl #define	CGA_BUF		0xB8000
20420e439b5Sfvdl 
20520e439b5Sfvdl /*
20620e439b5Sfvdl  * Variables and macros to deal with the ISA I/O hole.
20720e439b5Sfvdl  * XXX These should be converted to machine- and bus-mapping-independent
20820e439b5Sfvdl  * function definitions, invoked through the softc.
20920e439b5Sfvdl  */
21020e439b5Sfvdl 
21165fae562Sbouyer extern vaddr_t atdevbase;         /* kernel virtual address of "hole" */
21220e439b5Sfvdl 
21320e439b5Sfvdl /*
21420e439b5Sfvdl  * Given a kernel virtual address for some location
21520e439b5Sfvdl  * in the "hole" I/O space, return a physical address.
21620e439b5Sfvdl  */
21765fae562Sbouyer #define ISA_PHYSADDR(v) ((bus_addr_t)(v) - atdevbase + IOM_BEGIN)
21820e439b5Sfvdl 
21920e439b5Sfvdl /*
22020e439b5Sfvdl  * Given a physical address in the "hole",
22120e439b5Sfvdl  * return a kernel virtual address.
22220e439b5Sfvdl  */
22365fae562Sbouyer #define ISA_HOLE_VADDR(p)  ((void *) ((vaddr_t)(p) - IOM_BEGIN + atdevbase))
22420e439b5Sfvdl 
22520e439b5Sfvdl 
22620e439b5Sfvdl /*
227*4075f0e7Sandvar  * Miscellaneous functions.
22820e439b5Sfvdl  */
22920e439b5Sfvdl void sysbeep(int, int);		/* beep with the system speaker */
23020e439b5Sfvdl 
231f141fad5Syamt #endif /* _X86_ISA_MACHDEP_H_ XXX */
232