diff --git a/src/userland/hid/main.c b/src/userland/hid/main.c index bbf449d..42389f7 100644 --- a/src/userland/hid/main.c +++ b/src/userland/hid/main.c @@ -21,12 +21,11 @@ void hidListening(HIDDevice *device) { while (1) { - request(device->serviceId, device->normalFunction, device->deviceId, getPhysicalAddress(device->buffer)); + request(device->serviceId, device->normalFunction, device->deviceId, U32(getPhysicalAddress(device->buffer))); MouseReport *report = device->buffer; moveRelative((int32_t) report->x, (int32_t)report->y); updateButtons(report->buttons, 0); // todo: sleep for at least endpoint->interval? - // todo: start this loop in a fork? sleep(10); } } @@ -38,6 +37,7 @@ device->buffer = malloc(0x1000); device->normalFunction = getFunction(serviceId, "hid_normal"); fork(hidListening, device, 0, 0); + return 0; } void initialize() { diff --git a/src/userland/hid/main.c b/src/userland/hid/main.c index bbf449d..42389f7 100644 --- a/src/userland/hid/main.c +++ b/src/userland/hid/main.c @@ -21,12 +21,11 @@ void hidListening(HIDDevice *device) { while (1) { - request(device->serviceId, device->normalFunction, device->deviceId, getPhysicalAddress(device->buffer)); + request(device->serviceId, device->normalFunction, device->deviceId, U32(getPhysicalAddress(device->buffer))); MouseReport *report = device->buffer; moveRelative((int32_t) report->x, (int32_t)report->y); updateButtons(report->buttons, 0); // todo: sleep for at least endpoint->interval? - // todo: start this loop in a fork? sleep(10); } } @@ -38,6 +37,7 @@ device->buffer = malloc(0x1000); device->normalFunction = getFunction(serviceId, "hid_normal"); fork(hidListening, device, 0, 0); + return 0; } void initialize() { diff --git a/src/userland/usb/include/usb.h b/src/userland/usb/include/usb.h index 1bfbd4d..9277af1 100644 --- a/src/userland/usb/include/usb.h +++ b/src/userland/usb/include/usb.h @@ -64,7 +64,7 @@ typedef struct { uint32_t pciClass; void *(*initialize)(uint32_t, uint32_t, uint32_t); - void (*getDescriptor)(void *, uint32_t, uint32_t, void *); + void (*getDescriptor)(void *, uint32_t, uint32_t, void *, uint8_t); void (*setupEndpointsStart)(void *, uint32_t); void (*setupEndpointsEnd)(void *, uint32_t); void (*setupHID)(void *, uint32_t, void *); diff --git a/src/userland/hid/main.c b/src/userland/hid/main.c index bbf449d..42389f7 100644 --- a/src/userland/hid/main.c +++ b/src/userland/hid/main.c @@ -21,12 +21,11 @@ void hidListening(HIDDevice *device) { while (1) { - request(device->serviceId, device->normalFunction, device->deviceId, getPhysicalAddress(device->buffer)); + request(device->serviceId, device->normalFunction, device->deviceId, U32(getPhysicalAddress(device->buffer))); MouseReport *report = device->buffer; moveRelative((int32_t) report->x, (int32_t)report->y); updateButtons(report->buttons, 0); // todo: sleep for at least endpoint->interval? - // todo: start this loop in a fork? sleep(10); } } @@ -38,6 +37,7 @@ device->buffer = malloc(0x1000); device->normalFunction = getFunction(serviceId, "hid_normal"); fork(hidListening, device, 0, 0); + return 0; } void initialize() { diff --git a/src/userland/usb/include/usb.h b/src/userland/usb/include/usb.h index 1bfbd4d..9277af1 100644 --- a/src/userland/usb/include/usb.h +++ b/src/userland/usb/include/usb.h @@ -64,7 +64,7 @@ typedef struct { uint32_t pciClass; void *(*initialize)(uint32_t, uint32_t, uint32_t); - void (*getDescriptor)(void *, uint32_t, uint32_t, void *); + void (*getDescriptor)(void *, uint32_t, uint32_t, void *, uint8_t); void (*setupEndpointsStart)(void *, uint32_t); void (*setupEndpointsEnd)(void *, uint32_t); void (*setupHID)(void *, uint32_t, void *); diff --git a/src/userland/usb/main.c b/src/userland/usb/main.c index cdc9411..77f77e3 100644 --- a/src/userland/usb/main.c +++ b/src/userland/usb/main.c @@ -13,7 +13,7 @@ char *usbReadString(UsbSlot *slot, uint32_t language, uint32_t stringDescriptor, void *buffer) { slot->interface->getDescriptor(slot->data, 3 << 8 | stringDescriptor, language, - buffer); + buffer, 0); uint32_t length = ((*(uint8_t *)buffer) - 2) / 2; char *string = malloc(length); for (uint32_t i = 0; i < length; i++) { @@ -77,12 +77,12 @@ printf("--------\n"); void *buffer = requestMemory(1, 0, 0); UsbDeviceDescriptor *descriptor = malloc(sizeof(UsbDeviceDescriptor)); - slot->interface->getDescriptor(slot->data, 1 << 8, 0, buffer); + slot->interface->getDescriptor(slot->data, 1 << 8, 0, buffer, 0); memcpy(buffer, (void *)descriptor, sizeof(UsbDeviceDescriptor)); printf("port %i: usb version %x.%x, %i supported configuration(s)\n", slot->portIndex, descriptor->usbVersion >> 8, descriptor->usbVersion & 0xFF, descriptor->configurationCount); - slot->interface->getDescriptor(slot->data, 3 << 8, 0, buffer); + slot->interface->getDescriptor(slot->data, 3 << 8, 0, buffer, 0); uint32_t language = *((uint16_t *)(buffer + 2)); char *manufacturer = usbReadString( slot, language, descriptor->manufacturerStringDescriptor, buffer); @@ -93,7 +93,7 @@ printf("port %i: manufacturer:%s, device:%s, serial:%s\n", slot->portIndex, manufacturer, device, serial); - slot->interface->getDescriptor(slot->data, 2 << 8, 0, buffer); + slot->interface->getDescriptor(slot->data, 2 << 8, 0, buffer, 0); UsbConfigurationDescriptor *configuration = malloc(((uint16_t *)buffer)[1]); memcpy(buffer, configuration, ((uint16_t *)buffer)[1]); char *configurationString = usbReadString( diff --git a/src/userland/hid/main.c b/src/userland/hid/main.c index bbf449d..42389f7 100644 --- a/src/userland/hid/main.c +++ b/src/userland/hid/main.c @@ -21,12 +21,11 @@ void hidListening(HIDDevice *device) { while (1) { - request(device->serviceId, device->normalFunction, device->deviceId, getPhysicalAddress(device->buffer)); + request(device->serviceId, device->normalFunction, device->deviceId, U32(getPhysicalAddress(device->buffer))); MouseReport *report = device->buffer; moveRelative((int32_t) report->x, (int32_t)report->y); updateButtons(report->buttons, 0); // todo: sleep for at least endpoint->interval? - // todo: start this loop in a fork? sleep(10); } } @@ -38,6 +37,7 @@ device->buffer = malloc(0x1000); device->normalFunction = getFunction(serviceId, "hid_normal"); fork(hidListening, device, 0, 0); + return 0; } void initialize() { diff --git a/src/userland/usb/include/usb.h b/src/userland/usb/include/usb.h index 1bfbd4d..9277af1 100644 --- a/src/userland/usb/include/usb.h +++ b/src/userland/usb/include/usb.h @@ -64,7 +64,7 @@ typedef struct { uint32_t pciClass; void *(*initialize)(uint32_t, uint32_t, uint32_t); - void (*getDescriptor)(void *, uint32_t, uint32_t, void *); + void (*getDescriptor)(void *, uint32_t, uint32_t, void *, uint8_t); void (*setupEndpointsStart)(void *, uint32_t); void (*setupEndpointsEnd)(void *, uint32_t); void (*setupHID)(void *, uint32_t, void *); diff --git a/src/userland/usb/main.c b/src/userland/usb/main.c index cdc9411..77f77e3 100644 --- a/src/userland/usb/main.c +++ b/src/userland/usb/main.c @@ -13,7 +13,7 @@ char *usbReadString(UsbSlot *slot, uint32_t language, uint32_t stringDescriptor, void *buffer) { slot->interface->getDescriptor(slot->data, 3 << 8 | stringDescriptor, language, - buffer); + buffer, 0); uint32_t length = ((*(uint8_t *)buffer) - 2) / 2; char *string = malloc(length); for (uint32_t i = 0; i < length; i++) { @@ -77,12 +77,12 @@ printf("--------\n"); void *buffer = requestMemory(1, 0, 0); UsbDeviceDescriptor *descriptor = malloc(sizeof(UsbDeviceDescriptor)); - slot->interface->getDescriptor(slot->data, 1 << 8, 0, buffer); + slot->interface->getDescriptor(slot->data, 1 << 8, 0, buffer, 0); memcpy(buffer, (void *)descriptor, sizeof(UsbDeviceDescriptor)); printf("port %i: usb version %x.%x, %i supported configuration(s)\n", slot->portIndex, descriptor->usbVersion >> 8, descriptor->usbVersion & 0xFF, descriptor->configurationCount); - slot->interface->getDescriptor(slot->data, 3 << 8, 0, buffer); + slot->interface->getDescriptor(slot->data, 3 << 8, 0, buffer, 0); uint32_t language = *((uint16_t *)(buffer + 2)); char *manufacturer = usbReadString( slot, language, descriptor->manufacturerStringDescriptor, buffer); @@ -93,7 +93,7 @@ printf("port %i: manufacturer:%s, device:%s, serial:%s\n", slot->portIndex, manufacturer, device, serial); - slot->interface->getDescriptor(slot->data, 2 << 8, 0, buffer); + slot->interface->getDescriptor(slot->data, 2 << 8, 0, buffer, 0); UsbConfigurationDescriptor *configuration = malloc(((uint16_t *)buffer)[1]); memcpy(buffer, configuration, ((uint16_t *)buffer)[1]); char *configurationString = usbReadString( diff --git a/src/userland/usb/xhci/commands.c b/src/userland/usb/xhci/commands.c index 6669a67..d2f0055 100644 --- a/src/userland/usb/xhci/commands.c +++ b/src/userland/usb/xhci/commands.c @@ -44,9 +44,9 @@ } void *xhciGetDescriptor(SlotXHCI *slot, uint32_t value, uint32_t index, - void *buffer) { + void *buffer, uint8_t recepient) { XHCISetupStageTRB setup = {0}; - setup.requestType = 0x80; + setup.requestType = 0x80 | recepient; setup.request = 6; setup.value = value; setup.index = index; diff --git a/src/userland/hid/main.c b/src/userland/hid/main.c index bbf449d..42389f7 100644 --- a/src/userland/hid/main.c +++ b/src/userland/hid/main.c @@ -21,12 +21,11 @@ void hidListening(HIDDevice *device) { while (1) { - request(device->serviceId, device->normalFunction, device->deviceId, getPhysicalAddress(device->buffer)); + request(device->serviceId, device->normalFunction, device->deviceId, U32(getPhysicalAddress(device->buffer))); MouseReport *report = device->buffer; moveRelative((int32_t) report->x, (int32_t)report->y); updateButtons(report->buttons, 0); // todo: sleep for at least endpoint->interval? - // todo: start this loop in a fork? sleep(10); } } @@ -38,6 +37,7 @@ device->buffer = malloc(0x1000); device->normalFunction = getFunction(serviceId, "hid_normal"); fork(hidListening, device, 0, 0); + return 0; } void initialize() { diff --git a/src/userland/usb/include/usb.h b/src/userland/usb/include/usb.h index 1bfbd4d..9277af1 100644 --- a/src/userland/usb/include/usb.h +++ b/src/userland/usb/include/usb.h @@ -64,7 +64,7 @@ typedef struct { uint32_t pciClass; void *(*initialize)(uint32_t, uint32_t, uint32_t); - void (*getDescriptor)(void *, uint32_t, uint32_t, void *); + void (*getDescriptor)(void *, uint32_t, uint32_t, void *, uint8_t); void (*setupEndpointsStart)(void *, uint32_t); void (*setupEndpointsEnd)(void *, uint32_t); void (*setupHID)(void *, uint32_t, void *); diff --git a/src/userland/usb/main.c b/src/userland/usb/main.c index cdc9411..77f77e3 100644 --- a/src/userland/usb/main.c +++ b/src/userland/usb/main.c @@ -13,7 +13,7 @@ char *usbReadString(UsbSlot *slot, uint32_t language, uint32_t stringDescriptor, void *buffer) { slot->interface->getDescriptor(slot->data, 3 << 8 | stringDescriptor, language, - buffer); + buffer, 0); uint32_t length = ((*(uint8_t *)buffer) - 2) / 2; char *string = malloc(length); for (uint32_t i = 0; i < length; i++) { @@ -77,12 +77,12 @@ printf("--------\n"); void *buffer = requestMemory(1, 0, 0); UsbDeviceDescriptor *descriptor = malloc(sizeof(UsbDeviceDescriptor)); - slot->interface->getDescriptor(slot->data, 1 << 8, 0, buffer); + slot->interface->getDescriptor(slot->data, 1 << 8, 0, buffer, 0); memcpy(buffer, (void *)descriptor, sizeof(UsbDeviceDescriptor)); printf("port %i: usb version %x.%x, %i supported configuration(s)\n", slot->portIndex, descriptor->usbVersion >> 8, descriptor->usbVersion & 0xFF, descriptor->configurationCount); - slot->interface->getDescriptor(slot->data, 3 << 8, 0, buffer); + slot->interface->getDescriptor(slot->data, 3 << 8, 0, buffer, 0); uint32_t language = *((uint16_t *)(buffer + 2)); char *manufacturer = usbReadString( slot, language, descriptor->manufacturerStringDescriptor, buffer); @@ -93,7 +93,7 @@ printf("port %i: manufacturer:%s, device:%s, serial:%s\n", slot->portIndex, manufacturer, device, serial); - slot->interface->getDescriptor(slot->data, 2 << 8, 0, buffer); + slot->interface->getDescriptor(slot->data, 2 << 8, 0, buffer, 0); UsbConfigurationDescriptor *configuration = malloc(((uint16_t *)buffer)[1]); memcpy(buffer, configuration, ((uint16_t *)buffer)[1]); char *configurationString = usbReadString( diff --git a/src/userland/usb/xhci/commands.c b/src/userland/usb/xhci/commands.c index 6669a67..d2f0055 100644 --- a/src/userland/usb/xhci/commands.c +++ b/src/userland/usb/xhci/commands.c @@ -44,9 +44,9 @@ } void *xhciGetDescriptor(SlotXHCI *slot, uint32_t value, uint32_t index, - void *buffer) { + void *buffer, uint8_t recepient) { XHCISetupStageTRB setup = {0}; - setup.requestType = 0x80; + setup.requestType = 0x80 | recepient; setup.request = 6; setup.value = value; setup.index = index; diff --git a/src/userland/usb/xhci/commands.h b/src/userland/usb/xhci/commands.h index 8065075..94d878c 100644 --- a/src/userland/usb/xhci/commands.h +++ b/src/userland/usb/xhci/commands.h @@ -16,7 +16,7 @@ extern uint32_t requestSlotIndex(XHCIController *controller); extern void *xhciGetDescriptor(SlotXHCI *slot, uint32_t value, - uint32_t index, void *buffer); + uint32_t index, void *buffer, uint8_t recepient); extern TrbRing *createSlotTRB(SlotXHCI *slot);