bootparam_utils.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef _ASM_X86_BOOTPARAM_UTILS_H
  2. #define _ASM_X86_BOOTPARAM_UTILS_H
  3. #include <asm/bootparam.h>
  4. /*
  5. * This file is included from multiple environments. Do not
  6. * add completing #includes to make it standalone.
  7. */
  8. /*
  9. * Deal with bootloaders which fail to initialize unknown fields in
  10. * boot_params to zero. The list fields in this list are taken from
  11. * analysis of kexec-tools; if other broken bootloaders initialize a
  12. * different set of fields we will need to figure out how to disambiguate.
  13. *
  14. * Note: efi_info is commonly left uninitialized, but that field has a
  15. * private magic, so it is better to leave it unchanged.
  16. */
  17. static void sanitize_boot_params(struct boot_params *boot_params)
  18. {
  19. if (boot_params->sentinel) {
  20. /*fields in boot_params are not valid, clear them */
  21. memset(&boot_params->olpc_ofw_header, 0,
  22. (char *)&boot_params->efi_info -
  23. (char *)&boot_params->olpc_ofw_header);
  24. memset(&boot_params->kbd_status, 0,
  25. (char *)&boot_params->hdr -
  26. (char *)&boot_params->kbd_status);
  27. memset(&boot_params->_pad7[0], 0,
  28. (char *)&boot_params->edd_mbr_sig_buffer[0] -
  29. (char *)&boot_params->_pad7[0]);
  30. memset(&boot_params->_pad8[0], 0,
  31. (char *)&boot_params->eddbuf[0] -
  32. (char *)&boot_params->_pad8[0]);
  33. memset(&boot_params->_pad9[0], 0, sizeof(boot_params->_pad9));
  34. }
  35. }
  36. #endif /* _ASM_X86_BOOTPARAM_UTILS_H */