sbi_console.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2019 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. */
  9. #ifndef __SBI_CONSOLE_H__
  10. #define __SBI_CONSOLE_H__
  11. #include <sbi/sbi_types.h>
  12. struct sbi_console_device {
  13. /** Name of the console device */
  14. char name[32];
  15. /** Write a character to the console output */
  16. void (*console_putc)(char ch);
  17. /** Read a character from the console input */
  18. int (*console_getc)(void);
  19. };
  20. #define __printf(a, b) __attribute__((format(printf, a, b)))
  21. bool sbi_isprintable(char ch);
  22. int sbi_getc(void);
  23. void sbi_putc(char ch);
  24. void sbi_puts(const char *str);
  25. void sbi_gets(char *s, int maxwidth, char endchar);
  26. int __printf(2, 3) sbi_sprintf(char *out, const char *format, ...);
  27. int __printf(3, 4) sbi_snprintf(char *out, u32 out_sz, const char *format, ...);
  28. int __printf(1, 2) sbi_printf(const char *format, ...);
  29. int __printf(1, 2) sbi_dprintf(const char *format, ...);
  30. const struct sbi_console_device *sbi_console_get_device(void);
  31. void sbi_console_set_device(const struct sbi_console_device *dev);
  32. struct sbi_scratch;
  33. int sbi_console_init(struct sbi_scratch *scratch);
  34. #endif