OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * (C) Copyright 2010 |
| 3 * NVIDIA Corporation <www.nvidia.com> |
| 4 * |
| 5 * See file CREDITS for list of people who contributed to this |
| 6 * project. |
| 7 * |
| 8 * This program is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU General Public License as |
| 10 * published by the Free Software Foundation; either version 2 of |
| 11 * the License, or (at your option) any later version. |
| 12 * |
| 13 * This program is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 * GNU General Public License for more details. |
| 17 * |
| 18 * You should have received a copy of the GNU General Public License |
| 19 * along with this program; if not, write to the Free Software |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 * MA 02111-1307 USA |
| 22 */ |
| 23 |
| 24 #ifndef INCLUDED_NVRM_DRF_ASM_H |
| 25 #define INCLUDED_NVRM_DRF_ASM_H |
| 26 |
| 27 /** |
| 28 * @defgroup nvrm_drf RM DRF Macros |
| 29 * |
| 30 * @ingroup nvddk_rm |
| 31 * |
| 32 * The following suite of macros are used from assembly language code for |
| 33 * generating values to write into hardware registers, or for extracting |
| 34 * fields from read registers. These macros are less sophistocated than |
| 35 * C counterparts because the assembler does not understand the C ternary |
| 36 * operator. In particular, depending on the version of the assember, there |
| 37 * may not be common C-style aliases to the native assembler operators. To |
| 38 * accomodate the lowest common denominator, only the native assember operators |
| 39 * (e.g., :SHL:, :AND:, etc.) are used. |
| 40 */ |
| 41 |
| 42 /** |
| 43 * The default implementation of _MK_ENUM_CONST in the spec-generated headers |
| 44 * appends the C unsigned long suffix operator (UL). This is incompatible with |
| 45 * the assembler. Force _MK_ENUM_CONST to define just a plain constant. |
| 46 */ |
| 47 #if defined(_MK_ENUM_CONST) |
| 48 #undef _MK_ENUM_CONST |
| 49 #define _MK_ENUM_CONST(_constant_) (_constant_) |
| 50 #endif |
| 51 |
| 52 /*----------------------------------------------------------------------------- |
| 53 * Abstract logical operations because some ARM assemblers don't |
| 54 * understand C operators. |
| 55 *----------------------------------------------------------------------------- |
| 56 */ |
| 57 |
| 58 #if !defined(_AND_) |
| 59 #define _AND_ & |
| 60 #endif |
| 61 |
| 62 #if !defined(_OR_) |
| 63 #define _OR_ | |
| 64 #endif |
| 65 |
| 66 #if !defined(_SHL_) |
| 67 #define _SHL_ << |
| 68 #endif |
| 69 |
| 70 |
| 71 /** NV_DRF_OFFSET - Get a register offset |
| 72 |
| 73 @ingroup nvrm_drf |
| 74 |
| 75 @param d register domain (hardware block) |
| 76 @param r register name |
| 77 */ |
| 78 #define NV_DRF_OFFSET(d,r) (d##_##r##_0) |
| 79 |
| 80 /** NV_DRF_SHIFT - Get the shift count of a field |
| 81 |
| 82 @ingroup nvrm_drf |
| 83 |
| 84 @param d register domain (hardware block) |
| 85 @param r register name |
| 86 @param f register field |
| 87 */ |
| 88 #define NV_DRF_SHIFT(d,r,f) (d##_##r##_0_##f##_SHIFT) |
| 89 |
| 90 /** NV_DRF_MASK - Get the mask value of a field |
| 91 |
| 92 @ingroup nvrm_drf |
| 93 |
| 94 @param d register domain (hardware block) |
| 95 @param r register name |
| 96 @param f register field |
| 97 */ |
| 98 #define NV_DRF_MASK(d,r,f) ((d##_##r##_0_##f##_DEFAULT_MASK) _SHL_ (d##_##r##_0
_##f##_SHIFT)) |
| 99 |
| 100 /** NV_DRF_DEF - define a new register value. |
| 101 |
| 102 @ingroup nvrm_drf |
| 103 |
| 104 @param d register domain (hardware block) |
| 105 @param r register name |
| 106 @param f register field |
| 107 @param c defined value for the field |
| 108 */ |
| 109 #define NV_DRF_DEF(d,r,f,c) \ |
| 110 ((d##_##r##_0_##f##_##c) _SHL_ (d##_##r##_0_##f##_SHIFT)) |
| 111 |
| 112 /** NV_DRF_NUM - define a new register value. |
| 113 |
| 114 @ingroup nvrm_drf |
| 115 |
| 116 @param d register domain (hardware block) |
| 117 @param r register name |
| 118 @param f register field |
| 119 @param n numeric value for the field |
| 120 */ |
| 121 #define NV_DRF_NUM(d,r,f,n) \ |
| 122 ((((n) _AND_ (d##_##r##_0_##f##_DEFAULT_MASK))) _SHL_ \ |
| 123 (d##_##r##_0_##f##_SHIFT)) |
| 124 |
| 125 /** NV_RESETVAL - get the reset value for a register. |
| 126 |
| 127 @ingroup nvrm_drf |
| 128 |
| 129 @param d register domain (hardware block) |
| 130 @param r register name |
| 131 */ |
| 132 #define NV_RESETVAL(d,r) (d##_##r##_0_RESET_VAL) |
| 133 |
| 134 #endif /* INCLUDED_NVRM_DRF_ASM_H */ |
OLD | NEW |