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
This commit is contained in:
parent
15d7d70acd
commit
e27cd67efe
38
src/apps/bin/ideinfo.c
Normal file
38
src/apps/bin/ideinfo.c
Normal file
@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <BeBuild.h>
|
||||
|
||||
/* 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;
|
||||
}
|
52
src/apps/bin/idestatus.c
Normal file
52
src/apps/bin/idestatus.c
Normal file
@ -0,0 +1,52 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <BeBuild.h>
|
||||
|
||||
/* 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user