summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2018-09-24 23:53:51 +0200
committerAlexander Graf <agraf@suse.de>2018-12-02 21:59:36 +0100
commit87fc275caccfc6fdd2defba570c188f6c5fb15e7 (patch)
tree2c806b151f0c3ee26213ec823d4ce80ffed6081d /lib
parentd39646a38b504c377b5bcf282a2a9407f99b5f57 (diff)
efi_selftest: use CR LF in helloworld
The UEFI spec defines that a line feed moves the cursor to the next line and (only) a carriage return moves the cursor to the beginning of the line. So we should issue CR LF when we want to get to the start of the next line. Add some comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/helloworld.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c
index 3b8de5b4ea..2905479e65 100644
--- a/lib/efi_loader/helloworld.c
+++ b/lib/efi_loader/helloworld.c
@@ -17,6 +17,16 @@ static const efi_guid_t fdt_guid = EFI_FDT_GUID;
static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
+/**
+ * hw_memcmp() - compare memory areas
+ *
+ * @buf1: pointer to first area
+ * @buf2: pointer to second area
+ * @length: number of bytes to compare
+ * Return: 0 if both memory areas are the same, otherwise the sign of the
+ * result value is the same as the sign of ghe difference between
+ * the first differing pair of bytes taken as u8.
+ */
static int hw_memcmp(const void *buf1, const void *buf2, size_t length)
{
const u8 *pos1 = buf1;
@@ -31,12 +41,12 @@ static int hw_memcmp(const void *buf1, const void *buf2, size_t length)
return 0;
}
-/*
- * Entry point of the EFI application.
+/**
+ * efi_main() - entry point of the EFI application.
*
- * @handle handle of the loaded image
- * @systable system table
- * @return status code
+ * @handle: handle of the loaded image
+ * @systable: system table
+ * @return: status code
*/
efi_status_t EFIAPI efi_main(efi_handle_t handle,
struct efi_system_table *systable)
@@ -48,7 +58,8 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
efi_uintn_t i;
u16 rev[] = L"0.0.0";
- con_out->output_string(con_out, L"Hello, world!\n");
+ /* UEFI requires CR LF */
+ con_out->output_string(con_out, L"Hello, world!\r\n");
/* Print the revision number */
rev[0] = (systable->hdr.revision >> 16) + '0';
@@ -65,27 +76,30 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
con_out->output_string(con_out, L"Running on UEFI ");
con_out->output_string(con_out, rev);
- con_out->output_string(con_out, L"\n");
+ con_out->output_string(con_out, L"\r\n");
/* Get the loaded image protocol */
ret = boottime->handle_protocol(handle, &loaded_image_guid,
(void **)&loaded_image);
if (ret != EFI_SUCCESS) {
- con_out->output_string(con_out,
- L"Cannot open loaded image protocol\n");
+ con_out->output_string
+ (con_out, L"Cannot open loaded image protocol\r\n");
goto out;
}
/* Find configuration tables */
for (i = 0; i < systable->nr_tables; ++i) {
if (!hw_memcmp(&systable->tables[i].guid, &fdt_guid,
sizeof(efi_guid_t)))
- con_out->output_string(con_out, L"Have device tree\n");
+ con_out->output_string
+ (con_out, L"Have device tree\r\n");
if (!hw_memcmp(&systable->tables[i].guid, &acpi_guid,
sizeof(efi_guid_t)))
- con_out->output_string(con_out, L"Have ACPI 2.0 table\n");
+ con_out->output_string
+ (con_out, L"Have ACPI 2.0 table\r\n");
if (!hw_memcmp(&systable->tables[i].guid, &smbios_guid,
sizeof(efi_guid_t)))
- con_out->output_string(con_out, L"Have SMBIOS table\n");
+ con_out->output_string
+ (con_out, L"Have SMBIOS table\r\n");
}
/* Output the load options */
con_out->output_string(con_out, L"Load options: ");
@@ -94,7 +108,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
(u16 *)loaded_image->load_options);
else
con_out->output_string(con_out, L"<none>");
- con_out->output_string(con_out, L"\n");
+ con_out->output_string(con_out, L"\r\n");
out:
boottime->exit(handle, ret, 0, NULL);