HALcomdef.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. 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. * Assembly wrapper
  20. */
  21. #ifndef _ARM_ASM_
  22. /*
  23. * C++ wrapper
  24. */
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #include "com_dtypes.h"
  29. /* -----------------------------------------------------------------------
  30. ** Types
  31. ** ----------------------------------------------------------------------- */
  32. /*
  33. * Standard integer types.
  34. *
  35. * bool32 - boolean, 32 bit (TRUE or FALSE)
  36. */
  37. #ifndef _BOOL32_DEFINED
  38. typedef unsigned long int bool32;
  39. #define _BOOL32_DEFINED
  40. #endif
  41. /*
  42. * Macro to allow forcing an enum to 32 bits. The argument should be
  43. * an identifier in the namespace of the enumeration in question, i.e.
  44. * for the clk HAL we might use HAL_ENUM_32BITS(CLK_xxx).
  45. */
  46. #define HAL_ENUM_32BITS(x) HAL_##x##_FORCE32BITS = 0x7FFFFFFF
  47. /*===========================================================================
  48. FUNCTION inp, outp, inpw, outpw, inpdw, outpdw
  49. DESCRIPTION
  50. IN/OUT port macros for byte and word ports, typically inlined by compilers
  51. which support these routines
  52. PARAMETERS
  53. inp( xx_addr )
  54. inpw( xx_addr )
  55. inpdw( xx_addr )
  56. outp( xx_addr, xx_byte_val )
  57. outpw( xx_addr, xx_word_val )
  58. outpdw( xx_addr, xx_dword_val )
  59. xx_addr - Address of port to read or write (may be memory mapped)
  60. xx_byte_val - 8 bit value to write
  61. xx_word_val - 16 bit value to write
  62. xx_dword_val - 32 bit value to write
  63. DEPENDENCIES
  64. None
  65. RETURN VALUE
  66. inp/inpw/inpdw: the byte, word or dword read from the given address
  67. outp/outpw/outpdw: the byte, word or dword written to the given address
  68. SIDE EFFECTS
  69. None.
  70. ===========================================================================*/
  71. /* ARM based targets use memory mapped i/o, so the inp/outp calls are
  72. ** macroized to access memory directly
  73. */
  74. #define inp(port) (*((volatile byte *) (port)))
  75. #define inpw(port) (*((volatile word *) (port)))
  76. #define inpdw(port) (*((volatile dword *)(port)))
  77. #define outp(port, val) (*((volatile byte *) (port)) = ((byte) (val)))
  78. #define outpw(port, val) (*((volatile word *) (port)) = ((word) (val)))
  79. #define outpdw(port, val) (*((volatile dword *) (port)) = ((dword) (val)))
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif /* !_ARM_ASM_ */
  84. #endif /* HAL_COMDEF_H */