mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 14:38:47 +00:00
Mechanical, behavior-neutral: edition/resolver keys, unsafe extern blocks, unsafe(no_mangle)/unsafe(export_name), unsafe blocks inside unsafe fn, r#gen renames, --edition flags in Makefiles/tools, rustfmt style_edition pinned to 2021 so formatting stays edition-independent, and clippy collapsible_if allowed workspace-wide (let-chain churn). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
38 lines
1.3 KiB
Rust
38 lines
1.3 KiB
Rust
#![no_std]
|
|
#[path = "../src/nvidia/kernel/gpu_arch.rs"]
|
|
mod gpu_arch;
|
|
use core::{num::NonZeroU64, panic::PanicInfo};
|
|
use gpu_arch::{ArchitectureRegistry, GpuArchOwner};
|
|
use nv_rs_core::gpu::gpu_arch::Key;
|
|
|
|
#[unsafe(export_name = "NV_RS_AUDIT_ARCH_GET")]
|
|
pub fn get(registry: &mut ArchitectureRegistry<32>, key: Key) -> Result<GpuArchOwner, i32> {
|
|
registry.get_or_create(key)
|
|
}
|
|
#[unsafe(export_name = "NV_RS_AUDIT_ARCH_NEW")]
|
|
pub fn new(namespace: NonZeroU64) -> ArchitectureRegistry<32> {
|
|
ArchitectureRegistry::new(namespace)
|
|
}
|
|
#[unsafe(export_name = "NV_RS_AUDIT_ARCH_CLOSE")]
|
|
pub fn close(registry: &mut ArchitectureRegistry<32>) -> Result<(), i32> {
|
|
registry.close()
|
|
}
|
|
#[unsafe(export_name = "NV_RS_AUDIT_ARCH_REFERENCES")]
|
|
pub fn references(registry: &ArchitectureRegistry<32>) -> Result<bool, i32> {
|
|
registry.has_external_references()
|
|
}
|
|
#[unsafe(export_name = "NV_RS_AUDIT_ARCH_IMAGE")]
|
|
pub fn image(owner: &GpuArchOwner) -> Result<u64, i32> {
|
|
let base = owner.logical_base()?.get();
|
|
let key = owner.key()?;
|
|
let method = owner.method_value(0x68).map_err(|_| -95)?;
|
|
owner.with_legacy_hal(|hal| hal.logical_base().get())?;
|
|
owner.with_image(|bytes| base ^ u64::from(key.architecture) ^ method ^ u64::from(bytes[0]))
|
|
}
|
|
#[panic_handler]
|
|
fn panic(_: &PanicInfo<'_>) -> ! {
|
|
loop {
|
|
core::hint::spin_loop();
|
|
}
|
|
}
|