-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathio.c
42 lines (34 loc) · 747 Bytes
/
io.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "io.h"
#include "log.h"
efi_status_t efi_read_fixed(
struct efi_system_table *system,
struct efi_file_protocol *file,
uint64_t offset,
size_t size,
void *dst)
{
efi_status_t status = EFI_SUCCESS;
unsigned char *buf = dst;
size_t read = 0;
status = file->set_position(file, offset);
if (status != EFI_SUCCESS) {
err(
system,
"failed to set read position: %llu\r\n",
(unsigned long long)status);
return status;
}
while (read < size) {
efi_uint_t remains = size - read;
status = file->read(file, &remains, (void *)(buf + read));
if (status != EFI_SUCCESS) {
err(
system,
"read failed: %llu\r\n",
(unsigned long long)status);
return status;
}
read += remains;
}
return status;
}