2016-09-27 01:00:06 +02:00
|
|
|
#![feature(asm)]
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate bitflags;
|
2016-10-08 04:18:05 +02:00
|
|
|
extern crate dma;
|
2016-09-27 01:00:06 +02:00
|
|
|
extern crate io;
|
2016-09-28 04:52:26 +02:00
|
|
|
extern crate spin;
|
2016-09-27 01:00:06 +02:00
|
|
|
extern crate syscall;
|
|
|
|
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
use std::{env, thread, usize};
|
2016-09-28 04:52:26 +02:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::{Read, Write};
|
2016-10-20 20:52:58 +02:00
|
|
|
use std::os::unix::io::{AsRawFd, FromRawFd};
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
use syscall::{EVENT_READ, MAP_WRITE, Event, Packet, Scheme};
|
2016-09-27 01:00:06 +02:00
|
|
|
|
2016-09-28 04:52:26 +02:00
|
|
|
use scheme::DiskScheme;
|
2016-09-27 01:00:06 +02:00
|
|
|
|
|
|
|
pub mod ahci;
|
2016-09-28 04:52:26 +02:00
|
|
|
pub mod scheme;
|
2016-09-27 01:00:06 +02:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut args = env::args().skip(1);
|
|
|
|
|
|
|
|
let bar_str = args.next().expect("ahcid: no address provided");
|
|
|
|
let bar = usize::from_str_radix(&bar_str, 16).expect("ahcid: failed to parse address");
|
|
|
|
|
|
|
|
let irq_str = args.next().expect("ahcid: no irq provided");
|
|
|
|
let irq = irq_str.parse::<u8>().expect("ahcid: failed to parse irq");
|
|
|
|
|
2016-10-23 03:35:23 +02:00
|
|
|
print!("{}", format!(" + AHCI on: {:X} IRQ: {}\n", bar, irq));
|
|
|
|
|
2016-09-27 01:00:06 +02:00
|
|
|
thread::spawn(move || {
|
|
|
|
unsafe {
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
syscall::iopl(3).expect("ahcid: failed to get I/O permission");
|
2016-09-27 01:00:06 +02:00
|
|
|
asm!("cli" :::: "intel", "volatile");
|
|
|
|
}
|
|
|
|
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
let address = unsafe { syscall::physmap(bar, 4096, MAP_WRITE).expect("ahcid: failed to map address") };
|
2016-09-28 04:26:54 +02:00
|
|
|
{
|
2016-10-20 20:52:58 +02:00
|
|
|
let socket_fd = syscall::open(":disk", syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK).expect("ahcid: failed to create disk scheme");
|
|
|
|
let mut socket = unsafe { File::from_raw_fd(socket_fd) };
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
syscall::fevent(socket_fd, EVENT_READ).expect("ahcid: failed to fevent disk scheme");
|
|
|
|
|
|
|
|
let mut irq_file = File::open(&format!("irq:{}", irq)).expect("ahcid: failed to open irq file");
|
|
|
|
let irq_fd = irq_file.as_raw_fd();
|
|
|
|
syscall::fevent(irq_fd, EVENT_READ).expect("ahcid: failed to fevent irq file");
|
|
|
|
|
|
|
|
let mut event_file = File::open("event:").expect("ahcid: failed to open event file");
|
|
|
|
|
2016-09-28 04:52:26 +02:00
|
|
|
let scheme = DiskScheme::new(ahci::disks(address, irq));
|
2016-09-28 04:26:54 +02:00
|
|
|
loop {
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
let mut event = Event::default();
|
|
|
|
event_file.read(&mut event).expect("ahcid: failed to read event file");
|
|
|
|
if event.id == socket_fd {
|
|
|
|
let mut packet = Packet::default();
|
|
|
|
socket.read(&mut packet).expect("ahcid: failed to read disk scheme");
|
|
|
|
scheme.handle(&mut packet);
|
|
|
|
socket.write(&mut packet).expect("ahcid: failed to write disk scheme");
|
|
|
|
} else if event.id == irq_fd {
|
|
|
|
let mut irq = [0; 8];
|
|
|
|
if irq_file.read(&mut irq).expect("ahcid: failed to read irq file") >= irq.len() {
|
2016-10-20 22:37:05 +02:00
|
|
|
//TODO : Test for IRQ
|
|
|
|
//irq_file.write(&irq).expect("ahcid: failed to write irq file");
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
println!("Unknown event {}", event.id);
|
|
|
|
}
|
2016-09-28 04:26:54 +02:00
|
|
|
}
|
2016-09-27 01:00:06 +02:00
|
|
|
}
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
unsafe { let _ = syscall::physunmap(address); }
|
2016-09-27 01:00:06 +02:00
|
|
|
});
|
|
|
|
}
|