DF-2344 / umcshctl.c
/* * umcshctl.c -- userland driver for the umcs.c verification harness * (/dev/umcsh0). Runs scenarios and prints results. * * Build: cc -O -Wall -o umcshctl umcshctl.c * Run: ./umcshctl <scenario#> [arg [arg2]] */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <err.h> #include "umcsh.h" static void dump(const struct umcsh_req *r) { printf(" rc=%u numports=%u divisor=%u clk=0x%02x attached=%u " "rd=%u wr=%u oob_dword=0x%08x\n", r->r_rc, r->r_numports, r->r_divisor, r->r_clk, r->r_attached, r->r_rd_cnt, r->r_wr_cnt, r->r_oob_dword); if (r->r_msg[0]) printf(" msg: %s\n", r->r_msg); } int main(int argc, char **argv) { struct umcsh_req r; int fd; if (argc < 2) errx(1, "usage: %s <scenario> [arg [arg2]]", argv[0]); bzero(&r, sizeof(r)); r.scenario = (uint32_t)strtoul(argv[1], NULL, 0); if (argc > 2) r.arg = (uint32_t)strtoul(argv[2], NULL, 0); if (argc > 3) r.arg2 = (uint32_t)strtoul(argv[3], NULL, 0); fd = open("/dev/umcsh0", O_RDWR); if (fd < 0) err(1, "open /dev/umcsh0"); /* * Scenario return codes are DATA (EINVAL from pre_param(0), ENXIO * from a rejected attach, EPERM from the rate=0 guard...); never * abort on them. */ ioctl(fd, UMCSH_IOC, &r); dump(&r); return (0); } |