-
Notifications
You must be signed in to change notification settings - Fork 68
/
gdev_arch.h
90 lines (83 loc) · 3.71 KB
/
gdev_arch.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* Copyright 2011 Shinpei Kato
*
* University of California, Santa Cruz
* Systems Research Lab.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __GDEV_ARCH_H__
#define __GDEV_ARCH_H__
#include "gdev_conf.h"
#include "gdev_time.h"
struct gdev_device; /* prototype declaration */
/**
* Gdev types: they are not exposed to end users.
*/
typedef struct gdev_vas gdev_vas_t;
typedef struct gdev_ctx gdev_ctx_t;
typedef struct gdev_mem gdev_mem_t;
/**
* architecture-dependent compute functions.
*/
int gdev_compute_setup(struct gdev_device *gdev);
uint32_t gdev_launch(gdev_ctx_t *ctx, struct gdev_kernel *kern);
uint32_t gdev_memcpy(gdev_ctx_t *ctx, uint64_t dst_addr, uint64_t src_addr, uint32_t size, int async);
uint32_t gdev_read32(gdev_mem_t *mem, uint64_t addr);
void gdev_write32(gdev_mem_t *mem, uint64_t addr, uint32_t val);
int gdev_read(gdev_mem_t *mem, void *buf, uint64_t addr, uint32_t size);
int gdev_write(gdev_mem_t *mem, uint64_t addr, const void *buf, uint32_t size);
int gdev_poll(gdev_ctx_t *ctx, uint32_t seq, struct gdev_time *timeout);
int gdev_query(struct gdev_device *gdev, uint32_t type, uint64_t *result);
/**
* architecture-dependent resource management functions.
*/
struct gdev_device *gdev_dev_open(int minor);
void gdev_dev_close(struct gdev_device *gdev);
gdev_vas_t *gdev_vas_new(struct gdev_device *gdev, uint64_t size, void *handle);
void gdev_vas_free(gdev_vas_t *vas);
gdev_ctx_t *gdev_ctx_new(struct gdev_device *gdev, gdev_vas_t *vas);
void gdev_ctx_free(gdev_ctx_t *ctx);
int gdev_ctx_get_cid(gdev_ctx_t *ctx);
gdev_mem_t *gdev_mem_alloc(gdev_vas_t *vas, uint64_t size, int type);
void gdev_mem_free(gdev_mem_t *mem);
void gdev_mem_gc(gdev_vas_t *vas);
int gdev_shmem_evict(gdev_ctx_t *ctx, gdev_mem_t *mem);
int gdev_shmem_evict_all(gdev_ctx_t *ctx, gdev_vas_t *vas);
int gdev_shmem_reload(gdev_ctx_t *ctx, gdev_mem_t *mem);
int gdev_shmem_reload_all(gdev_ctx_t *ctx, gdev_vas_t *vas);
gdev_mem_t *gdev_shmem_request(gdev_vas_t *vas, gdev_mem_t *mem, uint64_t size);
void gdev_shmem_lock(gdev_mem_t *mem);
void gdev_shmem_unlock(gdev_mem_t *mem);
void gdev_shmem_lock_all(gdev_vas_t *vas);
void gdev_shmem_unlock_all(gdev_vas_t *vas);
int gdev_swap_create(struct gdev_device *gdev, uint32_t size);
void gdev_swap_destroy(struct gdev_device *gdev);
void gdev_vas_list_add(gdev_vas_t *vas);
void gdev_vas_list_del(gdev_vas_t *vas);
void gdev_mem_list_add(gdev_mem_t *mem, int type);
void gdev_mem_list_del(gdev_mem_t *mem);
gdev_mem_t *gdev_mem_lookup(gdev_vas_t *vas, uint64_t addr, int type);
void *gdev_mem_get_buf(gdev_mem_t *mem);
uint64_t gdev_mem_get_addr(gdev_mem_t *mem);
uint64_t gdev_mem_get_size(gdev_mem_t *mem);
#endif