Browse Source

Allocate 64-bit BARs from 32-bit address space.

Andrew Walbran 2 years ago
parent
commit
7735f7a437
1 changed files with 17 additions and 7 deletions
  1. 17 7
      examples/aarch64/src/main.rs

+ 17 - 7
examples/aarch64/src/main.rs

@@ -263,13 +263,23 @@ fn allocate_bars(
             address_type, size, ..
         } = info
         {
-            if address_type != MemoryBarType::Width32 {
-                panic!("Memory BAR address type {:?} not supported.", address_type);
-            }
-            if size > 0 {
-                let address = allocator.allocate_memory_32(size);
-                debug!("Allocated address {:#010x}", address);
-                root.set_bar_32(device_function, bar_index, address);
+            match address_type {
+                MemoryBarType::Width32 => {
+                    if size > 0 {
+                        let address = allocator.allocate_memory_32(size);
+                        debug!("Allocated address {:#010x}", address);
+                        root.set_bar_32(device_function, bar_index, address);
+                    }
+                }
+                MemoryBarType::Width64 => {
+                    if size > 0 {
+                        let address = allocator.allocate_memory_32(size);
+                        debug!("Allocated address {:#010x}", address);
+                        root.set_bar_64(device_function, bar_index, address.into());
+                    }
+                }
+
+                _ => panic!("Memory BAR address type {:?} not supported.", address_type),
             }
         }