agppriv.h revision 189578
190075Sobrien/*-
2169689Skan * Copyright (c) 2000 Doug Rabson
3169689Skan * All rights reserved.
490075Sobrien *
590075Sobrien * Redistribution and use in source and binary forms, with or without
690075Sobrien * modification, are permitted provided that the following conditions
7132718Skan * are met:
890075Sobrien * 1. Redistributions of source code must retain the above copyright
9132718Skan *    notice, this list of conditions and the following disclaimer.
1090075Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1190075Sobrien *    notice, this list of conditions and the following disclaimer in the
1290075Sobrien *    documentation and/or other materials provided with the distribution.
1390075Sobrien *
14132718Skan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1590075Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1690075Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1790075Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1890075Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1990075Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20132718Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21169689Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22169689Skan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2390075Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2490075Sobrien * SUCH DAMAGE.
2590075Sobrien *
2690075Sobrien *	$FreeBSD: head/sys/dev/agp/agppriv.h 189578 2009-03-09 13:27:33Z imp $
2790075Sobrien */
2890075Sobrien
2990075Sobrien#ifndef _PCI_AGPPRIV_H_
3090075Sobrien#define _PCI_AGPPRIV_H_
3190075Sobrien
3290075Sobrien/*
33117395Skan * This file *must not* be included by code outside the agp driver itself.
34117395Skan */
35117395Skan
36117395Skan#include <sys/agpio.h>
37117395Skan#include <dev/agp/agpvar.h>
38117395Skan
39117395Skan#ifdef AGP_DEBUG
40117395Skan#define AGP_DPF(fmt, ...) do {				\
41117395Skan    printf("agp: " fmt, ##__VA_ARGS__);			\
42117395Skan} while (0)
43117395Skan#else
44117395Skan#define AGP_DPF(fmt, ...) do {} while (0)
45132718Skan#endif
46132718Skan
47132718Skan#include "agp_if.h"
48132718Skan
4996263Sobrien/*
50132718Skan * Data structure to describe an AGP memory allocation.
51132718Skan */
5290075SobrienTAILQ_HEAD(agp_memory_list, agp_memory);
5390075Sobrienstruct agp_memory {
5490075Sobrien	TAILQ_ENTRY(agp_memory) am_link;	/* wiring for the tailq */
5596263Sobrien	int		am_id;			/* unique id for block */
5696263Sobrien	vm_size_t	am_size;		/* number of bytes allocated */
57169689Skan	int		am_type;		/* chipset specific type */
58169689Skan	struct vm_object *am_obj;		/* VM object owning pages */
59169689Skan	vm_offset_t	am_physical;		/* bogus hack for i810 */
6096263Sobrien	vm_offset_t	am_offset;		/* page offset if bound */
61132718Skan	int		am_is_bound;		/* non-zero if bound */
62132718Skan};
63132718Skan
64132718Skan/*
65132718Skan * All chipset drivers must have this at the start of their softc.
66132718Skan */
67132718Skanstruct agp_softc {
68132718Skan	struct resource	        *as_aperture;	/* location of aperture */
69132718Skan	int			as_aperture_rid;
70117395Skan	u_int32_t		as_maxmem;	/* allocation upper bound */
71117395Skan	u_int32_t		as_allocated;	/* amount allocated */
72117395Skan	enum agp_acquire_state	as_state;
73117395Skan	struct agp_memory_list	as_memory;	/* list of allocated memory */
74132718Skan	int			as_nextid;	/* next memory block id */
75117395Skan	int			as_isopen;	/* user device is open */
76117395Skan	struct cdev *as_devnode;	/* from make_dev */
77169689Skan	struct mtx		as_lock;	/* lock for access to GATT */
78169689Skan};
79169689Skan
80169689Skanstruct agp_gatt {
81117395Skan	u_int32_t	ag_entries;
82117395Skan	u_int32_t      *ag_virtual;
83117395Skan	vm_offset_t	ag_physical;
84117395Skan};
85169689Skan
86169689Skanvoid			agp_flush_cache(void);
8790075Sobrienu_int8_t		agp_find_caps(device_t dev);
88169689Skanstruct agp_gatt	       *agp_alloc_gatt(device_t dev);
89169689Skanvoid			agp_set_aperture_resource(device_t dev, int rid);
90169689Skanvoid			agp_free_cdev(device_t dev);
91169689Skanvoid		        agp_free_gatt(struct agp_gatt *gatt);
92169689Skanvoid			agp_free_res(device_t dev);
93169689Skanint			agp_generic_attach(device_t dev);
9490075Sobrienint			agp_generic_detach(device_t dev);
9590075Sobrienu_int32_t		agp_generic_get_aperture(device_t dev);
9690075Sobrienint			agp_generic_set_aperture(device_t dev,
9790075Sobrien						 u_int32_t aperture);
98169689Skanint			agp_generic_enable(device_t dev, u_int32_t mode);
9990075Sobrienstruct agp_memory      *agp_generic_alloc_memory(device_t dev, int type,
10090075Sobrien						 vm_size_t size);
10190075Sobrienint			agp_generic_free_memory(device_t dev,
10290075Sobrien						struct agp_memory *mem);
10390075Sobrienint			agp_generic_bind_memory(device_t dev,
10490075Sobrien						struct agp_memory *mem,
105132718Skan						vm_offset_t offset);
106169689Skanint			agp_generic_unbind_memory(device_t dev,
107132718Skan						  struct agp_memory *mem);
108132718Skan
109132718Skan#endif /* !_PCI_AGPPRIV_H_ */
110132718Skan