summaryrefslogtreecommitdiff
path: root/gpt/crc32.ha
diff options
context:
space:
mode:
authorAlejandro Sior <aho@sior.be>2022-06-17 14:43:27 +0200
committerAlejandro Sior <aho@sior.be>2022-06-17 14:43:27 +0200
commit12577f3445df86023ba0cbe2462d55ea5dcafe20 (patch)
treee72d03b6339084760d4c781cbbb5e7e4dd71385d /gpt/crc32.ha
parent3c8602ee9f04991e1d60b8d6504e12296ca671d9 (diff)
gptman: now can allocate partitions
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;
+};