Files
mop3/kernel/device/usb/usb.h
kamkow1 e5ebd7f3ba
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 2m21s
Build documentation / build-and-deploy (push) Successful in 54s
Use a big-lock for kernel sychronization instead of fine-grained locking
2026-04-27 18:06:02 +02:00

97 lines
2.1 KiB
C

#ifndef _KERNEL_DEVICE_USB_H
#define _KERNEL_DEVICE_USB_H
#include <aux/compiler.h>
#include <device/device.h>
#include <libk/std.h>
#include <proc/proc.h>
#include <proc/reschedule.h>
#define USB_DRIVER_MAX_MATCHES 1
/* descriptor types */
#define USB_DESC_DEVICE 1
#define USB_DESC_CONFIG 2
#define USB_DESC_STRING 3
#define USB_DESC_IF 4
#define USB_DESC_ENDPOINT 5
#define USB_DESC_IF_POWER 8
#define USB_DESC_OTG 9
#define USB_DESC_DEBUG 10
#define USB_DESC_IF_ASSOC 11
#define USB_DESC_BOS 15
#define USB_DESC_DEV_CAPABILITY 16
#define USB_DESC_SS_USB_EP_COMP 48
struct xhci;
struct xhci_usb_device;
struct usb_desc_hdr {
uint8_t length;
uint8_t desc_type;
} PACKED;
struct usb_device_desc {
struct usb_desc_hdr hdr;
uint16_t bcd_usb;
uint8_t dev_class;
uint8_t dev_subclass;
uint8_t dev_proto;
uint8_t max_packet_size; /* If USB 3.0, this must be read as (1 << max_packet_size) */
uint16_t vendor_id;
uint16_t product_id;
uint16_t bcd_device;
uint8_t manufacturer;
uint8_t product;
uint8_t serial_num;
uint8_t num_configs;
} PACKED;
struct usb_string_lang_desc {
struct usb_desc_hdr hdr;
uint16_t langs[126];
} PACKED;
struct usb_config_desc {
struct usb_desc_hdr hdr;
uint16_t total_length;
uint8_t num_ifs;
uint8_t config_value;
uint8_t config;
uint8_t attrs;
uint8_t max_power;
uint8_t data[245];
} PACKED;
struct usb_if_desc {
struct usb_desc_hdr hdr;
uint8_t if_num;
uint8_t alt_setting;
uint8_t num_endpoints;
uint8_t if_class;
uint8_t if_subclass;
uint8_t if_proto;
uint8_t if1;
} PACKED;
struct usb_endpoint_desc {
struct usb_desc_hdr hdr;
uint8_t endpoint_addr;
uint8_t attrs;
uint16_t max_packet_size;
uint8_t interval;
} PACKED;
struct usb_driver_info {
uint8_t if_class;
uint8_t if_subclass;
uint8_t if_proto;
struct device* (*init)(struct xhci* xhci, struct xhci_usb_device* usb_device, struct proc* proc,
struct reschedule_ctx* rctx);
};
extern struct usb_driver_info usb_driver_infos[USB_DRIVER_MAX_MATCHES];
#endif // _KERNEL_DEVICE_USB_H