kernel/device/platform/
resource.rs

1//! Platform device resource management module.
2//!
3//! This module defines the `PlatformDeviceResource` struct and the `PlatformDeviceResourceType` enum,
4//! which represent the resources associated with platform devices.
5//!
6
7/// PlatformDeviceResource struct
8///
9/// This struct represents a resource associated with a platform device.
10/// It contains the resource type (memory, I/O, IRQ, or DMA),
11/// the starting address, and the ending address of the resource.
12#[derive(Debug)]
13pub struct PlatformDeviceResource {
14    pub res_type: PlatformDeviceResourceType,
15    pub start: usize,
16    pub end: usize,
17    /// Optional metadata for IRQ resources (e.g., type, flags from Device Tree)
18    pub irq_metadata: Option<IrqMetadata>,
19}
20
21/// IRQ metadata from Device Tree interrupt specifiers
22#[derive(Debug, Clone, Copy)]
23pub struct IrqMetadata {
24    /// Interrupt type (e.g., 0=SPI, 1=PPI for ARM GIC)
25    pub irq_type: u32,
26    /// Interrupt number (before controller-specific translation)
27    pub irq_number: u32,
28    /// Interrupt flags (e.g., trigger type, polarity)
29    pub irq_flags: u32,
30}
31
32/// PlatformDeviceResourceType enum
33///
34/// This enum defines the types of resources that can be associated with a platform device.
35/// The types include memory (MEM), I/O (IO), interrupt request (IRQ), and direct memory access (DMA).
36/// Each type is represented as a variant of the enum.
37#[derive(PartialEq, Eq, Debug)]
38pub enum PlatformDeviceResourceType {
39    MEM,
40    IO,
41    IRQ,
42    DMA,
43}