check_signature.c 635 B

12345678910111213141516171819202122232425262728
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/io.h>
  3. #include <linux/export.h>
  4. /**
  5. * check_signature - find BIOS signatures
  6. * @io_addr: mmio address to check
  7. * @signature: signature block
  8. * @length: length of signature
  9. *
  10. * Perform a signature comparison with the mmio address io_addr. This
  11. * address should have been obtained by ioremap.
  12. * Returns 1 on a match.
  13. */
  14. int check_signature(const volatile void __iomem *io_addr,
  15. const unsigned char *signature, int length)
  16. {
  17. while (length--) {
  18. if (readb(io_addr) != *signature)
  19. return 0;
  20. io_addr++;
  21. signature++;
  22. }
  23. return 1;
  24. }
  25. EXPORT_SYMBOL(check_signature);