UINTN cursor_color = TEXT_ATTR_SWAP(COLOR_EDIT);
j = MIN(len - first, x_max);
- CopyMem(print, line + first, j * sizeof(CHAR16));
+ memcpy(print, line + first, j * sizeof(CHAR16));
while (clear > 0 && j < x_max) {
clear--;
print[j++] = ' ';
if (EFI_ERROR(err) || size != read)
return FALSE;
- return CompareMem(content, magic, sizeof(magic)) == 0;
+ return memcmp(content, magic, sizeof(magic)) == 0;
}
static ConfigEntry *config_entry_add_loader_auto(
if (EFI_ERROR(err))
continue;
- if (CompareMem(buf + 3, "-FVE-FS-", STRLEN("-FVE-FS-")) == 0) {
+ if (memcmp(buf + 3, "-FVE-FS-", STRLEN("-FVE-FS-")) == 0) {
found = TRUE;
break;
}
UINTN l;
l = strsize16(config->entries[i]->id);
- CopyMem(p, config->entries[i]->id, l);
+ memcpy(p, config->entries[i]->id, l);
p += l;
}
*cpio_buffer = a;
a = (CHAR8*) *cpio_buffer + *cpio_buffer_size;
- CopyMem(a, "070701", 6); /* magic ID */
+ memcpy(a, "070701", 6); /* magic ID */
a += 6;
a = write_cpio_word(a, (*inode_counter)++); /* inode */
a = write_cpio_word(a, target_dir_prefix_size + fname_size + 2); /* fname size */
a = write_cpio_word(a, 0); /* "crc" */
- CopyMem(a, target_dir_prefix, target_dir_prefix_size);
+ memcpy(a, target_dir_prefix, target_dir_prefix_size);
a += target_dir_prefix_size;
*(a++) = '/';
a = mangle_filename(a, fname);
/* Pad to next multiple of 4 */
a = pad4(a, *cpio_buffer);
- CopyMem(a, contents, contents_size);
+ memcpy(a, contents, contents_size);
a += contents_size;
/* Pad to next multiple of 4 */
*cpio_buffer = a = xreallocate_pool(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + l);
a = (CHAR8*) *cpio_buffer + *cpio_buffer_size;
- CopyMem(a, "070701", 6); /* magic ID */
+ memcpy(a, "070701", 6); /* magic ID */
a += 6;
a = write_cpio_word(a, (*inode_counter)++); /* inode */
a = write_cpio_word(a, path_size + 1); /* fname size */
a = write_cpio_word(a, 0); /* "crc" */
- CopyMem(a, path, path_size + 1);
+ memcpy(a, path, path_size + 1);
a += path_size + 1;
/* Pad to next multiple of 4 */
assert_cc(sizeof(trailer) % 4 == 0);
*cpio_buffer = xreallocate_pool(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + sizeof(trailer));
- CopyMem((UINT8*) *cpio_buffer + *cpio_buffer_size, trailer, sizeof(trailer));
+ memcpy((UINT8*) *cpio_buffer + *cpio_buffer_size, trailer, sizeof(trailer));
*cpio_buffer_size += sizeof(trailer);
return EFI_SUCCESS;
if (EFI_ERROR(err))
return err;
- CopyMem(PHYSICAL_ADDRESS_TO_POINTER(state->addr), oldptr, len);
+ memcpy(PHYSICAL_ADDRESS_TO_POINTER(state->addr), oldptr, len);
err = BS->FreePages(oldaddr, oldpages);
if (EFI_ERROR(err))
return err;
if (EFI_ERROR(err))
return err;
- CopyMem(PHYSICAL_ADDRESS_TO_POINTER(state->addr), dtb_buffer, dtb_length);
+ memcpy(PHYSICAL_ADDRESS_TO_POINTER(state->addr), dtb_buffer, dtb_length);
err = devicetree_fixup(state, dtb_length);
if (EFI_ERROR(err))
return EFI_BUFFER_TOO_SMALL;
}
- CopyMem(buffer, loader->address, loader->length);
+ memcpy(buffer, loader->address, loader->length);
*buffer_size = loader->length;
return EFI_SUCCESS;
}
if (EFI_ERROR(err))
return EFI_OUT_OF_RESOURCES;
new_buffer = PHYSICAL_ADDRESS_TO_POINTER(ALIGN_TO(kernel.addr, kernel_alignment));
- CopyMem(new_buffer, linux_buffer, linux_length);
+ memcpy(new_buffer, linux_buffer, linux_length);
/* zero out rest of memory (probably not needed, but BSS section should be 0) */
- SetMem((UINT8 *)new_buffer + linux_length, kernel_size_of_image - linux_length, 0);
+ memset((UINT8 *)new_buffer + linux_length, 0, kernel_size_of_image - linux_length);
/* get the entry point inside the relocated kernel */
kernel_entry = (EFI_IMAGE_ENTRY_POINT) ((const UINT8 *)new_buffer + kernel_entry_address);
return err;
boot_params = (struct boot_params *) PHYSICAL_ADDRESS_TO_POINTER(addr);
- ZeroMem(boot_params, 0x4000);
+ memset(boot_params, 0, 0x4000);
boot_params->hdr = image_params->hdr;
boot_params->hdr.type_of_loader = 0xff;
setup_sectors = image_params->hdr.setup_sects > 0 ? image_params->hdr.setup_sects : 4;
if (EFI_ERROR(err))
return err;
- CopyMem(PHYSICAL_ADDRESS_TO_POINTER(addr), cmdline, cmdline_len);
+ memcpy(PHYSICAL_ADDRESS_TO_POINTER(addr), cmdline, cmdline_len);
((CHAR8 *) PHYSICAL_ADDRESS_TO_POINTER(addr))[cmdline_len] = 0;
boot_params->hdr.cmd_line_ptr = (UINT32) addr;
}
.PCRIndex = pcrindex,
.EventType = EV_IPL,
};
- CopyMem(tcg_event->Event, description, desc_len);
+ memcpy(tcg_event->Event, description, desc_len);
return tcg->HashLogExtendEvent(
(EFI_TCG *) tcg,
.Header.EventType = EV_IPL,
};
- CopyMem(tcg_event->Event, description, desc_len);
+ memcpy(tcg_event->Event, description, desc_len);
return tcg->HashLogExtendEvent(
tcg,
static inline BOOLEAN verify_dos(const struct DosFileHeader *dos) {
assert(dos);
- return CompareMem(dos->Magic, DOS_FILE_MAGIC, STRLEN(DOS_FILE_MAGIC)) == 0;
+ return memcmp(dos->Magic, DOS_FILE_MAGIC, STRLEN(DOS_FILE_MAGIC)) == 0;
}
static inline BOOLEAN verify_pe(const struct PeFileHeader *pe, BOOLEAN allow_compatibility) {
assert(pe);
- return CompareMem(pe->Magic, PE_FILE_MAGIC, STRLEN(PE_FILE_MAGIC)) == 0 &&
+ return memcmp(pe->Magic, PE_FILE_MAGIC, STRLEN(PE_FILE_MAGIC)) == 0 &&
(pe->FileHeader.Machine == TARGET_MACHINE_TYPE ||
(allow_compatibility && pe->FileHeader.Machine == TARGET_MACHINE_TYPE_COMPATIBILITY)) &&
pe->FileHeader.NumberOfSections > 0 &&
const struct PeSectionHeader *sect = section_table + i;
for (UINTN j = 0; sections[j]; j++) {
- if (CompareMem(sect->Name, sections[j], strlen8((const char *) sections[j])) != 0)
+ if (memcmp(sect->Name, sections[j], strlen8((const char *) sections[j])) != 0)
continue;
if (addrs)
sha256_process_bytes(array[i].string, strlen8(array[i].string), &hash);
sha256_finish_ctx(&hash, result);
- assert(CompareMem(result, array[i].hash, HASH_VALUE_SIZE) == 0);
+ assert(memcmp(result, array[i].hash, HASH_VALUE_SIZE) == 0);
}
#endif
/* Order matters, the real initrd must come first, since it might include microcode updates
* which the kernel only looks for in the first cpio archive */
- CopyMem(p, PHYSICAL_ADDRESS_TO_POINTER(initrd_base), initrd_size);
+ memcpy(p, PHYSICAL_ADDRESS_TO_POINTER(initrd_base), initrd_size);
p += initrd_size;
pad = ALIGN_TO(initrd_size, 4) - initrd_size;
if (pad > 0) {
- ZeroMem(p, pad);
+ memset(p, 0, pad);
p += pad;
}
}
if (credential_initrd) {
- CopyMem(p, credential_initrd, credential_initrd_size);
+ memcpy(p, credential_initrd, credential_initrd_size);
p += credential_initrd_size;
}
if (global_credential_initrd) {
- CopyMem(p, global_credential_initrd, global_credential_initrd_size);
+ memcpy(p, global_credential_initrd, global_credential_initrd_size);
p += global_credential_initrd_size;
}
if (sysext_initrd) {
- CopyMem(p, sysext_initrd, sysext_initrd_size);
+ memcpy(p, sysext_initrd, sysext_initrd_size);
p += sysext_initrd_size;
}
/* Make sure a terminating NUL is available at the end */
val = xallocate_pool(size + sizeof(CHAR16));
- CopyMem(val, buf, size);
+ memcpy(val, buf, size);
val[size / sizeof(CHAR16) - 1] = 0; /* NUL terminate */
*value = val;
return err;
/* Note that handle->Read() changes size to reflect the actually bytes read. */
- ZeroMem(buf + size, extra);
+ memset(buf + size, 0, extra);
*ret = TAKE_PTR(buf);
if (ret_size)
n = xallocate_pool(sz + 1);
if (sz > 0)
- CopyMem(n, p, sz);
+ memcpy(n, p, sz);
n[sz] = 0;
return n;
UINTN len = (UINT8 *) node - (UINT8 *) path;
EFI_DEVICE_PATH *chopped = xallocate_pool(len + END_DEVICE_PATH_LENGTH);
- CopyMem(chopped, path, len);
+ memcpy(chopped, path, len);
SetDevicePathEndNode((EFI_DEVICE_PATH *) ((UINT8 *) chopped + len));
return chopped;
h = &gpt_header_buffer->gpt_header;
/* Some superficial validation of the GPT header */
- if (CompareMem(&h->Header.Signature, "EFI PART", sizeof(h->Header.Signature)) != 0)
+ if (memcmp(&h->Header.Signature, "EFI PART", sizeof(h->Header.Signature)) != 0)
return FALSE;
if (h->Header.HeaderSize < 92 || h->Header.HeaderSize > 512)
entry = (EFI_PARTITION_ENTRY*) ((UINT8*) entries + gpt.gpt_header.SizeOfPartitionEntry * i);
- if (CompareMem(&entry->PartitionTypeGUID, XBOOTLDR_GUID, sizeof(entry->PartitionTypeGUID)) != 0)
+ if (memcmp(&entry->PartitionTypeGUID, XBOOTLDR_GUID, sizeof(entry->PartitionTypeGUID)) != 0)
continue;
/* Let's use memcpy(), in case the structs are not aligned (they really should be though) */
- CopyMem(&start, &entry->StartingLBA, sizeof(start));
- CopyMem(&end, &entry->EndingLBA, sizeof(end));
+ memcpy(&start, &entry->StartingLBA, sizeof(start));
+ memcpy(&end, &entry->EndingLBA, sizeof(end));
if (end < start) /* Bogus? */
continue;
ret_hd->PartitionSize = end - start + 1;
ret_hd->MBRType = MBR_TYPE_EFI_PARTITION_TABLE_HEADER;
ret_hd->SignatureType = SIGNATURE_TYPE_GUID;
- CopyMem(ret_hd->Signature, &entry->UniquePartitionGUID, sizeof(ret_hd->Signature));
+ memcpy(ret_hd->Signature, &entry->UniquePartitionGUID, sizeof(ret_hd->Signature));
return EFI_SUCCESS;
}
/* Patch in the data we found */
EFI_DEVICE_PATH *xboot_path = ASSERT_SE_PTR(DuplicateDevicePath(partition_path));
- CopyMem((UINT8 *) xboot_path + ((UINT8 *) part_node - (UINT8 *) partition_path), &hd, sizeof(hd));
+ memcpy((UINT8 *) xboot_path + ((UINT8 *) part_node - (UINT8 *) partition_path), &hd, sizeof(hd));
*ret_device_path = xboot_path;
return EFI_SUCCESS;
}
#define static_assert _Static_assert
#define assert_se(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); })
- #define memcpy(a, b, c) CopyMem((a), (b), (c))
#define free(a) FreePool(a)
#endif
/* Written by Ulrich Drepper <drepper@redhat.com>, 2007. */
-#ifndef SD_BOOT
-#include <string.h>
+#ifdef SD_BOOT
+# include "efi-string.h"
+#else
+# include <string.h>
#endif
#include "macro-fundamental.h"
# define strcasecmp strcasecmp16
# define strncasecmp strncasecmp16
# define STR_C(str) (L ## str)
-# define memcmp(a, b, n) CompareMem(a, b, n)
#else
# define STR_C(str) (str)
#endif