/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2011 The FreeBSD Foundation4*5* This software was developed by Konstantin Belousov under sponsorship from6* the FreeBSD Foundation.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions and the following disclaimer.13* 2. Redistributions in binary form must reproduce the above copyright14* notice, this list of conditions and the following disclaimer in the15* documentation and/or other materials provided with the distribution.16*17* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE21* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*/2930#ifndef AGP_AGP_I810_H31#define AGP_AGP_I810_H3233#include <sys/param.h>34#include <sys/rman.h>35#include <sys/sglist.h>3637#include <vm/vm.h>38#include <vm/vm_page.h>3940/* Special gtt memory types */41#define AGP_DCACHE_MEMORY 142#define AGP_PHYS_MEMORY 24344/* New caching attributes for gen6/sandybridge */45#define AGP_USER_CACHED_MEMORY_LLC_MLC (AGP_USER_TYPES + 2)46#define AGP_USER_UNCACHED_MEMORY (AGP_USER_TYPES + 4)4748/* flag for GFDT type */49#define AGP_USER_CACHED_MEMORY_GFDT (1 << 3)5051struct intel_gtt {52/* Size of memory reserved for graphics by the BIOS */53unsigned int stolen_size;54/* Total number of gtt entries. */55unsigned int gtt_total_entries;56/* Part of the gtt that is mappable by the cpu, for those chips where57* this is not the full gtt. */58unsigned int gtt_mappable_entries;59/* Whether i915 needs to use the dmar apis or not. */60unsigned int needs_dmar : 1;61/* Whether we idle the gpu before mapping/unmapping */62unsigned int do_idle_maps : 1;63/* Share the scratch page dma with ppgtts. */64vm_paddr_t scratch_page_dma;65vm_page_t scratch_page;66/* for ppgtt PDE access */67uint32_t *gtt;68/* needed for ioremap in drm/i915 */69bus_addr_t gma_bus_addr;70};7172struct intel_gtt agp_intel_gtt_get(device_t dev);73int agp_intel_gtt_chipset_flush(device_t dev);74void agp_intel_gtt_unmap_memory(device_t dev, struct sglist *sg_list);75void agp_intel_gtt_clear_range(device_t dev, u_int first_entry,76u_int num_entries);77int agp_intel_gtt_map_memory(device_t dev, vm_page_t *pages, u_int num_entries,78struct sglist **sg_list);79void agp_intel_gtt_insert_sg_entries(device_t dev, struct sglist *sg_list,80u_int pg_start, u_int flags);81void agp_intel_gtt_insert_pages(device_t dev, u_int first_entry,82u_int num_entries, vm_page_t *pages, u_int flags);8384struct intel_gtt *intel_gtt_get(void);85int intel_gtt_chipset_flush(void);86void intel_gtt_unmap_memory(struct sglist *sg_list);87void intel_gtt_clear_range(u_int first_entry, u_int num_entries);88void intel_gtt_install_pte(u_int index, vm_paddr_t addr, u_int flags);89int intel_gtt_map_memory(vm_page_t *pages, u_int num_entries,90struct sglist **sg_list);91void intel_gtt_insert_sg_entries(struct sglist *sg_list, u_int pg_start,92u_int flags);93void intel_gtt_insert_pages(u_int first_entry, u_int num_entries,94vm_page_t *pages, u_int flags);95vm_paddr_t intel_gtt_read_pte_paddr(u_int entry);96u_int32_t intel_gtt_read_pte(u_int entry);97device_t intel_gtt_get_bridge_device(void);98void intel_gtt_write(u_int entry, uint32_t val);99100#endif101102103