+ /*
+ * attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ * EFI_VARIABLE_RUNTIME_ACCESS;
+ */
+ value = NULL;
+ size = 0;
+ attributes = 0;
+ guid = efi_global_variable_guid;
+ default_guid = true;
+ verbose = false;
+ value_on_memory = false;
+ for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
+ if (!strcmp(argv[0], "-guid")) {
+ if (argc == 1)
+ return CMD_RET_USAGE;
+
+ argc--;
+ argv++;
+ if (uuid_str_to_bin(argv[0], guid.b,
+ UUID_STR_FORMAT_GUID)) {
+ printf("## Guid not specified or in XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX format\n");
+ return CMD_RET_FAILURE;
+ }
+ default_guid = false;
+ } else if (!strcmp(argv[0], "-bs")) {
+ attributes |= EFI_VARIABLE_BOOTSERVICE_ACCESS;
+ } else if (!strcmp(argv[0], "-rt")) {
+ attributes |= EFI_VARIABLE_RUNTIME_ACCESS;
+ } else if (!strcmp(argv[0], "-nv")) {
+ attributes |= EFI_VARIABLE_NON_VOLATILE;
+ } else if (!strcmp(argv[0], "-at")) {
+ attributes |=
+ EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
+ } else if (!strcmp(argv[0], "-a")) {
+ attributes |= EFI_VARIABLE_APPEND_WRITE;
+ } else if (!strcmp(argv[0], "-i")) {
+ /* data comes from memory */
+ if (argc == 1)
+ return CMD_RET_USAGE;
+
+ argc--;
+ argv++;
+ addr = simple_strtoul(argv[0], &ep, 16);
+ if (*ep != ',')
+ return CMD_RET_USAGE;
+
+ /* 0 should be allowed for delete */
+ size = simple_strtoul(++ep, NULL, 16);
+
+ value_on_memory = true;
+ } else if (!strcmp(argv[0], "-v")) {
+ verbose = true;
+ } else {
+ return CMD_RET_USAGE;
+ }
+ }
+ if (!argc)
+ return CMD_RET_USAGE;
+
+ var_name = argv[0];
+ if (default_guid) {
+ if (!strcmp(var_name, "db") || !strcmp(var_name, "dbx") ||
+ !strcmp(var_name, "dbt"))
+ guid = efi_guid_image_security_database;
+ else
+ guid = efi_global_variable_guid;
+ }
+
+ if (verbose) {
+ printf("GUID: %s\n", efi_guid_to_str((const efi_guid_t *)
+ &guid));
+ printf("Attributes: 0x%x\n", attributes);
+ }