1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! Hardware Abstraction Layer (HAL) for the ixgbe driver.
//!
//! This module defines the [`IxgbeHal`] trait, which must be implemented by the platform
//! specific code to integrate the ixgbe driver with a given operating system or bare-metal
//! environment.
//!
//! # The HAL Interface
//!
//! The HAL trait provides three categories of functionality:
//!
//! 1. **DMA Memory Management**: Allocating and freeing physically contiguous memory
//! that the NIC can access directly
//!
//! 2. **MMIO Address Translation**: Converting between physical and virtual addresses
//! for accessing device registers
//!
//! 3. **Timing/Waiting**: Blocking execution for a specified duration
//!
//! # Example Implementation
//!
//! ```rust,ignore
//! use core::ptr::NonNull;
//! use core::time::Duration;
//! use ixgbe_driver::hal::IxgbeHal;
//! use ixgbe_driver::memory::PhysAddr;
//!
//! struct MyHal;
//!
//! unsafe impl IxgbeHal for MyHal {
//! fn dma_alloc(size: usize) -> (PhysAddr, NonNull<u8>) {
//! // Platform-specific DMA allocation
//! todo!()
//! }
//!
//! unsafe fn dma_dealloc(paddr: PhysAddr, vaddr: NonNull<u8>, size: usize) -> i32 {
//! // Platform-specific DMA deallocation
//! todo!()
//! }
//!
//! unsafe fn mmio_phys_to_virt(paddr: PhysAddr, size: usize) -> NonNull<u8> {
//! // Map MMIO physical address to virtual
//! todo!()
//! }
//!
//! unsafe fn mmio_virt_to_phys(vaddr: NonNull<u8>, size: usize) -> PhysAddr {
//! // Map MMIO virtual address to physical
//! todo!()
//! }
//!
//! fn wait_until(duration: Duration) -> Result<(), &'static str> {
//! // Block for the specified duration
//! todo!()
//! }
//! }
//! ```
use cratePhysAddr;
use NonNull;
use Duration;
/// The interface which a particular hardware implementation must implement.
///
/// # Safety
///
/// Implementations of this trait must follow the "implementation safety" requirements documented
/// for each method. Callers must follow the safety requirements documented for the unsafe methods.
pub unsafe