system_util.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright (c) 2011-2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. /*!
  31. * @file system_util.h
  32. * @brief header file for the system utility functions.
  33. *
  34. */
  35. #ifndef _SYSTEM_UTIL_H_
  36. #define _SYSTEM_UTIL_H_
  37. //! @addtogroup diag_util
  38. //! @{
  39. ////////////////////////////////////////////////////////////////////////////////
  40. // Definitions
  41. ////////////////////////////////////////////////////////////////////////////////
  42. //! @brief Typedef for an input filter function for read_input_string().
  43. typedef bool (*input_string_filter_t)(char newChar, const char * currentString);
  44. //! @brief HAB failsafe routine typedef.
  45. typedef void hab_rvt_failsafe_t(void);
  46. //! ROM Vector Table starts at address 0x94
  47. #define HAB_RVT_FAILSAFE (*(uint32_t *) 0x000000BC)
  48. #define hab_rvt_failsafe ((hab_rvt_failsafe_t *) HAB_RVT_FAILSAFE)
  49. ////////////////////////////////////////////////////////////////////////////////
  50. // Board support
  51. ////////////////////////////////////////////////////////////////////////////////
  52. //! @name Board support
  53. //@{
  54. //! @brief UART port instance number used for the debug UART.
  55. //!
  56. //! This is used by the driver in order to factor out board
  57. //! specific functionality. It must be defined by the board support
  58. //! library or the application.
  59. extern uint32_t g_debug_uart_port;
  60. //@}
  61. ////////////////////////////////////////////////////////////////////////////////
  62. // Prototypes
  63. ////////////////////////////////////////////////////////////////////////////////
  64. #if defined(__cplusplus)
  65. extern "C" {
  66. #endif
  67. /*!
  68. * @brief Exception signaling and handling for C lib functions.
  69. *
  70. * This function never returns.
  71. *
  72. * In release builds (i.e., the DEBUG macro is not defined), the processor will be put
  73. * to sleep using the WFI instruction.
  74. *
  75. * @param return_code not used
  76. */
  77. void _sys_exit(int32_t return_code);
  78. /*!
  79. * @brief Breakpoint function.
  80. */
  81. void mybkpt(void);
  82. int _raw_puts(char str[]);
  83. /*!
  84. * @brief Read a string from interactive console input.
  85. *
  86. * @param filter Optional filter function. If this parameter is not NULL, it will be called
  87. * for every character that is read from the input. If it returns true, then the
  88. * new character will be added to the output string.
  89. * @return The string that was read in. The string is allocated with malloc() and must be
  90. * freed by the caller.
  91. */
  92. char * read_input_string(input_string_filter_t filter);
  93. /*!
  94. * This function waits for an input char to be received from the UART. Once a char is received,
  95. * it tests against the passed in char and return 0 if they don't match.
  96. * @param c the input character to be expected (NOT case sensitive)
  97. * @param indent pointer to a character buffer to use for indenting text to screen
  98. * @return 0 if input char doesn't match with c
  99. * non-zero otherwise
  100. */
  101. int32_t is_input_char(uint8_t c, const char* const indent);
  102. /*!
  103. * @brief Reads a hex number from console input.
  104. */
  105. uint32_t get_input_hex(void);
  106. /*!
  107. * @brief Reads a decimal number from console input.
  108. */
  109. int read_int(void);
  110. /*!
  111. * @brief Function to jump into the ROM Serial Download Protocol.
  112. *
  113. * Control never returns to the caller once this function is called.
  114. */
  115. void jump_to_sdp(void);
  116. #if defined(__cplusplus)
  117. }
  118. #endif
  119. //! @}
  120. #endif //_SYSTEM_UTIL_H_
  121. ////////////////////////////////////////////////////////////////////////////////
  122. // EOF
  123. ////////////////////////////////////////////////////////////////////////////////