base: apply Red Bear patches on latest upstream/main

251 files: init, acpid, ipcd, netcfg, ihdgd, virtio-gpud, scheme-utils,
inputd, block driver, ptyd, ramfs, randd, initfs bootstrap, path deps,
version +rb0.3.1, author attribution
This commit is contained in:
Red Bear OS
2026-07-11 11:39:24 +03:00
parent 1b17b3fc24
commit bd595851e2
251 changed files with 24641 additions and 5993 deletions
+14 -17
View File
@@ -1,15 +1,12 @@
use std::fs::File;
use std::io::prelude::*;
use std::os::fd::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::os::fd::{FromRawFd, IntoRawFd, RawFd};
use std::path::Path;
use std::ptr::{self, NonNull};
use std::ptr::NonNull;
use std::{env, io};
use std::{fmt, process};
use common::MemoryType;
use daemon::Daemon;
use libredox::call::MmapArgs;
use libredox::flag::{MAP_SHARED, PROT_READ, PROT_WRITE};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
pub use bar::PciBar;
@@ -147,6 +144,10 @@ impl PciFunction {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SubdriverArguments {
pub func: PciFunction,
/// Full device ID (vendor, device, class, subclass, etc.) — pcid
/// reads this from the kernel's PCIe config space and passes it at
/// spawn time. Used by subdrivers to apply per-vendor quirks.
pub device_id: Option<crate::driver_interface::FullDeviceId>,
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
@@ -271,7 +272,6 @@ pub enum PcidClientResponse {
pub struct MappedBar {
pub ptr: NonNull<u8>,
pub bar_size: usize,
pub memory_type: MemoryType,
}
/// A handle from a `pcid` client (e.g. `ahcid`) to `pcid`.
@@ -456,23 +456,21 @@ impl PciFunctionHandle {
}
}
}
pub unsafe fn map_bar(&mut self, bir: u8, memory_type: MemoryType) -> &MappedBar {
pub unsafe fn map_bar(&mut self, bir: u8) -> &MappedBar {
let mapped_bar = &mut self.mapped_bars[bir as usize];
if let Some(mapped_bar) = mapped_bar {
assert_eq!(mapped_bar.memory_type, memory_type);
mapped_bar
} else {
let (bar, bar_size) = self.config.func.bars[bir as usize].expect_mem();
let ptr = match unsafe {
libredox::call::mmap(MmapArgs {
addr: ptr::null_mut(),
length: bar_size,
prot: PROT_READ | PROT_WRITE,
flags: MAP_SHARED,
fd: self.channel.as_raw_fd() as usize,
offset: u64::from(bir) << (64 - 3) | (memory_type as u64) << (64 - 3 - 2) | 0,
})
common::physmap(
bar,
bar_size,
common::Prot::RW,
// FIXME once the kernel supports this use write-through for prefetchable BAR
common::MemoryType::Uncacheable,
)
} {
Ok(ptr) => ptr,
Err(err) => {
@@ -484,7 +482,6 @@ impl PciFunctionHandle {
mapped_bar.insert(MappedBar {
ptr: NonNull::new(ptr.cast::<u8>()).expect("Mapping a BAR resulted in a nullptr"),
bar_size,
memory_type,
})
}
}
+1 -2
View File
@@ -5,7 +5,6 @@ use crate::driver_interface::PciBar;
use crate::PciFunctionHandle;
use common::io::{Io, Mmio};
use common::MemoryType;
use serde::{Deserialize, Serialize};
/// The address and data to use for MSI and MSI-X.
@@ -40,7 +39,7 @@ impl MsixInfo {
let virt_table_base = unsafe {
pcid_handle
.map_bar(self.table_bar, MemoryType::Uncacheable)
.map_bar(self.table_bar)
.ptr
.as_ptr()
.byte_add(self.table_offset as usize)