Skip to content

Commit

Permalink
wip-index
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Mar 10, 2023
1 parent b860e15 commit 81ad836
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ QEMU_ARGS := \
-M virt \
-device virtio-blk-device,drive=hd0 \

# riscv64 doesn't like loading a dtb at the moment.
# Fails -- possibly our fault!
# qemu-system-riscv64: FDT: Failed to create subnode /fw-cfg@10100000: FDT_ERR_EXISTS
QEMU_DTB_ARGS :=
QEMU_RAMFB =

EFI_BOOTLOADER_NAME := BOOTRISCV64
else
$(error ARCH must be set to arm64 or riscv64)
Expand All @@ -43,7 +41,7 @@ else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
ifeq ($(ARCH),arm64)
QEMU_ACCEL := hvf
QEMU_ACCEL := tcg
endif
endif
endif
Expand All @@ -64,7 +62,7 @@ QEMU_CMD := $(QEMU_BIN) \
-usb \

qemu: target/disk/EFI/BOOT/$(EFI_BOOTLOADER_NAME).efi target/disk/dainkrnl.$(ARCH)
$(QEMU_CMD) $(QEMU_DTB_ARGS) $$EXTRA_ARGS
$(QEMU_CMD) $(QEMU_DTB_ARGS) -s $$EXTRA_ARGS

dtb/src/%.dtb:
$(QEMU_CMD) -machine dumpdtb=$@
Expand Down
3 changes: 3 additions & 0 deletions dainkrnl/src/riscv64/entry.zig
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ pub export fn daintree_mmu_start(entry_data: *dcommon.EntryData) noreturn {
var it = p.PAGING.range(1, entry_data.conventional_start, entry_data.conventional_bytes + 100 * 1048576);
while (it.next()) |r| {
hw.entry_uart.carefully(.{ "mapping identity: page ", r.page, " address ", r.address, "\r\n" });
hw.entry_uart.carefully(.{ "p.K_DIRECTORY is ", @ptrToInt(p.K_DIRECTORY), "\r\n" });
p.K_DIRECTORY.map(r.page, r.address, .kernel_promisc);
hw.entry_uart.carefully(.{"did that\r\n "});
}
hw.entry_uart.carefully(.{"done mapping\r\n "});

p.K_DIRECTORY.map(256, @ptrToInt(l2), .non_leaf);
l2.map(0, @ptrToInt(l3), .non_leaf);
Expand Down
13 changes: 12 additions & 1 deletion dainkrnl/src/riscv64/paging.zig
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@ pub fn mapPage(phys_address: usize, flags: paging.MapFlags) paging.Error!usize {
pub const PageTable = extern struct {
entries: [PAGING.index_size]u64,

pub fn map(self: *PageTable, index: usize, phys_address: usize, flags: paging.MapFlags) void {
pub inline fn map(self: *PageTable, index: usize, phys_address: usize, flags: paging.MapFlags) void {
hw.entry_uart.carefully(.{
"mapping self ",
@ptrToInt(self),
" index ",
index,
" phys ",
phys_address,
" flags ",
@enumToInt(flagsToRWX(flags)),
"\r\n",
});
self.entries[index] = (ArchPte{
.rwx = flagsToRWX(flags),
.u = 0,
Expand Down
2 changes: 1 addition & 1 deletion objdump.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cd "$(dirname "$0")"
objdump -dSl --prefix=. --prefix-strip=4 dainkrnl/zig-cache/bin/dainkrnl|less
objdump -dSl --prefix=. --prefix-strip=4 dainkrnl/zig-out/bin/dainkrnl.qemu_riscv64|less

0 comments on commit 81ad836

Please sign in to comment.