summaryrefslogtreecommitdiff
path: root/old.c
diff options
context:
space:
mode:
Diffstat (limited to 'old.c')
-rw-r--r--old.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/old.c b/old.c
new file mode 100644
index 0000000..f066ad9
--- /dev/null
+++ b/old.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2017 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Authors: Jérôme Glisse <jglisse@redhat.com>
+ */
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <strings.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include "compote.h"
+#include "compote-uapi.h"
+
+int main(int argc, char *argv[])
+{
+ compote_context_t *ctx;
+ compote_mo_t *mo;
+ int ret;
+
+ ret = compote_context_new(&ctx);
+ if (ret) {
+ return ret;
+ }
+
+ ret = compote_mo_new(ctx, &mo, 64 << 10);
+ if (ret) {
+ goto out;
+ }
+
+ {
+ uint32_t *ptr = mo->ptr;
+ uint32_t *sem = &ptr[128 >> 2];
+
+ sem[0] = 0xcafedead;
+
+ ptr[0] = nvk_sq_cmd(1, 0x10, 4);
+ ptr[1] = ((unsigned long)sem) >> 32;
+ ptr[2] = ((unsigned long)sem) & 0xffffffff;
+ ptr[3] = 0xdeadcafe;
+ ptr[4] = 0x00000002;
+ ret = compote_context_execute(ctx, ptr, 5);
+ if (ret) {
+ goto out;
+ }
+
+ for (unsigned c = 0; (c < 10) && (ptr[128 >> 2] != 0xdeadcafe); c++) {
+ printf("[%4d] = 0x%08x 0x%08x 0x%08x\n", 128 >> 2, sem[0], sem[1], sem[2]);
+ sleep(1);
+ }
+ printf("[%4d] = 0x%08x 0x%08x 0x%08x\n", 128 >> 2, sem[0], sem[1], sem[2]);
+ }
+
+ printf("La compote c'est bon !\n");
+
+out:
+ compote_mo_del(ctx, &mo);
+ compote_context_del(&ctx);
+ return ret;
+}