xref: /freebsd-src/sys/dev/agp/agppriv.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
159747216SDoug Rabson /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
459747216SDoug Rabson  * Copyright (c) 2000 Doug Rabson
559747216SDoug Rabson  * All rights reserved.
659747216SDoug Rabson  *
759747216SDoug Rabson  * Redistribution and use in source and binary forms, with or without
859747216SDoug Rabson  * modification, are permitted provided that the following conditions
959747216SDoug Rabson  * are met:
1059747216SDoug Rabson  * 1. Redistributions of source code must retain the above copyright
1159747216SDoug Rabson  *    notice, this list of conditions and the following disclaimer.
1259747216SDoug Rabson  * 2. Redistributions in binary form must reproduce the above copyright
1359747216SDoug Rabson  *    notice, this list of conditions and the following disclaimer in the
1459747216SDoug Rabson  *    documentation and/or other materials provided with the distribution.
1559747216SDoug Rabson  *
1659747216SDoug Rabson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1759747216SDoug Rabson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1859747216SDoug Rabson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1959747216SDoug Rabson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2059747216SDoug Rabson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2159747216SDoug Rabson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2259747216SDoug Rabson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2359747216SDoug Rabson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2459747216SDoug Rabson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2559747216SDoug Rabson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2659747216SDoug Rabson  * SUCH DAMAGE.
2759747216SDoug Rabson  */
2859747216SDoug Rabson 
2959747216SDoug Rabson #ifndef _PCI_AGPPRIV_H_
3059747216SDoug Rabson #define _PCI_AGPPRIV_H_
3159747216SDoug Rabson 
3259747216SDoug Rabson /*
3359747216SDoug Rabson  * This file *must not* be included by code outside the agp driver itself.
3459747216SDoug Rabson  */
3559747216SDoug Rabson 
3659747216SDoug Rabson #include <sys/agpio.h>
37dbac8ff4SJohn Baldwin #include <dev/agp/agpvar.h>
3859747216SDoug Rabson 
3959747216SDoug Rabson #ifdef AGP_DEBUG
40b02ae948SRobert Noland #define AGP_DPF(fmt, ...) do {				\
41213ab42eSRobert Noland     printf("agp: " fmt, ##__VA_ARGS__);			\
4259747216SDoug Rabson } while (0)
4359747216SDoug Rabson #else
44b02ae948SRobert Noland #define AGP_DPF(fmt, ...) do {} while (0)
4559747216SDoug Rabson #endif
4659747216SDoug Rabson 
4759747216SDoug Rabson #include "agp_if.h"
4859747216SDoug Rabson 
4959747216SDoug Rabson /*
5059747216SDoug Rabson  * Data structure to describe an AGP memory allocation.
5159747216SDoug Rabson  */
5259747216SDoug Rabson TAILQ_HEAD(agp_memory_list, agp_memory);
5359747216SDoug Rabson struct agp_memory {
5459747216SDoug Rabson 	TAILQ_ENTRY(agp_memory) am_link;	/* wiring for the tailq */
5559747216SDoug Rabson 	int		am_id;			/* unique id for block */
5659747216SDoug Rabson 	vm_size_t	am_size;		/* number of bytes allocated */
57e547d6fdSDoug Rabson 	int		am_type;		/* chipset specific type */
5859747216SDoug Rabson 	struct vm_object *am_obj;		/* VM object owning pages */
5959747216SDoug Rabson 	vm_offset_t	am_physical;		/* bogus hack for i810 */
6059747216SDoug Rabson 	vm_offset_t	am_offset;		/* page offset if bound */
6159747216SDoug Rabson 	int		am_is_bound;		/* non-zero if bound */
6259747216SDoug Rabson };
6359747216SDoug Rabson 
6459747216SDoug Rabson /*
6559747216SDoug Rabson  * All chipset drivers must have this at the start of their softc.
6659747216SDoug Rabson  */
6759747216SDoug Rabson struct agp_softc {
6859747216SDoug Rabson 	struct resource	        *as_aperture;	/* location of aperture */
69d450e052SEric Anholt 	int			as_aperture_rid;
7059747216SDoug Rabson 	u_int32_t		as_maxmem;	/* allocation upper bound */
7159747216SDoug Rabson 	u_int32_t		as_allocated;	/* amount allocated */
7259747216SDoug Rabson 	enum agp_acquire_state	as_state;
7359747216SDoug Rabson 	struct agp_memory_list	as_memory;	/* list of allocated memory */
7459747216SDoug Rabson 	int			as_nextid;	/* next memory block id */
7559747216SDoug Rabson 	int			as_isopen;	/* user device is open */
7689c9c53dSPoul-Henning Kamp 	struct cdev		*as_devnode;	/* from make_dev */
77437ea82cSMark Johnston 	struct cdev		*as_devalias;
78d8a821e8SMaxime Henrion 	struct mtx		as_lock;	/* lock for access to GATT */
7959747216SDoug Rabson };
8059747216SDoug Rabson 
8159747216SDoug Rabson struct agp_gatt {
8259747216SDoug Rabson 	u_int32_t	ag_entries;
8359747216SDoug Rabson 	u_int32_t      *ag_virtual;
8459747216SDoug Rabson 	vm_offset_t	ag_physical;
8559747216SDoug Rabson };
8659747216SDoug Rabson 
8759747216SDoug Rabson u_int8_t		agp_find_caps(device_t dev);
8859747216SDoug Rabson struct agp_gatt	       *agp_alloc_gatt(device_t dev);
89d450e052SEric Anholt void			agp_set_aperture_resource(device_t dev, int rid);
90f82a1d49SJohn Baldwin void			agp_free_cdev(device_t dev);
9159747216SDoug Rabson void		        agp_free_gatt(struct agp_gatt *gatt);
92f82a1d49SJohn Baldwin void			agp_free_res(device_t dev);
9359747216SDoug Rabson int			agp_generic_attach(device_t dev);
9459747216SDoug Rabson int			agp_generic_detach(device_t dev);
95cd6d5177SWarner Losh u_int32_t		agp_generic_get_aperture(device_t dev);
96d450e052SEric Anholt int			agp_generic_set_aperture(device_t dev,
97d450e052SEric Anholt 						 u_int32_t aperture);
9859747216SDoug Rabson int			agp_generic_enable(device_t dev, u_int32_t mode);
9959747216SDoug Rabson struct agp_memory      *agp_generic_alloc_memory(device_t dev, int type,
10059747216SDoug Rabson 						 vm_size_t size);
10159747216SDoug Rabson int			agp_generic_free_memory(device_t dev,
10259747216SDoug Rabson 						struct agp_memory *mem);
10359747216SDoug Rabson int			agp_generic_bind_memory(device_t dev,
10459747216SDoug Rabson 						struct agp_memory *mem,
10559747216SDoug Rabson 						vm_offset_t offset);
10659747216SDoug Rabson int			agp_generic_unbind_memory(device_t dev,
10759747216SDoug Rabson 						  struct agp_memory *mem);
10859747216SDoug Rabson 
10959747216SDoug Rabson #endif /* !_PCI_AGPPRIV_H_ */
110