FreeBSD kernel AGP device code
agp.c File Reference
#include <sys/cdefs.h>
#include "opt_agp.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/ioccom.h>
#include <sys/agpio.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/rwlock.h>
#include <dev/agp/agppriv.h>
#include <dev/agp/agpvar.h>
#include <dev/agp/agpreg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/vm_kern.h>
#include <vm/vm_param.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_pageout.h>
#include <vm/pmap.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
Include dependency graph for agp.c:

Go to the source code of this file.

Macros

#define AGP_MAX_SIZE   nitems(agp_max)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 MODULE_VERSION (agp, 1)
 
 MALLOC_DEFINE (M_AGP, "agp", "AGP data structures")
 
u_int8_t agp_find_caps (device_t dev)
 
static device_t agp_find_display (void)
 
struct agp_gattagp_alloc_gatt (device_t dev)
 
void agp_free_gatt (struct agp_gatt *gatt)
 
void agp_set_aperture_resource (device_t dev, int rid)
 
int agp_generic_attach (device_t dev)
 
void agp_free_cdev (device_t dev)
 
void agp_free_res (device_t dev)
 
int agp_generic_detach (device_t dev)
 
u_int32_t agp_generic_get_aperture (device_t dev)
 
int agp_generic_set_aperture (device_t dev, u_int32_t aperture)
 
static int agp_v3_enable (device_t dev, device_t mdev, u_int32_t mode)
 
static int agp_v2_enable (device_t dev, device_t mdev, u_int32_t mode)
 
int agp_generic_enable (device_t dev, u_int32_t mode)
 
struct agp_memoryagp_generic_alloc_memory (device_t dev, int type, vm_size_t size)
 
int agp_generic_free_memory (device_t dev, struct agp_memory *mem)
 
int agp_generic_bind_memory (device_t dev, struct agp_memory *mem, vm_offset_t offset)
 
int agp_generic_unbind_memory (device_t dev, struct agp_memory *mem)
 
static int agp_acquire_helper (device_t dev, enum agp_acquire_state state)
 
static int agp_release_helper (device_t dev, enum agp_acquire_state state)
 
static struct agp_memoryagp_find_memory (device_t dev, int id)
 
static int agp_info_user (device_t dev, agp_info *info)
 
static int agp_setup_user (device_t dev, agp_setup *setup)
 
static int agp_allocate_user (device_t dev, agp_allocate *alloc)
 
static int agp_deallocate_user (device_t dev, int id)
 
static int agp_bind_user (device_t dev, agp_bind *bind)
 
static int agp_unbind_user (device_t dev, agp_unbind *unbind)
 
static int agp_chipset_flush (device_t dev)
 
static int agp_open (struct cdev *kdev, int oflags, int devtype, struct thread *td)
 
static int agp_close (struct cdev *kdev, int fflag, int devtype, struct thread *td)
 
static int agp_ioctl (struct cdev *kdev, u_long cmd, caddr_t data, int fflag, struct thread *td)
 
static int agp_mmap (struct cdev *kdev, vm_ooffset_t offset, vm_paddr_t *paddr, int prot, vm_memattr_t *memattr)
 
device_t agp_find_device ()
 
enum agp_acquire_state agp_state (device_t dev)
 
void agp_get_info (device_t dev, struct agp_info *info)
 
int agp_acquire (device_t dev)
 
int agp_release (device_t dev)
 
int agp_enable (device_t dev, u_int32_t mode)
 
void * agp_alloc_memory (device_t dev, int type, vm_size_t bytes)
 
void agp_free_memory (device_t dev, void *handle)
 
int agp_bind_memory (device_t dev, void *handle, vm_offset_t offset)
 
int agp_unbind_memory (device_t dev, void *handle)
 
void agp_memory_info (device_t dev, void *handle, struct agp_memory_info *mi)
 
int agp_bind_pages (device_t dev, vm_page_t *pages, vm_size_t size, vm_offset_t offset)
 
int agp_unbind_pages (device_t dev, vm_size_t size, vm_offset_t offset)
 

Variables

static d_open_t agp_open
 
static d_close_t agp_close
 
static d_ioctl_t agp_ioctl
 
static d_mmap_t agp_mmap
 
static struct cdevsw agp_cdevsw
 
