Further parse AHCI information.
Send an IDENTIFY command to each drive and set up a hook to handle interrupts.
This commit is contained in:
parent
4e1888bd24
commit
0f0e39d1e9
25 changed files with 721 additions and 90 deletions
|
|
@ -35,6 +35,7 @@ class MemoryObject : public KernelObject {
|
|||
|
||||
class FixedMemoryObject : public MemoryObject {
|
||||
public:
|
||||
// FIXME: Validate that this is 4k aligned.
|
||||
FixedMemoryObject(uint64_t physical_addr, uint64_t size)
|
||||
: MemoryObject(size, true), physical_addr_(physical_addr) {}
|
||||
|
||||
|
|
|
|||
50
zion/object/port.cpp
Normal file
50
zion/object/port.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#include "object/port.h"
|
||||
|
||||
Port::Port() {}
|
||||
|
||||
z_err_t Port::Write(const ZMessage& msg) {
|
||||
if (msg.num_caps > 0) {
|
||||
dbgln("Unimplemented passing caps on port");
|
||||
return Z_ERR_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
if (msg.num_bytes > 0x1000) {
|
||||
dbgln("Large message size unimplemented: %x", msg.num_bytes);
|
||||
return Z_ERR_INVALID;
|
||||
}
|
||||
|
||||
Message message{
|
||||
.type = msg.type,
|
||||
.num_bytes = msg.num_bytes,
|
||||
.bytes = new uint8_t[msg.num_bytes],
|
||||
};
|
||||
for (uint64_t i = 0; i < msg.num_bytes; i++) {
|
||||
message.bytes[i] = msg.bytes[i];
|
||||
}
|
||||
pending_messages_.PushBack(message);
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
z_err_t Port::Read(ZMessage& msg) {
|
||||
if (pending_messages_.size() < 1) {
|
||||
dbgln("Implement blocking");
|
||||
return Z_ERR_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
Message next_msg = pending_messages_.PeekFront();
|
||||
if (next_msg.num_bytes > msg.num_bytes) {
|
||||
return Z_ERR_BUFF_SIZE;
|
||||
}
|
||||
|
||||
msg.type = next_msg.type;
|
||||
msg.num_bytes = next_msg.num_bytes;
|
||||
msg.num_caps = 0;
|
||||
|
||||
for (uint64_t i = 0; i < msg.num_bytes; i++) {
|
||||
msg.bytes[i] = next_msg.bytes[i];
|
||||
}
|
||||
|
||||
pending_messages_.PopFront();
|
||||
|
||||
return Z_OK;
|
||||
}
|
||||
22
zion/object/port.h
Normal file
22
zion/object/port.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include "lib/linked_list.h"
|
||||
#include "object/kernel_object.h"
|
||||
#include "usr/zcall_internal.h"
|
||||
|
||||
class Port : public KernelObject {
|
||||
public:
|
||||
Port();
|
||||
|
||||
z_err_t Write(const ZMessage& msg);
|
||||
z_err_t Read(ZMessage& msg);
|
||||
|
||||
private:
|
||||
struct Message {
|
||||
uint64_t type;
|
||||
uint64_t num_bytes;
|
||||
uint8_t* bytes;
|
||||
};
|
||||
|
||||
LinkedList<Message> pending_messages_;
|
||||
};
|
||||
|
|
@ -127,6 +127,13 @@ uint64_t Process::AddCapability(const RefPtr<Channel>& chan) {
|
|||
return cap_id;
|
||||
}
|
||||
|
||||
uint64_t Process::AddCapability(const RefPtr<Port>& port) {
|
||||
uint64_t cap_id = next_cap_id_++;
|
||||
caps_.PushBack(MakeRefCounted<Capability>(port, Capability::PORT, cap_id,
|
||||
ZC_WRITE | ZC_READ));
|
||||
return cap_id;
|
||||
}
|
||||
|
||||
void Process::AddCapability(uint64_t cap_id, const RefPtr<MemoryObject>& vmmo) {
|
||||
caps_.PushBack(MakeRefCounted<Capability>(vmmo, Capability::MEMORY_OBJECT,
|
||||
cap_id, ZC_WRITE));
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "lib/ref_ptr.h"
|
||||
#include "object/address_space.h"
|
||||
#include "object/channel.h"
|
||||
#include "object/port.h"
|
||||
|
||||
// Forward decl due to cyclic dependency.
|
||||
class Thread;
|
||||
|
|
@ -37,6 +38,7 @@ class Process : public KernelObject {
|
|||
uint64_t AddCapability(const RefPtr<AddressSpace>& vmas);
|
||||
uint64_t AddCapability(const RefPtr<MemoryObject>& vmmo);
|
||||
uint64_t AddCapability(const RefPtr<Channel>& chan);
|
||||
uint64_t AddCapability(const RefPtr<Port>& chan);
|
||||
|
||||
void AddCapability(uint64_t cap_id, const RefPtr<MemoryObject>& vmmo);
|
||||
// Checks the state of all child threads and transitions to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue