mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 16:16:16 +04:00
Now we can parse the partion entries. Yeeeeaaahh!
This commit is contained in:
parent
a3f8601d18
commit
e20a2ca8e2
@ -1236,7 +1236,7 @@ impl EmmcCtl {
|
|||||||
|
|
||||||
pub fn read(&mut self, block_no_arg: u32, count: usize, buf: &mut[u32]) -> Result<(), ()> {
|
pub fn read(&mut self, block_no_arg: u32, count: usize, buf: &mut[u32]) -> Result<(), ()> {
|
||||||
let mut block_no = block_no_arg;
|
let mut block_no = block_no_arg;
|
||||||
if self.card_supports_sdhc {
|
if !self.card_supports_sdhc {
|
||||||
block_no *= 512;
|
block_no *= 512;
|
||||||
}
|
}
|
||||||
//assert_eq!(count * self.block_size, buf.len());
|
//assert_eq!(count * self.block_size, buf.len());
|
||||||
@ -1286,7 +1286,7 @@ impl EmmcCtl {
|
|||||||
|
|
||||||
pub fn write(&mut self, block_no_arg: u32, count: usize, buf: &[u32]) -> Result<(), ()> {
|
pub fn write(&mut self, block_no_arg: u32, count: usize, buf: &[u32]) -> Result<(), ()> {
|
||||||
let mut block_no = block_no_arg;
|
let mut block_no = block_no_arg;
|
||||||
if self.card_supports_sdhc {
|
if !self.card_supports_sdhc {
|
||||||
block_no *= 512;
|
block_no *= 512;
|
||||||
}
|
}
|
||||||
//assert_eq!(count * self.block_size, buf.len());
|
//assert_eq!(count * self.block_size, buf.len());
|
||||||
@ -1346,7 +1346,6 @@ lazy_static! {
|
|||||||
|
|
||||||
fn demo() {
|
fn demo() {
|
||||||
// print out the first section of the sd_card.
|
// print out the first section of the sd_card.
|
||||||
|
|
||||||
let section: [u8; 512] = [0; 512];
|
let section: [u8; 512] = [0; 512];
|
||||||
let buf = unsafe { slice::from_raw_parts_mut(section.as_ptr() as *mut u32, 512 / 4) };
|
let buf = unsafe { slice::from_raw_parts_mut(section.as_ptr() as *mut u32, 512 / 4) };
|
||||||
println!("Trying to fetch the first section of the SD card.");
|
println!("Trying to fetch the first section of the SD card.");
|
||||||
@ -1354,13 +1353,43 @@ fn demo() {
|
|||||||
error!("Failed in fetching.");
|
error!("Failed in fetching.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
println!("Content:");
|
||||||
for i in 0..32 {
|
for i in 0..32 {
|
||||||
for j in 0..16{
|
for j in 0..16{
|
||||||
print!("{:02X} ", section[i*16+j]);
|
print!("{:02X} ", section[i*16+j]);
|
||||||
}
|
}
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
|
println!("");
|
||||||
|
|
||||||
|
let mut start_pos = 446; // start position of the partion table
|
||||||
|
for entry in 0..4 {
|
||||||
|
print!("Partion entry #{}: ", entry);
|
||||||
|
let partion_type = section[start_pos + 0x4];
|
||||||
|
fn partion_type_map(partion_type : u8) -> &'static str {
|
||||||
|
match partion_type {
|
||||||
|
0x00 => "Empty",
|
||||||
|
0x0c => "FAT32",
|
||||||
|
0x83 => "Linux",
|
||||||
|
0x82 => "Swap",
|
||||||
|
_ => "Not supported"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print!("{:^14}", partion_type_map(partion_type));
|
||||||
|
if partion_type != 0x00 {
|
||||||
|
let start_section: u32 = (section[start_pos + 0x8] as u32)
|
||||||
|
| (section[start_pos + 0x9] as u32) << 8
|
||||||
|
| (section[start_pos + 0xa] as u32) << 16
|
||||||
|
| (section[start_pos + 0xb] as u32) << 24;
|
||||||
|
let total_section: u32= (section[start_pos + 0xc] as u32)
|
||||||
|
| (section[start_pos + 0xd] as u32) << 8
|
||||||
|
| (section[start_pos + 0xe] as u32) << 16
|
||||||
|
| (section[start_pos + 0xf] as u32) << 24;
|
||||||
|
print!(" start section no. = {}, a total of {} sections in use.", start_section, total_section);
|
||||||
|
}
|
||||||
|
println!("");
|
||||||
|
start_pos += 16;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
println!("Initializing EmmcCtl...");
|
println!("Initializing EmmcCtl...");
|
||||||
|
Loading…
Reference in New Issue
Block a user