init: Convert vesad, fbbootlogd and fbcond to services
This commit is contained in:
@@ -25,7 +25,7 @@ pub struct FbbootlogScheme {
|
||||
impl FbbootlogScheme {
|
||||
pub fn new() -> FbbootlogScheme {
|
||||
let mut scheme = FbbootlogScheme {
|
||||
input_handle: ConsumerHandle::new_vt().expect("fbbootlogd: Failed to open vt"),
|
||||
input_handle: ConsumerHandle::bootlog_vt().expect("fbbootlogd: Failed to open vt"),
|
||||
display_map: None,
|
||||
text_screen: console_draw::TextScreen::new(),
|
||||
text_buffer: console_draw::TextBuffer::new(1000),
|
||||
|
||||
@@ -47,6 +47,14 @@ impl ConsumerHandle {
|
||||
Ok(Self(file))
|
||||
}
|
||||
|
||||
pub fn bootlog_vt() -> io::Result<Self> {
|
||||
let file = OpenOptions::new()
|
||||
.read(true)
|
||||
.custom_flags(O_NONBLOCK as i32)
|
||||
.open(format!("/scheme/input/consumer_bootlog"))?;
|
||||
Ok(Self(file))
|
||||
}
|
||||
|
||||
pub fn event_handle(&self) -> BorrowedFd<'_> {
|
||||
self.0.as_fd()
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ use redox_scheme::{CallerCtx, OpenResult, RequestKind, Response, SignalBehavior,
|
||||
|
||||
use orbclient::{Event, EventOption};
|
||||
use syscall::schemev2::NewFdFlags;
|
||||
use syscall::{Error as SysError, EventFlags, EACCES, EBADF, EINVAL};
|
||||
use syscall::{Error as SysError, EventFlags, EACCES, EBADF, EEXIST, EINVAL};
|
||||
|
||||
pub mod keymap;
|
||||
|
||||
@@ -79,7 +79,7 @@ impl InputScheme {
|
||||
handles: BTreeMap::new(),
|
||||
|
||||
next_id: AtomicUsize::new(0),
|
||||
next_vt_id: AtomicUsize::new(1),
|
||||
next_vt_id: AtomicUsize::new(2), // VT 1 is reserved for the bootlog
|
||||
|
||||
display: None,
|
||||
vts: BTreeSet::new(),
|
||||
@@ -195,6 +195,20 @@ impl SchemeSync for InputScheme {
|
||||
vt,
|
||||
}
|
||||
}
|
||||
"consumer_bootlog" => {
|
||||
if !self.vts.insert(1) {
|
||||
return Err(SysError::new(EEXIST));
|
||||
}
|
||||
|
||||
self.switch_vt(1);
|
||||
Handle::Consumer {
|
||||
events: EventFlags::empty(),
|
||||
pending: Vec::new(),
|
||||
needs_handoff: false,
|
||||
notified: false,
|
||||
vt: 1,
|
||||
}
|
||||
}
|
||||
"handle" | "handle_early" => {
|
||||
let display = path_parts.collect::<Vec<_>>().join(".");
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"unit": {
|
||||
"description": "Graphical bootlog",
|
||||
"requires_weak": ["10_inputd.service"]
|
||||
},
|
||||
"service": {
|
||||
"cmd": "fbbootlogd",
|
||||
"type": {
|
||||
"scheme": "fbbootlog"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"unit": {
|
||||
"description": "Framebuffer text console",
|
||||
"requires_weak": ["10_inputd.service", "20_vesad.service"]
|
||||
},
|
||||
"service": {
|
||||
"cmd": "fbcond",
|
||||
"args": ["2"],
|
||||
"type": {
|
||||
"scheme": "fbcon"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
requires_weak 10_inputd.service
|
||||
notify FRAMEBUFFER_ADDR=$ FRAMEBUFFER_VIRT=$ FRAMEBUFFER_WIDTH=$ FRAMEBUFFER_HEIGHT=$ FRAMEBUFFER_STRIDE=$ vesad
|
||||
scheme fbbootlog fbbootlogd
|
||||
scheme fbcon fbcond 2
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"unit": {
|
||||
"description": "Graphics subsystem",
|
||||
"requires_weak": [
|
||||
"10_inputd.service",
|
||||
"20_vesad.service",
|
||||
"20_fbbootlogd.service",
|
||||
"20_fbcond.service"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"unit": {
|
||||
"description": "Bootloader framebuffer handler",
|
||||
"requires_weak": [
|
||||
"10_inputd.service"
|
||||
]
|
||||
},
|
||||
"service": {
|
||||
"cmd": "vesad",
|
||||
"inherit_envs": [
|
||||
"FRAMEBUFFER_ADDR",
|
||||
"FRAMEBUFFER_VIRT",
|
||||
"FRAMEBUFFER_WIDTH",
|
||||
"FRAMEBUFFER_HEIGHT",
|
||||
"FRAMEBUFFER_STRIDE"
|
||||
],
|
||||
"type": "notify"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
requires_weak 10_lived.service 20_graphics
|
||||
requires_weak 10_lived.service 20_graphics.target
|
||||
notify ps2d
|
||||
notify RSDP_ADDR=$ RSDP_SIZE=$ hwd
|
||||
pcid-spawner --initfs
|
||||
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::{env, io, iter};
|
||||
|
||||
use crate::service::{Service, ServiceType};
|
||||
@@ -66,6 +66,7 @@ impl Command {
|
||||
cmd: process.cmd,
|
||||
args: process.args,
|
||||
envs: process.envs,
|
||||
inherit_envs: BTreeSet::new(),
|
||||
type_: ServiceType::Notify,
|
||||
}))
|
||||
}
|
||||
@@ -80,6 +81,7 @@ impl Command {
|
||||
cmd: process.cmd,
|
||||
args: process.args,
|
||||
envs: process.envs,
|
||||
inherit_envs: BTreeSet::new(),
|
||||
type_: ServiceType::Scheme(scheme),
|
||||
}))
|
||||
}
|
||||
@@ -90,6 +92,7 @@ impl Command {
|
||||
cmd: process.cmd,
|
||||
args: process.args,
|
||||
envs: process.envs,
|
||||
inherit_envs: BTreeSet::new(),
|
||||
type_: ServiceType::OneshotAsync,
|
||||
}))
|
||||
}
|
||||
@@ -100,6 +103,7 @@ impl Command {
|
||||
cmd: process.cmd,
|
||||
args: process.args,
|
||||
envs: process.envs,
|
||||
inherit_envs: BTreeSet::new(),
|
||||
type_: ServiceType::Oneshot,
|
||||
}))
|
||||
}
|
||||
|
||||
+11
-2
@@ -1,4 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::process::Command;
|
||||
|
||||
@@ -11,6 +12,8 @@ pub struct Service {
|
||||
pub args: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub envs: BTreeMap<String, String>,
|
||||
#[serde(default)]
|
||||
pub inherit_envs: BTreeSet<String>,
|
||||
#[serde(rename = "type")]
|
||||
pub type_: ServiceType,
|
||||
}
|
||||
@@ -29,7 +32,13 @@ impl Service {
|
||||
pub fn spawn(&self, base_envs: &BTreeMap<String, OsString>) {
|
||||
let mut command = Command::new(&self.cmd);
|
||||
command.args(&self.args);
|
||||
command.env_clear().envs(base_envs).envs(&self.envs);
|
||||
command.env_clear();
|
||||
for env in &self.inherit_envs {
|
||||
if let Some(value) = env::var_os(env) {
|
||||
command.env(env, value);
|
||||
}
|
||||
}
|
||||
command.envs(base_envs).envs(&self.envs);
|
||||
|
||||
match &self.type_ {
|
||||
ServiceType::Notify => {
|
||||
|
||||
Reference in New Issue
Block a user