/* * 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 */ #include #include #include #include #include #include #include #include #include #include #include #include "compote.h" #include "compote-uapi.h" int main(int argc, char *argv[]) { compote_context_t *ctx; compote_mo_t *mo, *dst; int ret; ret = compote_context_new(&ctx); if (ret) { return ret; } ret = compote_mo_new(ctx, &mo, 32 << 20); if (ret) { goto out; } ret = compote_mo_new(ctx, &dst, 4 << 20); 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]); } ret = test_compute(ctx, mo->ptr, dst->ptr, 1024); if (ret) goto out; printf("La compote c'est bon !\n"); out: compote_mo_del(ctx, &mo); compote_context_del(&ctx); return ret; }