@@ -14,6 +14,7 @@
/* From lib/argv.c */
extern int __argc, __envc;
+extern const char *__args;
extern char *__argv[100];
extern char *__environ[200];
@@ -212,6 +213,28 @@ efi_set_up_envs_error:
return EFI_ABORTED;
}
+static efi_status_t efi_set_up_args(efi_file_protocol_t *volume)
+{
+ efi_char16_t file_name[] = L"ARGS.TXT";
+ unsigned long file_size;
+ char *file_data = NULL;
+ efi_status_t status;
+
+ status = efi_read_file(volume, file_name, &file_size, &file_data);
+ if (status != EFI_SUCCESS) {
+ printf("Failed to read file\n");
+ goto efi_set_up_envs_error;
+ }
+
+ __args = file_data;
+ __setup_args();
+
+ return EFI_SUCCESS;
+
+efi_set_up_envs_error:
+ return EFI_ABORTED;
+}
+
efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab)
{
int ret;
@@ -234,6 +257,7 @@ efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab)
}
efi_set_up_envs(volume);
+ efi_set_up_args(volume);
/* Set up efi_bootinfo */
efi_bootinfo.mem_map.map = ↦
@@ -44,9 +44,10 @@ fi
mkdir -p "$EFI_CASE_DIR"
cp "$EFI_SRC/$EFI_CASE.efi" "$EFI_CASE_BINARY"
-# Capture -initrd
+# Capture -initrd and -append
efi_qemu_args=""
efi_qemu_initrd=""
+efi_qemu_append=""
while [[ -n "$1" ]]; do
case "$1" in
--initrd|-initrd)
@@ -54,6 +55,11 @@ while [[ -n "$1" ]]; do
efi_qemu_initrd="$1"
shift 1
;;
+ --append|-append)
+ shift 1
+ efi_qemu_append="$1"
+ shift 1
+ ;;
*)
efi_qemu_args+=" $1"
shift 1
@@ -67,6 +73,10 @@ KVM_UNIT_TESTS_EFI_ENV="$EFI_TEST/$EFI_CASE/ENVS.TXT"
mv "$KVM_UNIT_TESTS_ENV" "$KVM_UNIT_TESTS_EFI_ENV"
[[ -f "$efi_qemu_initrd" ]] && cat "$efi_qemu_initrd" >> "$KVM_UNIT_TESTS_EFI_ENV"
+# Create ARGS file
+KVM_UNIT_TESTS_EFI_ARG="$EFI_TEST/$EFI_CASE/ARGS.TXT"
+echo -n "$efi_qemu_append" > "$KVM_UNIT_TESTS_EFI_ARG"
+
# Run test case with 256MiB QEMU memory. QEMU default memory size is 128MiB.
# After UEFI boot up and we call `LibMemoryMap()`, the largest consecutive
# memory region is ~42MiB. Although this is sufficient for many test cases to