X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/97901724584e74554916b89dfb8e95dc6497e687..7c7b5f05d39b7739d990f71256a2267ec67a6913:/lunaix-os/kernel/block/blkpart_gpt.c diff --git a/lunaix-os/kernel/block/blkpart_gpt.c b/lunaix-os/kernel/block/blkpart_gpt.c index 4f9beec..0bc977d 100644 --- a/lunaix-os/kernel/block/blkpart_gpt.c +++ b/lunaix-os/kernel/block/blkpart_gpt.c @@ -3,11 +3,12 @@ #include #include #include +#include #include #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 @@ -15,6 +16,8 @@ static u8_t NULL_GUID[16] = { 0 }; +LOG_MODULE("GPT") + int blkpart_parse(struct device* master, struct gpt_header* header) { @@ -22,7 +25,7 @@ blkpart_parse(struct device* master, struct gpt_header* header) if (!bdev) return ENODEV; - int errno; + int errno = 0; u32_t ent_lba = (u32_t)header->ents_lba; struct gpt_entry* ents_parial = (struct gpt_entry*)valloc(GPT_BLKSIZE); @@ -43,9 +46,15 @@ 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) / bdev->blk_size; + 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; + kprintf("%s: guid part#%d: %d..%d\n", + bdev->bdev_id, + i, + (u32_t)slba_local, + (u32_t)elba_local); // we ignore the partition name, as it rarely used. blk_mount_part(bdev, NULL, i, slba_local, elba_local); } @@ -73,6 +82,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"); // FUTURE check the backup header return EINVAL; }