HALcomdef.h 3.0 KB

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