semihosting.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2022 Ventana Micro Systems Inc.
  5. *
  6. * Authors:
  7. * Anup Patel <apatel@ventanamicro.com>
  8. * Kautuk Consul <kconsul@ventanamicro.com>
  9. */
  10. #ifndef __SERIAL_SEMIHOSTING_H__
  11. #define __SERIAL_SEMIHOSTING_H__
  12. #include <sbi/sbi_types.h>
  13. /**
  14. * enum semihosting_open_mode - Numeric file modes for use with semihosting_open()
  15. * MODE_READ: 'r'
  16. * MODE_BINARY: 'b'
  17. * MODE_PLUS: '+'
  18. * MODE_WRITE: 'w'
  19. * MODE_APPEND: 'a'
  20. *
  21. * These modes represent the mode string used by fopen(3) in a form which can
  22. * be passed to semihosting_open(). These do NOT correspond directly to %O_RDONLY,
  23. * %O_CREAT, etc; see fopen(3) for details. In particular, @MODE_PLUS
  24. * effectively results in adding %O_RDWR, and @MODE_WRITE will add %O_TRUNC.
  25. * For compatibility, @MODE_BINARY should be added when opening non-text files
  26. * (such as images).
  27. */
  28. enum semihosting_open_mode {
  29. MODE_READ = 0x0,
  30. MODE_BINARY = 0x1,
  31. MODE_PLUS = 0x2,
  32. MODE_WRITE = 0x4,
  33. MODE_APPEND = 0x8,
  34. };
  35. #ifdef CONFIG_SERIAL_SEMIHOSTING
  36. int semihosting_init(void);
  37. int semihosting_enabled(void);
  38. #else
  39. static inline int semihosting_init(void) { return SBI_ENODEV; }
  40. static inline int semihosting_enabled(void) { return 0; }
  41. #endif
  42. #endif