diff options
| -rw-r--r-- | Cargo.toml | 4 | ||||
| -rw-r--r-- | Makefile | 10 | ||||
| -rw-r--r-- | boot/startup-x86_64.s | 22 | ||||
| -rw-r--r-- | defs/x86_64-linker.ld | 76 | ||||
| -rw-r--r-- | src/arch/x86_64/context.rs | 2 | ||||
| -rw-r--r-- | src/arch/x86_64/interrupt/mod.rs | 2 |
6 files changed, 58 insertions, 58 deletions
@@ -22,8 +22,8 @@ default-features = false version = "1.4" features = ["spin_no_std"] -[build] -target = "x86_64-rustubs" +# [build] +# target = "x86_64-rustubs" [lib] crate-type = ["staticlib"] @@ -43,16 +43,18 @@ RUST_OBJECT = target/$(ARCH)-rustubs/$(RUST_BUILD)/librustubs.a all: bootdisk.iso bootdisk.iso : $(BUILD)/kernel + @echo "---BUILDING BOOTDISK IMAGE---" $(VERBOSE) cp $< isofiles/boot/ - $(VERBOSE) grub-mkrescue -d /usr/lib/grub/i386-pc --locales=en@piglatin --themes=none -o bootdisk.iso isofiles + $(VERBOSE) grub-mkrescue -d /usr/lib/grub/i386-pc --locales=en@piglatin --themes=none -o bootdisk.iso isofiles > /dev/null 2>&1 # Note: explicitly tell the linker to use startup: as the entry point (we have no main here) $(BUILD)/kernel : rust_kernel startup.o $(ASMOBJ_PREFIXED) + @echo "---LINKING ... ---" $(VERBOSE) ld -static -e startup -T $(LINKER_SCRIPT) -o $@ $(BUILD)/startup.o $(ASMOBJ_PREFIXED) $(RUST_OBJECT) # Note: this target works when the VPATH is set correctly $(BUILD)/_%.o : %.s | $(BUILD) - @echo "ASM $@" + @echo "---ASM $@" @if test \( ! \( -d $(@D) \) \) ;then mkdir -p $(@D);fi $(VERBOSE) $(ASM) -f $(ASMOBJFORMAT) $(ASMFLAGS) -o $@ $< @@ -61,11 +63,13 @@ $(BUILD)/_%.o : %.s | $(BUILD) # Compile the rust part: note that the the cargo crate is of type [staticlib], if you don't # define this, the linker will have troubles, especially when we use a "no_std" build rust_kernel: check - cargo xbuild --target $(CARGO_XBUILD_TARGET) $(CARGO_XBUILD_FLAGS) + @echo "---BUILDING RUST KERNEL---" + @cargo xbuild --target $(CARGO_XBUILD_TARGET) $(CARGO_XBUILD_FLAGS) # need nasm # TODO make this arch dependent startup.o: boot/startup-$(ARCH).s | $(BUILD) + @echo "---ASM $@" @if test \( ! \( -d $(@D) \) \) ;then mkdir -p $(@D);fi $(VERBOSE) $(ASM) -f $(ASMOBJFORMAT) $(ASMFLAGS) -o $(BUILD)/startup.o boot/startup-$(ARCH).s diff --git a/boot/startup-x86_64.s b/boot/startup-x86_64.s index 4f34cc7..4855bf0 100644 --- a/boot/startup-x86_64.s +++ b/boot/startup-x86_64.s @@ -26,17 +26,16 @@ MAX_MEM: equ 512 [BITS 32] startup: - cld ; GCC-compiled code expects the direction flag to be 0 - cli ; disable interrupts + cld + cli lgdt [gdt_80] ; set new segment descriptors ; global data segment mov eax, 3 * 0x8 - ; 0x8 is the length of each entry - ; these registers point to 4th entry the GDT (see also the code there) - ; in x86 long mode these are dummy pointers - ; which are not actually used in addressing. (don't use segmentation at all) - ; all the addresses are physical addresses from 0. + ; 0x8 is the length of each entry these registers point to 4th entry the GDT + ; (see also the code there) in x86 long mode these are dummy pointers which + ; are not actually used in addressing. (don't use segmentation at all) all + ; the addresses are physical addresses from 0. mov ds, ax mov es, ax mov fs, ax @@ -46,19 +45,16 @@ startup: mov ss, ax mov esp, init_stack+STACKSIZE -; -; Switch to 64-bit Long Mode -; - init_longmode: ; activate address extension (PAE) mov eax, cr4 or eax, 1 << 5 mov cr4, eax +setup_paging: ; Provisional identical page mapping, using 1G huge page (therefore only 2 table ; levels needed) -setup_paging: + ; ; PML4 (Page Map Level 4 / 1st level) mov eax, pdp or eax, 0xf @@ -96,7 +92,6 @@ activate_long_mode: ; jump to 64-bit code segment -> full activation of Long Mode jmp 2 * 0x8 : longmode_start - ; ; system start, part 2 (in 64-bit Long Mode) ; 1. clear BSS @@ -105,7 +100,6 @@ activate_long_mode: ; 4. (optional) enable SSE ; 5. jump to rust main code ; - longmode_start: [BITS 64] ; clear BSS diff --git a/defs/x86_64-linker.ld b/defs/x86_64-linker.ld index 1f53bf8..caecb48 100644 --- a/defs/x86_64-linker.ld +++ b/defs/x86_64-linker.ld @@ -5,7 +5,7 @@ MB_CHKSUM = 0x100000000 - (MB_MAGIC + MB_FLAGS); SECTIONS { - . = 0x100000; /* system's start address */ + . = 0x100000; /* system's start address */ .boot : { @@ -22,24 +22,25 @@ SECTIONS LONG(0) LONG(0) header_end = .; - } + } - PROVIDE (___KERNEL_START__ = .); - .text : - { - *(".text") - *(".text.*") - *(".text$") - } + PROVIDE (___KERNEL_START__ = .); + .text : + { + *(".text") + *(".text.*") + *(".text$") + } - .data : - { - *(".data") - *(".data.*") - *(".data$") - } + .data : + { + *(".data") + *(".data.*") + *(".data$") + } - .reserved : { + .reserved : + { *(".reserved") *(".reserved.*") } @@ -49,32 +50,33 @@ SECTIONS * for zeroing because it's explicitly overwritten anyways. I KNOW WHAT I'M * DOING! An example is the idt. */ - .reserved_0 (NOLOAD) : { + .reserved_0 (NOLOAD) : + { *(".reserved_0") *(".reserved_0.*") } - .rodata : - { - *(".rodata") - *(".rodata$") - *(".rodata.*") - } + .rodata : + { + *(".rodata") + *(".rodata$") + *(".rodata.*") + } - .bss : - { - PROVIDE (___BSS_START__ = .); - *(".bss") - *(".bss.*") - PROVIDE (___BSS_END__ = .); - } + .bss : + { + PROVIDE (___BSS_START__ = .); + *(".bss") + *(".bss.*") + PROVIDE (___BSS_END__ = .); + } - /* global page table for 64-bit long mode */ - .global_pagetable ALIGN(4096) (NOLOAD) : - { - *(".global_pagetable") - } + /* global page table for 64-bit long mode */ + .global_pagetable ALIGN(4096) (NOLOAD) : + { + *(".global_pagetable") + } - . = ALIGN(4096); - PROVIDE (___KERNEL_END__ = .); + . = ALIGN(4096); + PROVIDE (___KERNEL_END__ = .); } diff --git a/src/arch/x86_64/context.rs b/src/arch/x86_64/context.rs index 37b6c2f..6c46271 100644 --- a/src/arch/x86_64/context.rs +++ b/src/arch/x86_64/context.rs @@ -23,6 +23,6 @@ pub unsafe fn settle() { // regs->rsp = sp; } -pub unsafe fn switch(ctx_curr: usize, ctx_next: usize) { +pub unsafe fn switch(_ctx_curr: usize, _ctx_next: usize) { todo!() } diff --git a/src/arch/x86_64/interrupt/mod.rs b/src/arch/x86_64/interrupt/mod.rs index d961480..7e0cbb8 100644 --- a/src/arch/x86_64/interrupt/mod.rs +++ b/src/arch/x86_64/interrupt/mod.rs @@ -57,7 +57,7 @@ impl GateDescriptor64 { #[no_mangle] #[cfg(target_arch = "x86_64")] -extern "C" fn interrupt_gate(slot: u16) { +extern "C" fn interrupt_gate(_slot: u16) { interrupt_disable(); // NOTE: the interrupt handler should NEVER block on a lock; in this case // the CGA screen is protected by a spinlock. The lock holder will never be |
