[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 35/41] arm : acpi add helper function to calculate crc32
Add helper functions for calculating crc32. This is required for computing crc of efi table. These functions are copied from here http://mirrors.neusoft.edu.cn/rpi-kernel/lib/xz/xz_crc32.c Original author's are Lasse Collin and Igor Pavlov. Signed-off-by: Parth Dixit <parth.dixit@xxxxxxxxxx> --- xen/arch/arm/domain_build.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 36b072b..0ad70c1 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1227,6 +1227,39 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, } #ifdef CONFIG_ACPI +static uint32_t xz_crc32_table[256]; + +static void xz_crc32_init(void) +{ + const uint32_t poly = 0xEDB88320; + + uint32_t i; + uint32_t j; + uint32_t r; + + for (i = 0; i < 256; ++i) { + r = i; + for (j = 0; j < 8; ++j) + r = (r >> 1) ^ (poly & ~((r & 1) - 1)); + + xz_crc32_table[i] = r; + } + + return; +} + +static uint32_t xz_crc32(uint8_t *buf, size_t size, uint32_t crc) +{ + crc = ~crc; + + while (size != 0) { + crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8); + --size; + } + + return ~crc; +} + static int create_xen_acpi_tables(struct kernel_info *kinfo, struct domain *d, struct membank tbl_add[]) { -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |