vmbase: aarch64: Move power to platform

This commit add new directory `arch` that is intended to hold all
platform specific source code. Additionally, it moves functions `reboot`, `shutdown` the newly created directory.

Bug: 362733888
Test: m libvmbase

Change-Id: I515407e2fa55603c07651ef5d85c8c782f5307cd
diff --git a/libs/libvmbase/src/arch.rs b/libs/libvmbase/src/arch.rs
index 0348800..5cb578b 100644
--- a/libs/libvmbase/src/arch.rs
+++ b/libs/libvmbase/src/arch.rs
@@ -17,6 +17,9 @@
 #[cfg(target_arch = "aarch64")]
 pub mod aarch64;
 
+#[cfg(target_arch = "aarch64")]
+pub use aarch64::platform;
+
 /// Write with well-defined compiled behavior.
 ///
 /// See https://github.com/rust-lang/rust/issues/131894
diff --git a/libs/libvmbase/src/arch/aarch64.rs b/libs/libvmbase/src/arch/aarch64.rs
index 5006aca..068e001 100644
--- a/libs/libvmbase/src/arch/aarch64.rs
+++ b/libs/libvmbase/src/arch/aarch64.rs
@@ -14,6 +14,8 @@
 
 //! Wrappers of assembly calls.
 
+pub mod platform;
+
 /// Reads a value from a system register.
 #[macro_export]
 macro_rules! read_sysreg {
diff --git a/libs/libvmbase/src/arch/aarch64/platform.rs b/libs/libvmbase/src/arch/aarch64/platform.rs
new file mode 100644
index 0000000..6985445
--- /dev/null
+++ b/libs/libvmbase/src/arch/aarch64/platform.rs
@@ -0,0 +1,38 @@
+// Copyright 2022, The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! Definition of platform
+
+use smccc::{
+    psci::{system_off, system_reset},
+    Hvc,
+};
+
+/// Makes a `PSCI_SYSTEM_OFF` call to shutdown the VM.
+///
+/// Panics if it returns an error.
+pub fn shutdown() -> ! {
+    system_off::<Hvc>().unwrap();
+    #[allow(clippy::empty_loop)]
+    loop {}
+}
+
+/// Makes a `PSCI_SYSTEM_RESET` call to shutdown the VM abnormally.
+///
+/// Panics if it returns an error.
+pub fn reboot() -> ! {
+    system_reset::<Hvc>().unwrap();
+    #[allow(clippy::empty_loop)]
+    loop {}
+}
diff --git a/libs/libvmbase/src/power.rs b/libs/libvmbase/src/power.rs
index 9240acf..e3461c5 100644
--- a/libs/libvmbase/src/power.rs
+++ b/libs/libvmbase/src/power.rs
@@ -13,26 +13,18 @@
 // limitations under the License.
 
 //! Functions for shutting down the VM.
+use crate::arch::platform;
 
-use smccc::{
-    psci::{system_off, system_reset},
-    Hvc,
-};
-
-/// Makes a `PSCI_SYSTEM_OFF` call to shutdown the VM.
+/// Call shutdown VM using platform specific code.
 ///
 /// Panics if it returns an error.
 pub fn shutdown() -> ! {
-    system_off::<Hvc>().unwrap();
-    #[allow(clippy::empty_loop)]
-    loop {}
+    platform::shutdown();
 }
 
-/// Makes a `PSCI_SYSTEM_RESET` call to shutdown the VM abnormally.
+/// Call reboot VM using platform specific code.
 ///
 /// Panics if it returns an error.
 pub fn reboot() -> ! {
-    system_reset::<Hvc>().unwrap();
-    #[allow(clippy::empty_loop)]
-    loop {}
+    platform::reboot();
 }