Skip to content

Commit

Permalink
pci: Mark BAR reading as TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
marv7000 committed Dec 15, 2024
1 parent 085bec1 commit da2da9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
12 changes: 7 additions & 5 deletions kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,24 @@

ATTR(noreturn) void kernel_init(BootInfo* info)
{
// Initialize command line.
// Initialize command line (without allocations), so we can control the allocator at boot time.
cmd_early_init(info->cmd);

// Initialize basic IO.
arch_early_init();

// Initialize memory managers.
pm_init(info->phys_base, info->memory_map, info->mm_num);
alloc_init();

// Now that we can allocate, copy over the command line so it doesn't get lost when we drop `.reclaim`.
cmd_init();

// Initialize virtual file system.
vfs_init();
// Load initrd(s).
for (usize i = 0; i < info->file_num; i++)
ustarfs_init(vfs_get_root(), info->files[i].address, info->files[i].size);

// If no early framebuffer has been set previously, do it now.
fb_register(info->fb);
Expand All @@ -48,10 +53,7 @@ ATTR(noreturn) void kernel_init(BootInfo* info)
print_log("boot: Finished early initialization.\n");
arch_init(info);

// Load initrd(s).
for (usize i = 0; i < info->file_num; i++)
ustarfs_init(vfs_get_root(), info->files[i].address, info->files[i].size);

// Finalize virtual memory manager and drop reclaimable memory.
vm_init(info->kernel_phys, info->memory_map, info->mm_num);

// Initialize all modules and subsystems.
Expand Down
9 changes: 7 additions & 2 deletions modules/drv/block/nvme/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ i32 nvme_probe(PciDevice* pdev)
// Allocate device data.
NvmeController* nvme = kzalloc(sizeof(NvmeController));
dev_set_data(pdev->dev, nvme);
nvme->mmio_base =
pm_get_phys_base() + (((PhysAddr)pdev->generic.bar[1] << 32) | (pdev->generic.bar[0] & 0xFFFFC000));

// TODO: KVM puts this BAR in memory unmapped by phys_base.
// TODO: PCI needs a proper BAR detection + mapping function.
PhysAddr nvme_bar = (((PhysAddr)pdev->generic.bar[1] << 32) | (pdev->generic.bar[0] & 0xFFFFC000));
print_log("BAR: 0x%p\n", nvme_bar);
nvme->mmio_base = pm_get_phys_base() + nvme_bar;
todo();

// Disable the controller if it wasn't already.
nvme->regs->cc.en = false;
Expand Down

0 comments on commit da2da9c

Please sign in to comment.