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