1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2019 Intel Corporation
4  */
5 
6 #ifndef __I915_GEM_STOLEN_H__
7 #define __I915_GEM_STOLEN_H__
8 
9 #include <linux/types.h>
10 
11 struct drm_i915_private;
12 struct drm_mm_node;
13 struct drm_i915_gem_object;
14 
15 #define i915_stolen_fb drm_mm_node
16 
17 int i915_gem_stolen_insert_node(struct drm_i915_private *dev_priv,
18 				struct drm_mm_node *node, u64 size,
19 				unsigned alignment);
20 int i915_gem_stolen_insert_node_in_range(struct drm_i915_private *dev_priv,
21 					 struct drm_mm_node *node, u64 size,
22 					 unsigned alignment, u64 start,
23 					 u64 end);
24 void i915_gem_stolen_remove_node(struct drm_i915_private *dev_priv,
25 				 struct drm_mm_node *node);
26 struct intel_memory_region *
27 i915_gem_stolen_smem_setup(struct drm_i915_private *i915, u16 type,
28 			   u16 instance);
29 struct intel_memory_region *
30 i915_gem_stolen_lmem_setup(struct drm_i915_private *i915, u16 type,
31 			   u16 instance);
32 
33 struct drm_i915_gem_object *
34 i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
35 			      resource_size_t size);
36 
37 bool i915_gem_object_is_stolen(const struct drm_i915_gem_object *obj);
38 
39 #define I915_GEM_STOLEN_BIAS SZ_128K
40 
41 bool i915_gem_stolen_initialized(const struct drm_i915_private *i915);
42 u64 i915_gem_stolen_area_address(const struct drm_i915_private *i915);
43 u64 i915_gem_stolen_area_size(const struct drm_i915_private *i915);
44 
45 u64 i915_gem_stolen_node_address(const struct drm_i915_private *i915,
46 				 const struct drm_mm_node *node);
47 
48 bool i915_gem_stolen_node_allocated(const struct drm_mm_node *node);
49 u64 i915_gem_stolen_node_offset(const struct drm_mm_node *node);
50 u64 i915_gem_stolen_node_size(const struct drm_mm_node *node);
51 
52 #endif /* __I915_GEM_STOLEN_H__ */
53