static devclass_t agp_devclass
 
static u_int agp_max [][2]
 

Macro Definition Documentation

◆ AGP_MAX_SIZE

#define AGP_MAX_SIZE   nitems(agp_max)

Definition at line 189 of file agp.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ agp_acquire()

int agp_acquire ( device_t  dev)

Definition at line 954 of file agp.c.

References agp_acquire_helper(), and AGP_ACQUIRE_KERNEL.

Here is the call graph for this function:

◆ agp_acquire_helper()

static int agp_acquire_helper ( device_t  dev,
enum agp_acquire_state  state 
)
static

Definition at line 690 of file agp.c.

References AGP_ACQUIRE_FREE, and agp_softc::as_state.

Referenced by agp_acquire(), and agp_ioctl().

Here is the caller graph for this function:

◆ agp_alloc_gatt()

struct agp_gatt * agp_alloc_gatt ( device_t  dev)

Definition at line 135 of file agp.c.

References agp_gatt::ag_entries, agp_gatt::ag_physical, and agp_gatt::ag_virtual.

Referenced by agp_ali_attach(), agp_amd64_attach(), agp_apple_attach(), agp_intel_attach(), agp_nvidia_attach(), agp_sis_attach(), and agp_via_attach().

Here is the caller graph for this function:

◆ agp_alloc_memory()

void * agp_alloc_memory ( device_t  dev,
int  type,
vm_size_t  bytes 
)

Definition at line 971 of file agp.c.

References type.

◆ agp_allocate_user()

static int agp_allocate_user ( device_t  dev,
agp_allocate *  alloc 
)
static

Definition at line 760 of file agp.c.

References agp_memory::am_id, agp_memory::am_physical, and mem.

Referenced by agp_ioctl().

Here is the caller graph for this function:

◆ agp_bind_memory()

int agp_bind_memory ( device_t  dev,
void *  handle,
vm_offset_t  offset 
)

Definition at line 982 of file agp.c.

References handle, mem, and offset.

◆ agp_bind_pages()

int agp_bind_pages ( device_t  dev,
vm_page_t *  pages,
vm_size_t  size,
vm_offset_t  offset 
)

Definition at line 1006 of file agp.c.

References AGP_DPF, agp_softc::as_lock, offset, and size.

◆ agp_bind_user()

static int agp_bind_user ( device_t  dev,
agp_bind *  bind 
)
static

Definition at line 790 of file agp.c.

References agp_find_memory(), and mem.

Referenced by agp_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agp_chipset_flush()

static int agp_chipset_flush ( device_t  dev)
static

Definition at line 812 of file agp.c.

Referenced by agp_ioctl().

Here is the caller graph for this function:

◆ agp_close()

static int agp_close ( struct cdev *  kdev,
int  fflag,
int  devtype,
struct thread *  td 
)
static

Definition at line 833 of file agp.c.

References AGP_ACQUIRE_USER, agp_release_helper(), agp_memory::am_is_bound, agp_softc::as_isopen, agp_softc::as_memory, agp_softc::as_state, and mem.

Here is the call graph for this function:

◆ agp_deallocate_user()

static int agp_deallocate_user ( device_t  dev,
int  id 
)
static

Definition at line 777 of file agp.c.

References agp_find_memory(), and mem.

Referenced by agp_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agp_enable()

int agp_enable ( device_t  dev,
u_int32_t  mode 
)

Definition at line 966 of file agp.c.

References mode.

◆ agp_find_caps()

u_int8_t agp_find_caps ( device_t  dev)

◆ agp_find_device()

device_t agp_find_device ( void  )

Definition at line 910 of file agp.c.

References agp_devclass.

◆ agp_find_display()

static device_t agp_find_display ( void  )
static

Definition at line 105 of file agp.c.

References agp_find_caps().

Referenced by agp_generic_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agp_find_memory()

static struct agp_memory * agp_find_memory ( device_t  dev,
int  id 
)
static

Definition at line 717 of file agp.c.

References AGP_DPF, agp_memory::am_id, agp_softc::as_memory, and mem.

Referenced by agp_bind_user(), agp_deallocate_user(), and agp_unbind_user().

Here is the caller graph for this function:

◆ agp_free_cdev()

void agp_free_cdev ( device_t  dev)

