Index: uspace/dist/src/bithenge/usbdesc.bh
===================================================================
--- uspace/dist/src/bithenge/usbdesc.bh	(revision d8bd2ecea0a6735f52ed0a293bc3244efb4baf8c)
+++ uspace/dist/src/bithenge/usbdesc.bh	(revision 71450c851fb728ac6d9a6f1118949d81152b67e9)
@@ -7,10 +7,14 @@
 # Originally by Vojtech Horky.
 
+# Block prefixed with a byte length
+transform block = (in.data) <- struct {
+	.bLength <- uint8;
+	.data <- known_length(.bLength - 1);
+};
+
 # USB configuration descriptor
 # This is not the full configuration descriptor (i.e. with interface
 # and endpoint descriptors included) but only the header. 
 transform usb_configuration_descriptor_bare = struct {
-	.bLength <- uint8; # assert bLength = 9
-	.bDescriptorType <- uint8; # assert: bDescriptorType == 2
 	.wTotalLength <- uint16le;
 	.bNumInterfaces <- uint8;
@@ -23,6 +27,4 @@
 # USB interface descriptor
 transform usb_interface_descriptor = struct {
-	.bLength <- uint8; # assert bLength = 9
-	.bDescriptorType <- uint8; # assert: bDescriptorType == 4
 	.bInterfaceNumber <- uint8;
 	.bAlternateSetting <- uint8;
@@ -36,6 +38,4 @@
 # USB endpoint descriptor
 transform usb_endpoint_descriptor = struct {
-	.bLength <- uint8; # assert bLength = 7
-	.bDescriptorType <- uint8; # assert: bDescriptorType == 5
 	.bEndpointAddress  <- uint8;
 	.bmAttributes <- uint8;
@@ -46,21 +46,23 @@
 # USB HID descriptor
 transform usb_hid_descriptor = struct {
-	.bLength <- uint8;
-	.bDescriptorType <- uint8; # assert: bDescriptorType == 33
 	.bcdHID <- uint16le;
 	.bCountryCode <- uint8;
 	.bNumDescriptors <- uint8;
-	# Following is repeated bNumDescriptors times
-	.bDescriptorType <- uint8;
-	.wDescriptorLength <- uint16le;
+	<- repeat(.bNumDescriptors) { struct {
+		.bDescriptorType <- uint8;
+		.wDescriptorLength <- uint16le;
+	} };
 };
 
-# Fixed configuration for QEMU USB keyboard. 
-transform qemu_usb_keyboard = struct {
-	.configuration_descriptor <- usb_configuration_descriptor_bare;
-	.interface_descriptor <- usb_interface_descriptor;
-	.hid_descriptor <- usb_hid_descriptor;
-	.endpoint_descriptor <- usb_endpoint_descriptor;
-}; 
+# USB descriptor
+transform usb_descriptor = struct {
+	.bDescriptorType <- uint8;
+	<- switch (.bDescriptorType) {
+		 2: usb_configuration_descriptor_bare;
+		 4: usb_interface_descriptor;
+		 5: usb_endpoint_descriptor;
+		33: usb_hid_descriptor;
+	};
+} <- block;
 
-transform main = qemu_usb_keyboard;
+transform main = repeat { usb_descriptor };
