head 1.1; branch 1.1.1; access; symbols libdrm-1_0_4:1.1.1.1 AGPGART_2_0:1.1.1.1 TUNGSTEN:1.1.1; locks; strict; comment @ * @; 1.1 date 2003.01.11.02.27.45; author jhartmann; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2003.01.11.02.27.45; author jhartmann; state Exp; branches; next ; desc @@ 1.1 log @Initial revision @ text @/* * AGPGART module version 2.0 * Copyright (C) 2003 Tungsten Graphics * Copyright (C) 2003 Jeff Hartmann * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /* agp_vm.h: * This file describes the generic vm interface for agpgart. * It handles basic gatt functions and memory population. */ #ifndef _AGP_VM_PRIV_H #define _AGP_VM_PRIV_H 1 #define HIGH_BIT_ULONG ((sizeof(unsigned long) << 3) - 1) /* Defines for how many agp page entries fit on a system page. */ #define U32_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(u32)) #define U64_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(u64)) #define GATT_BOT_ADDR_MASK 0xfffff #define GATT_MID_ADDR_MASK 0xff00000 #define GATT_TOP_ADDR_MASK 0xffffffff0000000 #define GATT_STATUS_MASK 0xf /* VM specific structure declarations */ #define AGP_MAPPING_IS_DIRECT (1<<0) typedef struct _agp_page_debug { struct list_head list; struct page *page; } agp_page_debug; typedef struct _agp_memory_map { struct list_head memory_mappings; u32 flags; atomic_t ref_count; struct vm_area_struct *area; struct vm_struct *karea; agp_memory *memory; unsigned long start_offset; /* In bytes, size info in vma struct */ struct page *(*mem_ofs_to_page)(agp_memory *, unsigned long); } agp_memory_map; /* Function declarations */ /* Debug stuff */ void agp_vm_print_debug_list(void); /* agp_memory manipulation */ struct page *agp_stored_mem_ofs_to_page(agp_memory *memory, unsigned long offset); struct page *agp_u32_mem_ofs_to_page(agp_memory *memory, unsigned long offset); struct page *agp_u64_mem_ofs_to_page(agp_memory *memory, unsigned long offset); int agp_u32_mem_insert_pages(agp_memory *memory, int numberAgpPages); int agp_u64_mem_insert_pages(agp_memory *memory, int numberAgpPages); void agp_mem_remove_pages(agp_memory *memory); /* Direct table vm stuff */ void agp_u32_fill_range_with_page(int start, int end, struct page *page); void agp_u64_fill_range_with_page(int start, int end, struct page *page); void agp_u64_fill_range_with_page_nopack(int start, int end, struct page *page); /* generic routines which are vm in nature. */ int agp_generic_insert_memory(agp_memory *mem, off_t pg_start, int type); int agp_generic_remove_memory(agp_memory * mem, off_t pg_start, int type); struct page *agp_generic_alloc_page(pgprot_t prot); void agp_generic_free_page(struct page *agpPage); int agp_generic_create_gatt_table(void); int agp_generic_free_gatt_table(void); agp_memory *agp_generic_alloc_by_type(size_t page_count, int type); void agp_generic_free_by_type(agp_memory * curr); int agp_generic_get_vm_config(struct pci_dev *device); /* exported functions in agp_vm.c */ void agp_free_memory(agp_memory * curr); agp_memory *agp_allocate_memory(size_t page_count, u32 type); int agp_bind_memory(agp_memory * curr, off_t pg_start); int agp_unbind_memory(agp_memory * curr); void *agp_kmap(agp_memory *memory, unsigned long start_ofs, unsigned long size); void agp_kunmap(agp_memory *memory, void *address); int agp_vma_map_memory(struct vm_area_struct *vma, agp_memory *memory, unsigned long start_ofs); unsigned long agp_usermap(struct file *filp, agp_memory *mem, unsigned long start_ofs, unsigned long size, unsigned long prot, unsigned long flags); void agp_userunmap(agp_memory *mem, void *address); /* Arch specific vm functions: break these out better */ int agp_arch_remap_memory_pages(agp_memory_map *map); void agp_arch_handle_user_pgprot(pgprot_t *prot, u32 type, int direct); void agp_arch_get_vm_configuration(void); /* Random utility functions */ int agp_validate_type_settings(agp_memory *mem, u32 type); void agp_free_key(int key); int agp_get_key(void); agp_memory *agp_create_memory(int scratch_pages, int page_count); void agp_get_size_info(int *size, int *page_order, int *num_entries); void agp_set_size_idx(int idx); void agp_calc_table_size(int size, int *num_entries, int *no_pages, int *order); /* Functions used to initialize the agp vm subsystem. */ u8 agp_read_major_minor(struct pci_dev *device, int *major, int *minor); void agp_parse_3_5_status(struct pci_dev *device, u8 cap_ptr, int *gatt64b, int *htran, int *coherent); void agp_parse_nepg(struct pci_dev *device, u8 cap_ptr, int *agp_page_shift); int agp_initialize_vm(struct pci_dev *device); /* Remapping stuff */ /* Wrappers for get_vm_area/vfree which are used during the mapping * functions. */ struct vm_struct *agp_get_vm_area(unsigned long size, unsigned long flags); void agp_free_vm_area(struct vm_struct *vm); /* vm operations */ struct page *agp_memory_nopage(struct vm_area_struct *vma, unsigned long address, int unused); void agp_vm_open(struct vm_area_struct *vma); void agp_vm_close(struct vm_area_struct *vma); /* mapping and unmapping functions */ agp_memory_map *agp_build_map(agp_memory *memory, unsigned long start_ofs, unsigned long size, int direct); void agp_vma_make_direct(agp_memory_map *map); int agp_vma_make_indirect(agp_memory_map *map); int __agp_vma_map_memory(struct vm_area_struct *vma, agp_memory *memory, unsigned long start_ofs, int direct); int agp_vm_mmap_shell(struct file *filp, struct vm_area_struct *vma); unsigned long __agp_usermap(struct file *filp, agp_memory *mem, unsigned long start_ofs, unsigned long size, unsigned long prot, unsigned long flags, int direct); unsigned long agp_kmap_indirect(agp_memory *mem, unsigned long start_ofs, unsigned long size); unsigned long agp_kmap_direct(agp_memory *memory, unsigned long start_ofs, unsigned long size); void __agp_userunmap(agp_memory_map *map); void __agp_kunmap(agp_memory_map *map); /* Generic inline functions which pack a gatt entry. * Both u32 and u64 flavors are supported. */ /* u32 format * bits 19:0: 0xfffff -> bits 31:12 * bits 27:20: 0xff00000 -> bits 11:4 * status bits -> bits 3:0 */ static __inline__ u32 pack_gatt_u32(unsigned long address, u8 type_bits) { unsigned long temp = address >> agp_bridge->agp_page_shift; return (u32)(((temp & GATT_BOT_ADDR_MASK) << 12) | ((temp & GATT_MID_ADDR_MASK) >> 16) | (type_bits & GATT_STATUS_MASK)); } /* u64 format * bits 19:0: 0xfffff -> bits 31:12 * bits 27:20: 0xff00000 -> bits 11:4 * Bits 63:32 are 59:28. * status bits -> bits 3:0 */ static __inline__ u64 pack_gatt_u64(unsigned long address, u8 type_bits) { unsigned long temp = address >> agp_bridge->agp_page_shift; return (u64)(((temp & GATT_BOT_ADDR_MASK) << 12) | ((temp & GATT_MID_ADDR_MASK) >> 16) | (((u64)temp & GATT_TOP_ADDR_MASK) << 4) | (type_bits & GATT_STATUS_MASK)); } #endif /* _AGP_VM_PRIV_H */ @ 1.1.1.1 log @Import of Agpgart 2.0 module @ text @@