drivers/gpu/nova-core/sbuffer.rs
Source file repositories/reference/linux-study-clean/drivers/gpu/nova-core/sbuffer.rs
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/nova-core/sbuffer.rs- Extension
.rs- Size
- 7072 bytes
- Lines
- 225
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function get_slice_internalfunction Somefunction Somefunction Ok
Annotated Snippet
if let Some(slice) = core::mem::take(&mut self.cur_slice) {
buf.extend_from_slice(slice, flags)?;
}
for slice in &mut self.slices {
buf.extend_from_slice(slice, flags)?;
}
Ok(buf)
}
}
/// Provides a way to get mutable slices of data to write into.
impl<'a, I> SBufferIter<I>
where
I: Iterator<Item = &'a mut [u8]>,
{
/// Returns a mutable slice of at most `len` bytes, or [`None`] if we are at the end of the
/// data.
///
/// If a slice shorter than `len` bytes has been returned, the caller can call this method
/// again until it returns `None` to try and obtain the remainder of the data.
fn get_slice_mut(&mut self, len: usize) -> Option<&'a mut [u8]> {
self.get_slice_internal(len, |s, pos| s.split_at_mut(pos))
}
/// Ideally we would implement [`Write`], but it is not available in `core`.
/// So mimic `std::io::Write::write_all`.
pub(crate) fn write_all(&mut self, mut src: &[u8]) -> Result {
while !src.is_empty() {
match self.get_slice_mut(src.len()) {
None => return Err(ETOOSMALL),
Some(dst) => {
let src_slice;
(src_slice, src) = src.split_at(dst.len());
dst.copy_from_slice(src_slice);
}
}
}
Ok(())
}
}
impl<'a, I> Iterator for SBufferIter<I>
where
I: Iterator<Item = &'a [u8]>,
{
type Item = u8;
fn next(&mut self) -> Option<Self::Item> {
// Returned slices are guaranteed to not be empty so we can safely index the first entry.
self.get_slice(1).map(|s| s[0])
}
}
Annotation
- Detected declarations: `function get_slice_internal`, `function Some`, `function Some`, `function Ok`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.