--- /dev/null
+/*
+ * Copyright (c) 2016, Ian Sutton <ian@kremlin.cc>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <pruss/prussdrv.h>
+#include <pruss/pruss_intc_mapping.h>
+
+int main(int argc, char *argv[]) {
+
+ tpruss_intc_initdata init_data = PRUSS_INTC_INITDATA;
+
+ if(argc < 2) {
+ printf("usage: %s <obj>\n", argv[0]);
+ return EINVAL;
+ } else if(geteuid()) {
+ printf("%s\n", "run as root");
+ return EACCES;
+ }
+
+ /* init pru drv */
+ if(prussdrv_init())
+ return ENXIO;
+
+ /* open, bind intr */
+ if(prussdrv_open(PRU_EVTOUT0))
+ return ENXIO;
+ if(prussdrv_pruintc_init(&init_data))
+ return ENXIO;
+
+ /* exec */
+ if(prussdrv_exec_program(0, argv[1]))
+ return ENXIO;
+
+ /* block until intr */
+ prussdrv_pru_wait_event(PRU_EVTOUT_0);
+
+ /* clean up, halt & disable pru, terminate pru drv */
+ prussdrv_pru_clear_event(PRU_EVTOUT_0, PRU0_ARM_INTERRUPT);
+ prussdrv_pru_disable(0);
+ prussdrv_exit();
+
+ return 0;
+}
+