HALcomdef.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright (c) 2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef HAL_COMDEF_H
  17. #define HAL_COMDEF_H
  18. /*
  19. ==============================================================================
  20. FILE: HALcomdef.h
  21. DESCRIPTION:
  22. ==============================================================================
  23. Edit History
  24. $Header: /prj/iceng/SCALe/repository/cvs/scale/source/data/HALcomdef.h,v 1.1.1.1 2012/09/19 22:33:29 rjindal Exp $
  25. when who what, where, why
  26. -------- --- -----------------------------------------------------------
  27. 06/17/10 sc Included com_dtypes.h and cleaned up typedefs
  28. 05/15/08 gfr Added HAL_ENUM_32BITS macro.
  29. 02/14/08 gfr Added bool32 type.
  30. 11/13/07 gfr Removed dependency on comdef.h
  31. 01/08/07 hxw Created
  32. */
  33. /*
  34. * Assembly wrapper
  35. */
  36. #ifndef _ARM_ASM_
  37. /*
  38. * C++ wrapper
  39. */
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #include "com_dtypes.h"
  44. /* -----------------------------------------------------------------------
  45. ** Types
  46. ** ----------------------------------------------------------------------- */
  47. /*
  48. * Standard integer types.
  49. *
  50. * bool32 - boolean, 32 bit (TRUE or FALSE)
  51. */
  52. #ifndef _BOOL32_DEFINED
  53. typedef unsigned long int bool32;
  54. #define _BOOL32_DEFINED
  55. #endif
  56. /*
  57. * Macro to allow forcing an enum to 32 bits. The argument should be
  58. * an identifier in the namespace of the enumeration in question, i.e.
  59. * for the clk HAL we might use HAL_ENUM_32BITS(CLK_xxx).
  60. */
  61. #define HAL_ENUM_32BITS(x) HAL_##x##_FORCE32BITS = 0x7FFFFFFF
  62. /*===========================================================================
  63. FUNCTION inp, outp, inpw, outpw, inpdw, outpdw
  64. DESCRIPTION
  65. IN/OUT port macros for byte and word ports, typically inlined by compilers
  66. which support these routines
  67. PARAMETERS
  68. inp( xx_addr )
  69. inpw( xx_addr )
  70. inpdw( xx_addr )
  71. outp( xx_addr, xx_byte_val )
  72. outpw( xx_addr, xx_word_val )
  73. outpdw( xx_addr, xx_dword_val )
  74. xx_addr - Address of port to read or write (may be memory mapped)
  75. xx_byte_val - 8 bit value to write
  76. xx_word_val - 16 bit value to write
  77. xx_dword_val - 32 bit value to write
  78. DEPENDENCIES
  79. None
  80. RETURN VALUE
  81. inp/inpw/inpdw: the byte, word or dword read from the given address
  82. outp/outpw/outpdw: the byte, word or dword written to the given address
  83. SIDE EFFECTS
  84. None.
  85. ===========================================================================*/
  86. /* ARM based targets use memory mapped i/o, so the inp/outp calls are
  87. ** macroized to access memory directly
  88. */
  89. #define inp(port) (*((volatile byte *) (port)))
  90. #define inpw(port) (*((volatile word *) (port)))
  91. #define inpdw(port) (*((volatile dword *)(port)))
  92. #define outp(port, val) (*((volatile byte *) (port)) = ((byte) (val)))
  93. #define outpw(port, val) (*((volatile word *) (port)) = ((word) (val)))
  94. #define outpdw(port, val) (*((volatile dword *) (port)) = ((dword) (val)))
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif /* !_ARM_ASM_ */
  99. #endif /* HAL_COMDEF_H */