Subversion Repositories Kolibri OS

Rev

Rev 5078 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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