18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci#include <linux/io.h> 38c2ecf20Sopenharmony_ci#include <linux/export.h> 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/** 68c2ecf20Sopenharmony_ci * check_signature - find BIOS signatures 78c2ecf20Sopenharmony_ci * @io_addr: mmio address to check 88c2ecf20Sopenharmony_ci * @signature: signature block 98c2ecf20Sopenharmony_ci * @length: length of signature 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * Perform a signature comparison with the mmio address io_addr. This 128c2ecf20Sopenharmony_ci * address should have been obtained by ioremap. 138c2ecf20Sopenharmony_ci * Returns 1 on a match. 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciint check_signature(const volatile void __iomem *io_addr, 178c2ecf20Sopenharmony_ci const unsigned char *signature, int length) 188c2ecf20Sopenharmony_ci{ 198c2ecf20Sopenharmony_ci while (length--) { 208c2ecf20Sopenharmony_ci if (readb(io_addr) != *signature) 218c2ecf20Sopenharmony_ci return 0; 228c2ecf20Sopenharmony_ci io_addr++; 238c2ecf20Sopenharmony_ci signature++; 248c2ecf20Sopenharmony_ci } 258c2ecf20Sopenharmony_ci return 1; 268c2ecf20Sopenharmony_ci} 278c2ecf20Sopenharmony_ciEXPORT_SYMBOL(check_signature); 28