device paaaaaaaaaaaaaaaath
This commit is contained in:
parent
953487dc11
commit
82109dc98e
|
@ -4,16 +4,23 @@
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use aligned_vec::{AVec, ConstAlign};
|
use aligned_vec::{AVec, ConstAlign};
|
||||||
|
use alloc::borrow::ToOwned;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
|
use uefi::proto::device_path::build::media::HardDrive;
|
||||||
|
use uefi::proto::device_path::build::DevicePathBuilder;
|
||||||
|
use uefi::proto::device_path::media::{PartitionFormat, PartitionSignature};
|
||||||
|
|
||||||
use uefi::{prelude::*, CStr16};
|
use uefi::{prelude::*, println, CStr16};
|
||||||
|
|
||||||
use uefi::proto::console::gop::GraphicsOutput;
|
use uefi::proto::console::gop::GraphicsOutput;
|
||||||
|
use uefi::proto::device_path::{DeviceType, LoadedImageDevicePath};
|
||||||
use uefi::proto::loaded_image::LoadedImage;
|
use uefi::proto::loaded_image::LoadedImage;
|
||||||
use uefi::proto::media::block::{BlockIO, Lba};
|
use uefi::proto::media::block::{BlockIO, BlockIOMedia, Lba};
|
||||||
|
use uefi::proto::media::disk::DiskIo;
|
||||||
use uefi::proto::media::file::{File, FileSystemVolumeLabel};
|
use uefi::proto::media::file::{File, FileSystemVolumeLabel};
|
||||||
use uefi::proto::media::fs::SimpleFileSystem;
|
use uefi::proto::media::fs::SimpleFileSystem;
|
||||||
|
use uefi::proto::media::partition::PartitionInfo;
|
||||||
use uefi::proto::misc::Timestamp;
|
use uefi::proto::misc::Timestamp;
|
||||||
use uefi::table::boot::{OpenProtocolAttributes, OpenProtocolParams};
|
use uefi::table::boot::{OpenProtocolAttributes, OpenProtocolParams};
|
||||||
|
|
||||||
|
@ -38,14 +45,61 @@ fn main(_image_handle: Handle, mut boot_system_table: SystemTable<Boot>) -> Stat
|
||||||
boot_services.stall(1_000_000);
|
boot_services.stall(1_000_000);
|
||||||
|
|
||||||
let img_handle = boot_services.image_handle();
|
let img_handle = boot_services.image_handle();
|
||||||
|
let loaded_image = boot_services
|
||||||
|
.open_protocol_exclusive::<LoadedImage>(img_handle)
|
||||||
|
.expect("loaded image");
|
||||||
let loaded_image_dev_path = boot_services
|
let loaded_image_dev_path = boot_services
|
||||||
.open_protocol_exclusive::<LoadedImageDevicePath>(img_handle)
|
.open_protocol_exclusive::<LoadedImageDevicePath>(img_handle)
|
||||||
.expect("loaded image");
|
.expect("loaded image dev path");
|
||||||
|
|
||||||
loaded_image_dev_path.get()
|
println!("{:?}", loaded_image.file_path());
|
||||||
|
|
||||||
let mut device_handle = loaded_image.device().expect("device handle");
|
for dev_path_inst in loaded_image_dev_path.instance_iter() {
|
||||||
|
println!("inst: {:?}", dev_path_inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut dev_path_buf = Vec::new();
|
||||||
|
let mut dev_path_builder = DevicePathBuilder::with_vec(&mut dev_path_buf);
|
||||||
|
for dev_path_node in loaded_image_dev_path.node_iter() {
|
||||||
|
println!("node: {:?}", dev_path_node);
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
dev_path_node
|
||||||
|
.to_string(
|
||||||
|
&boot_services,
|
||||||
|
uefi::proto::device_path::text::DisplayOnly(false),
|
||||||
|
uefi::proto::device_path::text::AllowShortcuts(false),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
if dev_path_node.device_type() == DeviceType::MEDIA {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
dev_path_builder = dev_path_builder
|
||||||
|
.push(&dev_path_node)
|
||||||
|
.expect("push existing node");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let harder_drive = HardDrive {
|
||||||
|
partition_number: 0,
|
||||||
|
partition_start: 0,
|
||||||
|
partition_size: GIF_SIZE as u64 / 512,
|
||||||
|
partition_signature: PartitionSignature::None,
|
||||||
|
partition_format: PartitionFormat::MBR,
|
||||||
|
};
|
||||||
|
dev_path_builder = dev_path_builder
|
||||||
|
.push(&harder_drive)
|
||||||
|
.expect("push hard drive");
|
||||||
|
let mut dev_path = dev_path_builder.finalize().expect("finalize dev path");
|
||||||
|
let device_handle = boot_services
|
||||||
|
.locate_device_path::<DiskIo>(&mut dev_path)
|
||||||
|
.expect("locate dev path");
|
||||||
|
|
||||||
|
//let mut device_handle = loaded_image.device().expect("device handle");
|
||||||
|
|
||||||
|
let disk_io = boot_services
|
||||||
|
.open_protocol_exclusive::<DiskIo>(device_handle)
|
||||||
|
.expect("disk io");
|
||||||
/*
|
/*
|
||||||
let handles = boot_services
|
let handles = boot_services
|
||||||
.find_handles::<uefi::proto::media::fs::SimpleFileSystem>()
|
.find_handles::<uefi::proto::media::fs::SimpleFileSystem>()
|
||||||
|
@ -80,16 +134,19 @@ fn main(_image_handle: Handle, mut boot_system_table: SystemTable<Boot>) -> Stat
|
||||||
.expect("block io");
|
.expect("block io");
|
||||||
|
|
||||||
let mut gif_buf: AVec<u8, ConstAlign<512>> = AVec::with_capacity(512, GIF_SIZE);
|
let mut gif_buf: AVec<u8, ConstAlign<512>> = AVec::with_capacity(512, GIF_SIZE);
|
||||||
// for _ in 0..GIF_SIZE {
|
for _ in 0..GIF_SIZE {
|
||||||
for _ in 0..512 {
|
//for _ in 0..512 {
|
||||||
gif_buf.push(0u8);
|
gif_buf.push(0u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disk_io
|
||||||
|
.read_disk(block_io.media().media_id(), 0, &mut gif_buf)
|
||||||
|
.expect("read disk");
|
||||||
|
/*
|
||||||
block_io
|
block_io
|
||||||
.read_blocks(block_io.media().media_id(), Lba::from(0u64), &mut gif_buf)
|
.read_blocks(block_io.media().media_id(), Lba::from(0u64), &mut gif_buf)
|
||||||
.expect("read blocks");
|
.expect("read blocks");
|
||||||
|
*/
|
||||||
panic!("{:x?}", &gif_buf[..32]);
|
|
||||||
|
|
||||||
let gif = tinygif::Gif::<Rgb888>::from_slice(&gif_buf).expect("gif from slice");
|
let gif = tinygif::Gif::<Rgb888>::from_slice(&gif_buf).expect("gif from slice");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue