summaryrefslogtreecommitdiff
path: root/gpt/crc32.ha
diff options
context:
space:
mode:
Diffstat (limited to 'gpt/crc32.ha')
-rw-r--r--gpt/crc32.ha16
1 files changed, 16 insertions, 0 deletions
diff --git a/gpt/crc32.ha b/gpt/crc32.ha
index 24318bd..386779f 100644
--- a/gpt/crc32.ha
+++ b/gpt/crc32.ha
@@ -79,3 +79,19 @@ export fn header_crc32(self: *header) u32 = {
crc ^= 0xffffffff;
return crc;
};
+
+// Calculates the crc32 entries array checksum
+export fn entries_crc32(self: *[128]entry) u32 = {
+ const data = self: *[*]u8;
+
+ let crc: u32 = 0xffffffff;
+ for (let i = 0z; i < 128*128; i += 1) {
+ let d: u8 = data[i];
+
+ let lookup_index: u32 = (crc ^ d) & 0xff;
+ crc = (crc >> 8) ^ crc_table[lookup_index];
+ };
+
+ crc ^= 0xffffffff;
+ return crc;
+};