rename 'KERN_VA_BASE' to 'KERNEL_OFFSET'. fix compile error

master
WangRunji 6 years ago
parent a12dcb7595
commit a33d7632d6

@ -13,14 +13,14 @@ pub const RECURSIVE_INDEX: usize = 0o774;
// root_table[0776] points to a temp page table as leaf page
#[cfg(target_arch = "riscv32")]
pub const KERN_VA_BASE: usize = 0xC000_0000;
pub const KERNEL_OFFSET: usize = 0xC000_0000;
#[cfg(target_arch = "riscv64")]
pub const KERN_VA_BASE: usize = 0xFFFF_FFFF_C000_0000;
pub const KERNEL_OFFSET: usize = 0xFFFF_FFFF_C000_0000;
#[cfg(target_arch = "riscv32")]
pub const KERNEL_P2_INDEX: usize = (KERN_VA_BASE >> 12 >> 10) & 0x3ff;
pub const KERNEL_P2_INDEX: usize = (KERNEL_OFFSET >> 12 >> 10) & 0x3ff;
#[cfg(target_arch = "riscv64")]
pub const KERNEL_P4_INDEX: usize = (KERN_VA_BASE >> 12 >> 9 >> 9 >> 9) & 0o777;
pub const KERNEL_P4_INDEX: usize = (KERNEL_OFFSET >> 12 >> 9 >> 9 >> 9) & 0o777;
#[cfg(feature = "board_k210")]
pub const KERNEL_HEAP_SIZE: usize = 0x0010_0000;

@ -3,7 +3,7 @@ use riscv::{addr::*, register::sstatus};
use rcore_memory::PAGE_SIZE;
use log::*;
use crate::memory::{FRAME_ALLOCATOR, init_heap, MemoryAttr, MemorySet, Linear};
use crate::consts::{MEMORY_OFFSET, MEMORY_END, KERN_VA_BASE};
use crate::consts::{MEMORY_OFFSET, MEMORY_END, KERNEL_OFFSET};
use riscv::register::satp;
#[cfg(feature = "no_mmu")]
@ -49,7 +49,7 @@ fn init_frame_allocator() {
use core::ops::Range;
let mut ba = FRAME_ALLOCATOR.lock();
let range = to_range((end as usize) - KERN_VA_BASE + MEMORY_OFFSET + PAGE_SIZE, MEMORY_END);
let range = to_range((end as usize) - KERNEL_OFFSET + MEMORY_OFFSET + PAGE_SIZE, MEMORY_END);
ba.insert(range);
/*
@ -72,7 +72,7 @@ fn init_frame_allocator() {
/// Remap the kernel memory address with 4K page recorded in p1 page table
#[cfg(not(feature = "no_mmu"))]
fn remap_the_kernel(dtb: usize) {
let offset = -(KERN_VA_BASE as isize - MEMORY_OFFSET as isize);
let offset = -(KERNEL_OFFSET as isize - MEMORY_OFFSET as isize);
let mut ms = MemorySet::new_bare();
ms.push(stext as usize, etext as usize, Linear::new(offset, MemoryAttr::default().execute().readonly()), "text");
ms.push(sdata as usize, edata as usize, Linear::new(offset, MemoryAttr::default()), "data");

@ -15,7 +15,7 @@ use volatile::{ReadOnly, Volatile, WriteOnly};
use crate::arch::memory;
use crate::HEAP_ALLOCATOR;
use crate::memory::active_table;
use crate::arch::consts::{KERN_VA_BASE, MEMORY_OFFSET};
use crate::arch::consts::{KERNEL_OFFSET, MEMORY_OFFSET};
use super::super::block::virtio_blk;
use super::super::gpu::virtio_gpu;
@ -97,7 +97,7 @@ impl VirtIOVirtqueue {
header.queue_num.write(queue_num as u32);
header.queue_align.write(align as u32);
header.queue_pfn.write(((address - KERN_VA_BASE + MEMORY_OFFSET) as u32) >> 12);
header.queue_pfn.write(((address - KERNEL_OFFSET + MEMORY_OFFSET) as u32) >> 12);
// link desc together
let desc = unsafe { slice::from_raw_parts_mut(address as *mut VirtIOVirtqueueDesc, queue_num) };
@ -140,14 +140,14 @@ impl VirtIOVirtqueue {
let mut cur = self.free_head;
for i in 0..output.len() {
desc[cur].flags.write(VirtIOVirtqueueFlag::NEXT.bits());
desc[cur].addr.write(output[i].as_ptr() as u64 - KERN_VA_BASE as u64 + MEMORY_OFFSET as u64);
desc[cur].addr.write(output[i].as_ptr() as u64 - KERNEL_OFFSET as u64 + MEMORY_OFFSET as u64);
desc[cur].len.write(output[i].len() as u32);
prev = cur;
cur = desc[cur].next.read() as usize;
}
for i in 0..input.len() {
desc[cur].flags.write((VirtIOVirtqueueFlag::NEXT | VirtIOVirtqueueFlag::WRITE).bits());
desc[cur].addr.write(input[i].as_ptr() as u64 - KERN_VA_BASE as u64 + MEMORY_OFFSET as u64);
desc[cur].addr.write(input[i].as_ptr() as u64 - KERNEL_OFFSET as u64 + MEMORY_OFFSET as u64);
desc[cur].len.write(input[i].len() as u32);
prev = cur;
cur = desc[cur].next.read() as usize;

@ -14,7 +14,7 @@ use volatile::{ReadOnly, Volatile, WriteOnly};
use crate::arch::cpu;
use crate::HEAP_ALLOCATOR;
use crate::memory::active_table;
use crate::arch::consts::{KERN_VA_BASE, MEMORY_OFFSET};
use crate::arch::consts::{KERNEL_OFFSET, MEMORY_OFFSET};
use super::super::{DeviceType, Driver, DRIVERS};
use super::super::bus::virtio_mmio::*;
@ -253,7 +253,7 @@ fn setup_framebuffer(driver: &mut VirtIOGpu) {
header: VirtIOGpuCtrlHdr::with_type(VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING),
resource_id: VIRTIO_GPU_RESOURCE_ID,
nr_entries: 1,
addr: (frame_buffer - KERN_VA_BASE + MEMORY_OFFSET) as u64,
addr: (frame_buffer - KERNEL_OFFSET + MEMORY_OFFSET) as u64,
length: size,
padding: 0
};

Loading…
Cancel
Save