Ver Fonte

change link.x.in and disable some function for debug

Heinz há 7 meses atrás
pai
commit
0c6a045342

+ 1 - 0
crates/eonix_hal/src/arch/mod.rs

@@ -1,3 +1,4 @@
+#![allow(warnings)]
 cfg_if::cfg_if! {
     if #[cfg(target_arch = "x86_64")] {
         mod x86_64;

+ 6 - 5
crates/eonix_hal/src/arch/riscv64/bootstrap.rs

@@ -5,18 +5,16 @@ use crate::{
     bootstrap::BootStrapData,
     mm::{ArchMemory, ArchPagingMode, BasicPageAlloc, BasicPageAllocRef, ScopedAllocator},
 };
-use acpi::{platform::ProcessorState, AcpiHandler, AcpiTables, PhysicalMapping, PlatformInfo};
 use riscv::{asm::sfence_vma_all, register::{satp, sstatus::{self, FS}}};
 use core::{
     alloc::Allocator,
-    arch::{asm, global_asm},
+    arch::asm,
     cell::RefCell,
-    hint::spin_loop,
-    sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering},
+    sync::atomic::{AtomicBool, AtomicUsize},
 };
 use eonix_hal_traits::mm::Memory;
 use eonix_mm::{
-    address::{Addr as _, PAddr, PRange, PhysAccess, VAddr, VRange},
+    address::{Addr as _, PAddr, PRange, VAddr, VRange},
     page_table::{PageAttribute, PagingMode, PTE as _},
     paging::{Page, PageAccess, PageAlloc, PAGE_SIZE, PFN},
 };
@@ -25,6 +23,7 @@ use eonix_percpu::PercpuArea;
 use super::{
     config::{self, mm::*},
     fdt::get_num_harts,
+    console::write_str,
 };
 
 use core::arch::naked_asm;
@@ -84,6 +83,8 @@ unsafe extern "C" fn _start(hart_id: usize, dtb_addr: usize) -> ! {
 /// 启动所有的cpu
 #[unsafe(no_mangle)]
 pub unsafe extern "C" fn riscv64_start(hart_id: usize, dtb_addr: usize) -> ! {
+    write_str("hello\n");
+
     let real_allocator = RefCell::new(BasicPageAlloc::new());
     let alloc = BasicPageAllocRef::new(&real_allocator);
 

+ 16 - 0
crates/eonix_hal/src/arch/riscv64/console.rs

@@ -0,0 +1,16 @@
+use sbi::legacy::{console_putchar, console_getchar};
+
+pub fn getchar() -> Option<u8> {
+    let c = console_getchar();
+    if c == Some(!0) {
+        None
+    } else {
+        c
+    }
+}
+
+pub fn write_str(s: &str) {
+    for c in s.chars() {
+        console_putchar(c as u8);
+    }
+}

+ 0 - 14
crates/eonix_hal/src/arch/riscv64/link.x

@@ -1,17 +1,3 @@
-SECTIONS {
-    .text _stext : AT(RAM) {
-        __kernel_start = .;
-        __stext = .;
-
-        *(.text.entry);
-        *(.text .text.*);
-
-        . = ALIGN(0x1000);
-    } > REGION_TEXT
-
-    __etext = .;
-}
-
 SECTIONS {
     .text.syscall_fns :
     {

+ 1 - 1
crates/eonix_hal/src/arch/riscv64/memory.x

@@ -5,7 +5,7 @@ RAM = 0x80200000;
 
 MEMORY {
     LOWMEM : org = 0x0000000000000000, len = 1M
-    KBSS   : org = 0xffffffff00000000, len = 2M
+    KBSS   : org = 0xffffffff40000000, len = 2M
     KIMAGE : org = 0xffffffff80200000, len = 2M
 }
 

+ 7 - 2
crates/eonix_hal/src/arch/riscv64/mm.rs

@@ -283,12 +283,17 @@ impl Memory for ArchMemory {
         }
 
         let kernel_end = PAddr::from(__kernel_end as usize - KIMAGE_OFFSET);
-        let paddr_after_kimage_aligned = kernel_end.ceil_to(0x200000);
+        let paddr_after_kimage_aligned = kernel_end.ceil_to(0x2000000);
 
         core::iter::once(PRange::new(
             kernel_end,
             paddr_after_kimage_aligned,
         ))
+
+        /*core::iter::once(PRange::new(
+            kernel_end,
+            paddr_after_kimage_aligned,
+        ))
         .chain(
             Self::present_ram()
                 .filter(move |range| range.end() > paddr_after_kimage_aligned)
@@ -300,7 +305,7 @@ impl Memory for ArchMemory {
                         range
                     }
                 }),
-        )
+        )*/
     }
 }
 

+ 1 - 1
crates/eonix_hal/src/arch/riscv64/mod.rs

@@ -5,8 +5,8 @@ pub mod mm;
 pub mod context;
 pub mod trap;
 pub mod interrupt;
+pub mod console;
 mod config;
 
 // TODO:
 // linker
-// 开始做适配

+ 4 - 2
crates/eonix_hal/src/link.x.in

@@ -11,12 +11,14 @@ SECTIONS {
 
     } > REGION_TEXT
 
-    .text _stext :
-    {
+    .text _stext : AT(RAM) {
+        __kernel_start = .;
         __stext = .;
 
+        *(.text.entry);
         *(.text .text.*);
 
+        . = ALIGN(0x1000);
     } > REGION_TEXT
 
     __etext = .;