14478Skz151634 /* 24478Skz151634 * CDDL HEADER START 34478Skz151634 * 44478Skz151634 * The contents of this file are subject to the terms of the 54478Skz151634 * Common Development and Distribution License (the "License"). 64478Skz151634 * You may not use this file except in compliance with the License. 74478Skz151634 * 84478Skz151634 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 94478Skz151634 * or http://www.opensolaris.org/os/licensing. 104478Skz151634 * See the License for the specific language governing permissions 114478Skz151634 * and limitations under the License. 124478Skz151634 * 134478Skz151634 * When distributing Covered Code, include this CDDL HEADER in each 144478Skz151634 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 154478Skz151634 * If applicable, add the following below this CDDL HEADER, with the 164478Skz151634 * fields enclosed by brackets "[]" replaced with your own identifying 174478Skz151634 * information: Portions Copyright [yyyy] [name of copyright owner] 184478Skz151634 * 194478Skz151634 * CDDL HEADER END 204478Skz151634 */ 214478Skz151634 220Sstevel@tonic-gate /* 234303Skz151634 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_AGPDEFS_H 280Sstevel@tonic-gate #define _SYS_AGPDEFS_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate /* 374478Skz151634 * This AGP memory type is required by some hardware like i810 video 380Sstevel@tonic-gate * card, which need physical contiguous pages to setup hardware cursor. 390Sstevel@tonic-gate * Usually, several tens of kilo bytes are needed in this case. 400Sstevel@tonic-gate * We use DDI DMA interfaces to allocate such memory in agpgart driver, 410Sstevel@tonic-gate * and it can not be exported to user applications directly by calling mmap 420Sstevel@tonic-gate * on agpgart driver. The typical usage scenario is as the following: 430Sstevel@tonic-gate * Firstly, Xserver get the memory physical address by calling AGPIOC_ALLOCATE 440Sstevel@tonic-gate * on agpgart driver. Secondly, Xserver use the physical address to mmap 450Sstevel@tonic-gate * the memory to Xserver space area by xsvc driver. 460Sstevel@tonic-gate * 470Sstevel@tonic-gate */ 480Sstevel@tonic-gate #define AGP_PHYSICAL 2 /* Only used for i810, HW curosr */ 490Sstevel@tonic-gate 500Sstevel@tonic-gate #ifdef _KERNEL 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* AGP space units */ 530Sstevel@tonic-gate #define AGP_PAGE_SHIFT 12 540Sstevel@tonic-gate #define AGP_PAGE_SIZE (1 << AGP_PAGE_SHIFT) 550Sstevel@tonic-gate #define AGP_PAGE_OFFSET (AGP_PAGE_SIZE - 1) 560Sstevel@tonic-gate #define AGP_MB2PAGES(x) ((x) << 8) 570Sstevel@tonic-gate #define AGP_PAGES2BYTES(x) ((x) << AGP_PAGE_SHIFT) 580Sstevel@tonic-gate #define AGP_BYTES2PAGES(x) ((x) >> AGP_PAGE_SHIFT) 590Sstevel@tonic-gate #define AGP_PAGES2KB(x) ((x) << 2) 600Sstevel@tonic-gate #define AGP_ALIGNED(offset) (((offset) & AGP_PAGE_OFFSET) == 0) 610Sstevel@tonic-gate 620Sstevel@tonic-gate /* stand pci register offset */ 630Sstevel@tonic-gate #define PCI_CONF_CAP_MASK 0x10 640Sstevel@tonic-gate #define PCI_CONF_CAPID_MASK 0xff 650Sstevel@tonic-gate #define PCI_CONF_NCAPID_MASK 0xff00 660Sstevel@tonic-gate 670Sstevel@tonic-gate #define INTEL_VENDOR_ID 0x8086 680Sstevel@tonic-gate #define AMD_VENDOR_ID 0x1022 690Sstevel@tonic-gate #define VENDOR_ID_MASK 0xffff 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* macros for device types */ 720Sstevel@tonic-gate #define DEVICE_IS_I810 11 /* intel i810 series video card */ 730Sstevel@tonic-gate #define DEVICE_IS_I830 12 /* intel i830, i845, i855 series */ 740Sstevel@tonic-gate #define DEVICE_IS_AGP 21 /* external AGP video card */ 750Sstevel@tonic-gate #define CHIP_IS_INTEL 10 /* intel agp bridge */ 760Sstevel@tonic-gate #define CHIP_IS_AMD 20 /* amd agp bridge */ 770Sstevel@tonic-gate 780Sstevel@tonic-gate /* AGP bridge device id */ 790Sstevel@tonic-gate #define AMD_BR_8151 0x74541022 800Sstevel@tonic-gate #define INTEL_BR_810 0x71208086 810Sstevel@tonic-gate #define INTEL_BR_810DC 0x71228086 820Sstevel@tonic-gate #define INTEL_BR_810E 0x71248086 830Sstevel@tonic-gate #define INTEL_BR_815 0x11308086 /* include 815G/EG/P/EP */ 840Sstevel@tonic-gate #define INTEL_BR_830M 0x35758086 850Sstevel@tonic-gate #define INTEL_BR_845 0x25608086 /* include 845G/P */ 860Sstevel@tonic-gate #define INTEL_BR_855GM 0x35808086 /* include 852GM/PM */ 870Sstevel@tonic-gate #define INTEL_BR_855PM 0x33408086 880Sstevel@tonic-gate #define INTEL_BR_865 0x25708086 894478Skz151634 #define INTEL_BR_915 0x25808086 904478Skz151634 #define INTEL_BR_915GM 0x25908086 913198Szw161486 #define INTEL_BR_945 0x27708086 924303Skz151634 #define INTEL_BR_945GM 0x27a08086 934478Skz151634 #define INTEL_BR_946GZ 0x29708086 944478Skz151634 #define INTEL_BR_965G1 0x29808086 954478Skz151634 #define INTEL_BR_965Q 0x29908086 964478Skz151634 #define INTEL_BR_965G2 0x29a08086 974478Skz151634 #define INTEL_BR_965GM 0x2a008086 98*4618Skz151634 #define INTEL_BR_965GME 0x2a108086 990Sstevel@tonic-gate 1000Sstevel@tonic-gate /* AGP common register offset in pci configuration space */ 1010Sstevel@tonic-gate #define AGP_CONF_MISC 0x51 /* one byte */ 1020Sstevel@tonic-gate #define AGP_CONF_CAPPTR 0x34 1030Sstevel@tonic-gate #define AGP_CONF_APERBASE 0x10 1040Sstevel@tonic-gate #define AGP_CONF_STATUS 0x04 /* CAP + 0x4 */ 1050Sstevel@tonic-gate #define AGP_CONF_COMMAND 0x08 /* CAP + 0x8 */ 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate /* AGP target register and mask defines */ 1080Sstevel@tonic-gate #define AGP_CONF_CONTROL 0x10 /* CAP + 0x10 */ 1090Sstevel@tonic-gate #define AGP_TARGET_BAR1 1 1100Sstevel@tonic-gate #define AGP_32_APERBASE_MASK 0xffc00000 /* 4M aligned */ 1110Sstevel@tonic-gate #define AGP_64_APERBASE_MASK 0xffffc00000LL /* 4M aligned */ 1120Sstevel@tonic-gate #define AGP_CONF_APERSIZE 0x14 /* CAP + 0x14 */ 1130Sstevel@tonic-gate #define AGP_CONF_ATTBASE 0x18 /* CAP + 0x18 */ 1140Sstevel@tonic-gate #define AGP_ATTBASE_MASK 0xfffff000 1150Sstevel@tonic-gate #define AGPCTRL_GTLBEN (0x1 << 7) 1160Sstevel@tonic-gate #define AGP_APER_TYPE_MASK 0x4 1170Sstevel@tonic-gate #define AGP_APER_SIZE_MASK 0xf00 1180Sstevel@tonic-gate #define AGP_APER_128M_MASK 0x3f 1190Sstevel@tonic-gate #define AGP_APER_4G_MASK 0xf00 1200Sstevel@tonic-gate #define AGP_APER_4M 0x3f 1210Sstevel@tonic-gate #define AGP_APER_8M 0x3e 1220Sstevel@tonic-gate #define AGP_APER_16M 0x3c 1230Sstevel@tonic-gate #define AGP_APER_32M 0x38 1240Sstevel@tonic-gate #define AGP_APER_64M 0x30 1250Sstevel@tonic-gate #define AGP_APER_128M 0x20 1260Sstevel@tonic-gate #define AGP_APER_256M 0xf00 1270Sstevel@tonic-gate #define AGP_APER_512M 0xe00 1280Sstevel@tonic-gate #define AGP_APER_1024M 0xc00 1290Sstevel@tonic-gate #define AGP_APER_2048M 0x800 1300Sstevel@tonic-gate #define AGP_APER_4G 0x000 1310Sstevel@tonic-gate #define AGP_MISC_APEN 0x2 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate /* AGP gart table definition */ 1340Sstevel@tonic-gate #define AGP_ENTRY_VALID 0x1 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate /* AGP term definitions */ 1370Sstevel@tonic-gate #define AGP_CAP_ID 0x2 1380Sstevel@tonic-gate #define AGP_CAP_OFF_DEF 0xa0 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate /* Intel integrated video card, chipset id */ 1410Sstevel@tonic-gate #define INTEL_IGD_810 0x71218086 1420Sstevel@tonic-gate #define INTEL_IGD_810DC 0x71238086 1430Sstevel@tonic-gate #define INTEL_IGD_810E 0x71258086 1440Sstevel@tonic-gate #define INTEL_IGD_815 0x11328086 1450Sstevel@tonic-gate #define INTEL_IGD_830M 0x35778086 1460Sstevel@tonic-gate #define INTEL_IGD_845G 0x25628086 1470Sstevel@tonic-gate #define INTEL_IGD_855GM 0x35828086 1480Sstevel@tonic-gate #define INTEL_IGD_865G 0x25728086 1494478Skz151634 #define INTEL_IGD_915 0x25828086 1504478Skz151634 #define INTEL_IGD_915GM 0x25928086 1513198Szw161486 #define INTEL_IGD_945 0x27728086 1524303Skz151634 #define INTEL_IGD_945GM 0x27a28086 1534478Skz151634 #define INTEL_IGD_946GZ 0x29728086 1544478Skz151634 #define INTEL_IGD_965G1 0x29828086 1554478Skz151634 #define INTEL_IGD_965Q 0x29928086 1564478Skz151634 #define INTEL_IGD_965G2 0x29a28086 1574478Skz151634 #define INTEL_IGD_965GM 0x2a028086 158*4618Skz151634 #define INTEL_IGD_965GME 0x2a128086 1590Sstevel@tonic-gate #define I8XX_CONF_GMADR 0x10 /* offset in PCI config space */ 1601661Sms148562 #define I915_CONF_GMADR 0x18 /* offset in PCI config space */ 1610Sstevel@tonic-gate #define I8XX_CONF_GC 0x52 /* offset in PCI config space */ 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /* Intel integrated video card graphics mode mask */ 1640Sstevel@tonic-gate #define I8XX_GC_MODE_MASK 0x70 1650Sstevel@tonic-gate #define I8XX_GC_MODE0 0x00 1660Sstevel@tonic-gate #define I8XX_GC_MODE1 0x10 1670Sstevel@tonic-gate #define I8XX_GC_MODE2 0x20 1680Sstevel@tonic-gate #define I8XX_GC_MODE3 0x30 1690Sstevel@tonic-gate #define I8XX_GC_MODE4 0x40 1700Sstevel@tonic-gate #define I8XX_GC_MODE5 0x50 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate /* Intel integrated video card GTT definition */ 1730Sstevel@tonic-gate #define GTT_PAGE_SHIFT 12 1740Sstevel@tonic-gate #define GTT_PAGE_SIZE (1 << GTT_PAGE_SHIFT) 1750Sstevel@tonic-gate #define GTT_PAGE_OFFSET (GTT_PAGE_SIZE - 1) 1760Sstevel@tonic-gate #define GTT_PTE_MASK (~GTT_PAGE_OFFSET) 1770Sstevel@tonic-gate #define GTT_PTE_VALID 0x1 1780Sstevel@tonic-gate #define GTT_TABLE_VALID 0x1 1790Sstevel@tonic-gate #define GTT_BASE_MASK 0xfffff000 1800Sstevel@tonic-gate #define GTT_MB_TO_PAGES(m) ((m) << 8) 1810Sstevel@tonic-gate #define GTT_POINTER_MASK 0xffffffff 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* Intel i810 register offset */ 1840Sstevel@tonic-gate #define I810_POINTER_MASK 0x3fffffff 1850Sstevel@tonic-gate #define I810_CONF_SMRAM 0x70 /* offset in PCI config space */ 1860Sstevel@tonic-gate #define I810_GMS_MASK 0xc0 /* smram register mask */ 1870Sstevel@tonic-gate /* 1880Sstevel@tonic-gate * GART and GTT entry format table 1890Sstevel@tonic-gate * 1900Sstevel@tonic-gate * AMD64 GART entry 1910Sstevel@tonic-gate * from bios and kernel develop guide for amd64 1920Sstevel@tonic-gate * ----------------------------- 1930Sstevel@tonic-gate * Bits Description | 1940Sstevel@tonic-gate * 0 valid | 1950Sstevel@tonic-gate * 1 coherent | 1960Sstevel@tonic-gate * 3:2 reserved | 1970Sstevel@tonic-gate * 11:4 physaddr[39:32] | 1980Sstevel@tonic-gate * 31:12 physaddr[31:12] | 1990Sstevel@tonic-gate * ----------------------------- 2000Sstevel@tonic-gate * Intel GTT entry 2010Sstevel@tonic-gate * Intel video programming manual 2020Sstevel@tonic-gate * ----------------------------- 2030Sstevel@tonic-gate * Bits descrition | 2040Sstevel@tonic-gate * 0 valid | 2050Sstevel@tonic-gate * 2:1 memory type | 2060Sstevel@tonic-gate * 29:12 PhysAddr[29:12] | 2070Sstevel@tonic-gate * 31:30 reserved | 2080Sstevel@tonic-gate * ----------------------------- 2090Sstevel@tonic-gate * AGP entry 2100Sstevel@tonic-gate * from AGP protocol 3.0 2110Sstevel@tonic-gate * ----------------------------- 2120Sstevel@tonic-gate * Bits descrition | 2130Sstevel@tonic-gate * 0 valid | 2140Sstevel@tonic-gate * 1 coherent | 2150Sstevel@tonic-gate * 3:2 reserved | 2160Sstevel@tonic-gate * 11:4 PhysAddr[39:32] | 2170Sstevel@tonic-gate * 31:12 PhysAddr[31:12] | 2180Sstevel@tonic-gate * 63:32 PhysAddr[71:40] | 2190Sstevel@tonic-gate * ----------------------------- 2200Sstevel@tonic-gate */ 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate /* 2230Sstevel@tonic-gate * gart and gtt table base register format 2240Sstevel@tonic-gate * 2250Sstevel@tonic-gate * AMD64 register format 2260Sstevel@tonic-gate * from bios and kernel develop guide for AMD64 2270Sstevel@tonic-gate * --------------------------------------------- 2280Sstevel@tonic-gate * Bits Description | 2290Sstevel@tonic-gate * 3:0 reserved | 2300Sstevel@tonic-gate * 31:4 physical addr 39:12 | 2310Sstevel@tonic-gate * ---------------------------------------------- 2320Sstevel@tonic-gate * INTEL AGPGART table base register format 2330Sstevel@tonic-gate * from AGP protocol 3.0 p142, only support 32 bits 2340Sstevel@tonic-gate * --------------------------------------------- 2350Sstevel@tonic-gate * Bits Description | 2360Sstevel@tonic-gate * 11:0 reserved | 2370Sstevel@tonic-gate * 31:12 physical addr 31:12 | 2380Sstevel@tonic-gate * 63:32 physical addr 63:32 | 2390Sstevel@tonic-gate * --------------------------------------------- 2400Sstevel@tonic-gate * INTEL i810 GTT table base register format 2410Sstevel@tonic-gate * _____________________________________________ 2420Sstevel@tonic-gate * Bits Description | 2430Sstevel@tonic-gate * 0 GTT table enable bit | 2440Sstevel@tonic-gate * 11:1 reserved | 2450Sstevel@tonic-gate * 31:12 physical addr 31:12 | 2460Sstevel@tonic-gate * --------------------------------------------- 2470Sstevel@tonic-gate */ 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate /* Intel agp bridge specific */ 2500Sstevel@tonic-gate #define AGP_INTEL_POINTER_MASK 0xffffffff 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate /* Amd64 cpu gart device reigster offset */ 2530Sstevel@tonic-gate #define AMD64_APERTURE_CONTROL 0x90 2540Sstevel@tonic-gate #define AMD64_APERTURE_BASE 0x94 2550Sstevel@tonic-gate #define AMD64_GART_CACHE_CTL 0x9c 2560Sstevel@tonic-gate #define AMD64_GART_BASE 0x98 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate /* Amd64 cpu gart bits */ 2590Sstevel@tonic-gate #define AMD64_APERBASE_SHIFT 25 2600Sstevel@tonic-gate #define AMD64_APERBASE_MASK 0x00007fff 2610Sstevel@tonic-gate #define AMD64_GARTBASE_SHIFT 8 2620Sstevel@tonic-gate #define AMD64_GARTBASE_MASK 0xfffffff0 2630Sstevel@tonic-gate #define AMD64_POINTER_MASK 0xffffffffff 2640Sstevel@tonic-gate #define AMD64_INVALID_CACHE 0x1 2650Sstevel@tonic-gate #define AMD64_GART_SHIFT 12 2660Sstevel@tonic-gate #define AMD64_RESERVE_SHIFT 4 2670Sstevel@tonic-gate #define AMD64_APERSIZE_MASK 0xe 2680Sstevel@tonic-gate #define AMD64_GARTEN 0x1 2690Sstevel@tonic-gate #define AMD64_DISGARTCPU 0x10 2700Sstevel@tonic-gate #define AMD64_DISGARTIO 0x20 2710Sstevel@tonic-gate #define AMD64_ENTRY_VALID 0x1 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate /* Other common routines */ 2740Sstevel@tonic-gate #define MB2BYTES(m) ((m) << 20) 2750Sstevel@tonic-gate #define BYTES2MB(m) ((m) >> 20) 2760Sstevel@tonic-gate #define GIGA_MASK 0xC0000000 2770Sstevel@tonic-gate #define UI32_MASK 0xffffffffU 278417Sms148562 #define MAXAPERMEGAS 0x1000 /* Aper size no more than 4G */ 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate #endif /* _KERNEL */ 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate #ifdef __cplusplus 2830Sstevel@tonic-gate } 2840Sstevel@tonic-gate #endif 2850Sstevel@tonic-gate 2860Sstevel@tonic-gate #endif /* _SYS_AGPDEFS_H */ 287