/* SPDX-License-Identifier: MIT */
/*
 * Copyright © 2019 Intel Corporation
 */

#ifndef __I915_GEM_STOLEN_H__
#define __I915_GEM_STOLEN_H__

#include <linux/types.h>

struct drm_i915_private;
struct drm_mm_node;
struct drm_i915_gem_object;
struct intel_gt;

int i915_gem_stolen_insert_node(struct drm_i915_private *dev_priv,
				struct drm_mm_node *node, u64 size,
				unsigned alignment);
int i915_gem_stolen_insert_node_in_range(struct drm_i915_private *dev_priv,
					 struct drm_mm_node *node, u64 size,
					 unsigned alignment, u64 start,
					 u64 end);
void i915_gem_stolen_remove_node(struct drm_i915_private *dev_priv,
				 struct drm_mm_node *node);
struct intel_memory_region *
i915_gem_stolen_setup(struct intel_gt *gt, u16 type, u16 instance);

struct drm_i915_gem_object *
i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv,
					       resource_size_t stolen_offset,
					       resource_size_t size);

bool i915_gem_object_is_stolen(const struct drm_i915_gem_object *obj);

#define I915_GEM_STOLEN_BIAS SZ_128K

#endif /* __I915_GEM_STOLEN_H__ */