◆ agp_free_gatt()

void agp_free_gatt ( struct agp_gatt gatt)

Definition at line 171 of file agp.c.

References agp_gatt::ag_entries, and agp_gatt::ag_virtual.

Referenced by agp_ali_detach(), agp_amd64_detach(), agp_apple_detach(), agp_intel_detach(), agp_nvidia_detach(), agp_sis_detach(), and agp_via_detach().

Here is the caller graph for this function:

◆ agp_free_memory()

void agp_free_memory ( device_t  dev,
void *  handle 
)

Definition at line 976 of file agp.c.

References handle, and mem.

◆ agp_free_res()

◆ agp_generic_alloc_memory()

◆ agp_generic_attach()

◆ agp_generic_bind_memory()

int agp_generic_bind_memory ( device_t  dev,
struct agp_memory mem,
vm_offset_t  offset 
)

Definition at line 543 of file agp.c.

References AGP_DPF, agp_memory::am_is_bound, agp_memory::am_obj, agp_memory::am_offset, agp_memory::am_size, agp_softc::as_lock, mem, and offset.

Referenced by agp_i810_bind_memory().

Here is the caller graph for this function:

◆ agp_generic_detach()

int agp_generic_detach ( device_t  dev)

Definition at line 303 of file agp.c.

References agp_free_cdev(), and agp_free_res().

Referenced by agp_ali_attach(), agp_amd64_attach(), agp_amd_attach(), agp_apple_attach(), agp_ati_attach(), agp_i810_attach(), agp_intel_attach(), agp_nvidia_attach(), agp_sis_attach(), and agp_via_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agp_generic_enable()

int agp_generic_enable ( device_t  dev,
u_int32_t  mode 
)

Definition at line 466 of file agp.c.

References AGP_DPF, agp_find_caps(), agp_find_display(), AGP_STATUS, agp_v2_enable(), agp_v3_enable(), and mode.

Here is the call graph for this function:

◆ agp_generic_free_memory()

int agp_generic_free_memory ( device_t  dev,
struct agp_memory mem 
)

◆ agp_generic_get_aperture()

u_int32_t agp_generic_get_aperture ( device_t  dev)

Default AGP aperture size detection which simply returns the size of the aperture's PCI resource.

Definition at line 316 of file agp.c.

References agp_softc::as_aperture.

◆ agp_generic_set_aperture()

int agp_generic_set_aperture ( device_t  dev,
u_int32_t  aperture 
)

Default AGP aperture size setting function, which simply doesn't allow changes to resource size.

Definition at line 328 of file agp.c.

References aperture.

Referenced by agp_i915_set_aperture().

Here is the caller graph for this function:

◆ agp_generic_unbind_memory()

int agp_generic_unbind_memory ( device_t  dev,
struct agp_memory mem 
)

Definition at line 649 of file agp.c.

References agp_memory::am_is_bound, agp_memory::am_obj, agp_memory::am_offset, agp_memory::am_size, agp_softc::as_lock, and mem.

Referenced by agp_i810_unbind_memory().

Here is the caller graph for this function:

◆ agp_get_info()

void agp_get_info ( device_t  dev,
struct agp_info info 
)

◆ agp_info_user()

static int agp_info_user ( device_t  dev,
agp_info info 
)
static

Definition at line 734 of file agp.c.

References agp_find_caps(), AGP_STATUS, agp_softc::as_allocated, agp_softc::as_aperture, and agp_softc::as_maxmem.

Referenced by agp_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agp_ioctl()

static int agp_ioctl ( struct cdev *  kdev,
u_long  cmd,
caddr_t  data,
int  fflag,
struct thread *  td 
)
static

◆ agp_memory_info()

◆ agp_mmap()

static int agp_mmap ( struct cdev *  kdev,
vm_ooffset_t  offset,
vm_paddr_t *  paddr,
int  prot,
vm_memattr_t *  memattr 
)
static

Definition at line 893 of file agp.c.

References agp_softc::as_aperture, and offset.

◆ agp_open()

static int agp_open ( struct cdev *  kdev,
int  oflags,
int  devtype,
struct thread *  td 
)
static

Definition at line 819 of file agp.c.

References agp_softc::as_isopen.

◆ agp_release()

int agp_release ( device_t  dev)

