Assorted whitespace cleanup and typo fixes.
[haiku.git] / src / bin / idestatus.c
blob5d38b41e3b8fd784da5a16f3e332edde56c80405
1 #include <stdio.h>
2 #include <fcntl.h>
3 #include <errno.h>
4 #include <string.h>
5 #include <unistd.h>
6 #include <SupportDefs.h>
7 #include <BeBuild.h>
9 /* why isn't that documented ? */
10 #define IDE_GET_STATUS 0x2711
12 typedef struct {
13 uint8 dummy;
14 uint8 dma_status;
15 uint8 pio_mode;
16 uint8 dma_mode;
17 } _PACKED ide_status_t;
19 char *dma_status_strings[] = {
20 "drive does not support dma",
21 "dma enabled",
22 "dma disabled by user config",
23 "dma disabled by safe mode",
24 "ide controller does not support dma",
25 "driver disabled dma due to inproper drive configuration",
26 "dma disabled after dma failure"
29 char *dma_mode_strings[] = {
30 "Multiword DMA Mode 0 - 4.2 MB/s",
31 "Multiword DMA Mode 1 - 13.3 MB/s",
32 "Multiword DMA Mode 2 - 16.7 MB/s",
33 "Invalid",
34 "Invalid",
35 "Invalid",
36 "Invalid",
37 "Invalid",
38 "Invalid",
39 "Invalid",
40 "Invalid",
41 "Invalid",
42 "Invalid",
43 "Invalid",
44 "Invalid",
45 "Invalid",
46 "Ultra DMA Mode 0 - 16.7 MB/s",
47 "Ultra DMA Mode 1 - 25 MB/s",
48 "Ultra DMA Mode 2 - 33.3 MB/s",
49 "Ultra DMA Mode 3 - 44.4 MB/s",
50 "Ultra DMA Mode 4 - 66.7 MB/s",
51 "Ultra DMA Mode 5 - 100 MB/s",
52 "Ultra DMA Mode 6 - 133 MB/s"
55 int main(int argc, char **argv)
57 int fd;
58 ide_status_t st = {0x01, 0x00, 0x00, 0x80}; /* God knows... */
59 if (argc < 2) {
60 fprintf(stderr, "use: %s devicename\n", argv[0]);
61 return 1;
63 fd = open(argv[1], O_RDONLY);
64 if (fd < 0) {
65 fprintf(stderr, "could not open %s, %s\n", argv[1], strerror(errno));
66 return 2;
68 if (ioctl(fd, IDE_GET_STATUS, &st, sizeof(ide_status_t *)) < 0) {
69 fprintf(stderr, "could not get ide status for %s\n", argv[1]);
70 return 3;
72 if (st.dma_status > 6)
73 printf("dma_status bad\n");
74 else
75 printf("dma_status: %s\n", dma_status_strings[st.dma_status]);
76 printf("pio mode: %d\n", st.pio_mode);
77 printf("dma mode: %s\n", dma_mode_strings[st.dma_mode]);
78 close(fd);
79 return 0;