@@ -11,12 +11,6 @@ use crate::vmm::{VM, images::ImageLoader, vm_list::push_vm};
11
11
#[ cfg( target_arch = "aarch64" ) ]
12
12
use crate :: vmm:: fdt:: * ;
13
13
14
- #[ cfg( target_arch = "aarch64" ) ]
15
- use fdt_parser:: Fdt ;
16
-
17
- #[ cfg( target_arch = "aarch64" ) ]
18
- use alloc:: vec:: Vec ;
19
-
20
14
use alloc:: sync:: Arc ;
21
15
22
16
#[ allow( clippy:: module_inception) ]
@@ -71,51 +65,6 @@ pub mod config {
71
65
include ! ( concat!( env!( "OUT_DIR" ) , "/vm_configs.rs" ) ) ;
72
66
}
73
67
74
- #[ cfg( target_arch = "aarch64" ) ]
75
- pub fn get_developer_provided_dtb (
76
- vm_cfg : & AxVMConfig ,
77
- crate_config : & AxVMCrateConfig ,
78
- ) -> Option < Vec < u8 > > {
79
- match crate_config. kernel . image_location . as_deref ( ) {
80
- Some ( "memory" ) => {
81
- let vm_imags = config:: get_memory_images ( )
82
- . iter ( )
83
- . find ( |& v| v. id == vm_cfg. id ( ) ) ?;
84
-
85
- if let Some ( dtb) = vm_imags. dtb {
86
- info ! ( "DTB file in memory, size: 0x{:x}" , dtb. len( ) ) ;
87
- return Some ( dtb. to_vec ( ) ) ;
88
- }
89
- }
90
- #[ cfg( feature = "fs" ) ]
91
- Some ( "fs" ) => {
92
- use axerrno:: ax_err_type;
93
- use std:: io:: { BufReader , Read } ;
94
- if let Some ( dtb_path) = & crate_config. kernel . dtb_path {
95
- let ( dtb_file, dtb_size) = crate :: vmm:: images:: open_image_file ( dtb_path) . unwrap ( ) ;
96
- info ! ( "DTB file in fs, size: 0x{:x}" , dtb_size) ;
97
-
98
- let mut file = BufReader :: new ( dtb_file) ;
99
- let mut dtb_buffer = vec ! [ 0 ; dtb_size] ;
100
-
101
- file. read_exact ( & mut dtb_buffer)
102
- . map_err ( |err| {
103
- ax_err_type ! (
104
- Io ,
105
- format!( "Failed in reading from file {}, err {:?}" , dtb_path, err)
106
- )
107
- } )
108
- . unwrap ( ) ;
109
- return Some ( dtb_buffer) ;
110
- }
111
- }
112
- _ => unimplemented ! (
113
- "Check your \" image_location\" in config.toml, \" memory\" and \" fs\" are supported,\n ."
114
- ) ,
115
- }
116
- None
117
- }
118
-
119
68
pub fn get_vm_dtb_arc ( _vm_cfg : & AxVMConfig ) -> Option < Arc < [ u8 ] > > {
120
69
#[ cfg( target_arch = "aarch64" ) ]
121
70
{
@@ -127,39 +76,6 @@ pub fn get_vm_dtb_arc(_vm_cfg: &AxVMConfig) -> Option<Arc<[u8]>> {
127
76
None
128
77
}
129
78
130
- /// Handle all FDT-related operations for aarch64 architecture
131
- #[ cfg( target_arch = "aarch64" ) ]
132
- fn handle_fdt_operations ( vm_config : & mut AxVMConfig , vm_create_config : & AxVMCrateConfig ) {
133
- let host_fdt_bytes = get_host_fdt ( ) ;
134
- let host_fdt = Fdt :: from_bytes ( host_fdt_bytes)
135
- . map_err ( |e| format ! ( "Failed to parse FDT: {e:#?}" ) )
136
- . expect ( "Failed to parse FDT" ) ;
137
- set_phys_cpu_sets ( vm_config, & host_fdt, vm_create_config) ;
138
-
139
- if let Some ( provided_dtb) = get_developer_provided_dtb ( vm_config, vm_create_config) {
140
- info ! ( "VM[{}] found DTB , parsing..." , vm_config. id( ) ) ;
141
- update_provided_fdt ( & provided_dtb, host_fdt_bytes, vm_create_config) ;
142
- } else {
143
- info ! (
144
- "VM[{}] DTB not found, generating based on the configuration file." ,
145
- vm_config. id( )
146
- ) ;
147
- setup_guest_fdt_from_vmm ( host_fdt_bytes, vm_config, vm_create_config) ;
148
- }
149
-
150
- // Overlay VM config with the given DTB.
151
- if let Some ( dtb_arc) = get_vm_dtb_arc ( vm_config) {
152
- let dtb = dtb_arc. as_ref ( ) ;
153
- parse_passthrough_devices_address ( vm_config, dtb) ;
154
- parse_vm_interrupt ( vm_config, dtb) ;
155
- } else {
156
- error ! (
157
- "VM[{}] DTB not found in memory, skipping..." ,
158
- vm_config. id( )
159
- ) ;
160
- }
161
- }
162
-
163
79
pub fn init_guest_vms ( ) {
164
80
// Initialize the DTB cache in the fdt module
165
81
#[ cfg( target_arch = "aarch64" ) ]
0 commit comments