mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-09 13:26:48 +00:00
Fix lint errors
This commit is contained in:
parent
82a2c4cdec
commit
cbb4b4e631
@ -146,7 +146,7 @@ impl ConfigManager<VirtioBlockConfig> {
|
|||||||
let cap_high = self
|
let cap_high = self
|
||||||
.read_once::<u32>(offset_of!(VirtioBlockConfig, capacity) + 4)
|
.read_once::<u32>(offset_of!(VirtioBlockConfig, capacity) + 4)
|
||||||
.unwrap() as u64;
|
.unwrap() as u64;
|
||||||
blk_config.capacity = cap_high << 32 | cap_low;
|
blk_config.capacity = (cap_high << 32) | cap_low;
|
||||||
blk_config.size_max = self
|
blk_config.size_max = self
|
||||||
.read_once::<u32>(offset_of!(VirtioBlockConfig, size_max))
|
.read_once::<u32>(offset_of!(VirtioBlockConfig, size_max))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -193,7 +193,7 @@ impl ConfigManager<VirtioBlockConfig> {
|
|||||||
.read_once::<u32>(offset_of!(VirtioBlockConfig, capacity) + 4)
|
.read_once::<u32>(offset_of!(VirtioBlockConfig, capacity) + 4)
|
||||||
.unwrap() as usize;
|
.unwrap() as usize;
|
||||||
|
|
||||||
cap_high << 32 | cap_low
|
(cap_high << 32) | cap_low
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ impl EventTable {
|
|||||||
let segment = FrameAllocOptions::new().alloc_segment(1).unwrap();
|
let segment = FrameAllocOptions::new().alloc_segment(1).unwrap();
|
||||||
|
|
||||||
let default_event = VirtioInputEvent::default();
|
let default_event = VirtioInputEvent::default();
|
||||||
let iter = iter::repeat(&default_event).take(EVENT_SIZE);
|
let iter = iter::repeat_n(&default_event, EVENT_SIZE);
|
||||||
let nr_written = segment.write_vals(0, iter, 0).unwrap();
|
let nr_written = segment.write_vals(0, iter, 0).unwrap();
|
||||||
assert_eq!(nr_written, EVENT_SIZE);
|
assert_eq!(nr_written, EVENT_SIZE);
|
||||||
|
|
||||||
|
@ -53,10 +53,10 @@ impl SocketDevice {
|
|||||||
let guest_cid = field_ptr!(&virtio_vsock_config, VirtioVsockConfig, guest_cid_low)
|
let guest_cid = field_ptr!(&virtio_vsock_config, VirtioVsockConfig, guest_cid_low)
|
||||||
.read_once()
|
.read_once()
|
||||||
.unwrap() as u64
|
.unwrap() as u64
|
||||||
| (field_ptr!(&virtio_vsock_config, VirtioVsockConfig, guest_cid_high)
|
| ((field_ptr!(&virtio_vsock_config, VirtioVsockConfig, guest_cid_high)
|
||||||
.read_once()
|
.read_once()
|
||||||
.unwrap() as u64)
|
.unwrap() as u64)
|
||||||
<< 32;
|
<< 32);
|
||||||
|
|
||||||
let mut recv_queue = VirtQueue::new(QUEUE_RECV, QUEUE_SIZE, transport.as_mut())
|
let mut recv_queue = VirtQueue::new(QUEUE_RECV, QUEUE_SIZE, transport.as_mut())
|
||||||
.expect("creating recv queue fails");
|
.expect("creating recv queue fails");
|
||||||
|
@ -225,7 +225,7 @@ impl VirtioTransport for VirtioMmioTransport {
|
|||||||
let device_feature_high = field_ptr!(&self.layout, VirtioMmioLayout, device_features)
|
let device_feature_high = field_ptr!(&self.layout, VirtioMmioLayout, device_features)
|
||||||
.read_once()
|
.read_once()
|
||||||
.unwrap() as u64;
|
.unwrap() as u64;
|
||||||
device_feature_high << 32 | device_feature_low as u64
|
(device_feature_high << 32) | device_feature_low as u64
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_driver_features(&mut self, features: u64) -> Result<(), VirtioTransportError> {
|
fn write_driver_features(&mut self, features: u64) -> Result<(), VirtioTransportError> {
|
||||||
|
@ -163,7 +163,7 @@ impl VirtioTransport for VirtioPciModernTransport {
|
|||||||
let device_feature_high = field_ptr!(&self.common_cfg, VirtioPciCommonCfg, device_features)
|
let device_feature_high = field_ptr!(&self.common_cfg, VirtioPciCommonCfg, device_features)
|
||||||
.read_once()
|
.read_once()
|
||||||
.unwrap() as u64;
|
.unwrap() as u64;
|
||||||
device_feature_high << 32 | device_feature_low as u64
|
(device_feature_high << 32) | device_feature_low as u64
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_driver_features(&mut self, features: u64) -> Result<(), VirtioTransportError> {
|
fn write_driver_features(&mut self, features: u64) -> Result<(), VirtioTransportError> {
|
||||||
|
@ -70,8 +70,8 @@ impl Config {
|
|||||||
|
|
||||||
/// ensure the config to be valid. We will check three things.
|
/// ensure the config to be valid. We will check three things.
|
||||||
/// 1. The component ident and library name(The last segment of component path) cannot be duplicate.
|
/// 1. The component ident and library name(The last segment of component path) cannot be duplicate.
|
||||||
/// 2. The controlled type in whilelist should be in one of defined components.
|
/// 2. The controlled type in whitelist should be in one of defined components.
|
||||||
/// 3. The components in whilelist should be defined.
|
/// 3. The components in whitelist should be defined.
|
||||||
pub fn check_config(&self) {
|
pub fn check_config(&self) {
|
||||||
let mut component_idents = HashSet::new();
|
let mut component_idents = HashSet::new();
|
||||||
let mut lib_names = HashSet::new();
|
let mut lib_names = HashSet::new();
|
||||||
@ -89,14 +89,14 @@ impl Config {
|
|||||||
lib_names.insert(lib_name);
|
lib_names.insert(lib_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (type_, whilelist) in &self.whitelists {
|
for (type_, whitelist) in &self.whitelists {
|
||||||
// check 2
|
// check 2
|
||||||
let component_ident = type_.iter().nth(0).unwrap();
|
let component_ident = type_.iter().nth(0).unwrap();
|
||||||
if !component_idents.contains(component_ident) {
|
if !component_idents.contains(component_ident) {
|
||||||
panic!("The controlled type is not in any component.");
|
panic!("The controlled type is not in any component.");
|
||||||
}
|
}
|
||||||
// check 3
|
// check 3
|
||||||
for (component_name, _) in whilelist.iter() {
|
for (component_name, _) in whitelist.iter() {
|
||||||
if !component_idents.contains(component_name) {
|
if !component_idents.contains(component_name) {
|
||||||
panic!("The component in whitelist is not defined");
|
panic!("The component in whitelist is not defined");
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ use crate::{
|
|||||||
|
|
||||||
const BUFFER_CAPACITY: usize = 4096;
|
const BUFFER_CAPACITY: usize = 4096;
|
||||||
|
|
||||||
/// Pesudo terminal master.
|
/// Pseudo terminal master.
|
||||||
/// Internally, it has two buffers.
|
/// Internally, it has two buffers.
|
||||||
/// One is inside ldisc, which is written by master and read by slave,
|
/// One is inside ldisc, which is written by master and read by slave,
|
||||||
/// the other is a ring buffer, which is written by slave and read by master.
|
/// the other is a ring buffer, which is written by slave and read by master.
|
||||||
|
@ -1067,8 +1067,8 @@ impl ExfatInode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EmptyVistor;
|
struct EmptyVisitor;
|
||||||
impl DirentVisitor for EmptyVistor {
|
impl DirentVisitor for EmptyVisitor {
|
||||||
fn visit(&mut self, name: &str, ino: u64, type_: InodeType, offset: usize) -> Result<()> {
|
fn visit(&mut self, name: &str, ino: u64, type_: InodeType, offset: usize) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -1458,7 +1458,7 @@ impl Inode for ExfatInode {
|
|||||||
return Ok(0);
|
return Ok(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut empty_visitor = EmptyVistor;
|
let mut empty_visitor = EmptyVisitor;
|
||||||
|
|
||||||
let dir_read = {
|
let dir_read = {
|
||||||
let fs = inner.fs();
|
let fs = inner.fs();
|
||||||
|
@ -182,7 +182,7 @@ impl Clone for RangeLockItem {
|
|||||||
/// Rule of ordering:
|
/// Rule of ordering:
|
||||||
/// Locks are sorted by owner process, then by the starting offset.
|
/// Locks are sorted by owner process, then by the starting offset.
|
||||||
///
|
///
|
||||||
/// Rule of mergeing:
|
/// Rule of merging:
|
||||||
/// Adjacent and overlapping locks with same owner and type will be merged.
|
/// Adjacent and overlapping locks with same owner and type will be merged.
|
||||||
///
|
///
|
||||||
/// Rule of updating:
|
/// Rule of updating:
|
||||||
|
@ -139,7 +139,7 @@ mod gdb {
|
|||||||
Tcp, // IP_ADDR:PORT
|
Tcp, // IP_ADDR:PORT
|
||||||
}
|
}
|
||||||
pub fn stub_type_of(stub: &str) -> StubAddrType {
|
pub fn stub_type_of(stub: &str) -> StubAddrType {
|
||||||
if stub.split(':').last().unwrap().parse::<u16>().is_ok() {
|
if stub.split(':').next_back().unwrap().parse::<u16>().is_ok() {
|
||||||
return StubAddrType::Tcp;
|
return StubAddrType::Tcp;
|
||||||
}
|
}
|
||||||
StubAddrType::Unix
|
StubAddrType::Unix
|
||||||
|
@ -185,7 +185,7 @@ impl PageTableCreator {
|
|||||||
impl Ia32eTable {
|
impl Ia32eTable {
|
||||||
fn index(&mut self, level: usize, va: u64) -> &mut Ia32eEntry {
|
fn index(&mut self, level: usize, va: u64) -> &mut Ia32eEntry {
|
||||||
debug_assert!((1..=5).contains(&level));
|
debug_assert!((1..=5).contains(&level));
|
||||||
let index = va as usize >> (12 + 9 * (level - 1)) & (TABLE_ENTRY_COUNT - 1);
|
let index = (va as usize >> (12 + 9 * (level - 1))) & (TABLE_ENTRY_COUNT - 1);
|
||||||
&mut self.0[index]
|
&mut self.0[index]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,15 +150,15 @@ impl PageTableEntryTrait for PageTableEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn prop(&self) -> PageProperty {
|
fn prop(&self) -> PageProperty {
|
||||||
let flags = parse_flags!(self.0, PageTableFlags::READABLE, PageFlags::R)
|
let flags = (parse_flags!(self.0, PageTableFlags::READABLE, PageFlags::R))
|
||||||
| parse_flags!(self.0, PageTableFlags::WRITABLE, PageFlags::W)
|
| (parse_flags!(self.0, PageTableFlags::WRITABLE, PageFlags::W))
|
||||||
| parse_flags!(self.0, PageTableFlags::EXECUTABLE, PageFlags::X)
|
| (parse_flags!(self.0, PageTableFlags::EXECUTABLE, PageFlags::X))
|
||||||
| parse_flags!(self.0, PageTableFlags::ACCESSED, PageFlags::ACCESSED)
|
| (parse_flags!(self.0, PageTableFlags::ACCESSED, PageFlags::ACCESSED))
|
||||||
| parse_flags!(self.0, PageTableFlags::DIRTY, PageFlags::DIRTY)
|
| (parse_flags!(self.0, PageTableFlags::DIRTY, PageFlags::DIRTY))
|
||||||
| parse_flags!(self.0, PageTableFlags::RSV1, PageFlags::AVAIL1)
|
| (parse_flags!(self.0, PageTableFlags::RSV1, PageFlags::AVAIL1))
|
||||||
| parse_flags!(self.0, PageTableFlags::RSV2, PageFlags::AVAIL2);
|
| (parse_flags!(self.0, PageTableFlags::RSV2, PageFlags::AVAIL2));
|
||||||
let priv_flags = parse_flags!(self.0, PageTableFlags::USER, PrivFlags::USER)
|
let priv_flags = (parse_flags!(self.0, PageTableFlags::USER, PrivFlags::USER))
|
||||||
| parse_flags!(self.0, PageTableFlags::GLOBAL, PrivFlags::GLOBAL);
|
| (parse_flags!(self.0, PageTableFlags::GLOBAL, PrivFlags::GLOBAL));
|
||||||
|
|
||||||
let cache = if self.0 & PageTableFlags::PBMT_IO.bits() != 0 {
|
let cache = if self.0 & PageTableFlags::PBMT_IO.bits() != 0 {
|
||||||
CachePolicy::Uncacheable
|
CachePolicy::Uncacheable
|
||||||
|
@ -112,7 +112,7 @@ fn parse_memory_regions(mb1_info: &MultibootLegacyInfo) -> MemoryRegionArray {
|
|||||||
regions
|
regions
|
||||||
.push(MemoryRegion::new(
|
.push(MemoryRegion::new(
|
||||||
fb.address,
|
fb.address,
|
||||||
(fb.width * fb.height * fb.bpp + 7) / 8, // round up when divide with 8 (bits/Byte)
|
(fb.width * fb.height * fb.bpp).div_ceil(8), // round up when divide with 8 (bits/Byte)
|
||||||
MemoryRegionType::Framebuffer,
|
MemoryRegionType::Framebuffer,
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -116,7 +116,7 @@ fn parse_memory_regions() -> MemoryRegionArray {
|
|||||||
regions
|
regions
|
||||||
.push(MemoryRegion::new(
|
.push(MemoryRegion::new(
|
||||||
fb.address,
|
fb.address,
|
||||||
(fb.width * fb.height * fb.bpp + 7) / 8, // round up when divide with 8 (bits/Byte)
|
(fb.width * fb.height * fb.bpp).div_ceil(8), // round up when divide with 8 (bits/Byte)
|
||||||
MemoryRegionType::Framebuffer,
|
MemoryRegionType::Framebuffer,
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -159,7 +159,7 @@ impl IrtEntry {
|
|||||||
/// Enables this entry with no validation,
|
/// Enables this entry with no validation,
|
||||||
/// DST = 0, IM = 0, DLM = 0, TM = 0, RH = 0, DM = 0, FPD = 1, P = 1
|
/// DST = 0, IM = 0, DLM = 0, TM = 0, RH = 0, DM = 0, FPD = 1, P = 1
|
||||||
pub fn enable_default(&mut self, vector: u32) {
|
pub fn enable_default(&mut self, vector: u32) {
|
||||||
self.0 = 0b11 | (vector as u128) << 16;
|
self.0 = 0b11 | ((vector as u128) << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn source_validation_type(&self) -> SourceValidationType {
|
pub fn source_validation_type(&self) -> SourceValidationType {
|
||||||
|
@ -183,12 +183,12 @@ impl Icr {
|
|||||||
ApicId::X2Apic(d) => (d as u64) << 32,
|
ApicId::X2Apic(d) => (d as u64) << 32,
|
||||||
};
|
};
|
||||||
Icr(dest
|
Icr(dest
|
||||||
| (destination_shorthand as u64) << 18
|
| ((destination_shorthand as u64) << 18)
|
||||||
| (trigger_mode as u64) << 15
|
| ((trigger_mode as u64) << 15)
|
||||||
| (level as u64) << 14
|
| ((level as u64) << 14)
|
||||||
| (delivery_status as u64) << 12
|
| ((delivery_status as u64) << 12)
|
||||||
| (destination_mode as u64) << 11
|
| ((destination_mode as u64) << 11)
|
||||||
| (delivery_mode as u64) << 8
|
| ((delivery_mode as u64) << 8)
|
||||||
| (vector as u64))
|
| (vector as u64))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ impl ApicId {
|
|||||||
/// Logical x2APIC ID = [(x2APIC ID[19:4] << 16) | (1 << x2APIC ID[3:0])]
|
/// Logical x2APIC ID = [(x2APIC ID[19:4] << 16) | (1 << x2APIC ID[3:0])]
|
||||||
#[expect(unused)]
|
#[expect(unused)]
|
||||||
pub fn x2apic_logical_id(&self) -> u32 {
|
pub fn x2apic_logical_id(&self) -> u32 {
|
||||||
self.x2apic_logical_cluster_id() << 16 | 1 << self.x2apic_logical_field_id()
|
(self.x2apic_logical_cluster_id() << 16) | (1 << self.x2apic_logical_field_id())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the logical x2apic cluster ID.
|
/// Returns the logical x2apic cluster ID.
|
||||||
|
@ -46,7 +46,7 @@ impl X2Apic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set SVR, Enable APIC and set Spurious Vector to 15 (Reserved irq number)
|
// Set SVR, Enable APIC and set Spurious Vector to 15 (Reserved irq number)
|
||||||
let svr: u64 = 1 << 8 | 15;
|
let svr: u64 = (1 << 8) | 15;
|
||||||
wrmsr(IA32_X2APIC_SIVR, svr);
|
wrmsr(IA32_X2APIC_SIVR, svr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ impl super::Apic for X2Apic {
|
|||||||
wrmsr(IA32_X2APIC_ICR, icr.0);
|
wrmsr(IA32_X2APIC_ICR, icr.0);
|
||||||
loop {
|
loop {
|
||||||
let icr = rdmsr(IA32_X2APIC_ICR);
|
let icr = rdmsr(IA32_X2APIC_ICR);
|
||||||
if (icr >> 12 & 0x1) == 0 {
|
if ((icr >> 12) & 0x1) == 0 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if rdmsr(IA32_X2APIC_ESR) > 0 {
|
if rdmsr(IA32_X2APIC_ESR) > 0 {
|
||||||
|
@ -50,7 +50,7 @@ impl XApic {
|
|||||||
set_apic_base_address(get_apic_base_address());
|
set_apic_base_address(get_apic_base_address());
|
||||||
|
|
||||||
// Set SVR, Enable APIC and set Spurious Vector to 15 (Reserved irq number)
|
// Set SVR, Enable APIC and set Spurious Vector to 15 (Reserved irq number)
|
||||||
let svr: u32 = 1 << 8 | 15;
|
let svr: u32 = (1 << 8) | 15;
|
||||||
self.write(xapic::XAPIC_SVR, svr);
|
self.write(xapic::XAPIC_SVR, svr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ impl super::Apic for XApic {
|
|||||||
self.write(xapic::XAPIC_ICR0, icr.lower());
|
self.write(xapic::XAPIC_ICR0, icr.lower());
|
||||||
loop {
|
loop {
|
||||||
let icr = self.read(xapic::XAPIC_ICR0);
|
let icr = self.read(xapic::XAPIC_ICR0);
|
||||||
if (icr >> 12 & 0x1) == 0 {
|
if ((icr >> 12) & 0x1) == 0 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if self.read(xapic::XAPIC_ESR) > 0 {
|
if self.read(xapic::XAPIC_ESR) > 0 {
|
||||||
|
@ -198,18 +198,18 @@ impl PageTableEntryTrait for PageTableEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn prop(&self) -> PageProperty {
|
fn prop(&self) -> PageProperty {
|
||||||
let flags = parse_flags!(self.0, PageTableFlags::PRESENT, PageFlags::R)
|
let flags = (parse_flags!(self.0, PageTableFlags::PRESENT, PageFlags::R))
|
||||||
| parse_flags!(self.0, PageTableFlags::WRITABLE, PageFlags::W)
|
| (parse_flags!(self.0, PageTableFlags::WRITABLE, PageFlags::W))
|
||||||
| parse_flags!(!self.0, PageTableFlags::NO_EXECUTE, PageFlags::X)
|
| (parse_flags!(!self.0, PageTableFlags::NO_EXECUTE, PageFlags::X))
|
||||||
| parse_flags!(self.0, PageTableFlags::ACCESSED, PageFlags::ACCESSED)
|
| (parse_flags!(self.0, PageTableFlags::ACCESSED, PageFlags::ACCESSED))
|
||||||
| parse_flags!(self.0, PageTableFlags::DIRTY, PageFlags::DIRTY)
|
| (parse_flags!(self.0, PageTableFlags::DIRTY, PageFlags::DIRTY))
|
||||||
| parse_flags!(self.0, PageTableFlags::HIGH_IGN1, PageFlags::AVAIL1)
|
| (parse_flags!(self.0, PageTableFlags::HIGH_IGN1, PageFlags::AVAIL1))
|
||||||
| parse_flags!(self.0, PageTableFlags::HIGH_IGN2, PageFlags::AVAIL2);
|
| (parse_flags!(self.0, PageTableFlags::HIGH_IGN2, PageFlags::AVAIL2));
|
||||||
let priv_flags = parse_flags!(self.0, PageTableFlags::USER, PrivFlags::USER)
|
let priv_flags = (parse_flags!(self.0, PageTableFlags::USER, PrivFlags::USER))
|
||||||
| parse_flags!(self.0, PageTableFlags::GLOBAL, PrivFlags::GLOBAL);
|
| (parse_flags!(self.0, PageTableFlags::GLOBAL, PrivFlags::GLOBAL));
|
||||||
#[cfg(feature = "cvm_guest")]
|
#[cfg(feature = "cvm_guest")]
|
||||||
let priv_flags =
|
let priv_flags =
|
||||||
priv_flags | parse_flags!(self.0, PageTableFlags::SHARED, PrivFlags::SHARED);
|
priv_flags | (parse_flags!(self.0, PageTableFlags::SHARED, PrivFlags::SHARED));
|
||||||
let cache = if self.0 & PageTableFlags::NO_CACHE.bits() != 0 {
|
let cache = if self.0 & PageTableFlags::NO_CACHE.bits() != 0 {
|
||||||
CachePolicy::Uncacheable
|
CachePolicy::Uncacheable
|
||||||
} else if self.0 & PageTableFlags::WRITE_THROUGH.bits() != 0 {
|
} else if self.0 & PageTableFlags::WRITE_THROUGH.bits() != 0 {
|
||||||
@ -229,35 +229,35 @@ impl PageTableEntryTrait for PageTableEntry {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mut flags = PageTableFlags::empty().bits();
|
let mut flags = PageTableFlags::empty().bits();
|
||||||
flags |= parse_flags!(prop.flags.bits(), PageFlags::R, PageTableFlags::PRESENT)
|
flags |= (parse_flags!(prop.flags.bits(), PageFlags::R, PageTableFlags::PRESENT))
|
||||||
| parse_flags!(prop.flags.bits(), PageFlags::W, PageTableFlags::WRITABLE)
|
| (parse_flags!(prop.flags.bits(), PageFlags::W, PageTableFlags::WRITABLE))
|
||||||
| parse_flags!(!prop.flags.bits(), PageFlags::X, PageTableFlags::NO_EXECUTE)
|
| (parse_flags!(!prop.flags.bits(), PageFlags::X, PageTableFlags::NO_EXECUTE))
|
||||||
| parse_flags!(
|
| (parse_flags!(
|
||||||
prop.flags.bits(),
|
prop.flags.bits(),
|
||||||
PageFlags::ACCESSED,
|
PageFlags::ACCESSED,
|
||||||
PageTableFlags::ACCESSED
|
PageTableFlags::ACCESSED
|
||||||
)
|
))
|
||||||
| parse_flags!(prop.flags.bits(), PageFlags::DIRTY, PageTableFlags::DIRTY)
|
| (parse_flags!(prop.flags.bits(), PageFlags::DIRTY, PageTableFlags::DIRTY))
|
||||||
| parse_flags!(
|
| (parse_flags!(
|
||||||
prop.flags.bits(),
|
prop.flags.bits(),
|
||||||
PageFlags::AVAIL1,
|
PageFlags::AVAIL1,
|
||||||
PageTableFlags::HIGH_IGN1
|
PageTableFlags::HIGH_IGN1
|
||||||
)
|
))
|
||||||
| parse_flags!(
|
| (parse_flags!(
|
||||||
prop.flags.bits(),
|
prop.flags.bits(),
|
||||||
PageFlags::AVAIL2,
|
PageFlags::AVAIL2,
|
||||||
PageTableFlags::HIGH_IGN2
|
PageTableFlags::HIGH_IGN2
|
||||||
)
|
))
|
||||||
| parse_flags!(
|
| (parse_flags!(
|
||||||
prop.priv_flags.bits(),
|
prop.priv_flags.bits(),
|
||||||
PrivFlags::USER,
|
PrivFlags::USER,
|
||||||
PageTableFlags::USER
|
PageTableFlags::USER
|
||||||
)
|
))
|
||||||
| parse_flags!(
|
| (parse_flags!(
|
||||||
prop.priv_flags.bits(),
|
prop.priv_flags.bits(),
|
||||||
PrivFlags::GLOBAL,
|
PrivFlags::GLOBAL,
|
||||||
PageTableFlags::GLOBAL
|
PageTableFlags::GLOBAL
|
||||||
);
|
));
|
||||||
#[cfg(feature = "cvm_guest")]
|
#[cfg(feature = "cvm_guest")]
|
||||||
{
|
{
|
||||||
flags |= parse_flags!(
|
flags |= parse_flags!(
|
||||||
|
@ -31,7 +31,7 @@ const HPET_FREQ: usize = 1_000_000_000_000_000;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
struct HpetTimerRegister {
|
struct HpetTimerRegister {
|
||||||
configuration_and_capabilities_register: u32,
|
configuration_and_capabilities_register: u32,
|
||||||
timer_compartor_value_register: u32,
|
timer_comparator_value_register: u32,
|
||||||
fsb_interrupt_route_register: u32,
|
fsb_interrupt_route_register: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,8 +168,8 @@ pub(crate) fn init(operating_mode: OperatingMode) {
|
|||||||
// Bit 0 is BCD/binary mode, which is always set to binary mode(value: 0)
|
// Bit 0 is BCD/binary mode, which is always set to binary mode(value: 0)
|
||||||
MODE_COMMAND_PORT.write(
|
MODE_COMMAND_PORT.write(
|
||||||
((operating_mode as u8) << 1)
|
((operating_mode as u8) << 1)
|
||||||
| (AccessMode::LowAndHighByte as u8) << 4
|
| ((AccessMode::LowAndHighByte as u8) << 4)
|
||||||
| (Channel::Channel0 as u8) << 6,
|
| ((Channel::Channel0 as u8) << 6),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set timer frequency
|
// Set timer frequency
|
||||||
|
@ -141,7 +141,7 @@ impl PciDeviceLocation {
|
|||||||
let mask = (0xFF << dest) as u32;
|
let mask = (0xFF << dest) as u32;
|
||||||
self.write32(
|
self.write32(
|
||||||
offset & Self::BIT32_ALIGN_MASK,
|
offset & Self::BIT32_ALIGN_MASK,
|
||||||
((val as u32) << dest | (old & !mask)).to_le(),
|
(((val as u32) << dest) | (old & !mask)).to_le(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ impl PciDeviceLocation {
|
|||||||
let mask = (0xFFFF << dest) as u32;
|
let mask = (0xFFFF << dest) as u32;
|
||||||
self.write32(
|
self.write32(
|
||||||
offset & Self::BIT32_ALIGN_MASK,
|
offset & Self::BIT32_ALIGN_MASK,
|
||||||
((val as u32) << dest | (old & !mask)).to_le(),
|
(((val as u32) << dest) | (old & !mask)).to_le(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ fn get_log_level() -> Option<LevelFilter> {
|
|||||||
let value = kcmdline
|
let value = kcmdline
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.find(|arg| arg.starts_with("ostd.log_level="))
|
.find(|arg| arg.starts_with("ostd.log_level="))
|
||||||
.map(|arg| arg.split('=').last().unwrap_or_default())?;
|
.map(|arg| arg.split('=').next_back().unwrap_or_default())?;
|
||||||
|
|
||||||
LevelFilter::from_str(value).ok()
|
LevelFilter::from_str(value).ok()
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ const fn nr_pte_index_bits<C: PagingConstsTrait>() -> usize {
|
|||||||
|
|
||||||
/// The index of a VA's PTE in a page table node at the given level.
|
/// The index of a VA's PTE in a page table node at the given level.
|
||||||
const fn pte_index<C: PagingConstsTrait>(va: Vaddr, level: PagingLevel) -> usize {
|
const fn pte_index<C: PagingConstsTrait>(va: Vaddr, level: PagingLevel) -> usize {
|
||||||
va >> (C::BASE_PAGE_SIZE.ilog2() as usize + nr_pte_index_bits::<C>() * (level as usize - 1))
|
(va >> (C::BASE_PAGE_SIZE.ilog2() as usize + nr_pte_index_bits::<C>() * (level as usize - 1)))
|
||||||
& (nr_subpage_per_huge::<C>() - 1)
|
& (nr_subpage_per_huge::<C>() - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user