Skip to content

Commit 5b54bbc

Browse files
committed
Hacks
1 parent 4f2f830 commit 5b54bbc

2 files changed

Lines changed: 3 additions & 54 deletions

File tree

pixie-uefi/src/os/mod.rs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ struct UefiOSImpl {
7676
tasks: Vec<Arc<Task>>,
7777
input: ScopedProtocol<Input>,
7878
vga: ScopedProtocol<Output>,
79-
serial: ScopedProtocol<Serial>,
8079
net: Option<NetworkInterface>,
8180
messages: VecDeque<(f64, log::Level, String, String)>,
8281
ui_buf: Vec<(String, Color, Color)>,
@@ -183,9 +182,6 @@ impl UefiOS {
183182
let input_handles = uefi::boot::find_handles::<Input>().unwrap();
184183
let input = uefi::boot::open_protocol_exclusive::<Input>(input_handles[0]).unwrap();
185184

186-
let serial_handles = uefi::boot::find_handles::<Serial>().unwrap();
187-
let serial = uefi::boot::open_protocol_exclusive::<Serial>(serial_handles[0]).unwrap();
188-
189185
let vga_handles = uefi::boot::find_handles::<Output>().unwrap();
190186
let mut vga = uefi::boot::open_protocol_exclusive::<Output>(vga_handles[0]).unwrap();
191187

@@ -197,7 +193,6 @@ impl UefiOS {
197193
tasks: Vec::new(),
198194
input,
199195
vga,
200-
serial,
201196
net: None,
202197
messages: VecDeque::new(),
203198
ui_buf: vec![],
@@ -394,31 +389,6 @@ impl UefiOS {
394389
.to_string()
395390
}
396391

397-
/// Find the topmost device that implements this protocol.
398-
fn handle_on_device<P: Protocol>(&self, device: &DevicePath) -> Handle {
399-
for i in 0..device.node_iter().count() {
400-
let mut buf = vec![];
401-
let mut dev = DevicePathBuilder::with_vec(&mut buf);
402-
for node in device.node_iter().take(i + 1) {
403-
dev = dev.push(&node).unwrap();
404-
}
405-
let mut dev = dev.finalize().unwrap();
406-
if let Ok(h) = uefi::boot::locate_device_path::<P>(&mut dev) {
407-
return h;
408-
}
409-
}
410-
// TODO(veluca): bubble up errors.
411-
panic!("handle not found");
412-
}
413-
414-
fn open_protocol_on_device<P: Protocol>(
415-
&self,
416-
device: &DevicePath,
417-
) -> Result<ScopedProtocol<P>> {
418-
let handle = self.handle_on_device::<P>(device);
419-
Ok(uefi::boot::open_protocol_exclusive::<P>(handle)?)
420-
}
421-
422392
pub fn open_first_disk(&self) -> Disk {
423393
Disk::new(*self)
424394
}
@@ -542,19 +512,6 @@ impl UefiOS {
542512
{
543513
let mut os = self.borrow_mut();
544514

545-
let style = match level {
546-
log::Level::Trace => anstyle::AnsiColor::Cyan.on_default(),
547-
log::Level::Debug => anstyle::AnsiColor::Blue.on_default(),
548-
log::Level::Info => anstyle::AnsiColor::Green.on_default(),
549-
log::Level::Warn => anstyle::AnsiColor::Yellow.on_default(),
550-
log::Level::Error => anstyle::AnsiColor::Red.on_default().bold(),
551-
};
552-
write!(
553-
os.serial,
554-
"[{time:.1}s {style}{level:5}{style:#} {target}] {msg}\r\n"
555-
)
556-
.unwrap();
557-
558515
os.messages.push_back((time, level, target.into(), msg));
559516
const MAX_MESSAGES: usize = 5;
560517
if os.messages.len() > MAX_MESSAGES {

pixie-uefi/src/os/net.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,9 @@ pub struct NetworkInterface {
158158

159159
impl NetworkInterface {
160160
pub fn new(os: UefiOS) -> NetworkInterface {
161-
let bo = os.boot_options();
162-
let curopt = bo.get(bo.current());
163-
let (descr, device) = bo.boot_entry_info(&curopt[..]);
164-
log::info!(
165-
"Configuring network on interface used for booting ({} -- {})",
166-
descr,
167-
os.device_path_to_string(device)
168-
);
169-
let mut device = SnpDevice::new(Box::leak(Box::new(
170-
os.open_protocol_on_device::<SimpleNetwork>(device).unwrap(),
171-
)));
161+
let snp_handles = uefi::boot::find_handles::<SimpleNetwork>().unwrap();
162+
let snp = uefi::boot::open_protocol_exclusive::<SimpleNetwork>(snp_handles[0]).unwrap();
163+
let mut device = SnpDevice::new(Box::leak(Box::new(snp)));
172164

173165
let hw_addr = HardwareAddress::Ethernet(smoltcp::wire::EthernetAddress::from_bytes(
174166
&device.snp.mode().current_address.0[..6],

0 commit comments

Comments
 (0)