stub.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <efi.h>
  2. #include <efilib.h>
  3. #include <dragonstub/dragonstub.h>
  4. EFI_STATUS efi_handle_cmdline(EFI_LOADED_IMAGE *image, char **cmdline_ptr)
  5. {
  6. int cmdline_size = 0;
  7. EFI_STATUS status;
  8. char *cmdline;
  9. /*
  10. * Get the command line from EFI, using the LOADED_IMAGE
  11. * protocol. We are going to copy the command line into the
  12. * device tree, so this can be allocated anywhere.
  13. */
  14. cmdline = efi_convert_cmdline(image, &cmdline_size);
  15. if (!cmdline) {
  16. efi_err("getting command line via LOADED_IMAGE_PROTOCOL\n");
  17. return EFI_OUT_OF_RESOURCES;
  18. }
  19. // if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
  20. // IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
  21. // cmdline_size == 0) {
  22. // status = efi_parse_options(CONFIG_CMDLINE);
  23. // if (status != EFI_SUCCESS) {
  24. // efi_err("Failed to parse options\n");
  25. // goto fail_free_cmdline;
  26. // }
  27. // }
  28. // if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && cmdline_size > 0) {
  29. if (cmdline_size > 0) {
  30. status = efi_parse_options(cmdline);
  31. if (status != EFI_SUCCESS) {
  32. efi_err("Failed to parse options\n");
  33. goto fail_free_cmdline;
  34. }
  35. }
  36. *cmdline_ptr = cmdline;
  37. return EFI_SUCCESS;
  38. fail_free_cmdline:
  39. efi_bs_call(FreePool, cmdline_ptr);
  40. return status;
  41. }