7c7399e0a6
Add guard-recipes.sh with four modes: - --verify: check all local/recipes have correct symlinks into recipes/ - --fix: repair broken symlinks (run before builds) - --save-all: snapshot all recipe.toml into local/recipes/ - --restore: recreate all symlinks from local/recipes/ (run after sync-upstream) Wired into apply-patches.sh (post-patch) and sync-upstream.sh (post-sync). This prevents the build system from deleting recipe files during cargo cook, make distclean, or upstream source refresh.
34 lines
1.2 KiB
Plaintext
34 lines
1.2 KiB
Plaintext
mod registers;
|
|
|
|
use std::env;
|
|
use std::process;
|
|
use log::{info, error, LevelFilter};
|
|
|
|
struct StderrLogger;
|
|
impl log::Log for StderrLogger {
|
|
fn enabled(&self, md: &log::Metadata) -> bool { md.level() <= LevelFilter::Info }
|
|
fn log(&self, r: &log::Record) { eprintln!("[{}] ehcid: {}", r.level(), r.args()); }
|
|
fn flush(&self) {}
|
|
}
|
|
|
|
fn main() {
|
|
log::set_logger(&StderrLogger).ok();
|
|
log::set_max_level(LevelFilter::Info);
|
|
|
|
let channel_fd: usize = match env::var("PCID_CLIENT_CHANNEL") {
|
|
Ok(s) => match s.parse() { Ok(fd) => fd, Err(_) => { error!("invalid PCID_CLIENT_CHANNEL"); process::exit(1); } },
|
|
Err(_) => { error!("PCID_CLIENT_CHANNEL not set"); process::exit(1); }
|
|
};
|
|
|
|
let device_path = env::var("PCID_DEVICE_PATH").unwrap_or_default();
|
|
info!("EHCI USB 2.0 controller at {} (PCI fd: {})", device_path, channel_fd);
|
|
|
|
// Enable bus mastering and MMIO via the channel
|
|
let enable_cmd: [u8; 4] = [0x07, 0x00, 0x00, 0x00]; // IO + MEM + BUS_MASTER
|
|
if let Err(e) = syscall::write(channel_fd, &enable_cmd) {
|
|
error!("failed to enable device: {}", e);
|
|
}
|
|
|
|
info!("ehcid: initialized — ready for enumeration");
|
|
}
|