xref: /haiku/src/tests/add-ons/kernel/busses/usb/uhci_decode.cpp (revision 49546fa993e8de87ddebffd56f890aec71aa42d3)
1 #include <stdio.h>
2 #include <SupportDefs.h>
3 
4 struct uhci_td_control_status {
5 	uint32	actual_length : 11;
6 	uint32	reserved_1 : 6;
7 	uint32	bitstuff_error : 1;
8 	uint32	crc_timeout : 1;
9 	uint32	nak_received : 1;
10 	uint32	babble_detected : 1;
11 	uint32	data_buffer_error : 1;
12 	uint32	stalled : 1;
13 	uint32	active : 1;
14 	uint32	interrupt_on_complete : 1;
15 	uint32	isochronous_select : 1;
16 	uint32	low_speed_device : 1;
17 	uint32	error_counter : 2;
18 	uint32	short_packet_detect : 1;
19 	uint32	reserved_2 : 2;
20 };
21 
22 
23 int
24 main(int argc, char *argv[])
25 {
26 	if (argc < 2)
27 		return 1;
28 
29 	uint32 value;
30 	if (sscanf(argv[1], "%lx", &value) != 1)
31 		return 2;
32 
33 	uhci_td_control_status status;
34 	memcpy(&status, &value, sizeof(status));
35 
36 	printf("value: 0x%08lx\n", value);
37 	printf("actual_length: %ld\n", status.actual_length);
38 	printf("reserved_1: %ld\n", status.reserved_1);
39 	printf("bitstuff_error: %ld\n", status.bitstuff_error);
40 	printf("crc_timeout: %ld\n", status.crc_timeout);
41 	printf("nak_received: %ld\n", status.nak_received);
42 	printf("babble_detected: %ld\n", status.babble_detected);
43 	printf("data_buffer_error: %ld\n", status.data_buffer_error);
44 	printf("stalled: %ld\n", status.stalled);
45 	printf("active: %ld\n", status.active);
46 	printf("interrupt_on_complete: %ld\n", status.interrupt_on_complete);
47 	printf("isochronous_select: %ld\n", status.isochronous_select);
48 	printf("low_speed_device: %ld\n", status.low_speed_device);
49 	printf("error_counter: %ld\n", status.error_counter);
50 	printf("short_packet_detect: %ld\n", status.short_packet_detect);
51 	printf("reserved_2: %ld\n", status.reserved_2);
52 
53 	return 0;
54 }
55