23 #include <linux/types.h>
42 #define DMM_ADDR_VIRTUAL(a) \
43 (((struct map_page *)(a) - virtual_mapping_table) * PG_SIZE4K +\
45 #define DMM_ADDR_TO_INDEX(a) (((a) - dyn_mem_map_beg) / PG_SIZE4K)
62 static struct map_page *virtual_mapping_table;
63 static u32 free_region;
65 static u32 dyn_mem_map_beg;
66 static u32 table_size;
71 static struct map_page *get_mapped_region(
u32 addrs);
87 dyn_mem_map_beg =
addr;
90 virtual_mapping_table =
__vmalloc(table_size *
93 if (virtual_mapping_table ==
NULL)
105 pr_err(
"%s: failure, status 0x%x\n", __func__, status);
125 if (dmm_obj !=
NULL) {
127 *dmm_manager = dmm_obj;
166 vfree(virtual_mapping_table);
183 if (hprocessor !=
NULL)
211 chunk = (
struct map_page *)get_region(addr);
220 dev_dbg(
bridge,
"%s dmm_mgr %p, addr %x, size %x\n\tstatus %x, "
221 "chunk %p", __func__, dmm_mgr, addr, size, status, chunk);
243 node = get_free_region(size);
251 node[rsv_size].
mapped =
false;
264 *prsv_addr = rsv_addr;
271 dev_dbg(
bridge,
"%s dmm_mgr %p, size %x, prsv_addr %p\n\tstatus %x, "
272 "rsv_addr %x, rsv_size %x\n", __func__, dmm_mgr, size,
273 prsv_addr, status, rsv_addr, rsv_size);
290 chunk = get_mapped_region(addr);
302 dev_dbg(
bridge,
"%s: dmm_mgr %p, addr %x, psize %p\n\tstatus %x, "
303 "chunk %p\n", __func__, dmm_mgr, addr, psize, status, chunk);
324 chunk = get_mapped_region(rsv_addr);
351 dev_dbg(
bridge,
"%s: dmm_mgr %p, rsv_addr %x\n\tstatus %x chunk %p",
352 __func__, dmm_mgr, rsv_addr, status, chunk);
367 if (virtual_mapping_table !=
NULL) {
371 curr_region = virtual_mapping_table +
i;
374 dev_dbg(bridge,
"%s: curr_region %p, free_region %d, free_size %d\n",
375 __func__, curr_region, free_region, free_size);
391 if (virtual_mapping_table ==
NULL)
393 if (len > free_size) {
396 while (i < table_size) {
399 if (virtual_mapping_table[i].
reserved ==
false) {
401 if (next_i < table_size &&
402 virtual_mapping_table[next_i].
reserved
405 virtual_mapping_table
410 if (region_size > free_size) {
418 if (len <= free_size) {
419 curr_region = virtual_mapping_table + free_region;
431 static struct map_page *get_mapped_region(
u32 addrs)
436 if (virtual_mapping_table ==
NULL)
440 if (i < table_size && (virtual_mapping_table[i].
mapped ||
442 curr_region = virtual_mapping_table +
i;
456 if (virtual_mapping_table !=
NULL) {
457 for (i = 0; i < table_size; i +=
459 curr_node = virtual_mapping_table +
i;
479 freemem / (1024 * 1024));
481 (((table_size *
PG_SIZE4K) - freemem)) / (1024 * 1024));
483 (bigsize * PG_SIZE4K / (1024 * 1024)));