#ifndef _PCI_AGPVAR_H_
#define _PCI_AGPVAR_H_
#include <sys/mallocvar.h>
#include <sys/mutex.h>
#include <dev/pci/pcivar.h>
struct agpbus_attach_args {
char *_apa_busname;
struct pci_attach_args apa_pci_args;
};
enum agp_acquire_state {
AGP_ACQUIRE_FREE,
AGP_ACQUIRE_USER,
AGP_ACQUIRE_KERNEL
};
struct agp_info {
u_int32_t ai_mode;
bus_addr_t ai_aperture_base;
bus_size_t ai_aperture_size;
vsize_t ai_memory_allowed;
vsize_t ai_memory_used;
u_int32_t ai_devid;
};
struct agp_memory_info {
vsize_t ami_size;
bus_addr_t ami_physical;
off_t ami_offset;
int ami_is_bound;
};
#ifdef AGP_DEBUG
#define AGP_DPF(x) do { \
printf("agp: "); \
printf x; \
} while (0)
#else
#define AGP_DPF(x)
#endif
#define AGPUNIT(x) minor(x)
TAILQ_HEAD(agp_memory_list, agp_memory);
struct agp_memory {
TAILQ_ENTRY(agp_memory) am_link;
int am_id;
vsize_t am_size;
int am_type;
off_t am_offset;
int am_is_bound;
bus_addr_t am_physical;
void * am_virtual;
bus_dmamap_t am_dmamap;
bus_dma_segment_t *am_dmaseg;
int am_nseg;
};
struct agp_softc;
struct agp_methods {
u_int32_t (*get_aperture)(struct agp_softc *);
int (*set_aperture)(struct agp_softc *, u_int32_t);
int (*bind_page)(struct agp_softc *, off_t, bus_addr_t);
int (*unbind_page)(struct agp_softc *, off_t);
void (*flush_tlb)(struct agp_softc *);
int (*enable)(struct agp_softc *, u_int32_t mode);
struct agp_memory *(*alloc_memory)(struct agp_softc *, int, vsize_t);
int (*free_memory)(struct agp_softc *, struct agp_memory *);
int (*bind_memory)(struct agp_softc *, struct agp_memory *, off_t);
int (*unbind_memory)(struct agp_softc *, struct agp_memory *);
};
#define AGP_GET_APERTURE(sc) ((sc)->as_methods->get_aperture(sc))
#define AGP_SET_APERTURE(sc,a) ((sc)->as_methods->set_aperture((sc),(a)))
#define AGP_BIND_PAGE(sc,o,p) ((sc)->as_methods->bind_page((sc),(o),(p)))
#define AGP_UNBIND_PAGE(sc,o) ((sc)->as_methods->unbind_page((sc), (o)))
#define AGP_FLUSH_TLB(sc) ((sc)->as_methods->flush_tlb(sc))
#define AGP_ENABLE(sc,m) ((sc)->as_methods->enable((sc),(m)))
#define AGP_ALLOC_MEMORY(sc,t,s) ((sc)->as_methods->alloc_memory((sc),(t),(s)))
#define AGP_FREE_MEMORY(sc,m) ((sc)->as_methods->free_memory((sc),(m)))
#define AGP_BIND_MEMORY(sc,m,o) ((sc)->as_methods->bind_memory((sc),(m),(o)))
#define AGP_UNBIND_MEMORY(sc,m) ((sc)->as_methods->unbind_memory((sc),(m)))
struct agp_softc {
device_t as_dev;
bus_space_tag_t as_apt;
int as_capoff;
bus_addr_t as_apaddr;
bus_size_t as_apsize;
int as_apflags;
bus_dma_tag_t as_dmat;
u_int32_t as_maxmem;
u_int32_t as_allocated;
enum agp_acquire_state as_state;
struct agp_memory_list as_memory;
int as_nextid;
int as_isopen;
#if 0
dev_t as_devnode;
#endif
kmutex_t as_mtx;
struct agp_methods *as_methods;
void *as_chipc;
pci_chipset_tag_t as_pc;
pcitag_t as_tag;
pcireg_t as_id;
};
struct agp_gatt {
u_int32_t ag_entries;
u_int32_t *ag_virtual;
bus_addr_t ag_physical;
bus_dmamap_t ag_dmamap;
bus_dma_segment_t ag_dmaseg;
size_t ag_size;
};
int agpbusprint(void *, const char *);
void agp_flush_cache(void);
int agp_find_caps(pci_chipset_tag_t, pcitag_t);
int agp_map_aperture(struct pci_attach_args *, struct agp_softc *, int);
struct agp_gatt *agp_alloc_gatt(struct agp_softc *);
void agp_free_gatt(struct agp_softc *, struct agp_gatt *);
int agp_generic_attach(struct agp_softc *);
int agp_generic_detach(struct agp_softc *);
int agp_generic_enable(struct agp_softc *, u_int32_t);
struct agp_memory *agp_generic_alloc_memory(struct agp_softc *, int, vsize_t);
int agp_generic_free_memory(struct agp_softc *, struct agp_memory *);
int agp_generic_bind_memory(struct agp_softc *, struct agp_memory *, off_t);
int agp_generic_bind_memory_bounded(struct agp_softc *, struct agp_memory *,
off_t, off_t, off_t);
int agp_generic_unbind_memory(struct agp_softc *, struct agp_memory *);
int agp_amd_match(const struct pci_attach_args *);
int agp_amd64_match(const struct pci_attach_args *);
int agp_ali_attach(device_t, device_t, void *);
int agp_amd_attach(device_t, device_t, void *);
int agp_apple_attach(device_t, device_t, void *);
int agp_i810_attach(device_t, device_t, void *);
int agp_intel_attach(device_t, device_t, void *);
int agp_sis_attach(device_t, device_t, void *);
int agp_nvidia_attach(device_t, device_t, void *);
int agp_via_attach(device_t, device_t, void *);
int agp_amd64_attach(device_t, device_t, void *);
int agp_alloc_dmamem(bus_dma_tag_t, size_t, int, bus_dmamap_t *, void **,
bus_addr_t *, bus_dma_segment_t *, int, int *);
void agp_free_dmamem(bus_dma_tag_t, size_t, bus_dmamap_t, void *,
bus_dma_segment_t *, int) ;
MALLOC_DECLARE(M_AGP);
void *agp_find_device(int);
enum agp_acquire_state agp_state(void *);
void agp_get_info(void *, struct agp_info *);
int agp_acquire(void *);
int agp_release(void *);
int agp_enable(void *, u_int32_t);
void *agp_alloc_memory(void *, int, vsize_t);
void agp_free_memory(void *, void *);
int agp_bind_memory(void *, void *, off_t);
int agp_unbind_memory(void *, void *);
void agp_memory_info(void *, void *, struct agp_memory_info *);
int agp_i810_borrow(bus_addr_t, bus_size_t, bus_space_handle_t *);
#endif