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