Subversion Repositories Kolibri OS

Rev

Rev 4075 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4075 Serge 1
/**************************************************************************
2
 *
3
 * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
4
 * All Rights Reserved.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the
8
 * "Software"), to deal in the Software without restriction, including
9
 * without limitation the rights to use, copy, modify, merge, publish,
10
 * distribute, sub license, and/or sell copies of the Software, and to
11
 * permit persons to whom the Software is furnished to do so, subject to
12
 * the following conditions:
13
 *
14
 * The above copyright notice and this permission notice (including the
15
 * next paragraph) shall be included in all copies or substantial portions
16
 * of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
22
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25
 *
26
 **************************************************************************/
27
 
28
#define pr_fmt(fmt) "[TTM] " fmt
29
 
30
#include 
31
#include 
32
#include 
33
#include 
34
#include 
35
#include 
36
#include 
37
#include 
38
#include 
39
 
40
 
41
 
5078 serge 42
int ttm_mem_global_init(struct ttm_mem_global *glob)
4075 Serge 43
{
44
	int ret;
5078 serge 45
	int i;
4075 Serge 46
 
5078 serge 47
	spin_lock_init(&glob->lock);
4075 Serge 48
 
49
 
50
 
5078 serge 51
	ttm_page_alloc_init(glob, 4*1024);
4075 Serge 52
 
53
	return 0;
5078 serge 54
out_no_zone:
55
	ttm_mem_global_release(glob);
56
	return ret;
4075 Serge 57
}
5078 serge 58
EXPORT_SYMBOL(ttm_mem_global_init);
4075 Serge 59
 
60
void ttm_mem_global_release(struct ttm_mem_global *glob)
61
{
62
	unsigned int i;
63
 
64
	/* let the page allocator first stop the shrink work. */
5078 serge 65
//	ttm_page_alloc_fini();
66
//	ttm_dma_page_alloc_fini();
4075 Serge 67
 
5078 serge 68
 
4075 Serge 69
}
70
EXPORT_SYMBOL(ttm_mem_global_release);
71
 
72
 
73
 
74
size_t ttm_round_pot(size_t size)
75
{
76
	if ((size & (size - 1)) == 0)
77
		return size;
78
	else if (size > PAGE_SIZE)
79
		return PAGE_ALIGN(size);
80
	else {
81
		size_t tmp_size = 4;
82
 
83
		while (tmp_size < size)
84
			tmp_size <<= 1;
85
 
86
		return tmp_size;
87
	}
88
	return 0;
89
}
90
EXPORT_SYMBOL(ttm_round_pot);