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