hnd_cons.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Console support for RTE - for host use only.
  3. *
  4. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  5. *
  6. * Copyright (C) 1999-2020, Broadcom Corporation
  7. *
  8. * Unless you and Broadcom execute a separate written software license
  9. * agreement governing use of this software, this software is licensed to you
  10. * under the terms of the GNU General Public License version 2 (the "GPL"),
  11. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  12. * following added to such license:
  13. *
  14. * As a special exception, the copyright holders of this software give you
  15. * permission to link this software with independent modules, and to copy and
  16. * distribute the resulting executable under terms of your choice, provided that
  17. * you also meet, for each linked independent module, the terms and conditions of
  18. * the license of that module. An independent module is a module which is not
  19. * derived from this software. The special exception does not apply to any
  20. * modifications of the software.
  21. *
  22. * Notwithstanding the above, under no circumstances may you combine this
  23. * software in any way with any other Broadcom software provided under a license
  24. * other than the GPL, without Broadcom's express prior written consent.
  25. *
  26. *
  27. * <<Broadcom-WL-IPTag/Open:>>
  28. *
  29. * $Id: hnd_cons.h 624181 2016-03-10 18:58:22Z $
  30. */
  31. #ifndef _hnd_cons_h_
  32. #define _hnd_cons_h_
  33. #include <typedefs.h>
  34. #include <siutils.h>
  35. #define CBUF_LEN (128)
  36. #ifndef LOG_BUF_LEN
  37. #if defined(BCM_BIG_LOG)
  38. #define LOG_BUF_LEN (16 * 1024)
  39. #else
  40. #define LOG_BUF_LEN 1024
  41. #endif // endif
  42. #endif /* LOG_BUF_LEN */
  43. #ifdef BOOTLOADER_CONSOLE_OUTPUT
  44. #undef RWL_MAX_DATA_LEN
  45. #undef CBUF_LEN
  46. #undef LOG_BUF_LEN
  47. #define RWL_MAX_DATA_LEN (4 * 1024 + 8)
  48. #define CBUF_LEN (RWL_MAX_DATA_LEN + 64)
  49. #define LOG_BUF_LEN (16 * 1024)
  50. #endif // endif
  51. typedef struct {
  52. uint32 buf; /* Can't be pointer on (64-bit) hosts */
  53. uint buf_size;
  54. uint idx;
  55. uint out_idx; /* output index */
  56. } hnd_log_t;
  57. typedef struct {
  58. /* Virtual UART
  59. * When there is no UART (e.g. Quickturn), the host should write a complete
  60. * input line directly into cbuf and then write the length into vcons_in.
  61. * This may also be used when there is a real UART (at risk of conflicting with
  62. * the real UART). vcons_out is currently unused.
  63. */
  64. volatile uint vcons_in;
  65. volatile uint vcons_out;
  66. /* Output (logging) buffer
  67. * Console output is written to a ring buffer log_buf at index log_idx.
  68. * The host may read the output when it sees log_idx advance.
  69. * Output will be lost if the output wraps around faster than the host polls.
  70. */
  71. hnd_log_t log;
  72. /* Console input line buffer
  73. * Characters are read one at a time into cbuf until <CR> is received, then
  74. * the buffer is processed as a command line. Also used for virtual UART.
  75. */
  76. uint cbuf_idx;
  77. char cbuf[CBUF_LEN];
  78. } hnd_cons_t;
  79. #endif /* _hnd_cons_h_ */