setos

拙OS
Log | Files | Refs | LICENSE

xhc.h (1793B)


      1 // #include <libc.h>
      2 
      3 typedef struct xhc_capability_registers xhc_capability_registers;
      4 typedef struct xhc_operational_registers xhc_operational_registers;
      5 typedef struct xhc_runtime_registers xhc_runtime_registers;
      6 typedef struct xhc_doorbell_registers xhc_doorbell_registers;
      7 typedef struct xhc_device_context xhc_device_context;
      8 typedef struct xhc_slot_context xhc_slot_context;
      9 typedef struct xhc_endpoint_context xhc_endpoint_context;
     10 typedef struct xhc_trb xhc_trb;
     11 
     12 typedef struct Xhc {
     13 	uintptr                   base;
     14 	xhc_capability_registers  *cap;
     15 	xhc_operational_registers *op;
     16 	xhc_runtime_registers     *runtime;
     17 	xhc_doorbell_registers    *doorbell;
     18 } Xhc;
     19 
     20 struct xhc_capability_registers {
     21 	uint8 CAPLENGTH;
     22 	uint8 Rsvd0;
     23 	uint16 HCIVERSION;
     24 	uint32 HCSPARAMS1;
     25 	uint32 HCSPARAMS2;
     26 	uint32 HCSPARAMS3;
     27 	uint32 HCCPARAMS1;
     28 	uint32 DBOFF;
     29 	uint32 RTSOFF;
     30 	uint32 HCCPARAMS2;
     31 };
     32 
     33 struct xhc_operational_registers {
     34 	uint32 USBCMD;
     35 	uint32 USBSTS;
     36 	uint32 PAGESIZE;
     37 	uint8  RsvdZ0[8];
     38 	uint32 NDCTRL;
     39 	uint64 CRCR;
     40 	uint8  RsvdZ1[16];
     41 	uint64 DCBAAP;
     42 	uint32 CONFIG;
     43 	uint8  RsvdZ2[0x400-0x3c];
     44 	struct PRS {
     45 		uint32 PORTSC;
     46 		uint32 PORTPMSC;
     47 		uint32 PORTLI;
     48 		uint32 PORTHLPMC;
     49 	} PRS[];
     50 };
     51 
     52 struct xhc_runtime_registers {
     53 	uint32 MFINDEX;
     54 	uint8  RsvdZ[28];
     55 	struct interrupt_register_set {
     56 		uint32 IMAN;
     57 		uint32 IMOD;
     58 		uint32 ERSTSZ;
     59 		uint32 RsvdP;
     60 		uint64 ERSTBA;
     61 		uint64 ERDP;
     62 	} IR[1024];
     63 };
     64 
     65 struct xhc_doorbell_registers {
     66 	// TODO: implement.
     67 };
     68 
     69 struct xhc_slot_context {
     70 	// TODO: implement.
     71 	uint8 byte[32];
     72 };
     73 
     74 struct xhc_endpoint_context {
     75 	// TODO: implement.
     76 	uint8 byte[32];
     77 };
     78 
     79 struct xhc_device_context {
     80 	xhc_slot_context slot_context;
     81 	xhc_endpoint_context ep_context[31];
     82 };
     83 
     84 struct xhc_trb {
     85 	uint64 parameter;
     86 	uint32 status;
     87 	uint32 control;
     88 };