From e27cd67efea4bb9e6f959de83be5dbc22d935163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Wed, 17 Nov 2004 10:47:47 +0000 Subject: [PATCH] I rewrote them long ago but thought they were in already. We'll probably use less obscure ioctls in Haiku though... git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9985 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/bin/ideinfo.c | 38 +++++++++++++++++++++++++++++ src/apps/bin/idestatus.c | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/apps/bin/ideinfo.c create mode 100644 src/apps/bin/idestatus.c diff --git a/src/apps/bin/ideinfo.c b/src/apps/bin/ideinfo.c new file mode 100644 index 0000000000..75101cb332 --- /dev/null +++ b/src/apps/bin/ideinfo.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include + +/* why isn't that documented ? */ +#define IDE_GET_INFO 0x2710 +#define IDE_GET_STATUS 0x2711 + +/* in uint16 */ +#define IDE_INFO_LEN 0x100 + +int main(int argc, char **argv) +{ + int fd; + uint16 buffer[IDE_INFO_LEN]; + if (argc < 2) { + fprintf(stderr, "use: %s devicename\n", argv[0]); + return 1; + } + fd = open(argv[1], O_RDONLY); + if (fd < 0) { + fprintf(stderr, "could not open %s, %s\n", argv[1], strerror(errno)); + return 2; + } + if (ioctl(fd, IDE_GET_INFO, buffer, IDE_INFO_LEN*sizeof(uint16)) < 0) { + fprintf(stderr, "could not get ide info for %s\n", argv[1]); + return 3; + } + { + int f; + f = open("/tmp/ideinfo.dump", O_WRONLY|O_CREAT, 0666); + write(f, buffer, IDE_INFO_LEN*sizeof(uint16)); + } + close(fd); + return 0; +} diff --git a/src/apps/bin/idestatus.c b/src/apps/bin/idestatus.c new file mode 100644 index 0000000000..ef870c28d2 --- /dev/null +++ b/src/apps/bin/idestatus.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include + +/* why isn't that documented ? */ +#define IDE_GET_STATUS 0x2711 + +typedef struct { + uint8 dummy; + uint8 dma_status; + uint8 pio_mode; + uint8 dma_mode; +} _PACKED ide_status_t; + +char *dma_status_strings[] = { + "drive does not support dma", + "dma enabled", + "dma disabled by user config", + "dma disabled by safe mode", + "ide controller does not support dma", + "driver disabled dma due to inproper drive configuration", + "dma disabled after dma failure" +}; + +int main(int argc, char **argv) +{ + int fd; + ide_status_t st = {0x01, 0x00, 0x00, 0x80}; /* God knows... */ + if (argc < 2) { + fprintf(stderr, "use: %s devicename\n", argv[0]); + return 1; + } + fd = open(argv[1], O_RDONLY); + if (fd < 0) { + fprintf(stderr, "could not open %s, %s\n", argv[1], strerror(errno)); + return 2; + } + if (ioctl(fd, IDE_GET_STATUS, &st, sizeof(ide_status_t *)) < 0) { + fprintf(stderr, "could not get ide status for %s\n", argv[1]); + return 3; + } + if (st.dma_status > 6) + printf("dma_status bad\n"); + else + printf("dma_status %s\n", dma_status_strings[st.dma_status]); + printf("pio mode: %d\n", st.pio_mode); + printf("dma mode: 0x%02x\n", st.dma_mode); + close(fd); + return 0; +}