hrt_vaddress sh_css_refcount_alloc( int32_t id, const size_t size, const uint16_t attribute) { hrt_vaddress ptr; struct sh_css_refcount_entry *entry = NULL; uint32_t i; assert(size > 0); assert(id != FREE_BUF_CACHE); for (i = 0; i < myrefcount.size; i++) { entry = &myrefcount.items[i]; if ((entry->id == FREE_BUF_CACHE) && (entry->size == size)) { entry->id = id; assert(entry->count == 0); entry->count = 1; assert(entry->data != mmgr_NULL); if (attribute & MMGR_ATTRIBUTE_CLEARED) mmgr_clear(entry->data, size); sh_css_dtrace(SH_DBG_TRACE_PRIVATE, "sh_css_refcount_alloc(%x) 0x%x " "reused from cache, refcnt %d\n", id, entry->data, entry->count); return entry->data; } } ptr = mmgr_alloc_attr(size, attribute); assert(ptr != mmgr_NULL); /* This address should not exist in the administration yet */ assert(!find_entry(ptr)); entry = find_free_entry(ptr); assert(entry != NULL); if (entry == NULL) return mmgr_NULL; assert(entry->data == mmgr_NULL); entry->id = id; entry->data = ptr; entry->size = size; entry->count = 1; sh_css_dtrace(SH_DBG_TRACE_PRIVATE, "sh_css_refcount_alloc(%x) 0x%x " "new alloc refcnt %d\n", id, ptr, entry->count); return ptr; }
hrt_vaddress sh_css_load_blob(const unsigned char *blob, unsigned size) { hrt_vaddress target_addr = mmgr_malloc(size); /* this will allocate memory aligned to a DDR word boundary which is required for the CSS DMA to read the instructions. */ assert(blob != NULL); if (target_addr) { mmgr_store(target_addr, blob, size); #ifdef HRT_CSIM { unsigned padded_size = CEIL_MUL(size, HIVE_ISP_DDR_WORD_BYTES); mmgr_clear(target_addr + size, padded_size - size); } #endif } return target_addr; }
void ia_css_frame_zero(struct ia_css_frame *frame) { assert(frame != NULL); mmgr_clear(frame->data, frame->data_bytes); }