patina_internal_cpu 23.3.0

CPU support.
Documentation
//! Stub Interrupt module for tests.
//!
//! ## License
//!
//! Copyright (c) Microsoft Corporation.
//!
//! SPDX-License-Identifier: Apache-2.0
//!

use patina::{error::EfiError, pi::protocol::cpu_arch::EfiSystemContext};

use crate::interrupts::InterruptManager;

/// Null implementation of the `EfiSystemContextFactory` and `EfiExceptionInfoDump` traits.
#[derive(Debug)]
#[allow(dead_code)]
pub struct ExceptionContextStub;

impl super::EfiSystemContextFactory for ExceptionContextStub {
    fn create_efi_system_context(&mut self) -> EfiSystemContext {
        // Pointer being set is arbitrary, but EBC is architecture agnostic.
        EfiSystemContext { system_context_ebc: core::ptr::null_mut() }
    }
}

impl super::EfiExceptionInfoDump for ExceptionContextStub {
    fn dump_stack_trace(&self) {}
    fn dump_system_context_registers(&self) {}
}

/// Null Implementation of the `InterruptManager`.
#[derive(Default, Copy, Clone)]
pub struct InterruptsStub {}

impl InterruptsStub {
    /// Creates a new instance of the null implementation of the `InterruptManager`.
    pub const fn new() -> Self {
        Self {}
    }

    /// A do-nothing initialization function for the null implementation.
    pub fn initialize(&mut self) -> Result<(), EfiError> {
        Ok(())
    }
}

impl InterruptManager for InterruptsStub {}