1/* 2 * Copyright (c) 2006 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 * DEALINGS IN THE SOFTWARE. 21 * 22 * Neither the name of the Advanced Micro Devices, Inc. nor the names of its 23 * contributors may be used to endorse or promote products derived from this 24 * software without specific prior written permission. 25 */ 26 27 /* 28 * Base include file for the Cimarron library. This file should be modified 29 * and included in any Cimarron-based project. 30 */ 31 32#ifdef HAVE_CONFIG_H 33#include "config.h" 34#endif 35 36/*----------------------------------------------------------------------*/ 37/* MODULE SETTINGS */ 38/* The following #defines affect which modules are included in the */ 39/* project. */ 40/*----------------------------------------------------------------------*/ 41 42#define CIMARRON_INCLUDE_GP 1 43#define CIMARRON_INCLUDE_VG 1 44#define CIMARRON_INCLUDE_VIP 1 45#define CIMARRON_INCLUDE_VOP 1 46#define CIMARRON_INCLUDE_VIDEO 1 47#define CIMARRON_INCLUDE_INIT 1 48 49#define CIMARRON_INCLUDE_VG_READ_ROUTINES 1 50#define CIMARRON_INCLUDE_DF_READ_ROUTINES 1 51#define CIMARRON_INCLUDE_VIP_READ_ROUTINES 1 52#define CIMARRON_INCLUDE_VOP_READ_ROUTINES 1 53 54/*----------------------------------------------------------------------*/ 55/* HARDWARE ACCESS SETTINGS */ 56/* The following #defines affect how the Cimarron macros access the */ 57/* hardware. The hardware access macros are broken up into groups. */ 58/* Each group includes an enabling #define as well as several #define */ 59/* options that modify the macro configuration that is included. */ 60/* If the enabling define is deleted or all options are set to 0, the */ 61/* corresponding macros must be implemented by the user. The */ 62/* combinations are explained as follows: */ 63/* must be manually defined by the user. This allows a user to use the */ 64/* cim_defs.h file for only those macros that suit the needs of his/her */ 65/* project. For example, a user may need custom implementations of the */ 66/* I/O and MSR macros, but may still want to use the default macros to */ 67/* read and write hardware registers. The combinations are explained as */ 68/* follows: */ 69/* */ 70/* Register Group: */ 71/* Disabling define: */ 72/* CIMARRON_EXCLUDE_REGISTER_ACCESS_MACROS */ 73/* Define this setting to exclude the register access macros. */ 74/* This setting is the inverse of the other group settings in */ 75/* that these macros are included by default. This allows the */ 76/* cim_defs.h file to be included outside of cimarron.c for */ 77/* basic operations. */ 78/* */ 79/* Memory Group: */ 80/* Enabling define: */ 81/* CIMARRON_INCLUDE_STRING_MACROS */ 82/* Options: */ 83/* CIMARRON_OPTIMIZE_ASSEMBLY */ 84/* Set to 1 to allow the use of inline assembly when writing */ 85/* large chunks of data to memory. Essentially, this allows */ 86/* a rep movsd in place of a slower C for-loop. */ 87/* CIMARRON_OPTIMIZE_FORLOOP */ 88/* Define for C only data writes. */ 89/* */ 90/* MSR Group: */ 91/* Enabling define: */ 92/* CIMARRON_INCLUDE_MSR_MACROS */ 93/* Options: */ 94/* CIMARRON_MSR_DIRECT_ASM */ 95/* Set to 1 to allow the use of the rdmsr and wrmsr opcodes in */ 96/* inline assembly. */ 97/* CIMARRON_MSR_VSA_IO */ 98/* Set to 1 to access MSRs using a VSAII virtual register. */ 99/* CIMARRON_MSR_KERNEL_ROUTINE */ 100/* Set to 1 to access MSRs using a wrapper routine in the */ 101/* Linux kernel. */ 102/* */ 103/* IO Group: */ 104/* Enabling define: */ 105/* CIMARRON_INCLUDE_IO_MACROS */ 106/* Options: */ 107/* CIMARRON_IO_DIRECT_ACCESS */ 108/* Set to 1 to perform IO accesses using inline assembly. */ 109/* CIMARRON_IO_ABSTRACTED_ASM */ 110/* Set to 1 to perform IO using abstracted IO in Linux. */ 111/* */ 112/* Custom Group: */ 113/* Disabling define: */ 114/* CIMARRON_EXCLUDE_CUSTOM_MACROS */ 115/* By default, the custom macros (the macros used by */ 116/* gp_custom_convert_blt) are mapped to the normal command */ 117/* string macros. Setting this to 1 allows the user to */ 118/* create a custom implementation. */ 119/*----------------------------------------------------------------------*/ 120 121/* UNCOMMENT THE FOLLOWING LINE TO EXCLUDE BASIC REGISTER ACCESS MACROS */ 122 123/* #define CIMARRON_EXCLUDE_REGISTER_ACCESS_MACROS */ 124 125#define CIMARRON_INCLUDE_STRING_MACROS 126#define CIMARRON_OPTIMIZE_ASSEMBLY 0 127#define CIMARRON_OPTIMIZE_FORLOOP 0 128#define CIMARRON_OPTIMIZE_ABSTRACTED_ASM 1 129 130#define CIMARRON_INCLUDE_MSR_MACROS 131#define CIMARRON_MSR_DIRECT_ASM 0 132#define CIMARRON_MSR_VSA_IO 0 133#define CIMARRON_MSR_ABSTRACTED_ASM 0 134#define CIMARRON_MSR_KERNEL_ROUTINE 0 135#define CIMARRON_MSR_HOOKS 1 136 137#define CIMARRON_INCLUDE_IO_MACROS 138#define CIMARRON_IO_DIRECT_ACCESS 0 139#define CIMARRON_IO_ABSTRACTED_ASM 1 140 141/* 142 * UNCOMMENT THE FOLLOWING LINE TO IMPLEMENT CUSTOM MACROS FOR 143 * GP_CUSTOM_CONVERT_BLT 144 */ 145 146/* #define CIMARRON_EXCLUDE_CUSTOM_MACROS */ 147 148/*----------------------------------------------------------------------*/ 149/* MODULE VARIABLES */ 150/* The following #defines affect how global variables in each Cimarron */ 151/* module are defined. These variables can be made static (to prevent */ 152/* naming conflicts) or they can be defined without the static keyword */ 153/* (to allow extern references). */ 154/*----------------------------------------------------------------------*/ 155 156#if 1 157#define CIMARRON_STATIC static 158#else 159#define CIMARRON_STATIC 160#endif 161 162/*----------------------------------------------------------------------*/ 163/* CIMARRON GLOBAL VARIABLES */ 164/* These globals are used by the hardware access macros. They must be */ 165/* initialized by the application to point to the memory-mapped */ 166/* registers of their respective blocks. */ 167/*----------------------------------------------------------------------*/ 168 169unsigned char *cim_gp_ptr = (unsigned char *) 0; 170unsigned char *cim_fb_ptr = (unsigned char *) 0; 171unsigned char *cim_cmd_base_ptr = (unsigned char *) 0; 172unsigned char *cim_cmd_ptr = (unsigned char *) 0; 173unsigned char *cim_vid_ptr = (unsigned char *) 0; 174unsigned char *cim_vip_ptr = (unsigned char *) 0; 175unsigned char *cim_vg_ptr = (unsigned char *) 0; 176 177/* Define hooks for reading and writing MSRs - this is a major hack 178 * to share the MSR code with the GX code */ 179 180#ifdef CIMARRON_MSR_HOOKS 181void (*cim_rdmsr) (unsigned long, unsigned long *, unsigned long *); 182void (*cim_wrmsr) (unsigned long, unsigned long, unsigned long); 183#endif 184 185/*----------------------------------------------------------------------*/ 186/* INCLUDE RELEVANT CIMARRON HEADERS */ 187/*----------------------------------------------------------------------*/ 188 189/* HARDWARE REGISTER DEFINITIONS */ 190 191#include "cim_regs.h" 192 193/* ROUTINE DEFINITIONS */ 194/* All routines have a prototype, even those that are not included */ 195/* via #ifdefs. This prevents the user from having to include the */ 196/* correct #defines anywhere he/she wants to call a Cimarron routine. */ 197 198#include "cim_rtns.h" 199 200/* HARDWARE ACCESS MACROS */ 201 202#include "cim_defs.h" 203 204/*----------------------------------------------------------------------*/ 205/* CIMARRON MODULES */ 206/* Modules and sub-modules are included based on user settings. Note */ 207/* that excluding one or more modules may result in functionality */ 208/* holes. */ 209/*----------------------------------------------------------------------*/ 210 211/* GRAPHICS PROCESSOR */ 212 213#if CIMARRON_INCLUDE_GP 214#include "cim_gp.c" 215#endif 216 217/* VIDEO GENERATOR */ 218 219#if CIMARRON_INCLUDE_VG 220#include "cim_modes.c" 221#include "cim_vg.c" 222#endif 223 224/* DISPLAY FILTER */ 225 226#if CIMARRON_INCLUDE_VIDEO 227#include "cim_filter.c" 228#include "cim_df.c" 229#endif 230 231/* INITIALIZATION AND DETECTION */ 232 233#if CIMARRON_INCLUDE_INIT 234#include "cim_init.c" 235#endif 236 237/* VIP SUPPORT */ 238 239#if CIMARRON_INCLUDE_VIP 240#include "cim_vip.c" 241#endif 242 243/* VOP SUPPORT */ 244 245#if CIMARRON_INCLUDE_VOP 246#include "cim_vop.c" 247#endif 248 249/* MSR ACCESS */ 250/* This module is used to access machine-specific registers. */ 251/* It cannot be excluded from a project. */ 252 253#include "cim_msr.c" 254