mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
usb: add USBEndpoint
Start maintaining endpoint state at USBDevice level. Add USBEndpoint struct and some helper functions to deal with it. For now it contains the endpoint type only. Moved over some bits from usb-linux.c Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
62c6ae04cf
commit
d8e17efdec
4 changed files with 74 additions and 34 deletions
30
hw/usb.c
30
hw/usb.c
|
@ -414,3 +414,33 @@ void usb_packet_cleanup(USBPacket *p)
|
|||
{
|
||||
qemu_iovec_destroy(&p->iov);
|
||||
}
|
||||
|
||||
void usb_ep_init(USBDevice *dev)
|
||||
{
|
||||
int ep;
|
||||
|
||||
for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) {
|
||||
dev->ep_in[ep].type = USB_ENDPOINT_XFER_INVALID;
|
||||
dev->ep_out[ep].type = USB_ENDPOINT_XFER_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep)
|
||||
{
|
||||
struct USBEndpoint *eps = pid == USB_TOKEN_IN ? dev->ep_in : dev->ep_out;
|
||||
assert(pid == USB_TOKEN_IN || pid == USB_TOKEN_OUT);
|
||||
assert(ep > 0 && ep <= USB_MAX_ENDPOINTS);
|
||||
return eps + ep - 1;
|
||||
}
|
||||
|
||||
uint8_t usb_ep_get_type(USBDevice *dev, int pid, int ep)
|
||||
{
|
||||
struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);
|
||||
return uep->type;
|
||||
}
|
||||
|
||||
void usb_ep_set_type(USBDevice *dev, int pid, int ep, uint8_t type)
|
||||
{
|
||||
struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);
|
||||
uep->type = type;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue