2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015-2017, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 #include <type_support.h>
16 #include <system_types.h>
17 #include <assert_support.h>
18 #include <memory_access.h>
19 #include <ia_css_env.h>
20 #include <hrt/hive_isp_css_mm_hrt.h>
22 const hrt_vaddress mmgr_NULL = (hrt_vaddress)0;
23 const hrt_vaddress mmgr_EXCEPTION = (hrt_vaddress)-1;
26 mmgr_malloc(const size_t size)
28 return mmgr_alloc_attr(size, 0);
31 hrt_vaddress mmgr_alloc_attr(const size_t size, const uint16_t attrs)
33 uint16_t masked_attrs = attrs & MMGR_ATTRIBUTE_MASK;
34 WARN_ON(attrs & MMGR_ATTRIBUTE_CONTIGUOUS);
36 if (masked_attrs & MMGR_ATTRIBUTE_CLEARED) {
37 if (masked_attrs & MMGR_ATTRIBUTE_CACHED)
38 return (ia_css_ptr) hrt_isp_css_mm_calloc_cached(size);
40 return (ia_css_ptr) hrt_isp_css_mm_calloc(size);
42 if (masked_attrs & MMGR_ATTRIBUTE_CACHED)
43 return (ia_css_ptr) hrt_isp_css_mm_alloc_cached(size);
45 return (ia_css_ptr) hrt_isp_css_mm_alloc(size);
50 mmgr_calloc(const size_t N, const size_t size)
52 return mmgr_alloc_attr(size * N, MMGR_ATTRIBUTE_CLEARED);
55 void mmgr_clear(hrt_vaddress vaddr, const size_t size)
58 hmm_set(vaddr, 0, size);
61 void mmgr_load(const hrt_vaddress vaddr, void *data, const size_t size)
64 hmm_load(vaddr, data, size);
68 mmgr_store(const hrt_vaddress vaddr, const void *data, const size_t size)
71 hmm_store(vaddr, data, size);
75 mmgr_mmap(const void *ptr, const size_t size,
76 uint16_t attribute, void *context)
78 struct hrt_userbuffer_attr *userbuffer_attr = context;
79 return hrt_isp_css_mm_alloc_user_ptr(
80 size, (void *)ptr, userbuffer_attr->pgnr,
81 userbuffer_attr->type,
82 attribute & HRT_BUF_FLAG_CACHED);