fdtdec: support multiple phandles in memory carveout
[oweals/u-boot.git] / lib / efi_selftest / efi_selftest_block_device.c
index 1cd13042e90d9070d17658c15e641ed1151511b9..d98a854e6d1a81d97762ce6d2f9e8508a291c8ec 100644 (file)
@@ -24,8 +24,8 @@
 
 static struct efi_boot_services *boottime;
 
-static const efi_guid_t block_io_protocol_guid = BLOCK_IO_GUID;
-static const efi_guid_t guid_device_path = DEVICE_PATH_GUID;
+static const efi_guid_t block_io_protocol_guid = EFI_BLOCK_IO_PROTOCOL_GUID;
+static const efi_guid_t guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID;
 static const efi_guid_t guid_simple_file_system_protocol =
                                        EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
 static const efi_guid_t guid_file_system_info = EFI_FILE_SYSTEM_INFO_GUID;
@@ -257,14 +257,14 @@ static int teardown(void)
                                disk_handle, &block_io_protocol_guid,
                                &block_io);
                if (r != EFI_SUCCESS) {
-                       efi_st_todo(
+                       efi_st_error(
                                "Failed to uninstall block I/O protocol\n");
-                       return EFI_ST_SUCCESS;
+                       return EFI_ST_FAILURE;
                }
        }
 
        if (image) {
-               r = efi_free_pool(image);
+               r = boottime->free_pool(image);
                if (r != EFI_SUCCESS) {
                        efi_st_error("Failed to free image\n");
                        return EFI_ST_FAILURE;
@@ -308,6 +308,7 @@ static int execute(void)
        } system_info;
        efi_uintn_t buf_size;
        char buf[16] __aligned(ARCH_DMA_MINALIGN);
+       u64 pos;
 
        /* Connect controller to virtual disk */
        ret = boottime->connect_controller(disk_handle, NULL, NULL, 1);
@@ -336,7 +337,7 @@ static int execute(void)
                }
                if (len >= dp_size(dp_partition))
                        continue;
-               if (efi_st_memcmp(dp, dp_partition, len))
+               if (memcmp(dp, dp_partition, len))
                        continue;
                handle_partition = handles[i];
                break;
@@ -386,27 +387,42 @@ static int execute(void)
        }
 
        /* Read file */
-       ret = root->open(root, &file, (s16 *)L"hello.txt", EFI_FILE_MODE_READ,
+       ret = root->open(root, &file, L"hello.txt", EFI_FILE_MODE_READ,
                         0);
        if (ret != EFI_SUCCESS) {
                efi_st_error("Failed to open file\n");
                return EFI_ST_FAILURE;
        }
+       ret = file->setpos(file, 1);
+       if (ret != EFI_SUCCESS) {
+               efi_st_error("SetPosition failed\n");
+               return EFI_ST_FAILURE;
+       }
        buf_size = sizeof(buf) - 1;
        ret = file->read(file, &buf_size, buf);
        if (ret != EFI_SUCCESS) {
                efi_st_error("Failed to read file\n");
                return EFI_ST_FAILURE;
        }
-       if (buf_size != 13) {
+       if (buf_size != 12) {
                efi_st_error("Wrong number of bytes read: %u\n",
                             (unsigned int)buf_size);
                return EFI_ST_FAILURE;
        }
-       if (efi_st_memcmp(buf, "Hello world!", 12)) {
+       if (memcmp(buf, "ello world!", 11)) {
                efi_st_error("Unexpected file content\n");
                return EFI_ST_FAILURE;
        }
+       ret = file->getpos(file, &pos);
+       if (ret != EFI_SUCCESS) {
+               efi_st_error("GetPosition failed\n");
+               return EFI_ST_FAILURE;
+       }
+       if (pos != 13) {
+               efi_st_error("GetPosition returned %u, expected 13\n",
+                            (unsigned int)pos);
+               return EFI_ST_FAILURE;
+       }
        ret = file->close(file);
        if (ret != EFI_SUCCESS) {
                efi_st_error("Failed to close file\n");
@@ -415,7 +431,7 @@ static int execute(void)
 
 #ifdef CONFIG_FAT_WRITE
        /* Write file */
-       ret = root->open(root, &file, (s16 *)L"u-boot.txt", EFI_FILE_MODE_READ |
+       ret = root->open(root, &file, L"u-boot.txt", EFI_FILE_MODE_READ |
                         EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
        if (ret != EFI_SUCCESS) {
                efi_st_error("Failed to open file\n");
@@ -429,6 +445,16 @@ static int execute(void)
                efi_st_error("Failed to write file\n");
                return EFI_ST_FAILURE;
        }
+       ret = file->getpos(file, &pos);
+       if (ret != EFI_SUCCESS) {
+               efi_st_error("GetPosition failed\n");
+               return EFI_ST_FAILURE;
+       }
+       if (pos != 7) {
+               efi_st_error("GetPosition returned %u, expected 7\n",
+                            (unsigned int)pos);
+               return EFI_ST_FAILURE;
+       }
        ret = file->close(file);
        if (ret != EFI_SUCCESS) {
                efi_st_error("Failed to close file\n");
@@ -437,7 +463,7 @@ static int execute(void)
 
        /* Verify file */
        boottime->set_mem(buf, sizeof(buf), 0);
-       ret = root->open(root, &file, (s16 *)L"u-boot.txt", EFI_FILE_MODE_READ,
+       ret = root->open(root, &file, L"u-boot.txt", EFI_FILE_MODE_READ,
                         0);
        if (ret != EFI_SUCCESS) {
                efi_st_error("Failed to open file\n");
@@ -454,7 +480,7 @@ static int execute(void)
                             (unsigned int)buf_size);
                return EFI_ST_FAILURE;
        }
-       if (efi_st_memcmp(buf, "U-Boot", 7)) {
+       if (memcmp(buf, "U-Boot", 7)) {
                efi_st_error("Unexpected file content %s\n", buf);
                return EFI_ST_FAILURE;
        }