Definition at line 960 of file agp.c.

References AGP_ACQUIRE_KERNEL, and agp_release_helper().

Here is the call graph for this function:

◆ agp_release_helper()

static int agp_release_helper ( device_t  dev,
enum agp_acquire_state  state 
)
static

Definition at line 702 of file agp.c.

References AGP_ACQUIRE_FREE, and agp_softc::as_state.

Referenced by agp_close(), agp_ioctl(), and agp_release().

Here is the caller graph for this function:

◆ agp_set_aperture_resource()

void agp_set_aperture_resource ( device_t  dev,
int  rid 
)

Sets the PCI resource which represents the AGP aperture.

If not called, the default AGP aperture resource of AGP_APBASE will be used. Must be called before agp_generic_attach().

Definition at line 198 of file agp.c.

References agp_softc::as_aperture_rid.

Referenced by agp_apple_attach(), and agp_i810_attach().

Here is the caller graph for this function:

◆ agp_setup_user()

static int agp_setup_user ( device_t  dev,
agp_setup *  setup 
)
static

Definition at line 754 of file agp.c.

Referenced by agp_ioctl().

Here is the caller graph for this function:

◆ agp_state()

enum agp_acquire_state agp_state ( device_t  dev)

Definition at line 931 of file agp.c.

References agp_softc::as_state.

◆ agp_unbind_memory()

int agp_unbind_memory ( device_t  dev,
void *  handle 
)

Definition at line 988 of file agp.c.

References handle, and mem.

◆ agp_unbind_pages()

int agp_unbind_pages ( device_t  dev,
vm_size_t  size,
vm_offset_t  offset 
)

Definition at line 1057 of file agp.c.

References agp_softc::as_lock, offset, and size.

◆ agp_unbind_user()

static int agp_unbind_user ( device_t  dev,
agp_unbind *  unbind 
)
static

Definition at line 801 of file agp.c.

References agp_find_memory(), and mem.

Referenced by agp_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agp_v2_enable()

static int agp_v2_enable ( device_t  dev,
device_t  mdev,
u_int32_t  mode 
)
static

Definition at line 413 of file agp.c.

References AGP_COMMAND, agp_find_caps(), AGP_STATUS, and mode.

Referenced by agp_generic_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agp_v3_enable()

static int agp_v3_enable ( device_t  dev,
device_t  mdev,
u_int32_t  mode 
)
static

Definition at line 344 of file agp.c.

References AGP_COMMAND, agp_find_caps(), AGP_STATUS, and mode.

Referenced by agp_generic_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MALLOC_DEFINE()

MALLOC_DEFINE ( M_AGP  ,
"agp"  ,
"AGP data structures"   
)

◆ MODULE_VERSION()

MODULE_VERSION ( agp  ,
 
)

Variable Documentation

◆ agp_cdevsw

struct cdevsw agp_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_flags = D_NEEDGIANT,
.d_open = agp_open,
.d_close = agp_close,
.d_ioctl = agp_ioctl,
.d_mmap = agp_mmap,
.d_name = "agp",
}
static d_mmap_t agp_mmap
Definition: agp.c:75
static d_close_t agp_close
Definition: agp.c:73
static d_open_t agp_open
Definition: agp.c:72
static d_ioctl_t agp_ioctl
Definition: agp.c:74

Definition at line 77 of file agp.c.

Referenced by agp_generic_attach().

◆ agp_close

d_close_t agp_close
static

Definition at line 73 of file agp.c.

◆ agp_devclass

devclass_t agp_devclass
static

Definition at line 87 of file agp.c.

Referenced by agp_find_device(), and agp_generic_attach().

◆ agp_ioctl

d_ioctl_t agp_ioctl
static

Definition at line 74 of file agp.c.

◆ agp_max

u_int agp_max[][2]
static
Initial value:
= {
{0, 0},
{32, 4},
{64, 28},
{128, 96},
{256, 204},
{512, 440},
{1024, 942},
{2048, 1920},
{4096, 3932}
}

Definition at line 178 of file agp.c.

Referenced by agp_generic_attach().

◆ agp_mmap

d_mmap_t agp_mmap
static

Definition at line 75 of file agp.c.

◆ agp_open

d_open_t agp_open
static

Definition at line 72 of file agp.c.