mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
x86_64: regenerate bootparam bindings without unions
TEST=crosvm run still works BUG=chromium:761517 Change-Id: I6e95dde573febb5e498107b84b574373d1685c9a Reviewed-on: https://chromium-review.googlesource.com/1625947 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
e6c9558998
commit
b42b645cfa
3 changed files with 107 additions and 3534 deletions
File diff suppressed because it is too large
Load diff
|
@ -4,13 +4,25 @@
|
|||
|
||||
use arch::android::create_android_fdt;
|
||||
use arch::fdt::{begin_node, end_node, finish_fdt, start_fdt, Error};
|
||||
use data_model::DataInit;
|
||||
use std::fs::File;
|
||||
use std::mem;
|
||||
use sys_util::{GuestAddress, GuestMemory};
|
||||
|
||||
use crate::bootparam::setup_data;
|
||||
use crate::bootparam::SETUP_DTB;
|
||||
use crate::X86_64_FDT_MAX_SIZE;
|
||||
use crate::{SETUP_DTB, X86_64_FDT_MAX_SIZE};
|
||||
|
||||
// Like `setup_data` without the incomplete array field at the end, which allows us to safely
|
||||
// implement Copy, Clone, and DataInit.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Default)]
|
||||
struct setup_data_hdr {
|
||||
pub next: u64,
|
||||
pub type_: u32,
|
||||
pub len: u32,
|
||||
}
|
||||
|
||||
unsafe impl DataInit for setup_data_hdr {}
|
||||
|
||||
/// Creates a flattened device tree containing all of the parameters for the
|
||||
/// kernel and loads it into the guest memory at the specified offset.
|
||||
|
@ -42,7 +54,11 @@ pub fn create_fdt(
|
|||
let mut fdt_final = vec![0; fdt_data_size];
|
||||
finish_fdt(&mut fdt, &mut fdt_final, fdt_data_size)?;
|
||||
|
||||
let mut hdr: setup_data = Default::default();
|
||||
assert_eq!(
|
||||
mem::size_of::<setup_data>(),
|
||||
mem::size_of::<setup_data_hdr>()
|
||||
);
|
||||
let mut hdr: setup_data_hdr = Default::default();
|
||||
hdr.next = 0;
|
||||
hdr.type_ = SETUP_DTB;
|
||||
hdr.len = fdt_data_size as u32;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
mod fdt;
|
||||
|
||||
const E820_RAM: u32 = 1;
|
||||
const SETUP_DTB: u32 = 2;
|
||||
const X86_64_FDT_MAX_SIZE: u64 = 0x200000;
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -11,22 +13,9 @@ const X86_64_FDT_MAX_SIZE: u64 = 0x200000;
|
|||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_snake_case)]
|
||||
mod bootparam;
|
||||
// Bindgen didn't implement copy for boot_params because edid_info contains an array with len > 32.
|
||||
impl Copy for bootparam::edid_info {}
|
||||
impl Clone for bootparam::edid_info {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
impl Copy for bootparam::boot_params {}
|
||||
impl Clone for bootparam::boot_params {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
// boot_params is just a series of ints, it is safe to initialize it.
|
||||
unsafe impl data_model::DataInit for bootparam::boot_params {}
|
||||
unsafe impl data_model::DataInit for bootparam::setup_data {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[allow(non_upper_case_globals)]
|
||||
|
@ -64,7 +53,6 @@ use std::mem;
|
|||
use std::sync::Arc;
|
||||
|
||||
use crate::bootparam::boot_params;
|
||||
use crate::bootparam::E820_RAM;
|
||||
use arch::{RunnableLinuxVm, VmComponents};
|
||||
use devices::{get_serial_tty_string, PciConfigIo, PciDevice, PciInterruptPin, SerialParameters};
|
||||
use io_jail::Minijail;
|
||||
|
@ -258,13 +246,13 @@ fn configure_system(
|
|||
/// Add an e820 region to the e820 map.
|
||||
/// Returns Ok(()) if successful, or an error if there is no space left in the map.
|
||||
fn add_e820_entry(params: &mut boot_params, addr: u64, size: u64, mem_type: u32) -> Result<()> {
|
||||
if params.e820_entries >= params.e820_map.len() as u8 {
|
||||
if params.e820_entries >= params.e820_table.len() as u8 {
|
||||
return Err(Error::E820Configuration);
|
||||
}
|
||||
|
||||
params.e820_map[params.e820_entries as usize].addr = addr;
|
||||
params.e820_map[params.e820_entries as usize].size = size;
|
||||
params.e820_map[params.e820_entries as usize].type_ = mem_type;
|
||||
params.e820_table[params.e820_entries as usize].addr = addr;
|
||||
params.e820_table[params.e820_entries as usize].size = size;
|
||||
params.e820_table[params.e820_entries as usize].type_ = mem_type;
|
||||
params.e820_entries += 1;
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue