1/*
2 * Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Axel D��rfler, axeld@pinc-software.de
7 */
8
9
10#include "accelerant.h"
11#include "intel_extreme.h"
12
13#include <errno.h>
14#include <unistd.h>
15
16
17#undef TRACE
18//#define TRACE_MEMORY
19#ifdef TRACE_MEMORY
20#	define TRACE(x...) _sPrintf("intel_extreme accelerant:" x)
21#else
22#	define TRACE(x...)
23#endif
24
25#define ERROR(x...) _sPrintf("intel_extreme accelerant: " x)
26#define CALLED(x...) TRACE("CALLED %s\n", __PRETTY_FUNCTION__)
27
28
29void
30intel_free_memory(addr_t base)
31{
32	if (base == 0)
33		return;
34
35	intel_free_graphics_memory freeMemory;
36	freeMemory.magic = INTEL_PRIVATE_DATA_MAGIC;
37	freeMemory.buffer_base = base;
38
39	ioctl(gInfo->device, INTEL_FREE_GRAPHICS_MEMORY, &freeMemory,
40		sizeof(freeMemory));
41}
42
43
44status_t
45intel_allocate_memory(size_t size, uint32 flags, addr_t &base)
46{
47	intel_allocate_graphics_memory allocMemory;
48	allocMemory.magic = INTEL_PRIVATE_DATA_MAGIC;
49	allocMemory.size = size;
50	allocMemory.alignment = 0;
51	allocMemory.flags = flags;
52
53	if (ioctl(gInfo->device, INTEL_ALLOCATE_GRAPHICS_MEMORY, &allocMemory,
54			sizeof(allocMemory)) < 0)
55		return errno;
56
57	base = allocMemory.buffer_base;
58	return B_OK;
59}
60
61