vmm: debug user code page fault
This commit is contained in:
parent
a379d66784
commit
5168cfa4e1
4 changed files with 113 additions and 84 deletions
|
@ -167,54 +167,60 @@ all: bin-$(ARCH)/$(OUTPUT)
|
|||
|
||||
# Link rules for building the C compiler runtime.
|
||||
cc-runtime-$(ARCH)/cc-runtime.a: GNUmakefile cc-runtime/*
|
||||
rm -rf cc-runtime-$(ARCH)
|
||||
cp -r cc-runtime cc-runtime-$(ARCH)
|
||||
$(MAKE) -C cc-runtime-$(ARCH) -f cc-runtime.mk \
|
||||
@rm -rf cc-runtime-$(ARCH)
|
||||
@cp -r cc-runtime cc-runtime-$(ARCH)
|
||||
@$(MAKE) -C cc-runtime-$(ARCH) -f cc-runtime.mk \
|
||||
CC="$(CC)" \
|
||||
AR="$(AR)" \
|
||||
CFLAGS="$(CFLAGS)" \
|
||||
CPPFLAGS='-isystem ../freestnd-c-hdrs -DCC_RUNTIME_NO_FLOAT'
|
||||
@echo " C runtime built"
|
||||
|
||||
# Link rules for the final executable.
|
||||
bin-$(ARCH)/$(OUTPUT): GNUmakefile linker-$(ARCH).ld $(OBJ) cc-runtime-$(ARCH)/cc-runtime.a
|
||||
mkdir -p "$$(dirname $@)"
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) cc-runtime-$(ARCH)/cc-runtime.a -o $@
|
||||
@mkdir -p "$$(dirname $@)"
|
||||
@echo " LD $@"
|
||||
@$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) cc-runtime-$(ARCH)/cc-runtime.a -o $@
|
||||
|
||||
# Compilation rules for *.c files.
|
||||
obj-$(ARCH)/%.c.o: src/%.c GNUmakefile
|
||||
mkdir -p "$$(dirname $@)"
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
@mkdir -p "$$(dirname $@)"
|
||||
@echo " CC $@"
|
||||
@$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
# Compilation rules for *.S files.
|
||||
obj-$(ARCH)/%.S.o: src/%.S GNUmakefile
|
||||
mkdir -p "$$(dirname $@)"
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
@mkdir -p "$$(dirname $@)"
|
||||
@echo " AS $@"
|
||||
@$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
ifeq ($(ARCH),x86_64)
|
||||
# Compilation rules for *.asm (nasm) files.
|
||||
obj-$(ARCH)/%.asm.o: src/%.asm GNUmakefile
|
||||
mkdir -p "$$(dirname $@)"
|
||||
nasm $(NASMFLAGS) $< -o $@
|
||||
@mkdir -p "$$(dirname $@)"
|
||||
@echo " NASM $@"
|
||||
@nasm $(NASMFLAGS) $< -o $@
|
||||
endif
|
||||
|
||||
# Remove object files and the final executable.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf bin-$(ARCH) obj-$(ARCH) cc-runtime-$(ARCH)
|
||||
|
||||
@rm -rf bin-$(ARCH) obj-$(ARCH) cc-runtime-$(ARCH)
|
||||
@echo " The kernel output files have been removed."
|
||||
# Remove everything built and generated including downloaded dependencies.
|
||||
.PHONY: distclean
|
||||
distclean:
|
||||
rm -rf bin-* obj-* freestnd-c-hdrs cc-runtime* src/limine.h
|
||||
@rm -rf bin-* obj-* freestnd-c-hdrs cc-runtime* src/limine.h
|
||||
@echo " The kernel output & downloaded files have been removed."
|
||||
|
||||
# Install the final built executable to its final on-root location.
|
||||
.PHONY: install
|
||||
install: all
|
||||
install -d "$(DESTDIR)$(PREFIX)/share/$(OUTPUT)"
|
||||
install -m 644 bin-$(ARCH)/$(OUTPUT) "$(DESTDIR)$(PREFIX)/share/$(OUTPUT)/$(OUTPUT)-$(ARCH)"
|
||||
@install -d "$(DESTDIR)$(PREFIX)/share/$(OUTPUT)"
|
||||
@install -m 644 bin-$(ARCH)/$(OUTPUT) "$(DESTDIR)$(PREFIX)/share/$(OUTPUT)/$(OUTPUT)-$(ARCH)"
|
||||
|
||||
# Try to undo whatever the "install" target did.
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
rm -f "$(DESTDIR)$(PREFIX)/share/$(OUTPUT)/$(OUTPUT)-$(ARCH)"
|
||||
-rmdir "$(DESTDIR)$(PREFIX)/share/$(OUTPUT)"
|
||||
@rm -f "$(DESTDIR)$(PREFIX)/share/$(OUTPUT)/$(OUTPUT)-$(ARCH)"
|
||||
@-rmdir "$(DESTDIR)$(PREFIX)/share/$(OUTPUT)"
|
||||
|
|
|
@ -226,12 +226,12 @@ void vmm_map_user(pagemap_t *pm, uint64_t vaddr, uint64_t paddr,
|
|||
uint64_t pml2_entry = (vaddr >> 21) & 0x1ff;
|
||||
uint64_t pml1_entry = (vaddr >> 12) & 0x1ff;
|
||||
|
||||
uint64_t *pml3 =
|
||||
__vmm_get_next_lvl(pm->toplevel, pml4_entry, flags,
|
||||
|
||||
uint64_t *pml3 = __vmm_get_next_lvl(pm->toplevel, pml4_entry, flags | VMM_WRITABLE,
|
||||
true); // PML3 / Page Directory Pointer Entry
|
||||
uint64_t *pml2 = __vmm_get_next_lvl(pml3, pml3_entry, flags,
|
||||
uint64_t *pml2 = __vmm_get_next_lvl(pml3, pml3_entry, flags | VMM_WRITABLE,
|
||||
true); // PML2 / Page Directory Entry
|
||||
uint64_t *pml1 = __vmm_get_next_lvl(pml2, pml2_entry, flags,
|
||||
uint64_t *pml1 = __vmm_get_next_lvl(pml2, pml2_entry, flags | VMM_WRITABLE,
|
||||
true); // PML1 / Page Table Entry
|
||||
|
||||
pml1[pml1_entry] = paddr | flags;
|
||||
|
|
|
@ -153,6 +153,8 @@ void schedule(registers_t *regs) {
|
|||
if (curr_proc == NULL)
|
||||
curr_proc = proc_list;
|
||||
|
||||
log("sched - I choosed process %d\n", curr_proc->pid);
|
||||
|
||||
// log("sched - I choosed process %d\n", curr_proc->pid);
|
||||
memcpy(regs, &curr_proc->regs, sizeof(registers_t));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue