使得DragonOS kernel 能为riscv64编译通过(尚未能启动) (#457)

* 使得DragonOS kernel 能为riscv64编译通过(尚未能启动)

* 修正了系统调用号声明不正确的问题,同时添加了编译配置文档
This commit is contained in:
LoGin
2023-11-25 12:07:39 +08:00
committed by GitHub
parent a1fd1cf1cb
commit 4fda81ce81
112 changed files with 2587 additions and 615 deletions

View File

@ -12,12 +12,11 @@ use crate::driver::disk::ahci::HBA_PxIS_TFES;
use crate::filesystem::kernfs::KernFSInode;
use crate::filesystem::mbr::MbrDiskPartionTable;
use crate::include::bindings::bindings::verify_area;
use crate::kdebug;
use crate::libs::rwlock::{RwLockReadGuard, RwLockWriteGuard};
use crate::libs::{spinlock::SpinLock, vec_cursor::VecCursor};
use crate::mm::phys_2_virt;
use crate::mm::{phys_2_virt, verify_area, VirtAddr};
use crate::syscall::SystemError;
use crate::{
driver::disk::ahci::hba::{
@ -108,11 +107,8 @@ impl AhciDisk {
// 由于目前的内存管理机制无法把用户空间的内存地址转换为物理地址,所以只能先把数据拷贝到内核空间
// TODO在内存管理重构后可以直接使用用户空间的内存地址
let user_buf = if unsafe { verify_area(buf_ptr as u64, buf.len() as u64) } {
true
} else {
false
};
let user_buf = verify_area(VirtAddr::new(buf_ptr as usize), buf.len()).is_ok();
let mut kbuf = if user_buf {
let mut x: Vec<u8> = Vec::new();
x.resize(buf.len(), 0);
@ -267,11 +263,7 @@ impl AhciDisk {
// 由于目前的内存管理机制无法把用户空间的内存地址转换为物理地址,所以只能先把数据拷贝到内核空间
// TODO在内存管理重构后可以直接使用用户空间的内存地址
let user_buf = if unsafe { verify_area(buf_ptr as u64, buf.len() as u64) } {
true
} else {
false
};
let user_buf = verify_area(VirtAddr::new(buf_ptr as usize), buf.len()).is_ok();
let mut kbuf = if user_buf {
let mut x: Vec<u8> = Vec::with_capacity(buf.len());
x.resize(buf.len(), 0);

View File

@ -12,7 +12,7 @@ void pci_irq_enable(ul irq_num)
void pci_irq_disable(ul irq_num)
{
}
ul pci_irq_install(ul, void*)
ul pci_irq_install(ul num , void* data)
{
}
void pci_irq_uninstall(ul irq_num)

View File

@ -7,7 +7,7 @@ use alloc::ffi::CString;
use alloc::vec::Vec;
use super::pci::{PciDeviceStructure, PciDeviceStructureGeneralDevice, PciError};
use crate::arch::msi::{ia64_pci_get_arch_msi_message_address, ia64_pci_get_arch_msi_message_data};
use crate::arch::msi::{arch_msi_message_address, arch_msi_message_data};
use crate::arch::{PciArch, TraitPciArch};
use crate::include::bindings::bindings::{
c_irq_install, c_irq_uninstall, pt_regs, ul, EAGAIN, EINVAL,
@ -370,14 +370,14 @@ pub trait PciInterrupt: PciDeviceStructure {
}
//MSI中断只需配置一次PCI寄存器
if common_msg.irq_index == 0 {
let msg_address = ia64_pci_get_arch_msi_message_address(0);
let msg_address = arch_msi_message_address(0);
let trigger = match msg.irq_specific_message {
IrqSpecificMsg::Legacy => {
return Err(PciError::PciIrqError(PciIrqError::IrqTypeUnmatch));
}
IrqSpecificMsg::Msi { trigger_mode, .. } => trigger_mode,
};
let msg_data = ia64_pci_get_arch_msi_message_data(irq_num, 0, trigger);
let msg_data = arch_msi_message_data(irq_num, 0, trigger);
//写入Message Data和Message Address
if address_64 {
PciArch::write_config(
@ -518,14 +518,14 @@ pub trait PciInterrupt: PciDeviceStructure {
_ => {}
}
let msg_address = ia64_pci_get_arch_msi_message_address(0);
let msg_address = arch_msi_message_address(0);
let trigger = match msg.irq_specific_message {
IrqSpecificMsg::Legacy => {
return Err(PciError::PciIrqError(PciIrqError::IrqTypeUnmatch));
}
IrqSpecificMsg::Msi { trigger_mode, .. } => trigger_mode,
};
let msg_data = ia64_pci_get_arch_msi_message_data(irq_num, 0, trigger);
let msg_data = arch_msi_message_data(irq_num, 0, trigger);
//写入Message Data和Message Address
let pcistandardbar = self
.bar()

View File

@ -1,7 +1,6 @@
use crate::{
arch::CurrentIrqArch,
arch::{io::PortIOArch, CurrentIrqArch, CurrentPortIOArch},
exception::InterruptArch,
include::bindings::bindings::{io_in8, io_out8},
syscall::SystemError,
};
@ -63,7 +62,7 @@ impl RtcTime {
}
unsafe {
io_out8(0x70, 0x00);
CurrentPortIOArch::out8(0x70, 0x00);
}
if !is_binary
@ -92,8 +91,8 @@ impl RtcTime {
#[inline]
fn read_cmos(addr: u8) -> u8 {
unsafe {
io_out8(0x70, 0x80 | addr);
return io_in8(0x71);
CurrentPortIOArch::out8(0x70, 0x80 | addr);
return CurrentPortIOArch::in8(0x71);
}
}