add support to GIC ITS, and the MSI service base on it
[lunaix-os.git] / lunaix-os / kernel / block / blkpart_gpt.c
index 3eee27727008917155ab72366fa70dd1e1ac2115..4ffff4deb2864f3ca76311acc5114bb2a92d3fa2 100644 (file)
@@ -5,10 +5,12 @@
 #include <lunaix/status.h>
 #include <lunaix/syslog.h>
 
-#include <lib/crc.h>
+#include <asm/muldiv64.h>
+
+#include <klibc/crc.h>
 
 #define GPT_BLKSIZE 512
-#define LBA2OFF(lba) ((lba)*GPT_BLKSIZE)
+#define LBA2OFF(lba) ((lba) * GPT_BLKSIZE)
 #define ENT_PER_BLK (GPT_BLKSIZE / sizeof(struct gpt_entry))
 
 #define GPTSIG_LO 0x20494645UL
@@ -46,11 +48,10 @@ blkpart_parse(struct device* master, struct gpt_header* header)
         }
 
         // Convert UEFI's 512B LB representation into local LBA range.
-        u64_t slba_local =
-          (ent->start_lba * GPT_BLKSIZE) / (u64_t)bdev->blk_size;
-        u64_t elba_local = (ent->end_lba * GPT_BLKSIZE) / (u64_t)bdev->blk_size;
+        u64_t slba_local = udiv64(ent->start_lba * GPT_BLKSIZE, bdev->blk_size);
+        u64_t elba_local = udiv64(ent->end_lba * GPT_BLKSIZE, bdev->blk_size);
 
-        kprintf("%s: guid part#%d: %d..%d\n",
+        kprintf("%s: guid part#%d: %d..%d",
                 bdev->bdev_id,
                 i,
                 (u32_t)slba_local,
@@ -83,7 +84,7 @@ blkpart_probegpt(struct device* master)
     u32_t crc = gpt_hdr->hdr_cksum;
     gpt_hdr->hdr_cksum = 0;
     if (crc32b((void*)gpt_hdr, sizeof(*gpt_hdr)) != crc) {
-        kprintf(KWARN "checksum failed\n");
+        WARN("checksum failed");
         // FUTURE check the backup header
         return EINVAL;
     }