75 lines
1.4 KiB
C
75 lines
1.4 KiB
C
#ifndef _KERNEL_DEVICE_XHCI_H
|
|
#define _KERNEL_DEVICE_XHCI_H
|
|
|
|
#include <aux/compiler.h>
|
|
#include <device/def_device_op.h>
|
|
#include <libk/list.h>
|
|
#include <libk/std.h>
|
|
#include <proc/proc.h>
|
|
#include <proc/reschedule.h>
|
|
#include <proc/suspension_q.h>
|
|
|
|
/* event ring segment table entry */
|
|
struct xhci_erst_entry {
|
|
uint64_t ptr;
|
|
uint32_t size;
|
|
uint32_t _rsvd;
|
|
} PACKED;
|
|
|
|
/* transfer request block */
|
|
struct xhci_trb {
|
|
uint64_t param;
|
|
uint32_t status;
|
|
uint32_t ctrl;
|
|
} PACKED;
|
|
|
|
struct xhci_init {
|
|
uintptr_t xhci_mmio_base;
|
|
bool irqs_support;
|
|
uint8_t irq;
|
|
};
|
|
|
|
struct xhci {
|
|
struct device* device;
|
|
|
|
bool irqs_support;
|
|
uint8_t irq;
|
|
|
|
uintptr_t xhci_mmio_base;
|
|
uintptr_t xhci_oper_base;
|
|
uintptr_t xhci_runtime_base;
|
|
uintptr_t xhci_doorbell_base;
|
|
|
|
uintptr_t* xhci_dcbaa;
|
|
uintptr_t xhci_dcbaa_phys;
|
|
|
|
uint32_t max_scratchpad;
|
|
uintptr_t* scratchpads;
|
|
uintptr_t scratchpads_phys;
|
|
|
|
uint32_t max_slots;
|
|
|
|
struct xhci_trb* cmd_ring;
|
|
uintptr_t cmd_ring_phys;
|
|
uint32_t cmd_ring_idx;
|
|
uint32_t cmd_ring_size;
|
|
uint8_t cmd_cycle_bit;
|
|
|
|
struct xhci_trb* event_ring;
|
|
uintptr_t event_ring_phys;
|
|
uint32_t event_ring_idx;
|
|
uint32_t event_ring_size;
|
|
uint8_t event_cycle_bit;
|
|
|
|
struct xhci_erst_entry* erst;
|
|
uintptr_t erst_phys;
|
|
|
|
atomic_bool pending;
|
|
};
|
|
|
|
DEFINE_DEVICE_INIT (xhci_init);
|
|
|
|
DEFINE_DEVICE_FINI (xhci_fini);
|
|
|
|
#endif // _KERNEL_DEVICE_XHCI_H
|