agppriv.h revision 173203
1281526Sandrew/*-
2281526Sandrew * Copyright (c) 2000 Doug Rabson
3281526Sandrew * All rights reserved.
4281526Sandrew *
5281526Sandrew * Redistribution and use in source and binary forms, with or without
6281526Sandrew * modification, are permitted provided that the following conditions
7281526Sandrew * are met:
8281526Sandrew * 1. Redistributions of source code must retain the above copyright
9281526Sandrew *    notice, this list of conditions and the following disclaimer.
10281526Sandrew * 2. Redistributions in binary form must reproduce the above copyright
11281526Sandrew *    notice, this list of conditions and the following disclaimer in the
12281526Sandrew *    documentation and/or other materials provided with the distribution.
13281526Sandrew *
14281526Sandrew * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15281526Sandrew * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16281526Sandrew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17281526Sandrew * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18281526Sandrew * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19281526Sandrew * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20281526Sandrew * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21281526Sandrew * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22281526Sandrew * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23281526Sandrew * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24281526Sandrew * SUCH DAMAGE.
25281526Sandrew *
26281526Sandrew *	$FreeBSD: head/sys/dev/agp/agppriv.h 173203 2007-10-30 22:09:16Z jhb $
27281526Sandrew */
28281526Sandrew
29281526Sandrew#ifndef _PCI_AGPPRIV_H_
30281526Sandrew#define _PCI_AGPPRIV_H_
31281526Sandrew
32281526Sandrew/*
33281526Sandrew * This file *must not* be included by code outside the agp driver itself.
34281526Sandrew */
35281526Sandrew
36281526Sandrew#include <sys/agpio.h>
37281526Sandrew#include <pci/agpvar.h>
38281526Sandrew
39281526Sandrew#define AGP_DEBUGxx
40281526Sandrew
41281526Sandrew#ifdef AGP_DEBUG
42281526Sandrew#define AGP_DPF(x...) do {			\
43281526Sandrew    printf("agp: ");				\
44281526Sandrew    printf(##x);				\
45281526Sandrew} while (0)
46281526Sandrew#else
47281526Sandrew#define AGP_DPF(x...) do {} while (0)
48281526Sandrew#endif
49281526Sandrew
50281526Sandrew#include "agp_if.h"
51281526Sandrew
52281526Sandrew/*
53281526Sandrew * Data structure to describe an AGP memory allocation.
54281526Sandrew */
55281526SandrewTAILQ_HEAD(agp_memory_list, agp_memory);
56281526Sandrewstruct agp_memory {
57281526Sandrew	TAILQ_ENTRY(agp_memory) am_link;	/* wiring for the tailq */
58281526Sandrew	int		am_id;			/* unique id for block */
59281526Sandrew	vm_size_t	am_size;		/* number of bytes allocated */
60281526Sandrew	int		am_type;		/* chipset specific type */
61281526Sandrew	struct vm_object *am_obj;		/* VM object owning pages */
62281526Sandrew	vm_offset_t	am_physical;		/* bogus hack for i810 */
63281526Sandrew	vm_offset_t	am_offset;		/* page offset if bound */
64281526Sandrew	int		am_is_bound;		/* non-zero if bound */
65281526Sandrew};
66281526Sandrew
67281526Sandrew/*
68281526Sandrew * All chipset drivers must have this at the start of their softc.
69281526Sandrew */
70293724Ssmhstruct agp_softc {
71281526Sandrew	struct resource	        *as_aperture;	/* location of aperture */
72281526Sandrew	int			as_aperture_rid;
73281526Sandrew	u_int32_t		as_maxmem;	/* allocation upper bound */
74281526Sandrew	u_int32_t		as_allocated;	/* amount allocated */
75281526Sandrew	enum agp_acquire_state	as_state;
76281526Sandrew	struct agp_memory_list	as_memory;	/* list of allocated memory */
77281526Sandrew	int			as_nextid;	/* next memory block id */
78281526Sandrew	int			as_isopen;	/* user device is open */
79281526Sandrew	struct cdev *as_devnode;	/* from make_dev */
80281526Sandrew	struct mtx		as_lock;	/* lock for access to GATT */
81281526Sandrew};
82281526Sandrew
83281526Sandrewstruct agp_gatt {
84281526Sandrew	u_int32_t	ag_entries;
85281526Sandrew	u_int32_t      *ag_virtual;
86281526Sandrew	vm_offset_t	ag_physical;
87281526Sandrew};
88281526Sandrew
89281526Sandrewvoid			agp_flush_cache(void);
90281526Sandrewu_int8_t		agp_find_caps(device_t dev);
91281526Sandrewstruct agp_gatt	       *agp_alloc_gatt(device_t dev);
92281526Sandrewvoid			agp_set_aperture_resource(device_t dev, int rid);
93281526Sandrewvoid			agp_free_cdev(device_t dev);
94281526Sandrewvoid		        agp_free_gatt(struct agp_gatt *gatt);
95281526Sandrewvoid			agp_free_res(device_t dev);
96int			agp_generic_attach(device_t dev);
97int			agp_generic_detach(device_t dev);
98int			agp_generic_get_aperture(device_t dev);
99int			agp_generic_set_aperture(device_t dev,
100						 u_int32_t aperture);
101int			agp_generic_enable(device_t dev, u_int32_t mode);
102struct agp_memory      *agp_generic_alloc_memory(device_t dev, int type,
103						 vm_size_t size);
104int			agp_generic_free_memory(device_t dev,
105						struct agp_memory *mem);
106int			agp_generic_bind_memory(device_t dev,
107						struct agp_memory *mem,
108						vm_offset_t offset);
109int			agp_generic_unbind_memory(device_t dev,
110						  struct agp_memory *mem);
111
112#endif /* !_PCI_AGPPRIV_H_ */
113