#include #include #include #include #include #include #include #include #ifndef O_DIRECT #define O_DIRECT 040000 #endif #define array_elements(arr) (sizeof(arr) / sizeof(arr[0])) struct asys_input { int syscall_nr; unsigned long cookie; unsigned long nr_args; unsigned long *args; }; struct asys_completion { long return_code; unsigned long cookie; }; #define SYS_asys_submit 320 #define SYS_asys_await_completion 321 unsigned char buf[512] __attribute__((aligned(512))); int main(int argc, char **argv) { int fd; int i; int ret; struct timeval tv; struct asys_completion comp; unsigned long args[] = {0 /* fd */, (unsigned long)buf, 512}; struct asys_input inp[] = { { .syscall_nr = SYS_getpid, .cookie = 1234, .nr_args = 0, }, { .syscall_nr = SYS_read, .cookie = 5678, .nr_args = 3, .args = args, }, }; fd = open("/dev/hda", O_RDONLY|O_DIRECT); if (fd < 0) { printf("couldn't open /dev/hda\n"); exit(1); } args[0] = fd; ret = syscall(SYS_asys_submit, &inp, array_elements(inp)); gettimeofday(&tv, NULL); printf("submit returned %d at %ld.%ld\n", ret, tv.tv_sec, tv.tv_usec); for (i = 0; i < array_elements(inp) ; i++) { ret = syscall(SYS_asys_await_completion, &comp); gettimeofday(&tv, NULL); printf("completion returned %d at %ld.%ld, " "return code %ld cookie %lu\n", ret, tv.tv_sec, tv.tv_usec, comp.return_code, comp.cookie); } return 0; }