Merge branch 'master' of git://git.denx.de/u-boot
[oweals/u-boot.git] / include / efi_selftest.h
index be5ba4bfa91ccc0b8eca88cda6d06c42a3737f3f..eaee188de7ef60db32784f3f3d7a9fbe26fac95d 100644 (file)
@@ -1,9 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  *  EFI application loader
  *
  *  Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
- *
- *  SPDX-License-Identifier:     GPL-2.0+
  */
 
 #ifndef _EFI_SELFTEST_H
 
 #define EFI_ST_SUCCESS 0
 #define EFI_ST_FAILURE 1
+#define EFI_ST_SUCCESS_STR L"SUCCESS"
+/*
+ * Prints a message.
+ */
+#define efi_st_printf(...) \
+       (efi_st_printc(-1, __VA_ARGS__))
 
 /*
  * Prints an error message.
@@ -24,8 +29,8 @@
  * @...        format string followed by fields to print
  */
 #define efi_st_error(...) \
-       (efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__), \
-       efi_st_printf(__VA_ARGS__)) \
+       (efi_st_printc(EFI_LIGHTRED, "%s(%u):\nERROR: ", __FILE__, __LINE__), \
+       efi_st_printc(EFI_LIGHTRED, __VA_ARGS__))
 
 /*
  * Prints a TODO message.
@@ -33,8 +38,8 @@
  * @...        format string followed by fields to print
  */
 #define efi_st_todo(...) \
-       (efi_st_printf("%s(%u):\nTODO: ", __FILE__, __LINE__), \
-       efi_st_printf(__VA_ARGS__)) \
+       (efi_st_printc(EFI_YELLOW, "%s(%u):\nTODO: ", __FILE__, __LINE__), \
+       efi_st_printc(EFI_YELLOW, __VA_ARGS__)) \
 
 /*
  * A test may be setup and executed at boottime,
@@ -48,7 +53,7 @@ enum efi_test_phase {
 };
 
 extern struct efi_simple_text_output_protocol *con_out;
-extern struct efi_simple_input_interface *con_in;
+extern struct efi_simple_text_input_protocol *con_in;
 
 /*
  * Exit the boot services.
@@ -61,25 +66,31 @@ extern struct efi_simple_input_interface *con_in;
 void efi_st_exit_boot_services(void);
 
 /*
- * Print a pointer to an u16 string
+ * Print a colored message
  *
- * @pointer: pointer
- * @buf: pointer to buffer address
- * on return position of terminating zero word
+ * @color      color, see constants in efi_api.h, use -1 for no color
+ * @fmt                printf format
+ * @...                arguments to be printed
+ *             on return position of terminating zero word
  */
-void efi_st_printf(const char *fmt, ...)
-                __attribute__ ((format (__printf__, 1, 2)));
+void efi_st_printc(int color, const char *fmt, ...)
+                __attribute__ ((format (__printf__, 2, 3)));
 
-/*
- * Compare memory.
- * We cannot use lib/string.c due to different CFLAGS values.
+/**
+ * efi_st_translate_char() - translate a unicode character to a string
  *
- * @buf1:      first buffer
- * @buf2:      second buffer
- * @length:    number of bytes to compare
- * @return:    0 if both buffers contain the same bytes
+ * @code:      unicode character
+ * Return:     string
+ */
+u16 *efi_st_translate_char(u16 code);
+
+/**
+ * efi_st_translate_code() - translate a scan code to a human readable string
+ *
+ * @code:      unicode character
+ * Return:     string
  */
-int efi_st_memcmp(const void *buf1, const void *buf2, size_t length);
+u16 *efi_st_translate_code(u16 code);
 
 /*
  * Compare an u16 string to a char string.