sb1250_defs.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*  *********************************************************************
  2.     *  SB1250 Board Support Package
  3.     *
  4.     *  Global constants and macros File: sb1250_defs.h
  5.     *
  6.     *  This file contains macros and definitions used by the other
  7.     *  include files.
  8.     *
  9.     *  SB1250 specification level:  User's manual 1/02/02
  10.     *
  11.     *  Author:  Mitch Lichtenberg (mpl@broadcom.com)
  12.     *
  13.     *********************************************************************
  14.     *
  15.     *  Copyright 2000,2001
  16.     *  Broadcom Corporation. All rights reserved.
  17.     *
  18.     *  This program is free software; you can redistribute it and/or
  19.     *  modify it under the terms of the GNU General Public License as
  20.     *  published by the Free Software Foundation; either version 2 of
  21.     *  the License, or (at your option) any later version.
  22.     *
  23.     *  This program is distributed in the hope that it will be useful,
  24.     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  25.     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  26.     *  GNU General Public License for more details.
  27.     *
  28.     *  You should have received a copy of the GNU General Public License
  29.     *  along with this program; if not, write to the Free Software
  30.     *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  31.     *  MA 02111-1307 USA
  32.     ********************************************************************* */
  33. /*  *********************************************************************
  34.     *  Naming schemes for constants in these files:
  35.     *
  36.     *  M_xxx           MASK constant (identifies bits in a register).
  37.     *                  For multi-bit fields, all bits in the field will
  38.     *                  be set.
  39.     *
  40.     *  K_xxx           "Code" constant (value for data in a multi-bit
  41.     *                  field).  The value is right justified.
  42.     *
  43.     *  V_xxx           "Value" constant.  This is the same as the
  44.     *                  corresponding "K_xxx" constant, except it is
  45.     *                  shifted to the correct position in the register.
  46.     *
  47.     *  S_xxx           SHIFT constant.  This is the number of bits that
  48.     *                  a field value (code) needs to be shifted
  49.     *                  (towards the left) to put the value in the right
  50.     *                  position for the register.
  51.     *
  52.     *  A_xxx           ADDRESS constant.  This will be a physical
  53.     *                  address.  Use the PHYS_TO_K1 macro to generate
  54.     *                  a K1SEG address.
  55.     *
  56.     *  R_xxx           RELATIVE offset constant.  This is an offset from
  57.     *                  an A_xxx constant (usually the first register in
  58.     *                  a group).
  59.     *
  60.     *  G_xxx(X)        GET value.  This macro obtains a multi-bit field
  61.     *                  from a register, masks it, and shifts it to
  62.     *                  the bottom of the register (retrieving a K_xxx
  63.     *                  value, for example).
  64.     *
  65.     *  V_xxx(X)        VALUE.  This macro computes the value of a
  66.     *                  K_xxx constant shifted to the correct position
  67.     *                  in the register.
  68.     ********************************************************************* */
  69. #ifndef _SB1250_DEFS_H
  70. #define _SB1250_DEFS_H
  71. /*
  72.  * Cast to 64-bit number.  Presumably the syntax is different in
  73.  * assembly language.
  74.  *
  75.  * Note: you'll need to define uint32_t and uint64_t in your headers.
  76.  */
  77. #if !defined(__ASSEMBLY__)
  78. #define _SB_MAKE64(x) ((uint64_t)(x))
  79. #define _SB_MAKE32(x) ((uint32_t)(x))
  80. #else
  81. #define _SB_MAKE64(x) (x)
  82. #define _SB_MAKE32(x) (x)
  83. #endif
  84. /*
  85.  * Make a mask for 1 bit at position 'n'
  86.  */
  87. #define _SB_MAKEMASK1(n) (_SB_MAKE64(1) << _SB_MAKE64(n))
  88. #define _SB_MAKEMASK1_32(n) (_SB_MAKE32(1) << _SB_MAKE32(n))
  89. /*
  90.  * Make a mask for 'v' bits at position 'n'
  91.  */
  92. #define _SB_MAKEMASK(v,n) (_SB_MAKE64((_SB_MAKE64(1)<<(v))-1) << _SB_MAKE64(n))
  93. #define _SB_MAKEMASK_32(v,n) (_SB_MAKE32((_SB_MAKE32(1)<<(v))-1) << _SB_MAKE32(n))
  94. /*
  95.  * Make a value at 'v' at bit position 'n'
  96.  */
  97. #define _SB_MAKEVALUE(v,n) (_SB_MAKE64(v) << _SB_MAKE64(n))
  98. #define _SB_MAKEVALUE_32(v,n) (_SB_MAKE32(v) << _SB_MAKE32(n))
  99. #define _SB_GETVALUE(v,n,m) ((_SB_MAKE64(v) & _SB_MAKE64(m)) >> _SB_MAKE64(n))
  100. #define _SB_GETVALUE_32(v,n,m) ((_SB_MAKE32(v) & _SB_MAKE32(m)) >> _SB_MAKE32(n))
  101. /*
  102.  * Macros to read/write on-chip registers
  103.  * XXX should we do the PHYS_TO_K1 here?
  104.  */
  105. #if !defined(__ASSEMBLY__)
  106. #define SBWRITECSR(csr,val) *((volatile uint64_t *) PHYS_TO_K1(csr)) = (val)
  107. #define SBREADCSR(csr) (*((volatile uint64_t *) PHYS_TO_K1(csr)))
  108. #endif /* __ASSEMBLY__ */
  109. #endif