mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-11 09:06:47 +00:00
把opengrok.ringotek.cn替换为code.dragonos.org.cn (#484)
This commit is contained in:
parent
c566df451c
commit
e7071df6a4
@ -29,7 +29,7 @@ impl TSCManager {
|
||||
///
|
||||
/// 目前由于未支持acpi pm timer, 因此调用该函数时,HPET应当完成初始化,否则将无法校准TSC
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/arch/x86/kernel/tsc.c#1511
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/arch/x86/kernel/tsc.c#1511
|
||||
pub fn init() -> Result<(), SystemError> {
|
||||
let cpuid = x86::cpuid::CpuId::new();
|
||||
let feat = cpuid.get_feature_info().ok_or(SystemError::ENODEV)?;
|
||||
@ -57,7 +57,7 @@ impl TSCManager {
|
||||
///
|
||||
/// - `early`:是否在早期初始化
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/arch/x86/kernel/tsc.c#1438
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/arch/x86/kernel/tsc.c#1438
|
||||
fn determine_cpu_tsc_frequency(early: bool) -> Result<(), SystemError> {
|
||||
if unlikely(Self::cpu_khz() != 0 || Self::tsc_khz() != 0) {
|
||||
kwarn!("TSC and CPU frequency already determined");
|
||||
@ -237,7 +237,7 @@ impl TSCManager {
|
||||
/// 尝试使用PIT来校准tsc时间,并且返回tsc的频率(khz)。
|
||||
/// 如果失败,那么返回None
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/arch/x86/kernel/tsc.c#389
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/arch/x86/kernel/tsc.c#389
|
||||
fn pit_calibrate_tsc(latch: u64, ms: u64, loopmin: u64) -> Option<u64> {
|
||||
// 当前暂时没写legacy pic的驱动,因此这里直接返回
|
||||
let has_legacy_pic = false;
|
||||
@ -307,7 +307,7 @@ impl TSCManager {
|
||||
///
|
||||
/// - `Ok((tsc, ref))`:tsc和参考值
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/arch/x86/kernel/tsc.c#317
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/arch/x86/kernel/tsc.c#317
|
||||
fn read_refs(hpet_enabled: bool) -> (u64, u64) {
|
||||
let thresh = if Self::tsc_khz() == 0 {
|
||||
Self::DEFAULT_THRESHOLD
|
||||
@ -335,7 +335,7 @@ impl TSCManager {
|
||||
|
||||
/// 根据HPET的参考值计算tsc的频率
|
||||
///
|
||||
/// https://opengrok.ringotek.cn/xref/linux-6.1.9/arch/x86/kernel/tsc.c#339
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/arch/x86/kernel/tsc.c#339
|
||||
fn calc_hpet_ref(mut deltatsc: u64, ref1: u64, mut ref2: u64) -> u64 {
|
||||
if ref2 <= ref1 {
|
||||
ref2 += 0x100000000;
|
||||
|
@ -536,7 +536,7 @@ fn handle_signal(
|
||||
oldset: &SigSet,
|
||||
frame: &mut TrapFrame,
|
||||
) -> Result<i32, SystemError> {
|
||||
// TODO 这里要补充一段逻辑,好像是为了保证引入线程之后的地址空间不会出问题。详见https://opengrok.ringotek.cn/xref/linux-6.1.9/arch/mips/kernel/signal.c#830
|
||||
// TODO 这里要补充一段逻辑,好像是为了保证引入线程之后的地址空间不会出问题。详见https://code.dragonos.org.cn/xref/linux-6.1.9/arch/mips/kernel/signal.c#830
|
||||
|
||||
// 设置栈帧
|
||||
return setup_frame(sig, sigaction, info, oldset, frame);
|
||||
|
@ -134,7 +134,7 @@ impl X86_64SmpManager {
|
||||
}
|
||||
/// initialize the logical cpu number to APIC ID mapping
|
||||
pub fn build_cpu_map(&self) -> Result<(), SystemError> {
|
||||
// 参考:https://opengrok.ringotek.cn/xref/linux-6.1.9/arch/ia64/kernel/smpboot.c?fi=smp_build_cpu_map#496
|
||||
// 参考:https://code.dragonos.org.cn/xref/linux-6.1.9/arch/ia64/kernel/smpboot.c?fi=smp_build_cpu_map#496
|
||||
// todo!("build_cpu_map")
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use super::AcpiManager;
|
||||
impl AcpiManager {
|
||||
/// 通过acpi来匹配驱动
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/bus.c#949
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/bus.c#949
|
||||
pub fn driver_match_device(
|
||||
&self,
|
||||
_driver: &Arc<dyn Driver>,
|
||||
@ -28,7 +28,7 @@ impl AcpiManager {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1286
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1286
|
||||
pub(super) fn bus_init(&self) -> Result<(), SystemError> {
|
||||
self.acpi_sysfs_init()?;
|
||||
|
||||
@ -42,7 +42,7 @@ impl AcpiManager {
|
||||
|
||||
/// ACPI总线
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1072
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1072
|
||||
#[derive(Debug)]
|
||||
pub(super) struct AcpiBus {
|
||||
private: SubSysPrivate,
|
||||
@ -68,7 +68,7 @@ impl Bus for AcpiBus {
|
||||
self.name()
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1056
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1056
|
||||
fn remove(&self, _device: &Arc<dyn Device>) -> Result<(), SystemError> {
|
||||
todo!("acpi_bus: remove")
|
||||
}
|
||||
@ -83,7 +83,7 @@ impl Bus for AcpiBus {
|
||||
|
||||
/// 通过acpi来匹配驱动
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1005
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1005
|
||||
fn match_device(
|
||||
&self,
|
||||
_device: &Arc<dyn Device>,
|
||||
@ -93,7 +93,7 @@ impl Bus for AcpiBus {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1019
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1019
|
||||
fn probe(&self, _device: &Arc<dyn Device>) -> Result<(), SystemError> {
|
||||
todo!("acpi_bus: probe")
|
||||
}
|
||||
@ -110,7 +110,7 @@ impl Bus for AcpiBus {
|
||||
/// todo: 仿照linux的acpi_device去设计这个trait
|
||||
///
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/include/acpi/acpi_bus.h#364
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/acpi/acpi_bus.h#364
|
||||
pub trait AcpiDevice: Device {}
|
||||
|
||||
/// Acpi驱动应当实现的trait
|
||||
@ -119,5 +119,5 @@ pub trait AcpiDevice: Device {}
|
||||
///
|
||||
/// todo: 仿照linux的acpi_driver去设计这个trait
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/include/acpi/acpi_bus.h#163
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/acpi/acpi_bus.h#163
|
||||
pub trait AcpiDriver: Driver {}
|
||||
|
@ -2,7 +2,7 @@ use alloc::sync::Arc;
|
||||
|
||||
use crate::driver::base::device::Device;
|
||||
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/glue.c#352
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/glue.c#352
|
||||
pub fn acpi_device_notify(_dev: &Arc<dyn Device>) {
|
||||
return;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ impl AcpiManager {
|
||||
///
|
||||
/// ## 参考资料
|
||||
///
|
||||
/// https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1390
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/bus.c#1390
|
||||
pub fn init(&self, rsdp_vaddr1: u64, rsdp_vaddr2: u64) -> Result<(), SystemError> {
|
||||
kinfo!("Initializing Acpi Manager...");
|
||||
|
||||
|
@ -79,7 +79,7 @@ impl AcpiManager {
|
||||
|
||||
/// 在 sysfs 中创建 ACPI 表目录
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/sysfs.c?fi=acpi_sysfs_init#488
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/sysfs.c?fi=acpi_sysfs_init#488
|
||||
fn acpi_tables_sysfs_init(&self) -> Result<(), SystemError> {
|
||||
// 创建 `/sys/firmware/acpi/tables` 目录
|
||||
let acpi_tables_kset = KSet::new("tables".to_string());
|
||||
@ -115,7 +115,7 @@ impl AcpiManager {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/sysfs.c?fi=acpi_sysfs_init#469
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/sysfs.c?fi=acpi_sysfs_init#469
|
||||
fn acpi_table_data_init(&self, _header: &SdtHeader) -> Result<(), SystemError> {
|
||||
// todo!("AcpiManager::acpi_table_data_init()")
|
||||
return Ok(());
|
||||
@ -237,7 +237,7 @@ impl BinAttribute for AttrAcpiTable {
|
||||
|
||||
/// 展示 ACPI 表的内容
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/sysfs.c?fi=acpi_sysfs_init#320
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/acpi/sysfs.c?fi=acpi_sysfs_init#320
|
||||
fn read(
|
||||
&self,
|
||||
_kobj: Arc<dyn KObject>,
|
||||
|
@ -36,7 +36,7 @@ pub struct CpuDeviceManager;
|
||||
impl CpuDeviceManager {
|
||||
/// 初始化设备驱动模型的CPU子系统
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/cpu.c?fi=get_cpu_device#622
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/cpu.c?fi=get_cpu_device#622
|
||||
pub fn init(&self) -> Result<(), SystemError> {
|
||||
let cpu_subsys = CpuSubSystem::new();
|
||||
let root_device = CpuSubSystemFakeRootDevice::new();
|
||||
@ -53,7 +53,7 @@ impl CpuDeviceManager {
|
||||
|
||||
/// cpu子系统
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/cpu.c?fi=get_cpu_device#128
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/cpu.c?fi=get_cpu_device#128
|
||||
#[derive(Debug)]
|
||||
struct CpuSubSystem {
|
||||
subsys_private: SubSysPrivate,
|
||||
|
@ -99,7 +99,7 @@ impl From<BusState> for DeviceState {
|
||||
/// 总线子系统的trait,所有总线都应实现该trait
|
||||
///
|
||||
/// 请注意,这个trait是用于实现总线子系统的,而不是总线驱动/总线设备。
|
||||
/// https://opengrok.ringotek.cn/xref/linux-6.1.9/include/linux/device/bus.h#84
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/device/bus.h#84
|
||||
pub trait Bus: Debug + Send + Sync {
|
||||
fn name(&self) -> String;
|
||||
/// Used for subsystems to enumerate devices like ("foo%u", dev->id).
|
||||
@ -256,7 +256,7 @@ impl BusManager {
|
||||
/// - 在bus和设备文件夹下,创建软链接
|
||||
/// - 把设备添加到它的总线的设备列表中
|
||||
///
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_add_device#441
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_add_device#441
|
||||
///
|
||||
/// ## 参数
|
||||
///
|
||||
@ -290,7 +290,7 @@ impl BusManager {
|
||||
|
||||
/// 在总线上添加一个驱动
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_add_driver#590
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_add_driver#590
|
||||
pub fn add_driver(&self, driver: &Arc<dyn Driver>) -> Result<(), SystemError> {
|
||||
let bus = driver
|
||||
.bus()
|
||||
@ -350,7 +350,7 @@ impl BusManager {
|
||||
/// infrastructure, then register the children subsystems it has:
|
||||
/// the devices and drivers that belong to the subsystem.
|
||||
///
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_register#783
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_register#783
|
||||
///
|
||||
/// todo: 增加错误处理逻辑
|
||||
pub fn register(&self, bus: Arc<dyn Bus>) -> Result<(), SystemError> {
|
||||
@ -468,7 +468,7 @@ impl BusManager {
|
||||
///
|
||||
/// - `driver` - 驱动实例
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_remove_driver#666
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_remove_driver#666
|
||||
pub fn remove_driver(&self, _driver: &Arc<dyn Driver>) {
|
||||
todo!("BusManager::remove_driver")
|
||||
}
|
||||
@ -487,7 +487,7 @@ impl BusManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?r=&mo=5649&fi=241#684
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?r=&mo=5649&fi=241#684
|
||||
fn rescan_devices_helper(dev: &Arc<dyn Device>) -> Result<(), SystemError> {
|
||||
if dev.driver().is_none() {
|
||||
let need_parent_lock = dev
|
||||
@ -562,7 +562,7 @@ pub fn buses_init() -> Result<(), SystemError> {
|
||||
/// - 在bus和设备文件夹下,创建软链接
|
||||
/// - 把设备添加到它的总线的设备列表中
|
||||
///
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_add_device#441
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_add_device#441
|
||||
///
|
||||
/// ## 参数
|
||||
///
|
||||
@ -579,7 +579,7 @@ pub fn bus_add_device(dev: &Arc<dyn Device>) -> Result<(), SystemError> {
|
||||
///
|
||||
/// - `dev` - 要被添加的设备
|
||||
///
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_probe_device#478
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=bus_probe_device#478
|
||||
pub fn bus_probe_device(dev: &Arc<dyn Device>) {
|
||||
kinfo!("bus_probe_device: dev: {:?}", dev.name());
|
||||
bus_manager().probe_device(dev);
|
||||
@ -601,7 +601,7 @@ impl Attribute for BusAttrDriversProbe {
|
||||
return SysFSOpsSupport::STORE;
|
||||
}
|
||||
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?r=&mo=5649&fi=241#241
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?r=&mo=5649&fi=241#241
|
||||
fn store(&self, kobj: Arc<dyn KObject>, buf: &[u8]) -> Result<usize, SystemError> {
|
||||
let kset: Arc<KSet> = kobj.arc_any().downcast().map_err(|_| SystemError::EINVAL)?;
|
||||
let bus = bus_manager()
|
||||
@ -639,7 +639,7 @@ impl Attribute for BusAttrDriversAutoprobe {
|
||||
return SysFSOpsSupport::STORE | SysFSOpsSupport::SHOW;
|
||||
}
|
||||
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?r=&mo=5649&fi=241#231
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?r=&mo=5649&fi=241#231
|
||||
fn store(&self, kobj: Arc<dyn KObject>, buf: &[u8]) -> Result<usize, SystemError> {
|
||||
if buf.len() == 0 {
|
||||
return Ok(0);
|
||||
@ -659,7 +659,7 @@ impl Attribute for BusAttrDriversAutoprobe {
|
||||
return Ok(buf.len());
|
||||
}
|
||||
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?r=&mo=5649&fi=241#226
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?r=&mo=5649&fi=241#226
|
||||
fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
|
||||
let kset: Arc<KSet> = kobj.arc_any().downcast().map_err(|_| SystemError::EINVAL)?;
|
||||
let bus = bus_manager()
|
||||
@ -841,7 +841,7 @@ impl SubSystemManager {
|
||||
/// - `fake_root_dev` - 该子系统的伪根设备
|
||||
/// - `parent_of_root` - 该子系统的伪根设备的父级节点
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=subsys_system_register#1078
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?fi=subsys_system_register#1078
|
||||
pub fn subsys_register(
|
||||
&self,
|
||||
subsys: &Arc<dyn Bus>,
|
||||
|
@ -40,7 +40,7 @@ impl DeviceManager {
|
||||
///
|
||||
/// ## 参考
|
||||
///
|
||||
/// https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c#1049
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c#1049
|
||||
pub fn device_attach(&self, dev: &Arc<dyn Device>) -> Result<bool, SystemError> {
|
||||
return self.do_device_attach(dev, false);
|
||||
}
|
||||
@ -49,7 +49,7 @@ impl DeviceManager {
|
||||
return self.do_device_attach(dev, true);
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c#978
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c#978
|
||||
fn do_device_attach(
|
||||
&self,
|
||||
dev: &Arc<dyn Device>,
|
||||
@ -137,7 +137,7 @@ impl DeviceManager {
|
||||
/// - Ok(true): 匹配成功
|
||||
/// - Ok(false): 没有匹配成功
|
||||
/// - Err(SystemError): 匹配过程中出现意外错误,没有匹配成功
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c#899
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c#899
|
||||
fn do_device_attach_driver(
|
||||
&self,
|
||||
driver: &Arc<dyn Driver>,
|
||||
@ -202,7 +202,7 @@ impl DeviceManager {
|
||||
///
|
||||
/// 使用device_manager().driver_attach()会更好
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c#496
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c#496
|
||||
pub fn device_bind_driver(&self, dev: &Arc<dyn Device>) -> Result<(), SystemError> {
|
||||
let r = driver_manager().driver_sysfs_add(dev);
|
||||
if let Err(e) = r {
|
||||
@ -221,14 +221,14 @@ impl DeviceManager {
|
||||
return r;
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#528
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#528
|
||||
fn unbind_cleanup(&self, dev: &Arc<dyn Device>) {
|
||||
dev.set_driver(None);
|
||||
// todo: 添加更多操作,清理数据
|
||||
}
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c#866
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c#866
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct DeviceAttachData {
|
||||
@ -296,7 +296,7 @@ impl DriverManager {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#1134
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#1134
|
||||
fn do_driver_attach(&self, device: &Arc<dyn Device>, driver: &Arc<dyn Driver>) -> bool {
|
||||
let r = self.match_device(driver, device).unwrap_or(false);
|
||||
if r == false {
|
||||
@ -341,7 +341,7 @@ impl DriverManager {
|
||||
/// - Err(ENODEV): 设备未注册
|
||||
/// - Err(EBUSY): 设备已经绑定到驱动上
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#802
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#802
|
||||
fn probe_device(
|
||||
&self,
|
||||
driver: &Arc<dyn Driver>,
|
||||
@ -371,7 +371,7 @@ impl DriverManager {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#584
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#584
|
||||
fn really_probe(
|
||||
&self,
|
||||
driver: &Arc<dyn Driver>,
|
||||
@ -461,7 +461,7 @@ impl DriverManager {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#434
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#434
|
||||
fn add_to_sysfs(&self, device: &Arc<dyn Device>) -> Result<(), SystemError> {
|
||||
let driver = device.driver().ok_or(SystemError::EINVAL)?;
|
||||
|
||||
@ -500,7 +500,7 @@ impl DriverManager {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#469
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#469
|
||||
fn remove_from_sysfs(&self, _device: &Arc<dyn Device>) {
|
||||
todo!("remove_from_sysfs")
|
||||
}
|
||||
@ -554,7 +554,7 @@ impl DriverManager {
|
||||
}
|
||||
|
||||
/// 当设备被成功探测,进行了'设备->驱动'绑定后,调用这个函数,完成'驱动->设备'的绑定
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c#393
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c#393
|
||||
fn driver_bound(&self, device: &Arc<dyn Device>) {
|
||||
if self.driver_is_bound(device) {
|
||||
kwarn!("driver_bound: device '{}' is already bound.", device.name());
|
||||
|
@ -172,7 +172,7 @@ impl DriverManager {
|
||||
///
|
||||
/// - driver: 驱动
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/driver.c#222
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/driver.c#222
|
||||
pub fn register(&self, driver: Arc<dyn Driver>) -> Result<(), SystemError> {
|
||||
let bus = driver
|
||||
.bus()
|
||||
@ -215,7 +215,7 @@ impl DriverManager {
|
||||
bus_manager().remove_driver(driver);
|
||||
}
|
||||
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c#434
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c#434
|
||||
pub fn driver_sysfs_add(&self, _dev: &Arc<dyn Device>) -> Result<(), SystemError> {
|
||||
todo!("DriverManager::driver_sysfs_add()");
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ impl From<DeviceState> for u32 {
|
||||
pub struct DeviceKObjType;
|
||||
|
||||
impl KObjType for DeviceKObjType {
|
||||
// https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/core.c#2307
|
||||
// https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/core.c#2307
|
||||
fn release(&self, kobj: Arc<dyn KObject>) {
|
||||
let dev = kobj.cast::<dyn Device>().unwrap();
|
||||
/*
|
||||
@ -420,7 +420,7 @@ impl DeviceManager {
|
||||
/// @parameter dev: 设备实例
|
||||
/// @return: None
|
||||
///
|
||||
/// https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/core.c#3398
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/core.c#3398
|
||||
///
|
||||
/// todo: 完善错误处理逻辑:如果添加失败,需要将之前添加的内容全部回滚
|
||||
#[inline]
|
||||
@ -553,7 +553,7 @@ impl DeviceManager {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#542
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c?fi=driver_attach#542
|
||||
fn remove(&self, _dev: &Arc<dyn Device>) {
|
||||
todo!("DeviceManager::remove")
|
||||
}
|
||||
@ -759,21 +759,21 @@ impl DeviceManager {
|
||||
return kobj;
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/core.c?fi=device_links_force_bind#1226
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/core.c?fi=device_links_force_bind#1226
|
||||
pub fn device_links_force_bind(&self, _dev: &Arc<dyn Device>) {
|
||||
todo!("device_links_force_bind")
|
||||
}
|
||||
|
||||
/// 把device对象的一些结构进行默认初始化
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/core.c?fi=device_initialize#2976
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/core.c?fi=device_initialize#2976
|
||||
pub fn device_default_initialize(&self, dev: &Arc<dyn Device>) {
|
||||
dev.set_kset(Some(sys_devices_kset()));
|
||||
dev.set_kobj_type(Some(&DeviceKObjType));
|
||||
return;
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c?r=&mo=29885&fi=1100#1100
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c?r=&mo=29885&fi=1100#1100
|
||||
pub fn device_driver_attach(
|
||||
&self,
|
||||
_driver: &Arc<dyn Driver>,
|
||||
@ -782,7 +782,7 @@ impl DeviceManager {
|
||||
todo!("device_driver_attach")
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/dd.c?r=&mo=35401&fi=1313#1313
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c?r=&mo=35401&fi=1313#1313
|
||||
pub fn device_driver_detach(&self, _dev: &Arc<dyn Device>) {
|
||||
todo!("device_driver_detach")
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ impl KObjectManager {
|
||||
let r = Self::create_dir(kobj.clone());
|
||||
|
||||
if let Err(e) = r {
|
||||
// https://opengrok.ringotek.cn/xref/linux-6.1.9/lib/kobject.c?r=&mo=10426&fi=394#224
|
||||
// https://code.dragonos.org.cn/xref/linux-6.1.9/lib/kobject.c?r=&mo=10426&fi=394#224
|
||||
if let Some(kset) = kobj.kset() {
|
||||
kset.leave(&kobj);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ impl CompatibleTable {
|
||||
/// @parameter: None
|
||||
/// @return: None
|
||||
///
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/platform.c?fi=platform_bus_init#1511
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/platform.c?fi=platform_bus_init#1511
|
||||
pub fn platform_bus_init() -> Result<(), SystemError> {
|
||||
let platform_device: Arc<PlatformBusDevice> = PlatformBusDevice::new(
|
||||
DevicePrivateData::new(
|
||||
|
@ -103,7 +103,7 @@ impl PlatformDeviceManager {
|
||||
}
|
||||
}
|
||||
|
||||
// todo: 插入资源: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/platform.c?fi=platform_device_add#691
|
||||
// todo: 插入资源: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/platform.c?fi=platform_device_add#691
|
||||
let r = device_manager().add_device(pdev.clone() as Arc<dyn Device>);
|
||||
if r.is_ok() {
|
||||
pdev.set_state(DeviceState::Initialized);
|
||||
|
@ -39,7 +39,7 @@ pub struct PlatformDriverManager;
|
||||
impl PlatformDriverManager {
|
||||
/// 注册平台设备驱动
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/platform.c?fi=__platform_driver_register#861
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/platform.c?fi=__platform_driver_register#861
|
||||
pub fn register(&self, driver: Arc<dyn PlatformDriver>) -> Result<(), SystemError> {
|
||||
driver.set_bus(Some(Arc::downgrade(&(platform_bus() as Arc<dyn Bus>))));
|
||||
return driver_manager().register(driver as Arc<dyn Driver>);
|
||||
|
@ -111,7 +111,7 @@ impl Bus for PlatformBus {
|
||||
/// and compare it against the name of the driver. Return whether they match
|
||||
/// or not.
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/platform.c#1331
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/platform.c#1331
|
||||
///
|
||||
///
|
||||
fn match_device(
|
||||
@ -151,7 +151,7 @@ impl AttributeGroup for PlatformDeviceAttrGroup {
|
||||
}
|
||||
|
||||
fn attrs(&self) -> &[&'static dyn Attribute] {
|
||||
// todo: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/platform.c?r=&mo=38425&fi=1511#1311
|
||||
// todo: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/platform.c?r=&mo=38425&fi=1511#1311
|
||||
return &[];
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ impl SubSysPrivate {
|
||||
}
|
||||
}
|
||||
|
||||
/// 参考: https://opengrok.ringotek.cn/xref/linux-6.1.9/include/linux/device.h#63
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/device.h#63
|
||||
pub trait SubSysInterface: Debug + Send + Sync {
|
||||
fn name(&self) -> &str;
|
||||
fn bus(&self) -> Option<Weak<dyn Bus>>;
|
||||
|
@ -3,6 +3,6 @@ use alloc::sync::Arc;
|
||||
use super::device::Device;
|
||||
|
||||
pub fn software_node_notify(_dev: &Arc<dyn Device>) {
|
||||
// todo: https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/base/swnode.c?fi=software_node_notify#1120
|
||||
// todo: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/swnode.c?fi=software_node_notify#1120
|
||||
return;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ pub trait UartDriver: Debug + Send + Sync + TtyDriver {
|
||||
|
||||
/// 串口端口应当实现的trait
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/include/linux/serial_core.h#428
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/serial_core.h#428
|
||||
pub trait UartPort {
|
||||
fn iobase(&self) -> Option<usize> {
|
||||
None
|
||||
@ -55,7 +55,7 @@ pub(super) struct UartManager;
|
||||
impl UartManager {
|
||||
/// todo: 把uart设备注册到tty层
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/tty/serial/serial_core.c?fi=uart_register_driver#2720
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/tty/serial/serial_core.c?fi=uart_register_driver#2720
|
||||
pub fn register_driver(&self, _driver: &Arc<dyn UartDriver>) -> Result<(), SystemError> {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ impl Serial8250Manager {
|
||||
///
|
||||
/// 应当在设备驱动模型初始化之后调用这里
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/tty/serial/8250/8250_core.c?r=&mo=30224&fi=1169#1169
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/tty/serial/8250/8250_core.c?r=&mo=30224&fi=1169#1169
|
||||
pub fn init(&self) -> Result<(), SystemError> {
|
||||
// 初始化serial8250 isa设备
|
||||
let serial8250_isa_dev = Serial8250ISADevices::new();
|
||||
@ -123,7 +123,7 @@ impl Serial8250Manager {
|
||||
|
||||
/// 把uart端口与uart driver、uart device绑定
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/tty/serial/8250/8250_core.c?r=&mo=30224&fi=1169#553
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/tty/serial/8250/8250_core.c?r=&mo=30224&fi=1169#553
|
||||
fn register_ports(
|
||||
&self,
|
||||
uart_driver: &Arc<Serial8250ISADriver>,
|
||||
@ -134,7 +134,7 @@ impl Serial8250Manager {
|
||||
|
||||
/// 把uart端口与uart driver绑定
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/tty/serial/serial_core.c?fi=uart_add_one_port#3048
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/tty/serial/serial_core.c?fi=uart_add_one_port#3048
|
||||
pub(self) fn uart_add_one_port(
|
||||
&self,
|
||||
_uart_driver: &Arc<Serial8250ISADriver>,
|
||||
@ -344,7 +344,7 @@ impl InnerSerial8250ISADevices {
|
||||
}
|
||||
|
||||
/// Serial 8250平台设备的id
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/include/linux/serial_8250.h?fi=PLAT8250_DEV_LEGACY#49
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/serial_8250.h?fi=PLAT8250_DEV_LEGACY#49
|
||||
#[derive(Debug)]
|
||||
#[repr(i32)]
|
||||
enum Serial8250PlatformDeviceID {
|
||||
|
@ -9,7 +9,7 @@ use super::tty_device::TtyDevice;
|
||||
/// TTY 驱动
|
||||
///
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/include/linux/tty_driver.h#434
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/tty_driver.h#434
|
||||
pub trait TtyDriver: Debug + Send + Sync + Driver {
|
||||
fn driver_name(&self) -> &str;
|
||||
fn dev_name(&self) -> &str;
|
||||
@ -42,20 +42,20 @@ pub struct TtyDriverMetadata {
|
||||
subtype: TtyDriverSubtype,
|
||||
}
|
||||
|
||||
/// https://opengrok.ringotek.cn/xref/linux-6.1.9/include/linux/tty_driver.h#411
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/tty_driver.h#411
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum TtyDriverType {}
|
||||
|
||||
/// https://opengrok.ringotek.cn/xref/linux-6.1.9/include/linux/tty_driver.h#412
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/tty_driver.h#412
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum TtyDriverSubtype {}
|
||||
|
||||
bitflags! {
|
||||
/// https://opengrok.ringotek.cn/xref/linux-6.1.9/include/linux/tty_driver.h?fi=SERIAL_TYPE_NORMAL#492
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/tty_driver.h?fi=SERIAL_TYPE_NORMAL#492
|
||||
pub struct TtyDriverFlags: u64 {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/include/linux/tty_driver.h#350
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/tty_driver.h#350
|
||||
pub trait TtyDriverOperations {}
|
||||
|
@ -562,7 +562,7 @@ impl KernFSInode {
|
||||
///
|
||||
/// Returns the created node on success
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/fs/kernfs/symlink.c#25
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/fs/kernfs/symlink.c#25
|
||||
pub fn add_link(
|
||||
&self,
|
||||
name: String,
|
||||
|
@ -111,7 +111,7 @@ impl SysFS {
|
||||
return self.add_file_with_mode(&inode, attr, attr.mode());
|
||||
}
|
||||
|
||||
// https://opengrok.ringotek.cn/xref/linux-6.1.9/fs/sysfs/file.c?fi=sysfs_add_file_mode_ns#271
|
||||
// https://code.dragonos.org.cn/xref/linux-6.1.9/fs/sysfs/file.c?fi=sysfs_add_file_mode_ns#271
|
||||
pub(super) fn add_file_with_mode(
|
||||
&self,
|
||||
parent: &Arc<KernFSInode>,
|
||||
@ -200,7 +200,7 @@ impl SysFS {
|
||||
/// - `kobj` 要创建属性文件的kobject
|
||||
/// - `attr` 属性
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/fs/sysfs/file.c#558
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/fs/sysfs/file.c#558
|
||||
pub fn create_bin_file(
|
||||
&self,
|
||||
kobj: &Arc<dyn KObject>,
|
||||
@ -229,7 +229,7 @@ impl SysFS {
|
||||
}
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/fs/sysfs/file.c#304
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/fs/sysfs/file.c#304
|
||||
pub(super) fn add_bin_file_with_mode(
|
||||
&self,
|
||||
parent: &Arc<KernFSInode>,
|
||||
|
@ -164,7 +164,7 @@ impl SysFS {
|
||||
/// - `group` - 属性组
|
||||
/// - `update` - 当前是否正在更新属性
|
||||
///
|
||||
/// https://opengrok.ringotek.cn/xref/linux-6.1.9/fs/sysfs/group.c#34
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/fs/sysfs/group.c#34
|
||||
fn group_create_files(
|
||||
&self,
|
||||
parent: Arc<KernFSInode>,
|
||||
|
@ -19,7 +19,7 @@ impl SysFS {
|
||||
/// - `target`: object we're pointing to.
|
||||
/// - `name`: 符号链接的名称
|
||||
///
|
||||
/// 参考:https://opengrok.ringotek.cn/xref/linux-6.1.9/fs/sysfs/symlink.c#89
|
||||
/// 参考:https://code.dragonos.org.cn/xref/linux-6.1.9/fs/sysfs/symlink.c#89
|
||||
pub fn create_link(
|
||||
&self,
|
||||
kobj: Option<&Arc<dyn KObject>>,
|
||||
@ -37,7 +37,7 @@ impl SysFS {
|
||||
/// - `name`: 符号链接的名称
|
||||
///
|
||||
///
|
||||
/// 参考:https://opengrok.ringotek.cn/xref/linux-6.1.9/fs/sysfs/symlink.c#143
|
||||
/// 参考:https://code.dragonos.org.cn/xref/linux-6.1.9/fs/sysfs/symlink.c#143
|
||||
pub fn remove_link(&self, _kobj: &Arc<dyn KObject>, _name: String) {
|
||||
todo!("sysfs remove link")
|
||||
}
|
||||
@ -60,7 +60,7 @@ impl SysFS {
|
||||
return self.do_create_link_sd(&parent, target, name, warn);
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/fs/sysfs/symlink.c#20
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/fs/sysfs/symlink.c#20
|
||||
fn do_create_link_sd(
|
||||
&self,
|
||||
inode: &Arc<KernFSInode>,
|
||||
|
@ -3,7 +3,7 @@ const F_LINUX_SPECIFIC_BASE: u32 = 1024;
|
||||
/// fcntl syscall command
|
||||
///
|
||||
/// for linux-specific fcntl commands, see:
|
||||
/// https://opengrok.ringotek.cn/xref/linux-5.19.10/tools/include/uapi/linux/fcntl.h#8
|
||||
/// https://code.dragonos.org.cn/xref/linux-5.19.10/tools/include/uapi/linux/fcntl.h#8
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, FromPrimitive, ToPrimitive)]
|
||||
#[repr(u32)]
|
||||
pub enum FcntlCommand {
|
||||
|
@ -60,7 +60,7 @@ bitflags! {
|
||||
/// 其中,低2bit组合而成的数字的值,用于表示访问权限。其他的bit,才支持通过按位或的方式来表示参数
|
||||
///
|
||||
/// 与Linux 5.19.10的uapi/asm-generic/fcntl.h相同
|
||||
/// https://opengrok.ringotek.cn/xref/linux-5.19.10/tools/include/uapi/asm-generic/fcntl.h#19
|
||||
/// https://code.dragonos.org.cn/xref/linux-5.19.10/tools/include/uapi/asm-generic/fcntl.h#19
|
||||
pub struct FileMode: u32{
|
||||
/* File access modes for `open' and `fcntl'. */
|
||||
/// Open Read-only
|
||||
|
@ -79,7 +79,7 @@ impl Signal {
|
||||
force_send = matches!(siginfo.sig_code(), SigCode::Kernel);
|
||||
} else {
|
||||
// todo: 判断signal是否来自于一个祖先进程的namespace,如果是,则强制发送信号
|
||||
//详见 https://opengrok.ringotek.cn/xref/linux-6.1.9/kernel/signal.c?r=&mo=32170&fi=1220#1226
|
||||
//详见 https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/signal.c?r=&mo=32170&fi=1220#1226
|
||||
}
|
||||
|
||||
if !self.prepare_sianal(pcb.clone(), force_send) {
|
||||
@ -259,7 +259,7 @@ impl Signal {
|
||||
.flush_by_mask(&flush);
|
||||
let _r = ProcessManager::wakeup_stop(&pcb);
|
||||
// TODO 对每个子线程 flush mask
|
||||
// 这里需要补充一段逻辑,详见https://opengrok.ringotek.cn/xref/linux-6.1.9/kernel/signal.c#952
|
||||
// 这里需要补充一段逻辑,详见https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/signal.c#952
|
||||
}
|
||||
|
||||
// 一个被阻塞了的信号肯定是要被处理的
|
||||
|
@ -315,8 +315,8 @@ impl SigInfo {
|
||||
///
|
||||
/// ## 注意
|
||||
///
|
||||
/// 该函数对应Linux中的https://opengrok.ringotek.cn/xref/linux-6.1.9/kernel/signal.c#3323
|
||||
/// Linux还提供了 https://opengrok.ringotek.cn/xref/linux-6.1.9/kernel/signal.c#3383 用来实现
|
||||
/// 该函数对应Linux中的https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/signal.c#3323
|
||||
/// Linux还提供了 https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/signal.c#3383 用来实现
|
||||
/// kernel_siginfo 保存到 用户的 compact_siginfo 的功能,但是我们系统内还暂时没有对这两种
|
||||
/// siginfo做区分,因此暂时不需要第二个函数
|
||||
pub fn copy_siginfo_to_user(&self, to: *mut SigInfo) -> Result<i32, SystemError> {
|
||||
|
@ -157,7 +157,7 @@ impl ElfLoader {
|
||||
}
|
||||
|
||||
// todo: 增加与架构相关的处理
|
||||
// ref: https://opengrok.ringotek.cn/xref/linux-5.19.10/fs/binfmt_elf.c?r=&mo=22652&fi=824#572
|
||||
// ref: https://code.dragonos.org.cn/xref/linux-5.19.10/fs/binfmt_elf.c?r=&mo=22652&fi=824#572
|
||||
|
||||
return prot;
|
||||
}
|
||||
@ -165,7 +165,7 @@ impl ElfLoader {
|
||||
/// 加载ELF文件到用户空间
|
||||
///
|
||||
/// 参考Linux的elf_map函数
|
||||
/// https://opengrok.ringotek.cn/xref/linux-5.19.10/fs/binfmt_elf.c?r=&mo=22652&fi=824#365
|
||||
/// https://code.dragonos.org.cn/xref/linux-5.19.10/fs/binfmt_elf.c?r=&mo=22652&fi=824#365
|
||||
/// ## 参数
|
||||
///
|
||||
/// - `user_vm_guard`:用户空间地址空间
|
||||
@ -505,7 +505,7 @@ impl BinaryLoader for ElfLoader {
|
||||
let ehdr = Self::parse_ehdr(head_buf).map_err(|_| ExecError::NotExecutable)?;
|
||||
|
||||
// 参考linux-5.19的load_elf_binary函数
|
||||
// https://opengrok.ringotek.cn/xref/linux-5.19.10/fs/binfmt_elf.c?r=&mo=22652&fi=824#1034
|
||||
// https://code.dragonos.org.cn/xref/linux-5.19.10/fs/binfmt_elf.c?r=&mo=22652&fi=824#1034
|
||||
|
||||
let elf_type = ElfType::from(ehdr.e_type);
|
||||
// kdebug!("ehdr = {:?}", ehdr);
|
||||
|
@ -46,7 +46,7 @@ pub fn generate_iface_id() -> usize {
|
||||
|
||||
bitflags! {
|
||||
/// @brief 用于指定socket的关闭类型
|
||||
/// 参考:https://opengrok.ringotek.cn/xref/linux-6.1.9/include/net/sock.h?fi=SHUTDOWN_MASK#1573
|
||||
/// 参考:https://code.dragonos.org.cn/xref/linux-6.1.9/include/net/sock.h?fi=SHUTDOWN_MASK#1573
|
||||
pub struct ShutdownType: u8 {
|
||||
const RCV_SHUTDOWN = 1;
|
||||
const SEND_SHUTDOWN = 2;
|
||||
|
@ -1156,7 +1156,7 @@ impl Socket for TcpSocket {
|
||||
|
||||
/// @brief 地址族的枚举
|
||||
///
|
||||
/// 参考:https://opengrok.ringotek.cn/xref/linux-5.19.10/include/linux/socket.h#180
|
||||
/// 参考:https://code.dragonos.org.cn/xref/linux-5.19.10/include/linux/socket.h#180
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive)]
|
||||
pub enum AddressFamily {
|
||||
/// AF_UNSPEC 表示地址族未指定
|
||||
|
@ -103,7 +103,7 @@ pub fn kernel_wait4(
|
||||
return Ok(r);
|
||||
}
|
||||
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/kernel/exit.c#1573
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/exit.c#1573
|
||||
fn do_wait(kwo: &mut KernelWaitOption) -> Result<usize, SystemError> {
|
||||
let mut retval: Result<usize, SystemError>;
|
||||
// todo: 在signal struct里面增加等待队列,并在这里初始化子进程退出的回调,使得子进程退出时,能唤醒当前进程。
|
||||
|
@ -464,7 +464,7 @@ impl ProcessManager {
|
||||
.store(clone_args.exit_signal, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
// todo: 增加线程组相关的逻辑。 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/kernel/fork.c#2437
|
||||
// todo: 增加线程组相关的逻辑。 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/fork.c#2437
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use super::{user_access::UserBufferWriter, Syscall};
|
||||
|
||||
/// 系统信息
|
||||
///
|
||||
/// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/include/uapi/linux/sysinfo.h#8
|
||||
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/uapi/linux/sysinfo.h#8
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct SysInfo {
|
||||
uptime: u64,
|
||||
|
Loading…
x
Reference in New Issue
Block a user