Skip to content

Commit

Permalink
refactor autogenerated files
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandra Iordache <[email protected]>
  • Loading branch information
Alexandra Iordache committed Jun 15, 2020
1 parent bd9178d commit 1e0b776
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 26 deletions.
5 changes: 3 additions & 2 deletions coverage_config_x86_64.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"coverage_score": 81,
"coverage_score": 84.8,
"exclude_path": "",
"crate_features": "bzimage,elf"
"crate_features": "bzimage,elf",
"exclude_path": "loader_gen"
}
2 changes: 1 addition & 1 deletion src/configurator/x86_64/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl BootConfigurator for LinuxBootConfigurator {
#[cfg(test)]
mod tests {
use super::*;
use crate::loader::bootparam::boot_params;
use crate::loader_gen::bootparam::boot_params;
use std::mem;
use vm_memory::{Address, GuestAddress, GuestMemoryMmap};

Expand Down
2 changes: 1 addition & 1 deletion src/configurator/x86_64/pvh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use vm_memory::{ByteValued, Bytes, GuestMemory};

use crate::configurator::{BootConfigurator, BootParams, Error as BootConfiguratorError, Result};
use crate::loader::elf::start_info::{hvm_memmap_table_entry, hvm_modlist_entry, hvm_start_info};
use crate::loader_gen::start_info::{hvm_memmap_table_entry, hvm_modlist_entry, hvm_start_info};

use std::error::Error as StdError;
use std::fmt;
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ pub mod cmdline;
pub mod configurator;
pub mod loader;

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
mod loader_gen;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub use loader_gen::*;

extern crate vm_memory;
11 changes: 1 addition & 10 deletions src/loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,11 @@ use std::ffi::CStr;
use std::fmt::{self, Display};
use std::io::{Read, Seek};

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use vm_memory::ByteValued;
use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestUsize};

#[allow(dead_code)]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
#[allow(non_upper_case_globals)]
#[allow(missing_docs)]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::all))]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
// Hide the autogenerated documentation for bindgen'ed sources.
#[doc(hidden)]
pub mod bootparam;
pub use crate::loader_gen::bootparam;

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
mod x86_64;
Expand Down
15 changes: 3 additions & 12 deletions src/loader/x86_64/elf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,9 @@ use std::mem;

use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestUsize};

use super::super::{Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result};

#[allow(dead_code)]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
#[allow(non_upper_case_globals)]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::all))]
mod elf;

#[allow(missing_docs)]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::all))]
pub mod start_info;
use crate::loader::{Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result};
use crate::loader_gen::elf;
pub use crate::loader_gen::start_info;

unsafe impl ByteValued for elf::Elf64_Ehdr {}
unsafe impl ByteValued for elf::Elf64_Nhdr {}
Expand Down
15 changes: 15 additions & 0 deletions src/loader_gen/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2019 Intel Corporation. All rights reserved.
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-BSD-3-Clause file.
//
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause

//! Bindgen autogenerated structs for boot parameters.
#![cfg(any(target_arch = "x86", target_arch = "x86_64"))]

mod x86_64;
pub use x86_64::*;
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions src/loader_gen/x86_64/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2019 Intel Corporation. All rights reserved.
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-BSD-3-Clause file.
//
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause

//! Bindgen autogenerated structs for `x86_64` boot parameters.
#![cfg(any(target_arch = "x86", target_arch = "x86_64"))]

#![cfg_attr(feature = "cargo-clippy", allow(clippy::all))]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]

// Hide the autogenerated documentation for bindgen'ed sources.
#[doc(hidden)]
pub mod bootparam;

#[cfg(feature = "elf")]
pub mod elf;

#[cfg(feature = "elf")]
pub mod start_info;
File renamed without changes.

0 comments on commit 1e0b776

Please sign in to comment.