Merge branch 'master' of git://git.denx.de/u-boot
[oweals/u-boot.git] / lib / efi_loader / helloworld.c
index 046b46a2c1b38c87da074b5892147f887dbb3733..426f276361a6020f424ab30c9095005e31495d25 100644 (file)
 
 static const efi_guid_t loaded_image_guid = LOADED_IMAGE_GUID;
 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;
 
-static int hw_memcmp(const void *buf1, const void *buf2, size_t length)
-{
-       const u8 *pos1 = buf1;
-       const u8 *pos2 = buf2;
-
-       for (; length; --length) {
-               if (*pos1 != *pos2)
-                       return *pos1 - *pos2;
-               ++pos1;
-               ++pos2;
-       }
-       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)
@@ -47,7 +34,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';
@@ -64,24 +52,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");
-               if (!hw_memcmp(&systable->tables[i].guid, &smbios_guid,
-                              sizeof(efi_guid_t)))
-                       con_out->output_string(con_out, L"Have SMBIOS table\n");
+               if (!memcmp(&systable->tables[i].guid, &fdt_guid,
+                           sizeof(efi_guid_t)))
+                       con_out->output_string
+                                       (con_out, L"Have device tree\r\n");
+               if (!memcmp(&systable->tables[i].guid, &acpi_guid,
+                           sizeof(efi_guid_t)))
+                       con_out->output_string
+                                       (con_out, L"Have ACPI 2.0 table\r\n");
+               if (!memcmp(&systable->tables[i].guid, &smbios_guid,
+                           sizeof(efi_guid_t)))
+                       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: ");
@@ -90,7 +84,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);