implements PLN-0053
This commit is contained in:
@@ -1,25 +1,62 @@
|
||||
use crate::CrashReport;
|
||||
use crate::VirtualMachineRuntime;
|
||||
use crate::process::ProcessManager;
|
||||
use crate::services::window_manager::WindowManager;
|
||||
use crate::task::TaskId;
|
||||
use crate::task::TaskManager;
|
||||
use prometeu_hal::cartridge::Cartridge;
|
||||
use prometeu_hal::log::{LogLevel, LogService, LogSource};
|
||||
use prometeu_hal::telemetry::CertificationConfig;
|
||||
use prometeu_hal::{HardwareBridge, InputSignals};
|
||||
use prometeu_vm::VirtualMachine;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct SystemOS {
|
||||
pub vm_runtime: VirtualMachineRuntime,
|
||||
pub process_manager: ProcessManager,
|
||||
pub task_manager: TaskManager,
|
||||
pub window_manager: WindowManager,
|
||||
pub log_service: LogService,
|
||||
}
|
||||
|
||||
impl SystemOS {
|
||||
pub fn new(cap_config: Option<CertificationConfig>) -> Self {
|
||||
Self {
|
||||
vm_runtime: VirtualMachineRuntime::new(cap_config),
|
||||
let log_service = LogService::new(4096);
|
||||
let mut os = Self {
|
||||
vm_runtime: VirtualMachineRuntime::new_with_log_counter(
|
||||
cap_config,
|
||||
Arc::clone(&log_service.logs_count),
|
||||
),
|
||||
process_manager: ProcessManager::new(),
|
||||
task_manager: TaskManager::new(),
|
||||
window_manager: WindowManager::new(),
|
||||
}
|
||||
log_service,
|
||||
};
|
||||
|
||||
os.log(LogLevel::Info, LogSource::Pos, 0, "PrometeuOS starting...".to_string());
|
||||
|
||||
os
|
||||
}
|
||||
|
||||
pub fn log(&mut self, level: LogLevel, source: LogSource, tag: u16, msg: String) {
|
||||
self.vm_runtime.log(&mut self.log_service, level, source, tag, msg);
|
||||
}
|
||||
|
||||
pub fn initialize_vm(
|
||||
&mut self,
|
||||
vm: &mut VirtualMachine,
|
||||
cartridge: &Cartridge,
|
||||
) -> Result<(), CrashReport> {
|
||||
self.vm_runtime.initialize_vm(&mut self.log_service, vm, cartridge)
|
||||
}
|
||||
|
||||
pub fn tick_vm(
|
||||
&mut self,
|
||||
vm: &mut VirtualMachine,
|
||||
signals: &InputSignals,
|
||||
hw: &mut dyn HardwareBridge,
|
||||
) -> Option<CrashReport> {
|
||||
self.vm_runtime.tick(&mut self.log_service, vm, signals, hw)
|
||||
}
|
||||
|
||||
pub fn create_vm_game_task(&mut self, app_id: u32, title: impl Into<String>) -> TaskId {
|
||||
|
||||
Reference in New Issue
Block a user