Update submodules
This commit is contained in:
parent
66bcd0d1ba
commit
c805f53ade
|
@ -237,7 +237,7 @@ impl HbaPort {
|
|||
|
||||
pub fn ata_dma(&mut self, block: u64, sectors: usize, write: bool, clb: &mut Dma<[HbaCmdHeader; 32]>, ctbas: &mut [Dma<HbaCmdTable>; 32], buf: &mut Dma<[u8; 256 * 512]>) -> Result<usize> {
|
||||
if write {
|
||||
print!("{}", format!("AHCI {:X} DMA BLOCK: {:X} SECTORS: {} WRITE: {}\n", (self as *mut HbaPort) as usize, block, sectors, write));
|
||||
//print!("{}", format!("AHCI {:X} DMA BLOCK: {:X} SECTORS: {} WRITE: {}\n", (self as *mut HbaPort) as usize, block, sectors, write));
|
||||
}
|
||||
|
||||
assert!(sectors > 0 && sectors < 256);
|
||||
|
@ -246,7 +246,7 @@ impl HbaPort {
|
|||
|
||||
if let Some(slot) = self.slot() {
|
||||
if write {
|
||||
print!("{}", format!("SLOT {}\n", slot));
|
||||
//print!("{}", format!("SLOT {}\n", slot));
|
||||
}
|
||||
|
||||
let cmdheader = &mut clb[slot as usize];
|
||||
|
@ -291,26 +291,26 @@ impl HbaPort {
|
|||
}
|
||||
|
||||
if write {
|
||||
print!("WAIT ATA_DEV_BUSY | ATA_DEV_DRQ\n");
|
||||
//print!("WAIT ATA_DEV_BUSY | ATA_DEV_DRQ\n");
|
||||
}
|
||||
while self.tfd.readf((ATA_DEV_BUSY | ATA_DEV_DRQ) as u32) {
|
||||
pause();
|
||||
}
|
||||
|
||||
if write {
|
||||
print!("{}", format!("WRITE CI {:X} in {:X}\n", 1 << slot, self.ci.read()));
|
||||
//print!("{}", format!("WRITE CI {:X} in {:X}\n", 1 << slot, self.ci.read()));
|
||||
}
|
||||
self.ci.writef(1 << slot, true);
|
||||
|
||||
self.start();
|
||||
|
||||
if write {
|
||||
print!("{}", format!("WAIT CI {:X} in {:X}\n", 1 << slot, self.ci.read()));
|
||||
//print!("{}", format!("WAIT CI {:X} in {:X}\n", 1 << slot, self.ci.read()));
|
||||
}
|
||||
while (self.ci.readf(1 << slot) || self.tfd.readf(0x80)) && self.is.read() & HBA_PORT_IS_ERR == 0 {
|
||||
pause();
|
||||
if write {
|
||||
print!("{}", format!("WAIT CI {:X} TFD {:X} IS {:X} CMD {:X} SERR {:X}\n", self.ci.read(), self.tfd.read(), self.is.read(), self.cmd.read(), self.serr.read()));
|
||||
//print!("{}", format!("WAIT CI {:X} TFD {:X} IS {:X} CMD {:X} SERR {:X}\n", self.ci.read(), self.tfd.read(), self.is.read(), self.cmd.read(), self.serr.read()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ impl HbaPort {
|
|||
}
|
||||
|
||||
if write {
|
||||
print!("{}", format!("SUCCESS {}\n", sectors));
|
||||
//print!("{}", format!("SUCCESS {}\n", sectors));
|
||||
}
|
||||
Ok(sectors * 512)
|
||||
} else {
|
||||
|
|
2
libstd
2
libstd
|
@ -1 +1 @@
|
|||
Subproject commit 61ba4092b0d4bf9ab0346dbb51ef489a182a84a2
|
||||
Subproject commit 36c2227087fdb7ba76e47900bae5744b414fcb40
|
|
@ -1 +1 @@
|
|||
Subproject commit 44436af31b2b113c2893f9b909950cb382230bc0
|
||||
Subproject commit 4eae543a60a5d6b0298db09bc48b2e6fab60b021
|
|
@ -1,163 +0,0 @@
|
|||
use std::{mem, slice, u8, u16};
|
||||
|
||||
pub static mut MAC_ADDR: MacAddr = MacAddr { bytes: [0x50, 0x51, 0x52, 0x53, 0x54, 0x55] };
|
||||
|
||||
pub static mut IP_ADDR: Ipv4Addr = Ipv4Addr { bytes: [10, 0, 2, 15] };
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[repr(packed)]
|
||||
pub struct n16(u16);
|
||||
|
||||
impl n16 {
|
||||
pub fn new(value: u16) -> Self {
|
||||
n16(value.to_be())
|
||||
}
|
||||
|
||||
pub fn get(&self) -> u16 {
|
||||
u16::from_be(self.0)
|
||||
}
|
||||
|
||||
pub fn set(&mut self, value: u16) {
|
||||
self.0 = value.to_be();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct MacAddr {
|
||||
pub bytes: [u8; 6],
|
||||
}
|
||||
|
||||
impl MacAddr {
|
||||
pub fn equals(&self, other: Self) -> bool {
|
||||
for i in 0..6 {
|
||||
if self.bytes[i] != other.bytes[i] {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub fn from_str(string: &str) -> Self {
|
||||
let mut addr = MacAddr { bytes: [0, 0, 0, 0, 0, 0] };
|
||||
|
||||
let mut i = 0;
|
||||
for part in string.split('.') {
|
||||
let octet = u8::from_str_radix(part, 16).unwrap_or(0);
|
||||
match i {
|
||||
0 => addr.bytes[0] = octet,
|
||||
1 => addr.bytes[1] = octet,
|
||||
2 => addr.bytes[2] = octet,
|
||||
3 => addr.bytes[3] = octet,
|
||||
4 => addr.bytes[4] = octet,
|
||||
5 => addr.bytes[5] = octet,
|
||||
_ => break,
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
addr
|
||||
}
|
||||
|
||||
pub fn to_string(&self) -> String {
|
||||
let mut string = String::new();
|
||||
for i in 0..6 {
|
||||
if i > 0 {
|
||||
string.push('.');
|
||||
}
|
||||
string.push_str(&format!("{:X}", self.bytes[i]));
|
||||
}
|
||||
string
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Ipv4Addr {
|
||||
pub bytes: [u8; 4],
|
||||
}
|
||||
|
||||
impl Ipv4Addr {
|
||||
pub fn equals(&self, other: Self) -> bool {
|
||||
for i in 0..4 {
|
||||
if self.bytes[i] != other.bytes[i] {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub fn from_str(string: &str) -> Self {
|
||||
let mut addr = Ipv4Addr { bytes: [0, 0, 0, 0] };
|
||||
|
||||
let mut i = 0;
|
||||
for part in string.split('.') {
|
||||
let octet = part.parse::<u8>().unwrap_or(0);
|
||||
match i {
|
||||
0 => addr.bytes[0] = octet,
|
||||
1 => addr.bytes[1] = octet,
|
||||
2 => addr.bytes[2] = octet,
|
||||
3 => addr.bytes[3] = octet,
|
||||
_ => break,
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
addr
|
||||
}
|
||||
|
||||
pub fn to_string(&self) -> String {
|
||||
let mut string = String::new();
|
||||
|
||||
for i in 0..4 {
|
||||
if i > 0 {
|
||||
string = string + ".";
|
||||
}
|
||||
string = string + &format!("{}", self.bytes[i]);
|
||||
}
|
||||
|
||||
string
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(packed)]
|
||||
pub struct ArpHeader {
|
||||
pub htype: n16,
|
||||
pub ptype: n16,
|
||||
pub hlen: u8,
|
||||
pub plen: u8,
|
||||
pub oper: n16,
|
||||
pub src_mac: MacAddr,
|
||||
pub src_ip: Ipv4Addr,
|
||||
pub dst_mac: MacAddr,
|
||||
pub dst_ip: Ipv4Addr,
|
||||
}
|
||||
|
||||
pub struct Arp {
|
||||
pub header: ArpHeader,
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Arp {
|
||||
pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
|
||||
if bytes.len() >= mem::size_of::<ArpHeader>() {
|
||||
unsafe {
|
||||
return Some(Arp {
|
||||
header: *(bytes.as_ptr() as *const ArpHeader),
|
||||
data: bytes[mem::size_of::<ArpHeader>() ..].to_vec(),
|
||||
});
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self) -> Vec<u8> {
|
||||
unsafe {
|
||||
let header_ptr: *const ArpHeader = &self.header;
|
||||
let mut ret = Vec::from(slice::from_raw_parts(header_ptr as *const u8,
|
||||
mem::size_of::<ArpHeader>()));
|
||||
ret.extend_from_slice(&self.data);
|
||||
ret
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue