summaryrefslogtreecommitdiff
path: root/compote.h
blob: b7811fbe81de6ff4a44bc0a2e48b33099cfaaf57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * 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>
 */
#ifndef COMPOTE_H
#define COMPOTE_H

#include <stdint.h>

typedef struct {
    int                         fd;
} compote_context_t;

typedef struct {
    uint64_t                    foffset;
    uint64_t                    nbytes;
    void                        *ptr;
} compote_mo_t;

int compote_context_new(compote_context_t **ctxp);
void compote_context_del(compote_context_t **ctxp);
int compote_context_ioctl(compote_context_t *ctx, int command, void *arg);

int compote_mo_new(compote_context_t *ctx, compote_mo_t **mop, uint64_t nbytes);
void compote_mo_del(compote_context_t *ctx, compote_mo_t **mop);

static inline uint64_t compote_mo_gpu_addr(compote_mo_t *mo)
{
    if (mo == NULL || mo->ptr == NULL) {
        return -1UL;
    }

    return (unsigned long)mo->ptr;
}

#endif // COMPOTE_H