Skip to content

Commit 0ad26e8

Browse files
author
Alexandra Iordache
committed
add x86_64 and aarch64 modules
Phase 2 of code reorganization: separate x86_64 from aarch64 functionality in modules. Signed-off-by: Alexandra Iordache <aghecen@amazon.com>
1 parent 334290d commit 0ad26e8

File tree

7 files changed

+45
-13
lines changed

7 files changed

+45
-13
lines changed

src/loader/aarch64/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2019 Intel Corporation. All rights reserved.
2+
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
//
4+
// Copyright 2017 The Chromium OS Authors. All rights reserved.
5+
// Use of this source code is governed by a BSD-style license that can be
6+
// found in the LICENSE-BSD-3-Clause file.
7+
//
8+
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
9+
10+
//! Traits and structs for loading `aarch64` kernels into guest memory.
11+
12+
#![cfg(target_arch = "aarch64")]

src/loader/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestUsize};
3131
#[cfg_attr(feature = "cargo-clippy", allow(clippy::all))]
3232
pub mod bootparam;
3333

34-
#[cfg(all(feature = "elf", any(target_arch = "x86", target_arch = "x86_64")))]
35-
pub mod elf;
34+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
35+
mod x86_64;
3636

37-
#[cfg(all(feature = "bzimage", any(target_arch = "x86", target_arch = "x86_64")))]
38-
pub mod bzimage;
37+
#[cfg(target_arch = "aarch64")]
38+
mod aarch64;
3939

40-
pub mod struct_util;
40+
#[cfg(all(feature = "bzimage", any(target_arch = "x86", target_arch = "x86_64")))]
41+
pub use x86_64::bzimage::BzImage;
42+
#[cfg(all(feature = "bzimage", any(target_arch = "x86", target_arch = "x86_64")))]
43+
pub use x86_64::bzimage::Error as BzImageError;
4144

4245
#[cfg(all(feature = "elf", any(target_arch = "x86", target_arch = "x86_64")))]
43-
pub use elf::Elf;
46+
pub use x86_64::elf::Elf;
4447
#[cfg(all(feature = "elf", any(target_arch = "x86", target_arch = "x86_64")))]
45-
pub use elf::Error as ElfError;
48+
pub use x86_64::elf::Error as ElfError;
4649

47-
#[cfg(all(feature = "bzimage", any(target_arch = "x86", target_arch = "x86_64")))]
48-
pub use bzimage::BzImage;
49-
#[cfg(all(feature = "bzimage", any(target_arch = "x86", target_arch = "x86_64")))]
50-
pub use bzimage::Error as BzImageError;
50+
pub mod struct_util;
5151

5252
#[derive(Debug, PartialEq)]
5353
/// Kernel loader errors.

src/loader/bzimage/mod.rs renamed to src/loader/x86_64/bzimage/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::io::{Read, Seek, SeekFrom};
1717

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

20-
use super::{
20+
use super::super::{
2121
bootparam, struct_util, Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result,
2222
};
2323

File renamed without changes.

src/loader/elf/mod.rs renamed to src/loader/x86_64/elf/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use std::mem;
1818

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

21-
use super::{struct_util, Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result};
21+
use super::super::{
22+
struct_util, Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result,
23+
};
2224

2325
#[allow(dead_code)]
2426
#[allow(non_camel_case_types)]
File renamed without changes.

src/loader/x86_64/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2019 Intel Corporation. All rights reserved.
2+
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
//
4+
// Copyright 2017 The Chromium OS Authors. All rights reserved.
5+
// Use of this source code is governed by a BSD-style license that can be
6+
// found in the LICENSE-BSD-3-Clause file.
7+
//
8+
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
9+
10+
//! Traits and structs for loading `x86_64` kernels into guest memory.
11+
12+
#![cfg(any(target_arch = "x86", target_arch = "x86_64"))]
13+
14+
#[cfg(feature = "elf")]
15+
pub mod elf;
16+
17+
#[cfg(feature = "bzimage")]
18+
pub mod bzimage;

0 commit comments

Comments
 (0)