Merge changes I895cb04f,I9741a38f,I928fa370,I8dc9c122 into main
* changes:
Eliminate a short blackout during the resume of the VM display
More refactoring on android display service
Distinguish error messages from scanout surface and cursor surface
Better error handling using android-base/Result.h
diff --git a/demo_accessor/README.md b/demo_accessor/README.md
index a3959a5..c85cf3c 100644
--- a/demo_accessor/README.md
+++ b/demo_accessor/README.md
@@ -28,7 +28,7 @@
```shell
adb remount -R || adb wait-for-device # Remount to push apex to /system_ext
adb root && adb remount # Ensure it's rebooted.
-adb push $ANDROID_PRODUCT_OUT/system_ext/com.android.virt.accessor_demo.apex /system_ext/apex
+adb push $ANDROID_PRODUCT_OUT/system_ext/apex/com.android.virt.accessor_demo.apex /system_ext/apex
adb reboot && adb wait-for-device # Ensure that newly pushed apex at /system_ext is installed
```
diff --git a/libs/libvmbase/src/console.rs b/libs/libvmbase/src/console.rs
index cd05250..7b01bb6 100644
--- a/libs/libvmbase/src/console.rs
+++ b/libs/libvmbase/src/console.rs
@@ -23,8 +23,8 @@
// Matches the UART count in crosvm.
const MAX_CONSOLES: usize = 4;
-static CONSOLES: [SpinMutex<Option<Uart>>; MAX_CONSOLES] =
- [SpinMutex::new(None), SpinMutex::new(None), SpinMutex::new(None), SpinMutex::new(None)];
+static CONSOLES: [Once<SpinMutex<Uart>>; MAX_CONSOLES] =
+ [Once::new(), Once::new(), Once::new(), Once::new()];
static ADDRESSES: [Once<usize>; MAX_CONSOLES] =
[Once::new(), Once::new(), Once::new(), Once::new()];
@@ -48,10 +48,10 @@
ADDRESSES[i].call_once(|| base_address);
// Initialize the console driver, for normal console accesses.
- let mut console = CONSOLES[i].lock();
- assert!(console.is_none(), "console::init() called more than once");
- // SAFETY: base_address must be the base of a mapped UART.
- console.replace(unsafe { Uart::new(base_address) });
+ assert!(!CONSOLES[i].is_completed(), "console::init() called more than once");
+ // SAFETY: The caller promised that base_address is the base of a mapped UART with no
+ // aliases.
+ CONSOLES[i].call_once(|| SpinMutex::new(unsafe { Uart::new(base_address) }));
}
}
@@ -59,8 +59,7 @@
///
/// Panics if the n-th console was not initialized by calling [`init`] first.
pub fn writeln(n: usize, format_args: Arguments) {
- let mut guard = CONSOLES[n].lock();
- let uart = guard.as_mut().unwrap();
+ let uart = &mut *CONSOLES[n].get().unwrap().lock();
write(uart, format_args).unwrap();
let _ = uart.write_str("\n");