[Voyageurs] Send USB keypress data to the keyboard driver.
This commit is contained in:
parent
3c1e435e04
commit
02d4f8c80e
10 changed files with 79 additions and 20 deletions
|
|
@ -80,7 +80,8 @@ void DeviceSlot::TransferComplete(uint8_t endpoint_index, uint64_t trb_phys) {
|
|||
check(control_completion_sempahores_.Delete(trb_phys));
|
||||
}
|
||||
|
||||
mmth::Semaphore DeviceSlot::IssueConfigureDeviceCommand(uint8_t config_value) {
|
||||
mmth::Semaphore DeviceSlot::IssueConfigureDeviceCommand(
|
||||
uint8_t config_value, glcr::UniquePtr<mmth::PortClient> client) {
|
||||
input_context_->input.add_contexts = (0x1 << 3) | 0x1;
|
||||
input_context_->input.configuration_value = config_value;
|
||||
// TODO: Maybe don't hardcode this.
|
||||
|
|
@ -93,7 +94,8 @@ mmth::Semaphore DeviceSlot::IssueConfigureDeviceCommand(uint8_t config_value) {
|
|||
input_context_->slot_context.route_speed_entries |= (max_endpoint << 27);
|
||||
|
||||
// TODO: Dont' hardcode this.
|
||||
endpoints_[3].Initialize(input_context_->endpoint_contexts + 2);
|
||||
endpoints_[3].Initialize(input_context_->endpoint_contexts + 2,
|
||||
glcr::Move(client));
|
||||
|
||||
xhci_driver_->IssueCommand(CreateConfigureEndpointCommand(
|
||||
context_phys_ + kInputSlotContextOffset, slot_index_));
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ class DeviceSlot {
|
|||
XhciTrb CreateAddressDeviceCommand(uint8_t root_port, uint32_t route_string,
|
||||
uint16_t max_packet_size);
|
||||
|
||||
mmth::Semaphore IssueConfigureDeviceCommand(uint8_t config_value);
|
||||
mmth::Semaphore IssueConfigureDeviceCommand(
|
||||
uint8_t config_value, glcr::UniquePtr<mmth::PortClient> client);
|
||||
void SignalConfigureDeviceCompleted();
|
||||
|
||||
// Caller must keep the command in scope until it completes.
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
#include "xhci/trb.h"
|
||||
|
||||
void Endpoint::Initialize(XhciEndpointContext* context) {
|
||||
void Endpoint::Initialize(XhciEndpointContext* context,
|
||||
glcr::UniquePtr<mmth::PortClient> client) {
|
||||
enabled_ = true;
|
||||
context_ = context;
|
||||
client_ = glcr::Move(client);
|
||||
|
||||
trb_ring_ = glcr::MakeUnique<TrbRingWriter>();
|
||||
recv_mem_ = mmth::OwnedMemoryRegion::ContiguousPhysical(0x1000, &recv_phys_);
|
||||
|
|
@ -23,7 +25,8 @@ void Endpoint::Initialize(XhciEndpointContext* context) {
|
|||
void Endpoint::TransferComplete(uint64_t trb_phys) {
|
||||
uint64_t phys_offset =
|
||||
(trb_phys - trb_ring_->PhysicalAddress()) / sizeof(XhciTrb);
|
||||
dbgln("Data: {x}", *((uint64_t*)recv_mem_.vaddr() + phys_offset));
|
||||
uint64_t data = *((uint64_t*)recv_mem_.vaddr() + phys_offset);
|
||||
client_->Write(data);
|
||||
trb_ring_->EnqueueTrb(CreateNormalTrb(recv_phys_ + offset_, 8));
|
||||
offset_ += 8;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/memory/unique_ptr.h>
|
||||
#include <mammoth/ipc/port_client.h>
|
||||
|
||||
#include "xhci/trb_ring.h"
|
||||
#include "xhci/xhci.h"
|
||||
|
|
@ -9,7 +10,8 @@ class Endpoint {
|
|||
public:
|
||||
Endpoint() {}
|
||||
|
||||
void Initialize(XhciEndpointContext* context);
|
||||
void Initialize(XhciEndpointContext* context,
|
||||
glcr::UniquePtr<mmth::PortClient> client);
|
||||
|
||||
bool Enabled() { return enabled_; }
|
||||
|
||||
|
|
@ -24,4 +26,6 @@ class Endpoint {
|
|||
uint64_t recv_phys_;
|
||||
mmth::OwnedMemoryRegion recv_mem_;
|
||||
uint64_t offset_ = 0;
|
||||
|
||||
glcr::UniquePtr<mmth::PortClient> client_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <mammoth/util/memory_region.h>
|
||||
#include <zcall.h>
|
||||
|
||||
#include "keyboard/keyboard_driver.h"
|
||||
#include "xhci/descriptors.h"
|
||||
#include "xhci/trb.h"
|
||||
#include "xhci/xhci.h"
|
||||
|
|
@ -75,7 +76,9 @@ void configure_device(void* void_device_slot) {
|
|||
config_descriptor->configuration_value);
|
||||
|
||||
device_slot
|
||||
->IssueConfigureDeviceCommand(config_descriptor->configuration_value)
|
||||
->IssueConfigureDeviceCommand(
|
||||
config_descriptor->configuration_value,
|
||||
glcr::MakeUnique<mmth::PortClient>(KeyboardDriver::GetPortCap()))
|
||||
.Wait();
|
||||
|
||||
dbgln("Configured!");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue