Signed-off-by: cwx1272435 <caiyiming4@huawei.com>
This commit is contained in:
cwx1272435 2024-03-25 07:24:09 +00:00
parent 630dd08886
commit 2c5676a021
4 changed files with 40 additions and 0 deletions

View File

@ -86,6 +86,10 @@ int DmabufHeapClose(unsigned int fd)
int DmabufHeapBufferAlloc(unsigned int heapFd, DmabufHeapBuffer *buffer)
{
if (buffer == NULL) {
HILOG_ERROR(LOG_CORE, "%{public}s: buffer is NULL!", __func__);
return -EINVAL;
}
if (buffer->size == 0) {
HILOG_ERROR(LOG_CORE, "alloc buffer size is wrong.");
return -EINVAL;
@ -108,6 +112,10 @@ int DmabufHeapBufferAlloc(unsigned int heapFd, DmabufHeapBuffer *buffer)
int DmabufHeapBufferFree(DmabufHeapBuffer *buffer)
{
if (buffer == NULL) {
HILOG_ERROR(LOG_CORE, "%{public}s: buffer is NULL!", __func__);
return -EINVAL;
}
memtrace((void *)buffer, buffer->size, "DmabufHeap", false);
return close(buffer->fd);
}

View File

@ -85,6 +85,10 @@ bool PurgMemBuilderAppendFunc(struct PurgMemBuilder *builder, PurgMemBuilderFunc
/* build @data content from @builder */
bool PurgMemBuilderBuildAll(struct PurgMemBuilder *builder, void *data, size_t size)
{
if (builder == NULL) {
PM_HILOG_ERROR_C(LOG_CORE, "%{public}s: builder is NULL!", __func__);
return false;
}
if (!(builder->Build)) {
PM_HILOG_ERROR_C(LOG_CORE, "builder has no Build(), %{public}s", builder->name);
return true;
@ -111,6 +115,10 @@ bool PurgMemBuilderAppendBuilder(struct PurgMemBuilder *builder, struct PurgMemB
/* append a guest builder @newcomer to @head */
static void AppendBuilder(struct PurgMemBuilder *head, struct PurgMemBuilder *newcomer)
{
if (head == NULL) {
PM_HILOG_ERROR_C(LOG_CORE, "%{public}s: head is NULL!", __func__);
return;
}
if (!head->nextBuilder) {
head->nextBuilder = newcomer;
return;

View File

@ -41,6 +41,10 @@ struct PurgMem {
static inline void LogPurgMemInfo(struct PurgMem *obj)
{
if (obj == NULL) {
PM_HILOG_ERROR_C(LOG_CORE, "%{public}s: obj is NULL!", __func__);
return;
}
PM_HILOG_INFO_C(LOG_CORE, "purgMemObj(%{public}lx) dataPtr(%{public}lx) dataSizeInput(%{public}zu)"
" builderPtr(%{public}lx) uxpt(%{public}lx)",
(unsigned long)obj, (unsigned long)(obj->dataPtr), obj->dataSizeInput,

View File

@ -182,6 +182,10 @@ PMState InitUxPageTable(UxPageTableStruct *upt, uint64_t addr, size_t len)
HILOG_DEBUG(LOG_CORE, "%{public}s: not support uxpt", __func__);
return PM_OK;
}
if (upt == NULL) {
HILOG_ERROR(LOG_CORE, "%{public}s: upt is NULL!", __func__);
return PM_MMAP_UXPT_FAIL;
}
upt->dataAddr = addr;
upt->dataSize = len;
upt->uxpte = MapUxptePages(upt->dataAddr, upt->dataSize);
@ -198,6 +202,10 @@ PMState DeinitUxPageTable(UxPageTableStruct *upt)
HILOG_DEBUG(LOG_CORE, "%{public}s: not support uxpt", __func__);
return PM_OK;
}
if (upt == NULL) {
HILOG_ERROR(LOG_CORE, "%{public}s: upt is NULL!", __func__);
return PM_MMAP_UXPT_FAIL;
}
size_t size = GetUxPageSize(upt->dataAddr, upt->dataSize);
int unmapRet = 0;
if (upt->uxpte) {
@ -304,6 +312,10 @@ static inline size_t GetIndexInUxpte(uint64_t startAddr, uint64_t currAddr)
static void GetUxpteAt(UxPageTableStruct *upt, uint64_t addr)
{
if (upt == NULL) {
HILOG_ERROR(LOG_CORE, "%{public}s: upt is NULL!", __func__);
return;
}
size_t index = GetIndexInUxpte(upt->dataAddr, addr);
UxpteAdd(&(upt->uxpte[index]), UXPTE_REFCNT_ONE);
@ -313,6 +325,10 @@ static void GetUxpteAt(UxPageTableStruct *upt, uint64_t addr)
static void PutUxpteAt(UxPageTableStruct *upt, uint64_t addr)
{
if (upt == NULL) {
HILOG_ERROR(LOG_CORE, "%{public}s: upt is NULL!", __func__);
return;
}
size_t index = GetIndexInUxpte(upt->dataAddr, addr);
UxpteSub(&(upt->uxpte[index]), UXPTE_REFCNT_ONE);
@ -322,6 +338,10 @@ static void PutUxpteAt(UxPageTableStruct *upt, uint64_t addr)
static void ClearUxpteAt(UxPageTableStruct *upt, uint64_t addr)
{
if (upt == NULL) {
HILOG_ERROR(LOG_CORE, "%{public}s: upt is NULL!", __func__);
return;
}
size_t index = GetIndexInUxpte(upt->dataAddr, addr);
UxpteClear_(&(upt->uxpte[index]));
}