bootparam_utils.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. */
  15. static void sanitize_boot_params(struct boot_params *boot_params)
  16. {
  17. if (boot_params->sentinel) {
  18. /*fields in boot_params are not valid, clear them */
  19. memset(&boot_params->olpc_ofw_header, 0,
  20. (char *)&boot_params->alt_mem_k -
  21. (char *)&boot_params->olpc_ofw_header);
  22. memset(&boot_params->kbd_status, 0,
  23. (char *)&boot_params->hdr -
  24. (char *)&boot_params->kbd_status);
  25. memset(&boot_params->_pad7[0], 0,
  26. (char *)&boot_params->edd_mbr_sig_buffer[0] -
  27. (char *)&boot_params->_pad7[0]);
  28. memset(&boot_params->_pad8[0], 0,
  29. (char *)&boot_params->eddbuf[0] -
  30. (char *)&boot_params->_pad8[0]);
  31. memset(&boot_params->_pad9[0], 0, sizeof(boot_params->_pad9));
  32. }
  33. }
  34. #endif /* _ASM_X86_BOOTPARAM_UTILS_H */