• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2018 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  *
23  */
24 
25 #ifndef INTEL_AUB_MEM
26 #define INTEL_AUB_MEM
27 
28 #include <stdint.h>
29 
30 #include "util/list.h"
31 #include "util/rb_tree.h"
32 
33 #include "dev/gen_device_info.h"
34 #include "common/gen_decoder.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 struct aub_mem {
41    uint64_t pml4;
42 
43    int mem_fd;
44    off_t mem_fd_len;
45 
46    struct list_head maps;
47    struct rb_tree ggtt;
48    struct rb_tree mem;
49 };
50 
51 bool aub_mem_init(struct aub_mem *mem);
52 void aub_mem_fini(struct aub_mem *mem);
53 
54 void aub_mem_clear_bo_maps(struct aub_mem *mem);
55 
56 void aub_mem_phys_write(void *mem, uint64_t virt_address,
57                         const void *data, uint32_t size);
58 void aub_mem_ggtt_write(void *mem, uint64_t virt_address,
59                         const void *data, uint32_t size);
60 void aub_mem_ggtt_entry_write(void *mem, uint64_t virt_address,
61                               const void *data, uint32_t size);
62 void aub_mem_local_write(void *mem, uint64_t virt_address,
63                          const void *data, uint32_t size);
64 
65 struct gen_batch_decode_bo aub_mem_get_ggtt_bo(void *mem, uint64_t address);
66 struct gen_batch_decode_bo aub_mem_get_ppgtt_bo(void *mem, uint64_t address);
67 
68 struct gen_batch_decode_bo aub_mem_get_phys_addr_data(struct aub_mem *mem, uint64_t phys_addr);
69 struct gen_batch_decode_bo aub_mem_get_ppgtt_addr_data(struct aub_mem *mem, uint64_t virt_addr);
70 
71 struct gen_batch_decode_bo aub_mem_get_ppgtt_addr_aub_data(struct aub_mem *mem, uint64_t virt_addr);
72 
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif /* INTEL_AUB_MEM */
79