From 252932358569af6b99a82f40014189e83e396381 Mon Sep 17 00:00:00 2001 From: haizhouyang Date: Wed, 19 May 2021 17:22:58 +0800 Subject: [PATCH 1/3] add spi-dma support --- support/platform/include/dmac_core.h | 187 ++++--- support/platform/src/dmac_core.c | 468 +++++++++++------- .../test/unittest/common/hdf_spi_test.cpp | 13 + test/unittest/platform/common/spi_test.c | 142 +++++- test/unittest/platform/common/spi_test.h | 1 + 5 files changed, 536 insertions(+), 275 deletions(-) diff --git a/support/platform/include/dmac_core.h b/support/platform/include/dmac_core.h index 4e4eab4a7..174588d83 100644 --- a/support/platform/include/dmac_core.h +++ b/support/platform/include/dmac_core.h @@ -13,9 +13,9 @@ #include "hdf_device.h" #include "hdf_device_desc.h" #include "hdf_object.h" +#include "los_event.h" #include "osal_mutex.h" #include "osal_spinlock.h" -#include "los_event.h" #ifdef __cplusplus #if __cplusplus @@ -23,114 +23,145 @@ extern "C" { #endif #endif /* __cplusplus */ -typedef void DmacCallback(void *callbackData, int status); -typedef EVENT_CB_S DmacEvent; +#define PERIPH_ADDR_INVALID 0xfff +#define DMAC_CHAN_NUM_MAX 100 -#define DmaEventInit(event) LOS_EventInit(event) -#define DmaEventSignal(event, bit) LOS_EventWrite(event, bit) +#define DmaEventInit(event) LOS_EventInit(event) +#define DmaEventSignal(event, bit) LOS_EventWrite(event, bit) #define DmaEventWait(event, bit, timeout) LOS_EventRead(event, bit, LOS_WAITMODE_OR + LOS_WAITMODE_CLR, timeout) +typedef void DmacCallback(void *callbackData, int status); +typedef EVENT_CB_S DmacEvent; + /* definition for the return value */ -#define DMAC_ERROR_BASE 0x100 -#define DMAC_CHANNEL_INVALID ((DMAC_ERROR_BASE) + 1) -#define DMAC_TRXFERSIZE_INVALID ((DMAC_ERROR_BASE) + 2) -#define DMAC_SOURCE_ADDRESS_INVALID ((DMAC_ERROR_BASE) + 3) -#define DMAC_DESTINATION_ADDRESS_INVALID ((DMAC_ERROR_BASE) + 4) -#define DMAC_MEMORY_ADDRESS_INVALID ((DMAC_ERROR_BASE) + 5) -#define DMAC_PERIPHERAL_ID_INVALID ((DMAC_ERROR_BASE) + 6) -#define DMAC_DIRECTION_ERROR ((DMAC_ERROR_BASE) + 7) -#define DMAC_TRXFER_ERROR ((DMAC_ERROR_BASE) + 8) -#define DMAC_LLIHEAD_ERROR ((DMAC_ERROR_BASE) + 9) -#define DMAC_SWIDTH_ERROR ((DMAC_ERROR_BASE) + 0xa) -#define DMAC_LLI_ADDRESS_INVALID ((DMAC_ERROR_BASE) + 0xb) -#define DMAC_TRANS_CONTROL_INVALID ((DMAC_ERROR_BASE) + 0xc) -#define DMAC_MEMORY_ALLOCATE_ERROR ((DMAC_ERROR_BASE) + 0xd) -#define DMAC_NOT_FINISHED ((DMAC_ERROR_BASE) + 0xe) -#define DMAC_TIMEOUT ((DMAC_ERROR_BASE) + 0xf) -#define DMAC_CHN_SUCCESS ((DMAC_ERROR_BASE) + 0x10) -#define DMAC_CHN_ERROR ((DMAC_ERROR_BASE) + 0x11) -#define DMAC_CHN_TIMEOUT ((DMAC_ERROR_BASE) + 0x12) -#define DMAC_CHN_ALLOCAT ((DMAC_ERROR_BASE) + 0x13) -#define DMAC_CHN_VACANCY ((DMAC_ERROR_BASE) + 0x14) - -#define DMA_EVENT_WAIT_DEF_TIME ((LOSCFG_BASE_CORE_TICK_PER_SECOND) * 5) -#define DMAC_EVENT_DONE 0x1 -#define DMAC_EVENT_ERROR 0x2 - -#define TRASFER_TYPE_M2M 0x0 -#define TRASFER_TYPE_P2M 0x1 -#define TRASFER_TYPE_M2P 0x2 -#define PERIPHERALID_INVILD 0xfff - -#define DMAC_CHAN_NUM_MAX 100 +enum DmacErrorNumber { + DMAC_ERROR_BASE = 0x100, + DMAC_CHANNEL_INVALID = DMAC_ERROR_BASE + 1, + DMAC_TRXFERSIZE_INVALID = DMAC_ERROR_BASE + 2, + DMAC_SOURCE_ADDRESS_INVALID = DMAC_ERROR_BASE + 3, + DMAC_DESTINATION_ADDRESS_INVALID = DMAC_ERROR_BASE + 4, + DMAC_MEMORY_ADDRESS_INVALID = DMAC_ERROR_BASE + 5, + DMAC_PERIPHERAL_ID_INVALID = DMAC_ERROR_BASE + 6, + DMAC_DIRECTION_ERROR = DMAC_ERROR_BASE + 7, + DMAC_TRXFER_ERROR = DMAC_ERROR_BASE + 8, + DMAC_LLIHEAD_ERROR = DMAC_ERROR_BASE + 9, + DMAC_SWIDTH_ERROR = DMAC_ERROR_BASE + 0xa, + DMAC_LLI_ADDRESS_INVALID = DMAC_ERROR_BASE + 0xb, + DMAC_TRANS_CONTROL_INVALID = DMAC_ERROR_BASE + 0xc, + DMAC_MEMORY_ALLOCATE_ERROR = DMAC_ERROR_BASE + 0xd, + DMAC_NOT_FINISHED = DMAC_ERROR_BASE + 0xe, + DMAC_TIMEOUT = DMAC_ERROR_BASE + 0xf, + DMAC_CHN_SUCCESS = DMAC_ERROR_BASE + 0x10, + DMAC_CHN_ERROR = DMAC_ERROR_BASE + 0x11, + DMAC_CHN_TIMEOUT = DMAC_ERROR_BASE + 0x12, + DMAC_CHN_ALLOCAT = DMAC_ERROR_BASE + 0x13, + DMAC_CHN_VACANCY = DMAC_ERROR_BASE + 0x14, +}; + +enum DmacEvent { + DMAC_EVENT_DONE = 0x1, + DMAC_EVENT_ERROR = 0x2, +}; +#define DMA_EVENT_WAIT_DEF_TIME ((LOSCFG_BASE_CORE_TICK_PER_SECOND) * 5) + +enum DmacTransferType { + TRASFER_TYPE_M2M = 0x0, + TRASFER_TYPE_P2M = 0x1, + TRASFER_TYPE_M2P = 0x2, +}; struct DmacMsg { - UINTPTR srcAddr; - UINTPTR destAddr; - unsigned int transferSize; - unsigned int direct; /* 0: mem to mem; 1: periph to mem; 2:mem to periph */ + uintptr_t srcAddr; + uintptr_t destAddr; + uint8_t srcWidth; // src data width in bytes + uint8_t destWidth; // dest data width in bytes + uint8_t transType; // 0: mem to mem; 1: periph to mem; 2:mem to periph + size_t transLen; DmacCallback *cb; void *para; }; -/* structure for LLI */ +static inline uintptr_t DmacMsgGetPeriphAddr(struct DmacMsg *msg) +{ + return (msg->transType == TRASFER_TYPE_M2P) ? msg->destAddr : + (msg->transType == TRASFER_TYPE_P2M) ? msg->srcAddr : PERIPH_ADDR_INVALID; +} + +#define DMAC_LLI_HEAD \ + uintptr_t nextLli; \ + uintptr_t reserved0[6]; \ + unsigned long count; \ + uintptr_t srcAddr; \ + uintptr_t reserved1; \ + uintptr_t destAddr; \ + uintptr_t reserved2; \ + unsigned long config; + +struct DmacLliHead { + DMAC_LLI_HEAD +}; +#define DMAC_LLI_HEAD_SIZE (sizeof(struct DmacLliHead)) + +#define DMAC_LLI_SIZE 64 // must be 64 Bytes aligned struct DmacLli { - /* must be 64Byte aligned */ - long long nextLli; - unsigned int reserved[5]; - unsigned int count; - long long srcAddr; - long long destAddr; - unsigned int config; - unsigned int pad[51]; + DMAC_LLI_HEAD + uint8_t pad[DMAC_LLI_SIZE - DMAC_LLI_HEAD_SIZE]; }; struct DmacChanInfo { - unsigned int channel; - unsigned int status; - unsigned int useStatus; - unsigned int transferType; - unsigned int width; - unsigned int config; - long long lliEnFlag; + uint16_t channel; + int status; + int useStatus; + int transType; + uint8_t srcWidth; // src data width in bytes + uint8_t destWidth; // dest data width in bytes + unsigned long config; // cpu width expected + uintptr_t lliEnFlag; DmacEvent waitEvent; DmacCallback *callback; void *callbackData; - unsigned int lliCnt; + uint16_t lliCnt; struct DmacLli *lli; + void *dummyPage; }; struct DmaCntlr { struct IDeviceIoService service; struct HdfDeviceObject *device; - unsigned int index; - unsigned int irq; - unsigned int phyBase; - char *remapBase; - unsigned int regSize; - unsigned int maxTransSize; - unsigned int channelNum; + uint16_t index; + uint32_t irq; + uintptr_t phyBase; + volatile unsigned char *remapBase; + size_t regSize; + size_t maxTransSize; + uint16_t channelNum; OsalSpinlock lock; struct DmacChanInfo *channelList; - int (*getChanInfo)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, unsigned int periphAddr); - int (*dmaChanEnable)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo); - int (*dmaM2mChanEnable)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, - UINTPTR src, UINTPTR dest, unsigned int length); - void (*dmacChanDisable)(struct DmaCntlr *cntlr, unsigned int channel); - void (*dmacCacheInv)(UINTPTR addr, UINTPTR end); - void (*dmacCacheFlush)(UINTPTR addr, UINTPTR end); - void *(*dmacPaddrToVaddr)(long long paddr); - unsigned long (*dmacVaddrToPaddr)(void *vaddr); - unsigned int (*dmacGetChanStatus)(struct DmaCntlr *cntlr, unsigned int chan); - unsigned int (*dmacGetCurrDestAddr)(struct DmaCntlr *cntlr, unsigned int chan); + int32_t (*getChanInfo)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, struct DmacMsg *msg); + int32_t (*dmaChanEnable)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo); + int32_t (*dmaM2mChanEnable)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, + uintptr_t src, uintptr_t dest, size_t length); + void (*dmacChanDisable)(struct DmaCntlr *cntlr, uint16_t channel); + void (*dmacCacheInv)(uintptr_t vaddr, uintptr_t vend); + void (*dmacCacheFlush)(uintptr_t vaddr, uintptr_t vend); + void *(*dmacPaddrToVaddr)(uintptr_t paddr); + uintptr_t (*dmacVaddrToPaddr)(void *vaddr); + int (*dmacGetChanStatus)(struct DmaCntlr *cntlr, uint16_t chan); + uintptr_t (*dmacGetCurrDestAddr)(struct DmaCntlr *cntlr, uint16_t chan); void *private; }; struct DmaCntlr *DmaCntlrCreate(struct HdfDeviceObject *dev); + void DmaCntlrDestroy(struct DmaCntlr *cntlr); + +int32_t DmacCntlrAdd(struct DmaCntlr *cntlr); + +void DmacCntlrRemove(struct DmaCntlr *cntlr); + int32_t DmaCntlrTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg); -int DmacInit(struct DmaCntlr *cntlr); -unsigned int DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, unsigned int chan); + +uintptr_t DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, uint16_t chan); #ifdef __cplusplus #if __cplusplus diff --git a/support/platform/src/dmac_core.c b/support/platform/src/dmac_core.c index 320fcf5cd..5138bfd7c 100644 --- a/support/platform/src/dmac_core.c +++ b/support/platform/src/dmac_core.c @@ -1,5 +1,4 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. +/* * Copyright (c) 2020-2021 Huawei Device Co., Ltd. * * HDF is dual licensed: you can use it either under the terms of * the GPL, or the BSD license, at your option. @@ -17,21 +16,94 @@ #define DMA_ALIGN_SIZE 256 -static int DmacCheck(struct DmaCntlr *cntlr) +static int32_t DmacCntlrCheckOps(struct DmaCntlr *cntlr) { - if (cntlr == NULL || - cntlr->channelNum == 0 || - cntlr->dmacGetChanStatus == NULL || - cntlr->dmacCacheFlush == NULL || - cntlr->dmacCacheInv == NULL || - cntlr->dmaM2mChanEnable == NULL || - cntlr->dmacPaddrToVaddr == NULL || - cntlr->dmaChanEnable == NULL || - cntlr->dmacVaddrToPaddr == NULL || - cntlr->getChanInfo == NULL || - cntlr->dmacChanDisable == NULL || - cntlr->dmacGetCurrDestAddr == NULL) { - return HDF_FAILURE; + if (cntlr->getChanInfo == NULL) { + HDF_LOGE("%s: getChanInfo is null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->dmaChanEnable == NULL) { + HDF_LOGE("%s: dmaChanEnable is null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->dmaM2mChanEnable == NULL) { + HDF_LOGE("%s: dmaM2mChanEnable is null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->dmacChanDisable == NULL) { + HDF_LOGE("%s: dmacChanDisable is null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->dmacCacheInv == NULL) { + HDF_LOGE("%s: dmacCacheInv null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->dmacCacheFlush == NULL) { + HDF_LOGE("%s: dmacCacheFlush null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->dmacPaddrToVaddr == NULL) { + HDF_LOGE("%s: dmacPaddrToVaddr null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->dmacVaddrToPaddr == NULL) { + HDF_LOGE("%s: dmacVaddrToPaddr null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->dmacGetChanStatus == NULL) { + HDF_LOGE("%s: dmacGetChanStatus null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->dmacGetCurrDestAddr == NULL) { + HDF_LOGE("%s: dmacGetCurrDestAddr null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + return HDF_SUCCESS; +} + +static int32_t DmacCntlrCheckParam(struct DmaCntlr *cntlr) +{ + if (cntlr == NULL) { + HDF_LOGE("%s: cntlr is null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->maxTransSize == 0) { + HDF_LOGE("%s: cntlr is null", __func__); + return HDF_ERR_INVALID_OBJECT; + } + if (cntlr->channelNum == 0 || cntlr->channelNum > DMAC_CHAN_NUM_MAX ) { + HDF_LOGE("%s: invalid channelNum:%u", __func__, cntlr->channelNum); + return HDF_ERR_INVALID_OBJECT; + } + return HDF_SUCCESS; +} + +static int32_t DmacCntlrCheckInit(struct DmaCntlr *cntlr) +{ + int32_t ret; + + ret = DmacCntlrCheckParam(cntlr); + if (ret != HDF_SUCCESS) { + return ret; + } + ret = DmacCntlrCheckOps(cntlr); + if (ret != HDF_SUCCESS) { + return ret; + } + return HDF_SUCCESS; +} + +static int32_t DmacCntlrCheck(struct DmaCntlr *cntlr) +{ + int32_t ret; + + ret = DmacCntlrCheckInit(cntlr); + if (ret != HDF_SUCCESS) { + return ret; + } + if (cntlr->channelList == NULL) { + HDF_LOGE("%s: channelList is null", __func__); + return HDF_ERR_INVALID_OBJECT; } return HDF_SUCCESS; } @@ -45,7 +117,6 @@ struct DmaCntlr *DmaCntlrCreate(struct HdfDeviceObject *device) } cntlr = (struct DmaCntlr *)OsalMemCalloc(sizeof(struct DmaCntlr)); if (cntlr == NULL) { - HDF_LOGE("service malloc fail!\n"); return NULL; } cntlr->device = device; @@ -54,7 +125,7 @@ struct DmaCntlr *DmaCntlrCreate(struct HdfDeviceObject *device) static void DmacFreeLli(struct DmacChanInfo *chanInfo) { - if (chanInfo->lli != NULL) { + if (chanInfo != NULL && chanInfo->lli != NULL) { OsalMemFree(chanInfo->lli); chanInfo->lli = NULL; chanInfo->lliCnt = 0; @@ -66,10 +137,10 @@ static void DmacFreeLli(struct DmacChanInfo *chanInfo) */ void DmaCntlrDestroy(struct DmaCntlr *cntlr) { - int i; + uint16_t i; if (cntlr == NULL || cntlr->channelNum > DMAC_CHAN_NUM_MAX) { - HDF_LOGE("%s: cntlr null or channel invalid!", __func__); + HDF_LOGE("dma cntlr null or channel invalid!"); return; } if (cntlr->channelList != NULL) { @@ -96,7 +167,7 @@ static void DmacEventCallback(struct DmacChanInfo *chanInfo) static void DmacCallbackHandle(struct DmacChanInfo *chanInfo) { - if (chanInfo->transferType == TRASFER_TYPE_M2M) { + if (chanInfo->transType == TRASFER_TYPE_M2M) { DmacEventCallback(chanInfo); return; } @@ -105,37 +176,34 @@ static void DmacCallbackHandle(struct DmacChanInfo *chanInfo) } } -static int DmacWaitM2mSendComplete(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo) +static int32_t DmacWaitM2mSendComplete(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo) { unsigned int ret; - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); - return HDF_FAILURE; + if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { + return HDF_ERR_INVALID_OBJECT; } ret = DmaEventWait(&chanInfo->waitEvent, DMAC_EVENT_DONE | DMAC_EVENT_ERROR, DMA_EVENT_WAIT_DEF_TIME); if (ret == DMAC_EVENT_ERROR) { - HDF_LOGE("wait event error!"); + HDF_LOGE("%s: wait event error", __func__); return DMAC_CHN_ERROR; } else if (ret == LOS_ERRNO_EVENT_READ_TIMEOUT) { - HDF_LOGE("wait event timeout!"); + HDF_LOGE("%s: wait event timeout", __func__); return DMAC_CHN_TIMEOUT; } cntlr->dmacChanDisable(cntlr, chanInfo->channel); - HDF_LOGD("event finish!"); return DMAC_CHN_SUCCESS; } -static int DmacAllocateChannel(struct DmaCntlr *cntlr) +static uint16_t DmacAllocateChannel(struct DmaCntlr *cntlr) { - unsigned int flags; int i; + uint32_t flags; - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); - return HDF_FAILURE; + if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { + return HDF_ERR_INVALID_OBJECT; } OsalSpinLockIrqSave(&cntlr->lock, &flags); @@ -150,12 +218,11 @@ static int DmacAllocateChannel(struct DmaCntlr *cntlr) return HDF_FAILURE; } -static void DmacFreeChannel(struct DmaCntlr *cntlr, unsigned int channel) +static void DmacFreeChannel(struct DmaCntlr *cntlr, uint16_t channel) { uint32_t flags; - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); + if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { return; } @@ -164,155 +231,189 @@ static void DmacFreeChannel(struct DmaCntlr *cntlr, unsigned int channel) OsalSpinUnlockIrqRestore(&cntlr->lock, &flags); } -static struct DmacChanInfo *DmacRequestChannel(struct DmaCntlr *cntlr, - int type, unsigned int periphAddr) +static struct DmacChanInfo *DmacRequestChannel(struct DmaCntlr *cntlr, struct DmacMsg *msg) { - int ret; - struct DmacChanInfo *chanInfo = NULL; + int32_t ret; int chan; + struct DmacChanInfo *chanInfo = NULL; - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); + if (DmacCntlrCheck(cntlr) != HDF_SUCCESS || msg == NULL) { + HDF_LOGE("%s: cntlr check failed or msg invalid", __func__); return NULL; } chan = DmacAllocateChannel(cntlr); if (chan < 0) { - HDF_LOGE("%s: getChannel is NULL", __func__); + HDF_LOGE("%s: allocate channel failed", __func__); return NULL; } chanInfo = &(cntlr->channelList[chan]); chanInfo->channel = (unsigned int)chan; - chanInfo->transferType = type; - ret = cntlr->getChanInfo(cntlr, chanInfo, periphAddr); + chanInfo->transType = msg->transType; + ret = cntlr->getChanInfo(cntlr, chanInfo, msg); if (ret < 0) { DmacFreeChannel(cntlr, chan); - HDF_LOGE("%s: get channel fail ret = %d", __func__, ret); + HDF_LOGE("%s: get channel info failed ret = %d", __func__, ret); return NULL; } - HDF_LOGD("channel = %d, transfer type = %d width = %u, config = 0x%x, lliflag = 0x%x", - ret, chanInfo->transferType, chanInfo->width, chanInfo->config, chanInfo->lliEnFlag); +#ifdef DMA_CORE_DEBUG + HDF_LOGD("chan = %d, type = %d srcWidth = %u, destWidth = %u, config = 0x%x, lliEnflag = 0x%x", + chan, chanInfo->transType, chanInfo->srcWidth, chanInfo->destWidth, chanInfo->config, chanInfo->lliEnFlag); +#endif return chanInfo; } -static int DmacFillLli(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, - UINTPTR srcaddr, UINTPTR dstaddr, unsigned int length) +static uintptr_t DmacGetDummyBuf(struct DmaCntlr *cntlr, struct DmacChanInfo *chan) +{ + if (chan->dummyPage == NULL) { + chan->dummyPage = OsalMemCalloc(sizeof(cntlr->maxTransSize)); + } + + return chan->dummyPage == NULL ? 0 : (uintptr_t)LOS_PaddrQuery(chan->dummyPage); +} + +static inline size_t DmacAlignedTransMax(size_t maxSize, uint8_t srcWidth, uint8_t destWidth) +{ + size_t ret; + uint8_t maxWidth = (srcWidth >= destWidth) ? srcWidth : destWidth; + + ret = (maxWidth == 0) ? maxSize : maxSize - (maxSize % maxWidth); +#ifdef DMA_CORE_DEBUG + HDF_LOGD("%s: max:%zu, srcwidth:%u, dstwidth:%u, alignedmax:%zu", __func__, maxSize, srcWidth, destWidth, ret); +#endif + return ret; +} + +static int32_t DmacFillLli(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, + uintptr_t srcaddr, uintptr_t dstaddr, size_t length) { - unsigned int i; + int32_t ret = HDF_SUCCESS; + uint16_t i; + uint16_t lliNum; struct DmacLli *plli = NULL; - unsigned int lliNum; + size_t alignedMax; + uintptr_t srcDummy = 0; + uintptr_t dstDummy = 0; - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); - return HDF_FAILURE; + if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { + return HDF_ERR_INVALID_OBJECT; + } + if (chanInfo == NULL || chanInfo->lli == NULL) { + HDF_LOGE("%s: chanInfo or lli is null", __func__); + return HDF_ERR_INVALID_PARAM; + } + alignedMax = DmacAlignedTransMax(cntlr->maxTransSize, chanInfo->srcWidth, chanInfo->destWidth); + if (alignedMax == 0) { + HDF_LOGE("%s: maxTransSize:%zu srcWidth:%u dstWidth:%u", __func__, + cntlr->maxTransSize, chanInfo->srcWidth, chanInfo->destWidth); + return HDF_ERR_INVALID_PARAM; } - plli = chanInfo->lli; - if (plli == NULL) { - HDF_LOGE("lli is NULL!\n"); - return HDF_FAILURE; + + if (srcaddr == 0) { + srcaddr = srcDummy = DmacGetDummyBuf(cntlr, chanInfo); + } + if (dstaddr == 0) { + dstaddr = dstDummy = DmacGetDummyBuf(cntlr, chanInfo); } + if (srcaddr == 0 || dstaddr == 0) { + return HDF_ERR_MALLOC_FAIL; + } + lliNum = chanInfo->lliCnt; for (i = 0; i < lliNum; i++) { - plli->nextLli = (long long)cntlr->dmacVaddrToPaddr((void *)plli) + (long long)(i + 1) * sizeof(struct DmacLli); - if (i < lliNum - 1) { - plli->nextLli += chanInfo->lliEnFlag; - plli->count = cntlr->maxTransSize; - } else { - plli->nextLli = 0; - plli->count = (length % cntlr->maxTransSize); - } + plli->nextLli = (uintptr_t)cntlr->dmacVaddrToPaddr((void *)plli) + (uintptr_t)sizeof(struct DmacLli); + plli->nextLli = (i < lliNum - 1) ? (plli->nextLli + chanInfo->lliEnFlag) : 0; + plli->count = (i < lliNum - 1) ? alignedMax: (length % alignedMax); - plli->srcAddr = (long long)srcaddr; - plli->destAddr = (long long)dstaddr; + plli->srcAddr = srcaddr; + plli->destAddr = dstaddr; plli->config = chanInfo->config; - HDF_LOGD("plli->srcAddr = 0x%llx\n", plli->srcAddr); - HDF_LOGD("plli->destAddr = 0x%llx\n", plli->destAddr); - HDF_LOGD("plli->nextLli = 0x%llx\n", plli->nextLli); - HDF_LOGD("plli->config = 0x%x\n", plli->config); - HDF_LOGD("plli->count = 0x%x\n", plli->count); +#ifdef DMA_CORE_DEBUG + HDF_LOGD("plli=0x%lx, next=0x%lx, count=0x%lx, src=0x%lx, dst=0x%lx, cfg=0x%lx", + (uintptr_t)cntlr->dmacVaddrToPaddr(plli), plli->nextLli, plli->count, plli->srcAddr, plli->destAddr, plli->config); +#endif - if (chanInfo->transferType == TRASFER_TYPE_P2M) { + if (chanInfo->transType == TRASFER_TYPE_P2M && dstDummy == 0) { dstaddr += plli->count; - } else if (chanInfo->transferType == TRASFER_TYPE_M2P) { + } else if (chanInfo->transType == TRASFER_TYPE_M2P && srcDummy == 0) { srcaddr += plli->count; } plli++; } - cntlr->dmacCacheFlush((UINTPTR)plli, (UINTPTR)plli + (UINTPTR)(sizeof(struct DmacLli) * lliNum)); + plli = chanInfo->lli; + cntlr->dmacCacheFlush((uintptr_t)plli, (uintptr_t)plli + (uintptr_t)(sizeof(struct DmacLli) * lliNum)); +#ifdef DMA_CORE_DEBUG HDF_LOGD("alloc_addr = 0x%x, alloc_addr + (sizeof(DmacLli) * lli_num)= 0x%x\n", - (UINTPTR)plli, (UINTPTR)plli + (UINTPTR)(sizeof(struct DmacLli) * lliNum)); - return HDF_SUCCESS; + (uintptr_t)plli, (uintptr_t)plli + (uintptr_t)(sizeof(struct DmacLli) * lliNum)); +#endif + return ret; } -int DmacAllocLli(struct DmacChanInfo *chanInfo, unsigned int length, unsigned int maxSize) +static int32_t DmacAllocLli(struct DmacChanInfo *chanInfo, size_t length, size_t maxSize) { - unsigned int lliNum; - unsigned int allocLength; - unsigned long *allocAddr = NULL; + size_t lliNum; + size_t allocLength; + void *allocAddr = NULL; - if (maxSize == 0 || chanInfo == NULL) { - return HDF_FAILURE; - } - lliNum = length / maxSize; - if ((length % maxSize) > 0) { - lliNum++; + if (chanInfo == NULL || maxSize == 0) { + return HDF_ERR_INVALID_PARAM; } + lliNum = (length / maxSize) + ((length % maxSize) > 0 ? 1 : 0); if (lliNum > 2048) { /* 2048: lliNum is not more than 2048 */ - HDF_LOGE("lliNum %u is bigger than 2048", lliNum); - return HDF_FAILURE; + HDF_LOGE("%s: lliNum %u is bigger than 2048", __func__, lliNum); + return HDF_ERR_INVALID_PARAM; } + allocLength = lliNum * sizeof(struct DmacLli); allocLength = ALIGN(allocLength, CACHE_ALIGNED_SIZE); - allocAddr = (unsigned long *)OsalMemAllocAlign(DMA_ALIGN_SIZE, allocLength); + allocAddr = OsalMemAllocAlign(DMA_ALIGN_SIZE, allocLength); if (allocAddr == NULL) { - HDF_LOGE("can't malloc llimem for dma!\n "); + HDF_LOGE("%s: alloc lli mem failed", __func__); return HDF_FAILURE; } if (memset_s(allocAddr, allocLength, 0, allocLength) != EOK) { - HDF_LOGE("memset_s fail"); OsalMemFree(allocAddr); return HDF_FAILURE; } - chanInfo->lliCnt = lliNum; + chanInfo->lliCnt = (uint16_t)lliNum; chanInfo->lli = (struct DmacLli *)allocAddr; return HDF_SUCCESS; } -static int32_t DmacPeriphTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg, unsigned int periphAddr) +static int32_t DmacPeriphTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) { - int ret; + int32_t ret; struct DmacChanInfo *chanInfo = NULL; - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); - return HDF_FAILURE; - } - chanInfo = DmacRequestChannel(cntlr, msg->direct, periphAddr); + chanInfo = DmacRequestChannel(cntlr, msg); if (chanInfo == NULL) { - HDF_LOGE("allocate dma channel fail"); - return HDF_FAILURE; + HDF_LOGE("%s: request channel failed", __func__); + return HDF_ERR_INVALID_PARAM; + } + if (msg->srcAddr == 0 && msg->destAddr == 0) { + HDF_LOGE("%s: src addr & dest addr both null", __func__); + return HDF_ERR_INVALID_PARAM; } chanInfo->callbackData = msg->para; chanInfo->callback = (DmacCallback *)msg->cb; - ret = DmacAllocLli(chanInfo, msg->transferSize, cntlr->maxTransSize); + ret = DmacAllocLli(chanInfo, msg->transLen, + DmacAlignedTransMax(cntlr->maxTransSize, chanInfo->srcWidth, chanInfo->destWidth)); if (ret != HDF_SUCCESS) { - HDF_LOGE("malloc dmalli space failed"); DmacFreeChannel(cntlr, chanInfo->channel); - return HDF_FAILURE; + return ret; } - ret = DmacFillLli(cntlr, chanInfo, msg->srcAddr, msg->destAddr, msg->transferSize); + ret = DmacFillLli(cntlr, chanInfo, msg->srcAddr, msg->destAddr, msg->transLen); if (ret != HDF_SUCCESS) { - HDF_LOGE("build edmalli failed"); DmacFreeLli(chanInfo); DmacFreeChannel(cntlr, chanInfo->channel); - return HDF_FAILURE; + return ret; } ret = cntlr->dmaChanEnable(cntlr, chanInfo); if (ret != HDF_SUCCESS) { - HDF_LOGE("start edma failed!"); + HDF_LOGE("%s: enable channel failed", __func__); DmacFreeLli(chanInfo); DmacFreeChannel(cntlr, chanInfo->channel); return HDF_FAILURE; @@ -320,57 +421,49 @@ static int32_t DmacPeriphTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg, u return HDF_SUCCESS; } -static int DmacM2mTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) +static int32_t DmacM2mTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) { + int32_t ret; + size_t leftSize; + size_t dmaSize; + size_t dmaCount = 0; struct DmacChanInfo *chanInfo = NULL; - unsigned int leftSize; - unsigned int dmaCount = 0; - unsigned int dmaSize; - int ret; - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); - return HDF_FAILURE; + if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { + return HDF_ERR_INVALID_OBJECT; } - chanInfo = DmacRequestChannel(cntlr, TRASFER_TYPE_M2M, PERIPHERALID_INVILD); + chanInfo = DmacRequestChannel(cntlr, msg); if (chanInfo == NULL) { - HDF_LOGE("allocate channel fail\n"); - return -1; + HDF_LOGE("%s: request channel failed", __func__); + return HDF_FAILURE; } chanInfo->callback = msg->cb; chanInfo->callbackData = msg->para; - cntlr->dmacCacheFlush((UINTPTR)msg->srcAddr, (UINTPTR)(msg->srcAddr + msg->transferSize)); - cntlr->dmacCacheInv((UINTPTR)msg->destAddr, (UINTPTR)(msg->destAddr + msg->transferSize)); - leftSize = msg->transferSize; + cntlr->dmacCacheFlush((uintptr_t)msg->srcAddr, (uintptr_t)(msg->srcAddr + msg->transLen)); + cntlr->dmacCacheInv((uintptr_t)msg->destAddr, (uintptr_t)(msg->destAddr + msg->transLen)); + leftSize = msg->transLen; while (leftSize > 0) { - if (leftSize >= cntlr->maxTransSize) { - dmaSize = cntlr->maxTransSize; - } else { - dmaSize = leftSize; - } + dmaSize = (leftSize >= cntlr->maxTransSize) ? cntlr->maxTransSize : leftSize; ret = cntlr->dmaM2mChanEnable(cntlr, chanInfo, msg->srcAddr + dmaCount * cntlr->maxTransSize, msg->destAddr + dmaCount * cntlr->maxTransSize, dmaSize); - if (ret != 0) { - HDF_LOGE("HiedmacStartM2m error"); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: enable channel m2m failed", __func__); DmacFreeChannel(cntlr, chanInfo->channel); if (chanInfo->callback != NULL) { chanInfo->callback(chanInfo->callbackData, DMAC_CHN_ERROR); } - return HDF_FAILURE; + return ret; } ret = DmacWaitM2mSendComplete(cntlr, chanInfo); if (ret != DMAC_CHN_SUCCESS) { - HDF_LOGE("dma transfer error"); + HDF_LOGE("%s: m2m transfer failed, ret = %d", __func__, ret); DmacFreeChannel(cntlr, chanInfo->channel); if (chanInfo->callback != NULL) { chanInfo->callback(chanInfo->callbackData, ret); } return HDF_FAILURE; } - if (dmaSize == 0) { - return HDF_FAILURE; - } leftSize -= dmaSize; dmaCount++; } @@ -383,57 +476,54 @@ static int DmacM2mTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) int32_t DmaCntlrTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) { - unsigned int periphAddr; + uintptr_t phyAddr; - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); - return HDF_FAILURE; + if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { + return HDF_ERR_INVALID_OBJECT; } if (msg == NULL) { - return HDF_FAILURE; + return HDF_ERR_INVALID_PARAM; } - if (msg->direct == TRASFER_TYPE_P2M) { - periphAddr = msg->srcAddr; - cntlr->dmacCacheInv((UINTPTR)cntlr->dmacPaddrToVaddr((paddr_t)msg->destAddr), - (UINTPTR)cntlr->dmacPaddrToVaddr((paddr_t)msg->destAddr) + msg->transferSize); - } else if (msg->direct == TRASFER_TYPE_M2P) { - periphAddr = msg->destAddr; - cntlr->dmacCacheFlush((UINTPTR)cntlr->dmacPaddrToVaddr((paddr_t)msg->srcAddr), - (UINTPTR)cntlr->dmacPaddrToVaddr((paddr_t)msg->srcAddr) + msg->transferSize); - } else if (msg->direct == TRASFER_TYPE_M2M) { + if (msg->transType == TRASFER_TYPE_P2M) { + if (msg->destAddr != 0) { + phyAddr = (uintptr_t)cntlr->dmacPaddrToVaddr((paddr_t)msg->destAddr); + cntlr->dmacCacheInv(phyAddr, (uintptr_t)(phyAddr + msg->transLen)); + } + } else if (msg->transType == TRASFER_TYPE_M2P) { + if (msg->srcAddr != 0) { + phyAddr = (uintptr_t)cntlr->dmacPaddrToVaddr((paddr_t)msg->srcAddr); + cntlr->dmacCacheFlush(phyAddr, (uintptr_t)(phyAddr + msg->transLen)); + } + } else if (msg->transType == TRASFER_TYPE_M2M) { return DmacM2mTransfer(cntlr, msg); } else { - HDF_LOGE("%s: invalid direct %d", __func__, msg->direct); + HDF_LOGE("%s: invalid transType %d", __func__, msg->transType); return HDF_FAILURE; } - return DmacPeriphTransfer(cntlr, msg, periphAddr); + return DmacPeriphTransfer(cntlr, msg); } -unsigned int DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, unsigned int chan) +uintptr_t DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, uint16_t chan) { - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); - return HDF_FAILURE; + if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { + return HDF_ERR_INVALID_OBJECT; } - return cntlr->dmacGetCurrDestAddr(cntlr, chan); } -static uint32_t DmacIsr(int irq, void *dev) +static uint32_t DmacIsr(uint32_t irq, void *dev) { + uint16_t i; + int channelStatus; struct DmaCntlr *cntlr = (struct DmaCntlr *)dev; - unsigned int channelStatus; - unsigned int i; - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); - return HDF_FAILURE; + if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { + return HDF_ERR_INVALID_OBJECT; } if (irq != cntlr->irq || cntlr->channelNum > DMAC_CHAN_NUM_MAX) { - HDF_LOGE("%s: cntlr parm err! irq:%d, channel:%u", - __func__, cntlr->irq, cntlr->channelNum); - return HDF_SUCCESS; + HDF_LOGE("%s: cntlr parm err! irq:%d, channel:%u", __func__, cntlr->irq, cntlr->channelNum); + return HDF_ERR_INVALID_OBJECT; } for (i = 0; i < cntlr->channelNum; i++) { channelStatus = cntlr->dmacGetChanStatus(cntlr, i); @@ -446,39 +536,39 @@ static uint32_t DmacIsr(int irq, void *dev) return HDF_SUCCESS; } -int DmacInit(struct DmaCntlr *cntlr) +int32_t DmacCntlrAdd(struct DmaCntlr *cntlr) { - int i; - int ret; + int32_t ret; + uint16_t i; - if (DmacCheck(cntlr) != HDF_SUCCESS) { - HDF_LOGE("check fail"); - return HDF_FAILURE; + ret = DmacCntlrCheckInit(cntlr); + if (ret != HDF_SUCCESS) { + return ret; } - if (cntlr->channelNum > DMAC_CHAN_NUM_MAX) { - HDF_LOGE("%s: invalid channel:%d", __func__, cntlr->channelNum); - return HDF_FAILURE; + + (void)OsalSpinInit(&cntlr->lock); + ret = OsalRegisterIrq(cntlr->irq, 0, (OsalIRQHandle)DmacIsr, "PlatDmac", cntlr); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: request irq %u failed, ret = %d", __func__, cntlr->irq, ret); + (void)OsalSpinDestroy(&cntlr->lock); + return ret; } - cntlr->remapBase = (char *)OsalIoRemap((unsigned long)cntlr->phyBase, (unsigned long)cntlr->regSize); - OsalSpinInit(&cntlr->lock); cntlr->channelList = (struct DmacChanInfo *)OsalMemCalloc(sizeof(struct DmacChanInfo) * cntlr->channelNum); if (cntlr->channelList == NULL) { - HDF_LOGE("channel list malloc fail"); - OsalIoUnmap((void *)cntlr->remapBase); - return HDF_FAILURE; + HDF_LOGE("%s: alloc channel list failed", __func__); + (void)OsalUnregisterIrq(cntlr->irq, cntlr); + (void)OsalSpinDestroy(&cntlr->lock); + return HDF_ERR_MALLOC_FAIL; } for (i = 0; i < cntlr->channelNum; i++) { cntlr->dmacChanDisable(cntlr, i); DmaEventInit(&(cntlr->channelList[i].waitEvent)); cntlr->channelList[i].useStatus = DMAC_CHN_VACANCY; } - ret = OsalRegisterIrq(cntlr->irq, 0, (OsalIRQHandle)DmacIsr, "PlatDmac", cntlr); - if (ret != HDF_SUCCESS) { - HDF_LOGE("DMA Irq %d request failed, ret = %d\n", cntlr->irq, ret); - OsalMemFree(cntlr->channelList); - cntlr->channelList = NULL; - OsalIoUnmap((void *)cntlr->remapBase); - } - return ret; + return HDF_SUCCESS; } +void DmacCntlrRemove(struct DmaCntlr *cntlr) +{ + (void)cntlr; +} diff --git a/support/platform/test/unittest/common/hdf_spi_test.cpp b/support/platform/test/unittest/common/hdf_spi_test.cpp index 1a9eef0f3..38404e9e6 100644 --- a/support/platform/test/unittest/common/hdf_spi_test.cpp +++ b/support/platform/test/unittest/common/hdf_spi_test.cpp @@ -24,6 +24,7 @@ enum HdfTestCaseCmd { SPI_TRANSFER_TEST, SPI_WRITE_TEST, SPI_READ_TEST, + SPI_DMA_TEST, SPI_RELIABILITY_TEST, SPI_PERFORMANCE_TEST, }; @@ -102,6 +103,18 @@ HWTEST_F(HdfLiteSpiTest, SpiReadTest001, TestSize.Level1) EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); } +/** + * @tc.name: SpiDmaTest001 + * @tc.desc: Spi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteSpiTest, SpiDmaTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_DMA_TEST, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + /** * @tc.name: SpiReliabilityTest001 * @tc.desc: spi function test diff --git a/test/unittest/platform/common/spi_test.c b/test/unittest/platform/common/spi_test.c index 507376eec..7c8abce4c 100644 --- a/test/unittest/platform/common/spi_test.c +++ b/test/unittest/platform/common/spi_test.c @@ -40,16 +40,19 @@ static void SpiTestReleaseHandle(DevHandle handle) #define BITS_PER_WORD 10 #define MAX_SPEED_HZ 10000000 + +static struct SpiCfg g_spiCfg = { + .mode = SPI_CLK_PHASE | SPI_MODE_LOOP, + .bitsPerWord = BITS_PER_WORD, + .maxSpeedHz = MAX_SPEED_HZ, + .transferMode = SPI_POLLING_TRANSFER, +}; + static int32_t SpiSetCfgTest(struct SpiTest *test) { int32_t ret; - struct SpiCfg cfg; - cfg.mode = SPI_CLK_PHASE | SPI_MODE_LOOP; - cfg.bitsPerWord = BITS_PER_WORD; - cfg.maxSpeedHz = MAX_SPEED_HZ; - cfg.transferMode = SPI_INTERRUPT_TRANSFER; - ret = SpiSetCfg(test->handle, &cfg); + ret = SpiSetCfg(test->handle, &g_spiCfg); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: error", __func__); return HDF_FAILURE; @@ -58,6 +61,37 @@ static int32_t SpiSetCfgTest(struct SpiTest *test) return ret; } +static int32_t SpiCmpMemByBits(uint8_t *wbuf, uint8_t *rbuf, uint32_t len, uint8_t bits) +{ + int32_t i; + uint16_t vw; + uint16_t vr; + + if (bits < 4) { + bits = 4; + } else if (bits > 16) { + bits = 16; + } + + for (i = 0; i < len;) { + if (bits <= 8) { + vw = *((uint8_t *)(wbuf + i)) & (~(0xFFFF << bits)); + vr = *((uint8_t *)(rbuf + i)) & (~(0xFFFF << bits)); + } else { + vw = *((uint16_t *)(wbuf + i)) & (~(0xFFFF << bits)); + vr = *((uint16_t *)(rbuf + i)) & (~(0xFFFF << bits)); + } + if (vw != vr) { + HDF_LOGE("%s: compare mem fail(i=%d, vw=%u, vr=%u, bits = %u, len=%u)", + __func__, i, vw, vr, bits, len); + return HDF_FAILURE; + } + i += (bits <= 8) ? 1 : 2; + } + HDF_LOGE("%s: mem size(%u) compare success", __func__, len); + return HDF_SUCCESS; +} + static int32_t SpiTransferTest(struct SpiTest *test) { int32_t i; @@ -74,7 +108,10 @@ static int32_t SpiTransferTest(struct SpiTest *test) return HDF_FAILURE; } for (i = 0; i < test->len; i++) { - HDF_LOGE("%s: wbuf[%d] = 0x%x rbuff[%d] = 0x%x", __func__, i, test->wbuf[i], i, test->rbuf[i]); + HDF_LOGE("%s: wbuf[%d] = 0x%x rbuf[%d] = 0x%x", __func__, i, test->wbuf[i], i, test->rbuf[i]); + } + if (SpiCmpMemByBits(msg.wbuf, msg.rbuf, msg.len, g_spiCfg.bitsPerWord) != HDF_SUCCESS) { + return HDF_FAILURE; } HDF_LOGE("%s: success", __func__); return HDF_SUCCESS; @@ -100,6 +137,87 @@ static int32_t SpiReadTest(struct SpiTest *test) return HDF_SUCCESS; } +#define DMA_TRANSFER_SINGLE_MAX (1024 * 64 - 1) +#define DMA_TRANSFER_SINGLE_CNT (4) +#define DMA_TRANSFER_SINGLE_LEFT (254) +#define DMA_TRANSFER_SIZE_TOTAL (DMA_TRANSFER_SINGLE_MAX * DMA_TRANSFER_SINGLE_CNT + DMA_TRANSFER_SINGLE_LEFT) +#define DMA_TRANSFER_BUF_SEED (0x5A) + +static void SpiSetDmaMsg(struct SpiMsg *msg, uint8_t *wbuf, uint8_t *rbuf, uint32_t len) +{ + uint32_t i; + + wbuf[0] = DMA_TRANSFER_BUF_SEED; + for (i = 1; i < len; i++) { + wbuf[i] = wbuf[i - 1] + 1; + rbuf[i] = 0; + } + msg->wbuf = wbuf; + msg->rbuf = rbuf; + msg->len = len; + msg->csChange = 1; + msg->delayUs = 0, // switch off the CS after transfer + msg->speed = 0; // using default speed + return; +} + +static int32_t SpiDmaTest(struct SpiTest *test) +{ + int ret = HDF_SUCCESS; + uint8_t *wbuf = NULL; + uint8_t *rbuf = NULL; + uint8_t oldMode; + struct SpiMsg msg; + uint32_t len = DMA_TRANSFER_SIZE_TOTAL; + + oldMode = g_spiCfg.transferMode; + g_spiCfg.transferMode = SPI_DMA_TRANSFER; + if (SpiSetCfg(test->handle, &g_spiCfg) != HDF_SUCCESS) { + return HDF_FAILURE; + } + + wbuf = (uint8_t *)OsalMemAllocAlign(CACHE_ALIGNED_SIZE, len); + if (wbuf == NULL) { + return HDF_ERR_MALLOC_FAIL; + } + rbuf = (uint8_t *)OsalMemAllocAlign(CACHE_ALIGNED_SIZE, len); + if (wbuf == NULL) { + OsalMemFree(wbuf); + return HDF_ERR_MALLOC_FAIL; + } + SpiSetDmaMsg(&msg, wbuf, rbuf, len); + ret = SpiTransfer(test->handle, &msg, 1); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: spi transfer err", __func__); + goto __OUT; + } + + ret = SpiCmpMemByBits(msg.wbuf, msg.rbuf, msg.len, g_spiCfg.bitsPerWord); + if (ret != HDF_SUCCESS) { + goto __OUT; + } + + ret = SpiWrite(test->handle, msg.wbuf, msg.len); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: spi write err", __func__); + goto __OUT; + } + + ret = SpiRead(test->handle, msg.rbuf, msg.len); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: spi read err", __func__); + goto __OUT; + } + +__OUT: + OsalMemFree(wbuf); + OsalMemFree(rbuf); + g_spiCfg.transferMode = oldMode; + (void)SpiSetCfg(test->handle, &g_spiCfg); + HDF_LOGE("%s: success", __func__); + return ret; +} + static int32_t SpiReliabilityTest(struct SpiTest *test) { struct SpiCfg cfg = {0}; @@ -113,6 +231,8 @@ static int32_t SpiReliabilityTest(struct SpiTest *test) (void)SpiWrite(test->handle, NULL, -1); (void)SpiRead(test->handle, test->rbuf, test->len); (void)SpiRead(test->handle, NULL, -1); + + (void)test; HDF_LOGE("%s: success", __func__); return HDF_SUCCESS; } @@ -138,6 +258,10 @@ static int32_t SpiTestAll(struct SpiTest *test) error++; } total++; + if (SpiDmaTest(test) != HDF_SUCCESS) { + error++; + } + total++; if (SpiReliabilityTest(test) != HDF_SUCCESS) { error++; } @@ -146,11 +270,12 @@ static int32_t SpiTestAll(struct SpiTest *test) return HDF_SUCCESS; } -struct SpiTestFunc g_spiTestFunc[] = { +static struct SpiTestFunc g_spiTestFunc[] = { {SPI_SET_CFG_TEST, SpiSetCfgTest}, {SPI_TRANSFER_TEST, SpiTransferTest}, {SPI_WRITE_TEST, SpiWriteTest}, {SPI_READ_TEST, SpiReadTest}, + {SPI_DMA_TEST, SpiDmaTest}, {SPI_RELIABILITY_TEST, SpiReliabilityTest}, {SPI_PERFORMANCE_TEST, NULL}, {SPI_TEST_ALL, SpiTestAll}, @@ -161,6 +286,7 @@ static int32_t SpiTestEntry(struct SpiTest *test, int32_t cmd) int32_t i; int32_t ret = HDF_ERR_NOT_SUPPORT; + HDF_LOGE("%s: enter cmd %d ret %d", __func__, cmd, ret); if (test == NULL) { return HDF_ERR_INVALID_OBJECT; } diff --git a/test/unittest/platform/common/spi_test.h b/test/unittest/platform/common/spi_test.h index 31d474a3b..f796261e2 100644 --- a/test/unittest/platform/common/spi_test.h +++ b/test/unittest/platform/common/spi_test.h @@ -17,6 +17,7 @@ enum SpiTestCmd { SPI_TRANSFER_TEST, SPI_WRITE_TEST, SPI_READ_TEST, + SPI_DMA_TEST, SPI_RELIABILITY_TEST, SPI_PERFORMANCE_TEST, SPI_TEST_ALL, -- Gitee From f31aeb5d7187604e5ce6b8aba6e51a2b8164cf59 Mon Sep 17 00:00:00 2001 From: NickYang Date: Wed, 19 May 2021 18:25:32 +0800 Subject: [PATCH 2/3] Revert "add spi-dma support" This reverts commit 252932358569af6b99a82f40014189e83e396381. --- support/platform/include/dmac_core.h | 187 +++---- support/platform/src/dmac_core.c | 468 +++++++----------- .../test/unittest/common/hdf_spi_test.cpp | 13 - test/unittest/platform/common/spi_test.c | 142 +----- test/unittest/platform/common/spi_test.h | 1 - 5 files changed, 275 insertions(+), 536 deletions(-) diff --git a/support/platform/include/dmac_core.h b/support/platform/include/dmac_core.h index 174588d83..4e4eab4a7 100644 --- a/support/platform/include/dmac_core.h +++ b/support/platform/include/dmac_core.h @@ -13,9 +13,9 @@ #include "hdf_device.h" #include "hdf_device_desc.h" #include "hdf_object.h" -#include "los_event.h" #include "osal_mutex.h" #include "osal_spinlock.h" +#include "los_event.h" #ifdef __cplusplus #if __cplusplus @@ -23,145 +23,114 @@ extern "C" { #endif #endif /* __cplusplus */ -#define PERIPH_ADDR_INVALID 0xfff -#define DMAC_CHAN_NUM_MAX 100 - -#define DmaEventInit(event) LOS_EventInit(event) -#define DmaEventSignal(event, bit) LOS_EventWrite(event, bit) -#define DmaEventWait(event, bit, timeout) LOS_EventRead(event, bit, LOS_WAITMODE_OR + LOS_WAITMODE_CLR, timeout) - typedef void DmacCallback(void *callbackData, int status); typedef EVENT_CB_S DmacEvent; -/* definition for the return value */ -enum DmacErrorNumber { - DMAC_ERROR_BASE = 0x100, - DMAC_CHANNEL_INVALID = DMAC_ERROR_BASE + 1, - DMAC_TRXFERSIZE_INVALID = DMAC_ERROR_BASE + 2, - DMAC_SOURCE_ADDRESS_INVALID = DMAC_ERROR_BASE + 3, - DMAC_DESTINATION_ADDRESS_INVALID = DMAC_ERROR_BASE + 4, - DMAC_MEMORY_ADDRESS_INVALID = DMAC_ERROR_BASE + 5, - DMAC_PERIPHERAL_ID_INVALID = DMAC_ERROR_BASE + 6, - DMAC_DIRECTION_ERROR = DMAC_ERROR_BASE + 7, - DMAC_TRXFER_ERROR = DMAC_ERROR_BASE + 8, - DMAC_LLIHEAD_ERROR = DMAC_ERROR_BASE + 9, - DMAC_SWIDTH_ERROR = DMAC_ERROR_BASE + 0xa, - DMAC_LLI_ADDRESS_INVALID = DMAC_ERROR_BASE + 0xb, - DMAC_TRANS_CONTROL_INVALID = DMAC_ERROR_BASE + 0xc, - DMAC_MEMORY_ALLOCATE_ERROR = DMAC_ERROR_BASE + 0xd, - DMAC_NOT_FINISHED = DMAC_ERROR_BASE + 0xe, - DMAC_TIMEOUT = DMAC_ERROR_BASE + 0xf, - DMAC_CHN_SUCCESS = DMAC_ERROR_BASE + 0x10, - DMAC_CHN_ERROR = DMAC_ERROR_BASE + 0x11, - DMAC_CHN_TIMEOUT = DMAC_ERROR_BASE + 0x12, - DMAC_CHN_ALLOCAT = DMAC_ERROR_BASE + 0x13, - DMAC_CHN_VACANCY = DMAC_ERROR_BASE + 0x14, -}; - -enum DmacEvent { - DMAC_EVENT_DONE = 0x1, - DMAC_EVENT_ERROR = 0x2, -}; -#define DMA_EVENT_WAIT_DEF_TIME ((LOSCFG_BASE_CORE_TICK_PER_SECOND) * 5) +#define DmaEventInit(event) LOS_EventInit(event) +#define DmaEventSignal(event, bit) LOS_EventWrite(event, bit) +#define DmaEventWait(event, bit, timeout) LOS_EventRead(event, bit, LOS_WAITMODE_OR + LOS_WAITMODE_CLR, timeout) -enum DmacTransferType { - TRASFER_TYPE_M2M = 0x0, - TRASFER_TYPE_P2M = 0x1, - TRASFER_TYPE_M2P = 0x2, -}; +/* definition for the return value */ +#define DMAC_ERROR_BASE 0x100 +#define DMAC_CHANNEL_INVALID ((DMAC_ERROR_BASE) + 1) +#define DMAC_TRXFERSIZE_INVALID ((DMAC_ERROR_BASE) + 2) +#define DMAC_SOURCE_ADDRESS_INVALID ((DMAC_ERROR_BASE) + 3) +#define DMAC_DESTINATION_ADDRESS_INVALID ((DMAC_ERROR_BASE) + 4) +#define DMAC_MEMORY_ADDRESS_INVALID ((DMAC_ERROR_BASE) + 5) +#define DMAC_PERIPHERAL_ID_INVALID ((DMAC_ERROR_BASE) + 6) +#define DMAC_DIRECTION_ERROR ((DMAC_ERROR_BASE) + 7) +#define DMAC_TRXFER_ERROR ((DMAC_ERROR_BASE) + 8) +#define DMAC_LLIHEAD_ERROR ((DMAC_ERROR_BASE) + 9) +#define DMAC_SWIDTH_ERROR ((DMAC_ERROR_BASE) + 0xa) +#define DMAC_LLI_ADDRESS_INVALID ((DMAC_ERROR_BASE) + 0xb) +#define DMAC_TRANS_CONTROL_INVALID ((DMAC_ERROR_BASE) + 0xc) +#define DMAC_MEMORY_ALLOCATE_ERROR ((DMAC_ERROR_BASE) + 0xd) +#define DMAC_NOT_FINISHED ((DMAC_ERROR_BASE) + 0xe) +#define DMAC_TIMEOUT ((DMAC_ERROR_BASE) + 0xf) +#define DMAC_CHN_SUCCESS ((DMAC_ERROR_BASE) + 0x10) +#define DMAC_CHN_ERROR ((DMAC_ERROR_BASE) + 0x11) +#define DMAC_CHN_TIMEOUT ((DMAC_ERROR_BASE) + 0x12) +#define DMAC_CHN_ALLOCAT ((DMAC_ERROR_BASE) + 0x13) +#define DMAC_CHN_VACANCY ((DMAC_ERROR_BASE) + 0x14) + +#define DMA_EVENT_WAIT_DEF_TIME ((LOSCFG_BASE_CORE_TICK_PER_SECOND) * 5) +#define DMAC_EVENT_DONE 0x1 +#define DMAC_EVENT_ERROR 0x2 + +#define TRASFER_TYPE_M2M 0x0 +#define TRASFER_TYPE_P2M 0x1 +#define TRASFER_TYPE_M2P 0x2 +#define PERIPHERALID_INVILD 0xfff + +#define DMAC_CHAN_NUM_MAX 100 struct DmacMsg { - uintptr_t srcAddr; - uintptr_t destAddr; - uint8_t srcWidth; // src data width in bytes - uint8_t destWidth; // dest data width in bytes - uint8_t transType; // 0: mem to mem; 1: periph to mem; 2:mem to periph - size_t transLen; + UINTPTR srcAddr; + UINTPTR destAddr; + unsigned int transferSize; + unsigned int direct; /* 0: mem to mem; 1: periph to mem; 2:mem to periph */ DmacCallback *cb; void *para; }; -static inline uintptr_t DmacMsgGetPeriphAddr(struct DmacMsg *msg) -{ - return (msg->transType == TRASFER_TYPE_M2P) ? msg->destAddr : - (msg->transType == TRASFER_TYPE_P2M) ? msg->srcAddr : PERIPH_ADDR_INVALID; -} - -#define DMAC_LLI_HEAD \ - uintptr_t nextLli; \ - uintptr_t reserved0[6]; \ - unsigned long count; \ - uintptr_t srcAddr; \ - uintptr_t reserved1; \ - uintptr_t destAddr; \ - uintptr_t reserved2; \ - unsigned long config; - -struct DmacLliHead { - DMAC_LLI_HEAD -}; -#define DMAC_LLI_HEAD_SIZE (sizeof(struct DmacLliHead)) - -#define DMAC_LLI_SIZE 64 // must be 64 Bytes aligned +/* structure for LLI */ struct DmacLli { - DMAC_LLI_HEAD - uint8_t pad[DMAC_LLI_SIZE - DMAC_LLI_HEAD_SIZE]; + /* must be 64Byte aligned */ + long long nextLli; + unsigned int reserved[5]; + unsigned int count; + long long srcAddr; + long long destAddr; + unsigned int config; + unsigned int pad[51]; }; struct DmacChanInfo { - uint16_t channel; - int status; - int useStatus; - int transType; - uint8_t srcWidth; // src data width in bytes - uint8_t destWidth; // dest data width in bytes - unsigned long config; // cpu width expected - uintptr_t lliEnFlag; + unsigned int channel; + unsigned int status; + unsigned int useStatus; + unsigned int transferType; + unsigned int width; + unsigned int config; + long long lliEnFlag; DmacEvent waitEvent; DmacCallback *callback; void *callbackData; - uint16_t lliCnt; + unsigned int lliCnt; struct DmacLli *lli; - void *dummyPage; }; struct DmaCntlr { struct IDeviceIoService service; struct HdfDeviceObject *device; - uint16_t index; - uint32_t irq; - uintptr_t phyBase; - volatile unsigned char *remapBase; - size_t regSize; - size_t maxTransSize; - uint16_t channelNum; + unsigned int index; + unsigned int irq; + unsigned int phyBase; + char *remapBase; + unsigned int regSize; + unsigned int maxTransSize; + unsigned int channelNum; OsalSpinlock lock; struct DmacChanInfo *channelList; - int32_t (*getChanInfo)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, struct DmacMsg *msg); - int32_t (*dmaChanEnable)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo); - int32_t (*dmaM2mChanEnable)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, - uintptr_t src, uintptr_t dest, size_t length); - void (*dmacChanDisable)(struct DmaCntlr *cntlr, uint16_t channel); - void (*dmacCacheInv)(uintptr_t vaddr, uintptr_t vend); - void (*dmacCacheFlush)(uintptr_t vaddr, uintptr_t vend); - void *(*dmacPaddrToVaddr)(uintptr_t paddr); - uintptr_t (*dmacVaddrToPaddr)(void *vaddr); - int (*dmacGetChanStatus)(struct DmaCntlr *cntlr, uint16_t chan); - uintptr_t (*dmacGetCurrDestAddr)(struct DmaCntlr *cntlr, uint16_t chan); + int (*getChanInfo)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, unsigned int periphAddr); + int (*dmaChanEnable)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo); + int (*dmaM2mChanEnable)(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, + UINTPTR src, UINTPTR dest, unsigned int length); + void (*dmacChanDisable)(struct DmaCntlr *cntlr, unsigned int channel); + void (*dmacCacheInv)(UINTPTR addr, UINTPTR end); + void (*dmacCacheFlush)(UINTPTR addr, UINTPTR end); + void *(*dmacPaddrToVaddr)(long long paddr); + unsigned long (*dmacVaddrToPaddr)(void *vaddr); + unsigned int (*dmacGetChanStatus)(struct DmaCntlr *cntlr, unsigned int chan); + unsigned int (*dmacGetCurrDestAddr)(struct DmaCntlr *cntlr, unsigned int chan); void *private; }; struct DmaCntlr *DmaCntlrCreate(struct HdfDeviceObject *dev); - void DmaCntlrDestroy(struct DmaCntlr *cntlr); - -int32_t DmacCntlrAdd(struct DmaCntlr *cntlr); - -void DmacCntlrRemove(struct DmaCntlr *cntlr); - int32_t DmaCntlrTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg); - -uintptr_t DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, uint16_t chan); +int DmacInit(struct DmaCntlr *cntlr); +unsigned int DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, unsigned int chan); #ifdef __cplusplus #if __cplusplus diff --git a/support/platform/src/dmac_core.c b/support/platform/src/dmac_core.c index 5138bfd7c..320fcf5cd 100644 --- a/support/platform/src/dmac_core.c +++ b/support/platform/src/dmac_core.c @@ -1,4 +1,5 @@ -/* * Copyright (c) 2020-2021 Huawei Device Co., Ltd. +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. * * HDF is dual licensed: you can use it either under the terms of * the GPL, or the BSD license, at your option. @@ -16,94 +17,21 @@ #define DMA_ALIGN_SIZE 256 -static int32_t DmacCntlrCheckOps(struct DmaCntlr *cntlr) +static int DmacCheck(struct DmaCntlr *cntlr) { - if (cntlr->getChanInfo == NULL) { - HDF_LOGE("%s: getChanInfo is null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->dmaChanEnable == NULL) { - HDF_LOGE("%s: dmaChanEnable is null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->dmaM2mChanEnable == NULL) { - HDF_LOGE("%s: dmaM2mChanEnable is null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->dmacChanDisable == NULL) { - HDF_LOGE("%s: dmacChanDisable is null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->dmacCacheInv == NULL) { - HDF_LOGE("%s: dmacCacheInv null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->dmacCacheFlush == NULL) { - HDF_LOGE("%s: dmacCacheFlush null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->dmacPaddrToVaddr == NULL) { - HDF_LOGE("%s: dmacPaddrToVaddr null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->dmacVaddrToPaddr == NULL) { - HDF_LOGE("%s: dmacVaddrToPaddr null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->dmacGetChanStatus == NULL) { - HDF_LOGE("%s: dmacGetChanStatus null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->dmacGetCurrDestAddr == NULL) { - HDF_LOGE("%s: dmacGetCurrDestAddr null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - return HDF_SUCCESS; -} - -static int32_t DmacCntlrCheckParam(struct DmaCntlr *cntlr) -{ - if (cntlr == NULL) { - HDF_LOGE("%s: cntlr is null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->maxTransSize == 0) { - HDF_LOGE("%s: cntlr is null", __func__); - return HDF_ERR_INVALID_OBJECT; - } - if (cntlr->channelNum == 0 || cntlr->channelNum > DMAC_CHAN_NUM_MAX ) { - HDF_LOGE("%s: invalid channelNum:%u", __func__, cntlr->channelNum); - return HDF_ERR_INVALID_OBJECT; - } - return HDF_SUCCESS; -} - -static int32_t DmacCntlrCheckInit(struct DmaCntlr *cntlr) -{ - int32_t ret; - - ret = DmacCntlrCheckParam(cntlr); - if (ret != HDF_SUCCESS) { - return ret; - } - ret = DmacCntlrCheckOps(cntlr); - if (ret != HDF_SUCCESS) { - return ret; - } - return HDF_SUCCESS; -} - -static int32_t DmacCntlrCheck(struct DmaCntlr *cntlr) -{ - int32_t ret; - - ret = DmacCntlrCheckInit(cntlr); - if (ret != HDF_SUCCESS) { - return ret; - } - if (cntlr->channelList == NULL) { - HDF_LOGE("%s: channelList is null", __func__); - return HDF_ERR_INVALID_OBJECT; + if (cntlr == NULL || + cntlr->channelNum == 0 || + cntlr->dmacGetChanStatus == NULL || + cntlr->dmacCacheFlush == NULL || + cntlr->dmacCacheInv == NULL || + cntlr->dmaM2mChanEnable == NULL || + cntlr->dmacPaddrToVaddr == NULL || + cntlr->dmaChanEnable == NULL || + cntlr->dmacVaddrToPaddr == NULL || + cntlr->getChanInfo == NULL || + cntlr->dmacChanDisable == NULL || + cntlr->dmacGetCurrDestAddr == NULL) { + return HDF_FAILURE; } return HDF_SUCCESS; } @@ -117,6 +45,7 @@ struct DmaCntlr *DmaCntlrCreate(struct HdfDeviceObject *device) } cntlr = (struct DmaCntlr *)OsalMemCalloc(sizeof(struct DmaCntlr)); if (cntlr == NULL) { + HDF_LOGE("service malloc fail!\n"); return NULL; } cntlr->device = device; @@ -125,7 +54,7 @@ struct DmaCntlr *DmaCntlrCreate(struct HdfDeviceObject *device) static void DmacFreeLli(struct DmacChanInfo *chanInfo) { - if (chanInfo != NULL && chanInfo->lli != NULL) { + if (chanInfo->lli != NULL) { OsalMemFree(chanInfo->lli); chanInfo->lli = NULL; chanInfo->lliCnt = 0; @@ -137,10 +66,10 @@ static void DmacFreeLli(struct DmacChanInfo *chanInfo) */ void DmaCntlrDestroy(struct DmaCntlr *cntlr) { - uint16_t i; + int i; if (cntlr == NULL || cntlr->channelNum > DMAC_CHAN_NUM_MAX) { - HDF_LOGE("dma cntlr null or channel invalid!"); + HDF_LOGE("%s: cntlr null or channel invalid!", __func__); return; } if (cntlr->channelList != NULL) { @@ -167,7 +96,7 @@ static void DmacEventCallback(struct DmacChanInfo *chanInfo) static void DmacCallbackHandle(struct DmacChanInfo *chanInfo) { - if (chanInfo->transType == TRASFER_TYPE_M2M) { + if (chanInfo->transferType == TRASFER_TYPE_M2M) { DmacEventCallback(chanInfo); return; } @@ -176,34 +105,37 @@ static void DmacCallbackHandle(struct DmacChanInfo *chanInfo) } } -static int32_t DmacWaitM2mSendComplete(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo) +static int DmacWaitM2mSendComplete(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo) { unsigned int ret; - if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { - return HDF_ERR_INVALID_OBJECT; + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); + return HDF_FAILURE; } ret = DmaEventWait(&chanInfo->waitEvent, DMAC_EVENT_DONE | DMAC_EVENT_ERROR, DMA_EVENT_WAIT_DEF_TIME); if (ret == DMAC_EVENT_ERROR) { - HDF_LOGE("%s: wait event error", __func__); + HDF_LOGE("wait event error!"); return DMAC_CHN_ERROR; } else if (ret == LOS_ERRNO_EVENT_READ_TIMEOUT) { - HDF_LOGE("%s: wait event timeout", __func__); + HDF_LOGE("wait event timeout!"); return DMAC_CHN_TIMEOUT; } cntlr->dmacChanDisable(cntlr, chanInfo->channel); + HDF_LOGD("event finish!"); return DMAC_CHN_SUCCESS; } -static uint16_t DmacAllocateChannel(struct DmaCntlr *cntlr) +static int DmacAllocateChannel(struct DmaCntlr *cntlr) { + unsigned int flags; int i; - uint32_t flags; - if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { - return HDF_ERR_INVALID_OBJECT; + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); + return HDF_FAILURE; } OsalSpinLockIrqSave(&cntlr->lock, &flags); @@ -218,11 +150,12 @@ static uint16_t DmacAllocateChannel(struct DmaCntlr *cntlr) return HDF_FAILURE; } -static void DmacFreeChannel(struct DmaCntlr *cntlr, uint16_t channel) +static void DmacFreeChannel(struct DmaCntlr *cntlr, unsigned int channel) { uint32_t flags; - if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); return; } @@ -231,189 +164,155 @@ static void DmacFreeChannel(struct DmaCntlr *cntlr, uint16_t channel) OsalSpinUnlockIrqRestore(&cntlr->lock, &flags); } -static struct DmacChanInfo *DmacRequestChannel(struct DmaCntlr *cntlr, struct DmacMsg *msg) +static struct DmacChanInfo *DmacRequestChannel(struct DmaCntlr *cntlr, + int type, unsigned int periphAddr) { - int32_t ret; - int chan; + int ret; struct DmacChanInfo *chanInfo = NULL; + int chan; - if (DmacCntlrCheck(cntlr) != HDF_SUCCESS || msg == NULL) { - HDF_LOGE("%s: cntlr check failed or msg invalid", __func__); + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); return NULL; } chan = DmacAllocateChannel(cntlr); if (chan < 0) { - HDF_LOGE("%s: allocate channel failed", __func__); + HDF_LOGE("%s: getChannel is NULL", __func__); return NULL; } chanInfo = &(cntlr->channelList[chan]); chanInfo->channel = (unsigned int)chan; - chanInfo->transType = msg->transType; - ret = cntlr->getChanInfo(cntlr, chanInfo, msg); + chanInfo->transferType = type; + ret = cntlr->getChanInfo(cntlr, chanInfo, periphAddr); if (ret < 0) { DmacFreeChannel(cntlr, chan); - HDF_LOGE("%s: get channel info failed ret = %d", __func__, ret); + HDF_LOGE("%s: get channel fail ret = %d", __func__, ret); return NULL; } -#ifdef DMA_CORE_DEBUG - HDF_LOGD("chan = %d, type = %d srcWidth = %u, destWidth = %u, config = 0x%x, lliEnflag = 0x%x", - chan, chanInfo->transType, chanInfo->srcWidth, chanInfo->destWidth, chanInfo->config, chanInfo->lliEnFlag); -#endif + HDF_LOGD("channel = %d, transfer type = %d width = %u, config = 0x%x, lliflag = 0x%x", + ret, chanInfo->transferType, chanInfo->width, chanInfo->config, chanInfo->lliEnFlag); return chanInfo; } -static uintptr_t DmacGetDummyBuf(struct DmaCntlr *cntlr, struct DmacChanInfo *chan) -{ - if (chan->dummyPage == NULL) { - chan->dummyPage = OsalMemCalloc(sizeof(cntlr->maxTransSize)); - } - - return chan->dummyPage == NULL ? 0 : (uintptr_t)LOS_PaddrQuery(chan->dummyPage); -} - -static inline size_t DmacAlignedTransMax(size_t maxSize, uint8_t srcWidth, uint8_t destWidth) -{ - size_t ret; - uint8_t maxWidth = (srcWidth >= destWidth) ? srcWidth : destWidth; - - ret = (maxWidth == 0) ? maxSize : maxSize - (maxSize % maxWidth); -#ifdef DMA_CORE_DEBUG - HDF_LOGD("%s: max:%zu, srcwidth:%u, dstwidth:%u, alignedmax:%zu", __func__, maxSize, srcWidth, destWidth, ret); -#endif - return ret; -} - -static int32_t DmacFillLli(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, - uintptr_t srcaddr, uintptr_t dstaddr, size_t length) +static int DmacFillLli(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, + UINTPTR srcaddr, UINTPTR dstaddr, unsigned int length) { - int32_t ret = HDF_SUCCESS; - uint16_t i; - uint16_t lliNum; + unsigned int i; struct DmacLli *plli = NULL; - size_t alignedMax; - uintptr_t srcDummy = 0; - uintptr_t dstDummy = 0; + unsigned int lliNum; - if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { - return HDF_ERR_INVALID_OBJECT; - } - if (chanInfo == NULL || chanInfo->lli == NULL) { - HDF_LOGE("%s: chanInfo or lli is null", __func__); - return HDF_ERR_INVALID_PARAM; - } - alignedMax = DmacAlignedTransMax(cntlr->maxTransSize, chanInfo->srcWidth, chanInfo->destWidth); - if (alignedMax == 0) { - HDF_LOGE("%s: maxTransSize:%zu srcWidth:%u dstWidth:%u", __func__, - cntlr->maxTransSize, chanInfo->srcWidth, chanInfo->destWidth); - return HDF_ERR_INVALID_PARAM; + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); + return HDF_FAILURE; } - plli = chanInfo->lli; - if (srcaddr == 0) { - srcaddr = srcDummy = DmacGetDummyBuf(cntlr, chanInfo); - } - if (dstaddr == 0) { - dstaddr = dstDummy = DmacGetDummyBuf(cntlr, chanInfo); - } - if (srcaddr == 0 || dstaddr == 0) { - return HDF_ERR_MALLOC_FAIL; + plli = chanInfo->lli; + if (plli == NULL) { + HDF_LOGE("lli is NULL!\n"); + return HDF_FAILURE; } - lliNum = chanInfo->lliCnt; for (i = 0; i < lliNum; i++) { - plli->nextLli = (uintptr_t)cntlr->dmacVaddrToPaddr((void *)plli) + (uintptr_t)sizeof(struct DmacLli); - plli->nextLli = (i < lliNum - 1) ? (plli->nextLli + chanInfo->lliEnFlag) : 0; - plli->count = (i < lliNum - 1) ? alignedMax: (length % alignedMax); + plli->nextLli = (long long)cntlr->dmacVaddrToPaddr((void *)plli) + (long long)(i + 1) * sizeof(struct DmacLli); + if (i < lliNum - 1) { + plli->nextLli += chanInfo->lliEnFlag; + plli->count = cntlr->maxTransSize; + } else { + plli->nextLli = 0; + plli->count = (length % cntlr->maxTransSize); + } - plli->srcAddr = srcaddr; - plli->destAddr = dstaddr; + plli->srcAddr = (long long)srcaddr; + plli->destAddr = (long long)dstaddr; plli->config = chanInfo->config; -#ifdef DMA_CORE_DEBUG - HDF_LOGD("plli=0x%lx, next=0x%lx, count=0x%lx, src=0x%lx, dst=0x%lx, cfg=0x%lx", - (uintptr_t)cntlr->dmacVaddrToPaddr(plli), plli->nextLli, plli->count, plli->srcAddr, plli->destAddr, plli->config); -#endif + HDF_LOGD("plli->srcAddr = 0x%llx\n", plli->srcAddr); + HDF_LOGD("plli->destAddr = 0x%llx\n", plli->destAddr); + HDF_LOGD("plli->nextLli = 0x%llx\n", plli->nextLli); + HDF_LOGD("plli->config = 0x%x\n", plli->config); + HDF_LOGD("plli->count = 0x%x\n", plli->count); - if (chanInfo->transType == TRASFER_TYPE_P2M && dstDummy == 0) { + if (chanInfo->transferType == TRASFER_TYPE_P2M) { dstaddr += plli->count; - } else if (chanInfo->transType == TRASFER_TYPE_M2P && srcDummy == 0) { + } else if (chanInfo->transferType == TRASFER_TYPE_M2P) { srcaddr += plli->count; } plli++; } - plli = chanInfo->lli; - cntlr->dmacCacheFlush((uintptr_t)plli, (uintptr_t)plli + (uintptr_t)(sizeof(struct DmacLli) * lliNum)); -#ifdef DMA_CORE_DEBUG + cntlr->dmacCacheFlush((UINTPTR)plli, (UINTPTR)plli + (UINTPTR)(sizeof(struct DmacLli) * lliNum)); HDF_LOGD("alloc_addr = 0x%x, alloc_addr + (sizeof(DmacLli) * lli_num)= 0x%x\n", - (uintptr_t)plli, (uintptr_t)plli + (uintptr_t)(sizeof(struct DmacLli) * lliNum)); -#endif - return ret; + (UINTPTR)plli, (UINTPTR)plli + (UINTPTR)(sizeof(struct DmacLli) * lliNum)); + return HDF_SUCCESS; } -static int32_t DmacAllocLli(struct DmacChanInfo *chanInfo, size_t length, size_t maxSize) +int DmacAllocLli(struct DmacChanInfo *chanInfo, unsigned int length, unsigned int maxSize) { - size_t lliNum; - size_t allocLength; - void *allocAddr = NULL; + unsigned int lliNum; + unsigned int allocLength; + unsigned long *allocAddr = NULL; - if (chanInfo == NULL || maxSize == 0) { - return HDF_ERR_INVALID_PARAM; + if (maxSize == 0 || chanInfo == NULL) { + return HDF_FAILURE; + } + lliNum = length / maxSize; + if ((length % maxSize) > 0) { + lliNum++; } - lliNum = (length / maxSize) + ((length % maxSize) > 0 ? 1 : 0); if (lliNum > 2048) { /* 2048: lliNum is not more than 2048 */ - HDF_LOGE("%s: lliNum %u is bigger than 2048", __func__, lliNum); - return HDF_ERR_INVALID_PARAM; + HDF_LOGE("lliNum %u is bigger than 2048", lliNum); + return HDF_FAILURE; } - allocLength = lliNum * sizeof(struct DmacLli); allocLength = ALIGN(allocLength, CACHE_ALIGNED_SIZE); - allocAddr = OsalMemAllocAlign(DMA_ALIGN_SIZE, allocLength); + allocAddr = (unsigned long *)OsalMemAllocAlign(DMA_ALIGN_SIZE, allocLength); if (allocAddr == NULL) { - HDF_LOGE("%s: alloc lli mem failed", __func__); + HDF_LOGE("can't malloc llimem for dma!\n "); return HDF_FAILURE; } if (memset_s(allocAddr, allocLength, 0, allocLength) != EOK) { + HDF_LOGE("memset_s fail"); OsalMemFree(allocAddr); return HDF_FAILURE; } - chanInfo->lliCnt = (uint16_t)lliNum; + chanInfo->lliCnt = lliNum; chanInfo->lli = (struct DmacLli *)allocAddr; return HDF_SUCCESS; } -static int32_t DmacPeriphTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) +static int32_t DmacPeriphTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg, unsigned int periphAddr) { - int32_t ret; + int ret; struct DmacChanInfo *chanInfo = NULL; - chanInfo = DmacRequestChannel(cntlr, msg); - if (chanInfo == NULL) { - HDF_LOGE("%s: request channel failed", __func__); - return HDF_ERR_INVALID_PARAM; + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); + return HDF_FAILURE; } - if (msg->srcAddr == 0 && msg->destAddr == 0) { - HDF_LOGE("%s: src addr & dest addr both null", __func__); - return HDF_ERR_INVALID_PARAM; + chanInfo = DmacRequestChannel(cntlr, msg->direct, periphAddr); + if (chanInfo == NULL) { + HDF_LOGE("allocate dma channel fail"); + return HDF_FAILURE; } chanInfo->callbackData = msg->para; chanInfo->callback = (DmacCallback *)msg->cb; - ret = DmacAllocLli(chanInfo, msg->transLen, - DmacAlignedTransMax(cntlr->maxTransSize, chanInfo->srcWidth, chanInfo->destWidth)); + ret = DmacAllocLli(chanInfo, msg->transferSize, cntlr->maxTransSize); if (ret != HDF_SUCCESS) { + HDF_LOGE("malloc dmalli space failed"); DmacFreeChannel(cntlr, chanInfo->channel); - return ret; + return HDF_FAILURE; } - ret = DmacFillLli(cntlr, chanInfo, msg->srcAddr, msg->destAddr, msg->transLen); + ret = DmacFillLli(cntlr, chanInfo, msg->srcAddr, msg->destAddr, msg->transferSize); if (ret != HDF_SUCCESS) { + HDF_LOGE("build edmalli failed"); DmacFreeLli(chanInfo); DmacFreeChannel(cntlr, chanInfo->channel); - return ret; + return HDF_FAILURE; } ret = cntlr->dmaChanEnable(cntlr, chanInfo); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: enable channel failed", __func__); + HDF_LOGE("start edma failed!"); DmacFreeLli(chanInfo); DmacFreeChannel(cntlr, chanInfo->channel); return HDF_FAILURE; @@ -421,49 +320,57 @@ static int32_t DmacPeriphTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) return HDF_SUCCESS; } -static int32_t DmacM2mTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) +static int DmacM2mTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) { - int32_t ret; - size_t leftSize; - size_t dmaSize; - size_t dmaCount = 0; struct DmacChanInfo *chanInfo = NULL; + unsigned int leftSize; + unsigned int dmaCount = 0; + unsigned int dmaSize; + int ret; - if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { - return HDF_ERR_INVALID_OBJECT; + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); + return HDF_FAILURE; } - chanInfo = DmacRequestChannel(cntlr, msg); + chanInfo = DmacRequestChannel(cntlr, TRASFER_TYPE_M2M, PERIPHERALID_INVILD); if (chanInfo == NULL) { - HDF_LOGE("%s: request channel failed", __func__); - return HDF_FAILURE; + HDF_LOGE("allocate channel fail\n"); + return -1; } chanInfo->callback = msg->cb; chanInfo->callbackData = msg->para; - cntlr->dmacCacheFlush((uintptr_t)msg->srcAddr, (uintptr_t)(msg->srcAddr + msg->transLen)); - cntlr->dmacCacheInv((uintptr_t)msg->destAddr, (uintptr_t)(msg->destAddr + msg->transLen)); - leftSize = msg->transLen; + cntlr->dmacCacheFlush((UINTPTR)msg->srcAddr, (UINTPTR)(msg->srcAddr + msg->transferSize)); + cntlr->dmacCacheInv((UINTPTR)msg->destAddr, (UINTPTR)(msg->destAddr + msg->transferSize)); + leftSize = msg->transferSize; while (leftSize > 0) { - dmaSize = (leftSize >= cntlr->maxTransSize) ? cntlr->maxTransSize : leftSize; + if (leftSize >= cntlr->maxTransSize) { + dmaSize = cntlr->maxTransSize; + } else { + dmaSize = leftSize; + } ret = cntlr->dmaM2mChanEnable(cntlr, chanInfo, msg->srcAddr + dmaCount * cntlr->maxTransSize, msg->destAddr + dmaCount * cntlr->maxTransSize, dmaSize); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: enable channel m2m failed", __func__); + if (ret != 0) { + HDF_LOGE("HiedmacStartM2m error"); DmacFreeChannel(cntlr, chanInfo->channel); if (chanInfo->callback != NULL) { chanInfo->callback(chanInfo->callbackData, DMAC_CHN_ERROR); } - return ret; + return HDF_FAILURE; } ret = DmacWaitM2mSendComplete(cntlr, chanInfo); if (ret != DMAC_CHN_SUCCESS) { - HDF_LOGE("%s: m2m transfer failed, ret = %d", __func__, ret); + HDF_LOGE("dma transfer error"); DmacFreeChannel(cntlr, chanInfo->channel); if (chanInfo->callback != NULL) { chanInfo->callback(chanInfo->callbackData, ret); } return HDF_FAILURE; } + if (dmaSize == 0) { + return HDF_FAILURE; + } leftSize -= dmaSize; dmaCount++; } @@ -476,54 +383,57 @@ static int32_t DmacM2mTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) int32_t DmaCntlrTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) { - uintptr_t phyAddr; + unsigned int periphAddr; - if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { - return HDF_ERR_INVALID_OBJECT; + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); + return HDF_FAILURE; } if (msg == NULL) { - return HDF_ERR_INVALID_PARAM; + return HDF_FAILURE; } - if (msg->transType == TRASFER_TYPE_P2M) { - if (msg->destAddr != 0) { - phyAddr = (uintptr_t)cntlr->dmacPaddrToVaddr((paddr_t)msg->destAddr); - cntlr->dmacCacheInv(phyAddr, (uintptr_t)(phyAddr + msg->transLen)); - } - } else if (msg->transType == TRASFER_TYPE_M2P) { - if (msg->srcAddr != 0) { - phyAddr = (uintptr_t)cntlr->dmacPaddrToVaddr((paddr_t)msg->srcAddr); - cntlr->dmacCacheFlush(phyAddr, (uintptr_t)(phyAddr + msg->transLen)); - } - } else if (msg->transType == TRASFER_TYPE_M2M) { + if (msg->direct == TRASFER_TYPE_P2M) { + periphAddr = msg->srcAddr; + cntlr->dmacCacheInv((UINTPTR)cntlr->dmacPaddrToVaddr((paddr_t)msg->destAddr), + (UINTPTR)cntlr->dmacPaddrToVaddr((paddr_t)msg->destAddr) + msg->transferSize); + } else if (msg->direct == TRASFER_TYPE_M2P) { + periphAddr = msg->destAddr; + cntlr->dmacCacheFlush((UINTPTR)cntlr->dmacPaddrToVaddr((paddr_t)msg->srcAddr), + (UINTPTR)cntlr->dmacPaddrToVaddr((paddr_t)msg->srcAddr) + msg->transferSize); + } else if (msg->direct == TRASFER_TYPE_M2M) { return DmacM2mTransfer(cntlr, msg); } else { - HDF_LOGE("%s: invalid transType %d", __func__, msg->transType); + HDF_LOGE("%s: invalid direct %d", __func__, msg->direct); return HDF_FAILURE; } - return DmacPeriphTransfer(cntlr, msg); + return DmacPeriphTransfer(cntlr, msg, periphAddr); } -uintptr_t DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, uint16_t chan) +unsigned int DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, unsigned int chan) { - if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { - return HDF_ERR_INVALID_OBJECT; + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); + return HDF_FAILURE; } + return cntlr->dmacGetCurrDestAddr(cntlr, chan); } -static uint32_t DmacIsr(uint32_t irq, void *dev) +static uint32_t DmacIsr(int irq, void *dev) { - uint16_t i; - int channelStatus; struct DmaCntlr *cntlr = (struct DmaCntlr *)dev; + unsigned int channelStatus; + unsigned int i; - if (DmacCntlrCheck(cntlr) != HDF_SUCCESS) { - return HDF_ERR_INVALID_OBJECT; + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); + return HDF_FAILURE; } if (irq != cntlr->irq || cntlr->channelNum > DMAC_CHAN_NUM_MAX) { - HDF_LOGE("%s: cntlr parm err! irq:%d, channel:%u", __func__, cntlr->irq, cntlr->channelNum); - return HDF_ERR_INVALID_OBJECT; + HDF_LOGE("%s: cntlr parm err! irq:%d, channel:%u", + __func__, cntlr->irq, cntlr->channelNum); + return HDF_SUCCESS; } for (i = 0; i < cntlr->channelNum; i++) { channelStatus = cntlr->dmacGetChanStatus(cntlr, i); @@ -536,39 +446,39 @@ static uint32_t DmacIsr(uint32_t irq, void *dev) return HDF_SUCCESS; } -int32_t DmacCntlrAdd(struct DmaCntlr *cntlr) +int DmacInit(struct DmaCntlr *cntlr) { - int32_t ret; - uint16_t i; + int i; + int ret; - ret = DmacCntlrCheckInit(cntlr); - if (ret != HDF_SUCCESS) { - return ret; + if (DmacCheck(cntlr) != HDF_SUCCESS) { + HDF_LOGE("check fail"); + return HDF_FAILURE; } - - (void)OsalSpinInit(&cntlr->lock); - ret = OsalRegisterIrq(cntlr->irq, 0, (OsalIRQHandle)DmacIsr, "PlatDmac", cntlr); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: request irq %u failed, ret = %d", __func__, cntlr->irq, ret); - (void)OsalSpinDestroy(&cntlr->lock); - return ret; + if (cntlr->channelNum > DMAC_CHAN_NUM_MAX) { + HDF_LOGE("%s: invalid channel:%d", __func__, cntlr->channelNum); + return HDF_FAILURE; } + cntlr->remapBase = (char *)OsalIoRemap((unsigned long)cntlr->phyBase, (unsigned long)cntlr->regSize); + OsalSpinInit(&cntlr->lock); cntlr->channelList = (struct DmacChanInfo *)OsalMemCalloc(sizeof(struct DmacChanInfo) * cntlr->channelNum); if (cntlr->channelList == NULL) { - HDF_LOGE("%s: alloc channel list failed", __func__); - (void)OsalUnregisterIrq(cntlr->irq, cntlr); - (void)OsalSpinDestroy(&cntlr->lock); - return HDF_ERR_MALLOC_FAIL; + HDF_LOGE("channel list malloc fail"); + OsalIoUnmap((void *)cntlr->remapBase); + return HDF_FAILURE; } for (i = 0; i < cntlr->channelNum; i++) { cntlr->dmacChanDisable(cntlr, i); DmaEventInit(&(cntlr->channelList[i].waitEvent)); cntlr->channelList[i].useStatus = DMAC_CHN_VACANCY; } - return HDF_SUCCESS; + ret = OsalRegisterIrq(cntlr->irq, 0, (OsalIRQHandle)DmacIsr, "PlatDmac", cntlr); + if (ret != HDF_SUCCESS) { + HDF_LOGE("DMA Irq %d request failed, ret = %d\n", cntlr->irq, ret); + OsalMemFree(cntlr->channelList); + cntlr->channelList = NULL; + OsalIoUnmap((void *)cntlr->remapBase); + } + return ret; } -void DmacCntlrRemove(struct DmaCntlr *cntlr) -{ - (void)cntlr; -} diff --git a/support/platform/test/unittest/common/hdf_spi_test.cpp b/support/platform/test/unittest/common/hdf_spi_test.cpp index 38404e9e6..1a9eef0f3 100644 --- a/support/platform/test/unittest/common/hdf_spi_test.cpp +++ b/support/platform/test/unittest/common/hdf_spi_test.cpp @@ -24,7 +24,6 @@ enum HdfTestCaseCmd { SPI_TRANSFER_TEST, SPI_WRITE_TEST, SPI_READ_TEST, - SPI_DMA_TEST, SPI_RELIABILITY_TEST, SPI_PERFORMANCE_TEST, }; @@ -103,18 +102,6 @@ HWTEST_F(HdfLiteSpiTest, SpiReadTest001, TestSize.Level1) EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); } -/** - * @tc.name: SpiDmaTest001 - * @tc.desc: Spi function test - * @tc.type: FUNC - * @tc.require: NA - */ -HWTEST_F(HdfLiteSpiTest, SpiDmaTest001, TestSize.Level1) -{ - struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_DMA_TEST, -1}; - EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); -} - /** * @tc.name: SpiReliabilityTest001 * @tc.desc: spi function test diff --git a/test/unittest/platform/common/spi_test.c b/test/unittest/platform/common/spi_test.c index 7c8abce4c..507376eec 100644 --- a/test/unittest/platform/common/spi_test.c +++ b/test/unittest/platform/common/spi_test.c @@ -40,19 +40,16 @@ static void SpiTestReleaseHandle(DevHandle handle) #define BITS_PER_WORD 10 #define MAX_SPEED_HZ 10000000 - -static struct SpiCfg g_spiCfg = { - .mode = SPI_CLK_PHASE | SPI_MODE_LOOP, - .bitsPerWord = BITS_PER_WORD, - .maxSpeedHz = MAX_SPEED_HZ, - .transferMode = SPI_POLLING_TRANSFER, -}; - static int32_t SpiSetCfgTest(struct SpiTest *test) { int32_t ret; + struct SpiCfg cfg; - ret = SpiSetCfg(test->handle, &g_spiCfg); + cfg.mode = SPI_CLK_PHASE | SPI_MODE_LOOP; + cfg.bitsPerWord = BITS_PER_WORD; + cfg.maxSpeedHz = MAX_SPEED_HZ; + cfg.transferMode = SPI_INTERRUPT_TRANSFER; + ret = SpiSetCfg(test->handle, &cfg); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: error", __func__); return HDF_FAILURE; @@ -61,37 +58,6 @@ static int32_t SpiSetCfgTest(struct SpiTest *test) return ret; } -static int32_t SpiCmpMemByBits(uint8_t *wbuf, uint8_t *rbuf, uint32_t len, uint8_t bits) -{ - int32_t i; - uint16_t vw; - uint16_t vr; - - if (bits < 4) { - bits = 4; - } else if (bits > 16) { - bits = 16; - } - - for (i = 0; i < len;) { - if (bits <= 8) { - vw = *((uint8_t *)(wbuf + i)) & (~(0xFFFF << bits)); - vr = *((uint8_t *)(rbuf + i)) & (~(0xFFFF << bits)); - } else { - vw = *((uint16_t *)(wbuf + i)) & (~(0xFFFF << bits)); - vr = *((uint16_t *)(rbuf + i)) & (~(0xFFFF << bits)); - } - if (vw != vr) { - HDF_LOGE("%s: compare mem fail(i=%d, vw=%u, vr=%u, bits = %u, len=%u)", - __func__, i, vw, vr, bits, len); - return HDF_FAILURE; - } - i += (bits <= 8) ? 1 : 2; - } - HDF_LOGE("%s: mem size(%u) compare success", __func__, len); - return HDF_SUCCESS; -} - static int32_t SpiTransferTest(struct SpiTest *test) { int32_t i; @@ -108,10 +74,7 @@ static int32_t SpiTransferTest(struct SpiTest *test) return HDF_FAILURE; } for (i = 0; i < test->len; i++) { - HDF_LOGE("%s: wbuf[%d] = 0x%x rbuf[%d] = 0x%x", __func__, i, test->wbuf[i], i, test->rbuf[i]); - } - if (SpiCmpMemByBits(msg.wbuf, msg.rbuf, msg.len, g_spiCfg.bitsPerWord) != HDF_SUCCESS) { - return HDF_FAILURE; + HDF_LOGE("%s: wbuf[%d] = 0x%x rbuff[%d] = 0x%x", __func__, i, test->wbuf[i], i, test->rbuf[i]); } HDF_LOGE("%s: success", __func__); return HDF_SUCCESS; @@ -137,87 +100,6 @@ static int32_t SpiReadTest(struct SpiTest *test) return HDF_SUCCESS; } -#define DMA_TRANSFER_SINGLE_MAX (1024 * 64 - 1) -#define DMA_TRANSFER_SINGLE_CNT (4) -#define DMA_TRANSFER_SINGLE_LEFT (254) -#define DMA_TRANSFER_SIZE_TOTAL (DMA_TRANSFER_SINGLE_MAX * DMA_TRANSFER_SINGLE_CNT + DMA_TRANSFER_SINGLE_LEFT) -#define DMA_TRANSFER_BUF_SEED (0x5A) - -static void SpiSetDmaMsg(struct SpiMsg *msg, uint8_t *wbuf, uint8_t *rbuf, uint32_t len) -{ - uint32_t i; - - wbuf[0] = DMA_TRANSFER_BUF_SEED; - for (i = 1; i < len; i++) { - wbuf[i] = wbuf[i - 1] + 1; - rbuf[i] = 0; - } - msg->wbuf = wbuf; - msg->rbuf = rbuf; - msg->len = len; - msg->csChange = 1; - msg->delayUs = 0, // switch off the CS after transfer - msg->speed = 0; // using default speed - return; -} - -static int32_t SpiDmaTest(struct SpiTest *test) -{ - int ret = HDF_SUCCESS; - uint8_t *wbuf = NULL; - uint8_t *rbuf = NULL; - uint8_t oldMode; - struct SpiMsg msg; - uint32_t len = DMA_TRANSFER_SIZE_TOTAL; - - oldMode = g_spiCfg.transferMode; - g_spiCfg.transferMode = SPI_DMA_TRANSFER; - if (SpiSetCfg(test->handle, &g_spiCfg) != HDF_SUCCESS) { - return HDF_FAILURE; - } - - wbuf = (uint8_t *)OsalMemAllocAlign(CACHE_ALIGNED_SIZE, len); - if (wbuf == NULL) { - return HDF_ERR_MALLOC_FAIL; - } - rbuf = (uint8_t *)OsalMemAllocAlign(CACHE_ALIGNED_SIZE, len); - if (wbuf == NULL) { - OsalMemFree(wbuf); - return HDF_ERR_MALLOC_FAIL; - } - SpiSetDmaMsg(&msg, wbuf, rbuf, len); - ret = SpiTransfer(test->handle, &msg, 1); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: spi transfer err", __func__); - goto __OUT; - } - - ret = SpiCmpMemByBits(msg.wbuf, msg.rbuf, msg.len, g_spiCfg.bitsPerWord); - if (ret != HDF_SUCCESS) { - goto __OUT; - } - - ret = SpiWrite(test->handle, msg.wbuf, msg.len); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: spi write err", __func__); - goto __OUT; - } - - ret = SpiRead(test->handle, msg.rbuf, msg.len); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: spi read err", __func__); - goto __OUT; - } - -__OUT: - OsalMemFree(wbuf); - OsalMemFree(rbuf); - g_spiCfg.transferMode = oldMode; - (void)SpiSetCfg(test->handle, &g_spiCfg); - HDF_LOGE("%s: success", __func__); - return ret; -} - static int32_t SpiReliabilityTest(struct SpiTest *test) { struct SpiCfg cfg = {0}; @@ -231,8 +113,6 @@ static int32_t SpiReliabilityTest(struct SpiTest *test) (void)SpiWrite(test->handle, NULL, -1); (void)SpiRead(test->handle, test->rbuf, test->len); (void)SpiRead(test->handle, NULL, -1); - - (void)test; HDF_LOGE("%s: success", __func__); return HDF_SUCCESS; } @@ -258,10 +138,6 @@ static int32_t SpiTestAll(struct SpiTest *test) error++; } total++; - if (SpiDmaTest(test) != HDF_SUCCESS) { - error++; - } - total++; if (SpiReliabilityTest(test) != HDF_SUCCESS) { error++; } @@ -270,12 +146,11 @@ static int32_t SpiTestAll(struct SpiTest *test) return HDF_SUCCESS; } -static struct SpiTestFunc g_spiTestFunc[] = { +struct SpiTestFunc g_spiTestFunc[] = { {SPI_SET_CFG_TEST, SpiSetCfgTest}, {SPI_TRANSFER_TEST, SpiTransferTest}, {SPI_WRITE_TEST, SpiWriteTest}, {SPI_READ_TEST, SpiReadTest}, - {SPI_DMA_TEST, SpiDmaTest}, {SPI_RELIABILITY_TEST, SpiReliabilityTest}, {SPI_PERFORMANCE_TEST, NULL}, {SPI_TEST_ALL, SpiTestAll}, @@ -286,7 +161,6 @@ static int32_t SpiTestEntry(struct SpiTest *test, int32_t cmd) int32_t i; int32_t ret = HDF_ERR_NOT_SUPPORT; - HDF_LOGE("%s: enter cmd %d ret %d", __func__, cmd, ret); if (test == NULL) { return HDF_ERR_INVALID_OBJECT; } diff --git a/test/unittest/platform/common/spi_test.h b/test/unittest/platform/common/spi_test.h index f796261e2..31d474a3b 100644 --- a/test/unittest/platform/common/spi_test.h +++ b/test/unittest/platform/common/spi_test.h @@ -17,7 +17,6 @@ enum SpiTestCmd { SPI_TRANSFER_TEST, SPI_WRITE_TEST, SPI_READ_TEST, - SPI_DMA_TEST, SPI_RELIABILITY_TEST, SPI_PERFORMANCE_TEST, SPI_TEST_ALL, -- Gitee From 0638e7d703398f49f5cfafb7dd7aa5a92949189c Mon Sep 17 00:00:00 2001 From: NickYang Date: Wed, 19 May 2021 19:01:57 +0800 Subject: [PATCH 3/3] sync l2 weekly to l1 --- support/platform/src/dmac_core.c | 42 +++++----- support/platform/src/emmc_core.c | 78 +++++++++---------- support/platform/src/emmc_if.c | 20 ++--- support/platform/src/i2c_if.c | 2 +- support/platform/src/mipi_dsi_core.c | 25 +++--- support/platform/src/rtc_base.c | 4 +- support/platform/src/rtc_core.c | 2 +- support/platform/src/rtc_if.c | 4 +- support/platform/src/sdio_core.c | 2 +- support/platform/src/spi_if.c | 16 ++-- support/platform/src/uart_core.c | 2 +- support/platform/src/uart_if.c | 8 +- .../test/unittest/common/hdf_emmc_test.cpp | 4 +- .../test/unittest/common/hdf_gpio_test.cpp | 12 +-- .../test/unittest/common/hdf_i2c_test.cpp | 8 +- .../unittest/common/hdf_mipi_dsi_test.cpp | 8 +- .../test/unittest/common/hdf_pwm_test.cpp | 14 ++-- .../test/unittest/common/hdf_rtc_test.cpp | 34 ++++---- .../test/unittest/common/hdf_sdio_test.cpp | 14 ++-- .../test/unittest/common/hdf_spi_test.cpp | 10 +-- .../test/unittest/common/hdf_uart_test.cpp | 16 ++-- .../unittest/common/hdf_watchdog_test.cpp | 8 +- 22 files changed, 168 insertions(+), 165 deletions(-) diff --git a/support/platform/src/dmac_core.c b/support/platform/src/dmac_core.c index 320fcf5cd..b2b207b4c 100644 --- a/support/platform/src/dmac_core.c +++ b/support/platform/src/dmac_core.c @@ -6,16 +6,17 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "dmac_core.h" #include #include "hdf_log.h" #include "osal_io.h" #include "osal_irq.h" #include "osal_mem.h" -#include "dmac_core.h" #define HDF_LOG_TAG dmac_core #define DMA_ALIGN_SIZE 256 +#define DMA_MAX_TRANS_SIZE_DEFAULT 256 static int DmacCheck(struct DmaCntlr *cntlr) { @@ -66,7 +67,7 @@ static void DmacFreeLli(struct DmacChanInfo *chanInfo) */ void DmaCntlrDestroy(struct DmaCntlr *cntlr) { - int i; + unsigned int i; if (cntlr == NULL || cntlr->channelNum > DMAC_CHAN_NUM_MAX) { HDF_LOGE("%s: cntlr null or channel invalid!", __func__); @@ -107,7 +108,7 @@ static void DmacCallbackHandle(struct DmacChanInfo *chanInfo) static int DmacWaitM2mSendComplete(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo) { - unsigned int ret; + uint32_t ret; if (DmacCheck(cntlr) != HDF_SUCCESS) { HDF_LOGE("check fail"); @@ -130,7 +131,7 @@ static int DmacWaitM2mSendComplete(struct DmaCntlr *cntlr, struct DmacChanInfo * static int DmacAllocateChannel(struct DmaCntlr *cntlr) { - unsigned int flags; + uint32_t flags; int i; if (DmacCheck(cntlr) != HDF_SUCCESS) { @@ -190,7 +191,7 @@ static struct DmacChanInfo *DmacRequestChannel(struct DmaCntlr *cntlr, HDF_LOGE("%s: get channel fail ret = %d", __func__, ret); return NULL; } - HDF_LOGD("channel = %d, transfer type = %d width = %u, config = 0x%x, lliflag = 0x%x", + HDF_LOGD("channel = %d, transfer type = %u width = %u, config = 0x%x, lliflag = 0x%x", ret, chanInfo->transferType, chanInfo->width, chanInfo->config, chanInfo->lliEnFlag); return chanInfo; } @@ -220,19 +221,13 @@ static int DmacFillLli(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, plli->count = cntlr->maxTransSize; } else { plli->nextLli = 0; - plli->count = (length % cntlr->maxTransSize); + plli->count = cntlr->maxTransSize == 0 ? length : (length % cntlr->maxTransSize); } plli->srcAddr = (long long)srcaddr; plli->destAddr = (long long)dstaddr; plli->config = chanInfo->config; - HDF_LOGD("plli->srcAddr = 0x%llx\n", plli->srcAddr); - HDF_LOGD("plli->destAddr = 0x%llx\n", plli->destAddr); - HDF_LOGD("plli->nextLli = 0x%llx\n", plli->nextLli); - HDF_LOGD("plli->config = 0x%x\n", plli->config); - HDF_LOGD("plli->count = 0x%x\n", plli->count); - if (chanInfo->transferType == TRASFER_TYPE_P2M) { dstaddr += plli->count; } else if (chanInfo->transferType == TRASFER_TYPE_M2P) { @@ -240,6 +235,7 @@ static int DmacFillLli(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, } plli++; } + plli = chanInfo->lli; cntlr->dmacCacheFlush((UINTPTR)plli, (UINTPTR)plli + (UINTPTR)(sizeof(struct DmacLli) * lliNum)); HDF_LOGD("alloc_addr = 0x%x, alloc_addr + (sizeof(DmacLli) * lli_num)= 0x%x\n", (UINTPTR)plli, (UINTPTR)plli + (UINTPTR)(sizeof(struct DmacLli) * lliNum)); @@ -369,6 +365,7 @@ static int DmacM2mTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) return HDF_FAILURE; } if (dmaSize == 0) { + DmacFreeChannel(cntlr, chanInfo->channel); return HDF_FAILURE; } leftSize -= dmaSize; @@ -403,7 +400,7 @@ int32_t DmaCntlrTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) } else if (msg->direct == TRASFER_TYPE_M2M) { return DmacM2mTransfer(cntlr, msg); } else { - HDF_LOGE("%s: invalid direct %d", __func__, msg->direct); + HDF_LOGE("%s: invalid direct %u", __func__, msg->direct); return HDF_FAILURE; } return DmacPeriphTransfer(cntlr, msg, periphAddr); @@ -419,7 +416,7 @@ unsigned int DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, unsigned int chan) return cntlr->dmacGetCurrDestAddr(cntlr, chan); } -static uint32_t DmacIsr(int irq, void *dev) +static uint32_t DmacIsr(uint32_t irq, void *dev) { struct DmaCntlr *cntlr = (struct DmaCntlr *)dev; unsigned int channelStatus; @@ -431,9 +428,9 @@ static uint32_t DmacIsr(int irq, void *dev) } if (irq != cntlr->irq || cntlr->channelNum > DMAC_CHAN_NUM_MAX) { - HDF_LOGE("%s: cntlr parm err! irq:%d, channel:%u", + HDF_LOGE("%s: cntlr param err! irq:%u, channel:%u", __func__, cntlr->irq, cntlr->channelNum); - return HDF_SUCCESS; + return HDF_ERR_INVALID_PARAM; } for (i = 0; i < cntlr->channelNum; i++) { channelStatus = cntlr->dmacGetChanStatus(cntlr, i); @@ -455,15 +452,19 @@ int DmacInit(struct DmaCntlr *cntlr) HDF_LOGE("check fail"); return HDF_FAILURE; } - if (cntlr->channelNum > DMAC_CHAN_NUM_MAX) { - HDF_LOGE("%s: invalid channel:%d", __func__, cntlr->channelNum); + if (cntlr->channelNum == 0 || cntlr->channelNum > DMAC_CHAN_NUM_MAX) { + HDF_LOGE("%s: invalid channel:%u", __func__, cntlr->channelNum); return HDF_FAILURE; } + if (cntlr->maxTransSize == 0) { + cntlr->maxTransSize = DMA_MAX_TRANS_SIZE_DEFAULT; + } cntlr->remapBase = (char *)OsalIoRemap((unsigned long)cntlr->phyBase, (unsigned long)cntlr->regSize); - OsalSpinInit(&cntlr->lock); + (void)OsalSpinInit(&cntlr->lock); cntlr->channelList = (struct DmacChanInfo *)OsalMemCalloc(sizeof(struct DmacChanInfo) * cntlr->channelNum); if (cntlr->channelList == NULL) { HDF_LOGE("channel list malloc fail"); + (void)OsalSpinDestroy(&cntlr->lock); OsalIoUnmap((void *)cntlr->remapBase); return HDF_FAILURE; } @@ -474,9 +475,10 @@ int DmacInit(struct DmaCntlr *cntlr) } ret = OsalRegisterIrq(cntlr->irq, 0, (OsalIRQHandle)DmacIsr, "PlatDmac", cntlr); if (ret != HDF_SUCCESS) { - HDF_LOGE("DMA Irq %d request failed, ret = %d\n", cntlr->irq, ret); + HDF_LOGE("DMA Irq %u request failed, ret = %d\n", cntlr->irq, ret); OsalMemFree(cntlr->channelList); cntlr->channelList = NULL; + (void)OsalSpinDestroy(&cntlr->lock); OsalIoUnmap((void *)cntlr->remapBase); } return ret; diff --git a/support/platform/src/emmc_core.c b/support/platform/src/emmc_core.c index b30cc433f..3de968cb1 100644 --- a/support/platform/src/emmc_core.c +++ b/support/platform/src/emmc_core.c @@ -6,8 +6,8 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include "device_resource_if.h" #include "emmc_core.h" +#include "device_resource_if.h" #include "hdf_log.h" #include "osal_mem.h" @@ -15,12 +15,12 @@ int32_t EmmcCntlrFindHost(struct EmmcCntlr *cntlr) { - if (cntlr == NULL || cntlr->method == NULL || cntlr->method->findHost == NULL) { - HDF_LOGE("EmmcCntlrFindHost: cntlr or method or findHost is NULL!"); + if (cntlr == null || cntlr->method == null || cntlr->method->findHost == null) { + HDF_LOGE("EmmcCntlrFindHost: cntlr or method or findHost is null!"); return HDF_ERR_INVALID_PARAM; } if (cntlr->method->findHost(cntlr, &(cntlr->configData)) != HDF_SUCCESS) { - HDF_LOGE("EmmcCntlrFindHost: findHost fail!"); + HDF_LOGE("EmmcCntlrFindHost: findHost failed"); return HDF_ERR_INVALID_OBJECT; } return HDF_SUCCESS; @@ -28,12 +28,12 @@ int32_t EmmcCntlrFindHost(struct EmmcCntlr *cntlr) int32_t EmmcCntlrGetCid(struct EmmcCntlr *cntlr, uint8_t *cid, uint32_t size) { - if (cntlr == NULL) { + if (cntlr == null) { HDF_LOGE("EmmcCntlrGetCid: cntlr is null"); return HDF_ERR_INVALID_OBJECT; } - if (cntlr->method == NULL || cntlr->method->getCid == NULL) { + if (cntlr->method == null || cntlr->method->getCid == null) { HDF_LOGE("EmmcCntlrGetCid: ops or getCid is null"); return HDF_ERR_NOT_SUPPORT; } @@ -42,8 +42,8 @@ int32_t EmmcCntlrGetCid(struct EmmcCntlr *cntlr, uint8_t *cid, uint32_t size) static int32_t EmmcGetCidWriteBackReply(struct HdfSBuf *reply, uint8_t *cid, uint32_t size) { - if (HdfSbufWriteBuffer(reply, cid, size) == false) { - HDF_LOGE("EmmcGetCidWriteBackReply: write to reply fail!"); + if (!HdfSbufWriteBuffer(reply, cid, size)) { + HDF_LOGE("EmmcGetCidWriteBackReply: write to reply failed"); return HDF_ERR_IO; } return HDF_SUCCESS; @@ -56,7 +56,7 @@ static int32_t EmmcGetCidDispatch(struct EmmcCntlr *cntlr, struct HdfSBuf *reply ret = EmmcCntlrGetCid(cntlr, cid, EMMC_CID_LEN); if (ret != HDF_SUCCESS) { - HDF_LOGE("EmmcGetCidDispatch: EmmcCntlrGetCid fail!"); + HDF_LOGE("EmmcGetCidDispatch: EmmcCntlrGetCid failed"); return ret; } return EmmcGetCidWriteBackReply(reply, cid, EMMC_CID_LEN); @@ -65,27 +65,27 @@ static int32_t EmmcGetCidDispatch(struct EmmcCntlr *cntlr, struct HdfSBuf *reply static int32_t EmmcIoDispatch(struct HdfDeviceIoClient *client, int cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { int32_t ret; - struct EmmcCntlr *cntlr = NULL; + struct EmmcCntlr *cntlr = null; (void)data; - if (client == NULL || client->device == NULL) { - HDF_LOGE("EmmcIoDispatch: client or client->device is NULL"); + if (client == null || client->device == null) { + HDF_LOGE("EmmcIoDispatch: client or client->device is null"); return HDF_ERR_INVALID_OBJECT; } - if (reply == NULL) { - HDF_LOGE("EmmcIoDispatch: reply is NULL"); + if (reply == null) { + HDF_LOGE("EmmcIoDispatch: reply is null"); return HDF_ERR_INVALID_PARAM; } cntlr = (struct EmmcCntlr *)client->device->service; - if (cntlr == NULL) { - HDF_LOGE("EmmcIoDispatch: service is NULL"); + if (cntlr == null) { + HDF_LOGE("EmmcIoDispatch: service is null"); return HDF_ERR_INVALID_OBJECT; } - if (cntlr->priv == NULL) { + if (cntlr->priv == null) { if (EmmcCntlrFindHost(cntlr) != HDF_SUCCESS) { - HDF_LOGE("EmmcIoDispatch: find host fail!"); + HDF_LOGE("EmmcIoDispatch: find host failed"); return HDF_ERR_INVALID_OBJECT; } } @@ -104,17 +104,17 @@ static int32_t EmmcIoDispatch(struct HdfDeviceIoClient *client, int cmd, struct struct EmmcCntlr *EmmcCntlrCreateAndBind(struct HdfDeviceObject *device) { - struct EmmcCntlr *cntlr = NULL; + struct EmmcCntlr *cntlr = null; - if (device == NULL) { - HDF_LOGE("EmmcCntlrCreateAndBind: device is NULL!"); - return NULL; + if (device == null) { + HDF_LOGE("EmmcCntlrCreateAndBind: device is null!"); + return null; } cntlr = (struct EmmcCntlr *)OsalMemCalloc(sizeof(*cntlr)); - if (cntlr == NULL) { - HDF_LOGE("EmmcCntlrCreateAndBind: malloc host fail!"); - return NULL; + if (cntlr == null) { + HDF_LOGE("EmmcCntlrCreateAndBind: malloc host failed"); + return null; } cntlr->device = device; device->service = &cntlr->service; @@ -124,42 +124,42 @@ struct EmmcCntlr *EmmcCntlrCreateAndBind(struct HdfDeviceObject *device) void EmmcCntlrDestroy(struct EmmcCntlr *cntlr) { - if (cntlr != NULL) { - cntlr->device = NULL; - cntlr->priv = NULL; - cntlr->method = NULL; + if (cntlr != null) { + cntlr->device = null; + cntlr->priv = null; + cntlr->method = null; OsalMemFree(cntlr); } } int32_t EmmcFillConfigData(struct HdfDeviceObject *device, struct EmmcConfigData *configData) { - const struct DeviceResourceNode *node = NULL; - struct DeviceResourceIface *drsOps = NULL; + const struct DeviceResourceNode *node = null; + struct DeviceResourceIface *drsOps = null; int32_t ret; - if (device == NULL || configData == NULL) { - HDF_LOGE("EmmcFillConfigData: input para is NULL."); + if (device == null || configData == null) { + HDF_LOGE("EmmcFillConfigData: input para is null."); return HDF_FAILURE; } node = device->property; - if (node == NULL) { - HDF_LOGE("EmmcFillConfigData: drs node is NULL."); + if (node == null) { + HDF_LOGE("EmmcFillConfigData: drs node is null."); return HDF_FAILURE; } drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); - if (drsOps == NULL || drsOps->GetUint32 == NULL) { - HDF_LOGE("EmmcFillConfigData: invalid drs ops fail!"); + if (drsOps == null || drsOps->GetUint32 == null) { + HDF_LOGE("EmmcFillConfigData: invalid drs ops failed"); return HDF_FAILURE; } ret = drsOps->GetUint32(node, "hostId", &(configData->hostId), 0); if (ret != HDF_SUCCESS) { - HDF_LOGE("EmmcFillConfigData: read funcNum fail!"); + HDF_LOGE("EmmcFillConfigData: read funcNum failed"); return ret; } - HDF_LOGD("EmmcFillConfigData: Success! hostId = %d.", configData->hostId); + HDF_LOGD("EmmcFillConfigData: Success! hostId = %u.", configData->hostId); return HDF_SUCCESS; } diff --git a/support/platform/src/emmc_if.c b/support/platform/src/emmc_if.c index 1010af751..ed70d88c7 100644 --- a/support/platform/src/emmc_if.c +++ b/support/platform/src/emmc_if.c @@ -6,12 +6,12 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "emmc_if.h" #include #ifndef __USER__ #include "devsvc_manager_clnt.h" #include "emmc_core.h" #endif -#include "emmc_if.h" #include "hdf_base.h" #ifdef __USER__ #include "hdf_io_service_if.h" @@ -96,16 +96,10 @@ static int32_t EmmcGetCidReadReplyData(struct HdfSBuf *reply, uint8_t *cid, uint uint32_t rLen; const void *rBuf = NULL; - if (HdfSbufReadBuffer(reply, &rBuf, &rLen) == false) { + if (!HdfSbufReadBuffer(reply, &rBuf, &rLen)) { HDF_LOGE("EmmcGetCidReadReplyData: read rBuf fail!"); return HDF_ERR_IO; } - if (size != rLen) { - HDF_LOGE("EmmcGetCidReadReplyData: err len:%u, rLen:%u", size, rLen); - if (rLen > size) { - rLen = size; - } - } if (memcpy_s(cid, size, rBuf, rLen) != EOK) { HDF_LOGE("EmmcGetCidReadReplyData: memcpy rBuf fail!"); @@ -115,7 +109,7 @@ static int32_t EmmcGetCidReadReplyData(struct HdfSBuf *reply, uint8_t *cid, uint return HDF_SUCCESS; } -int32_t EmmcServiceGetCid(struct HdfIoService *service, uint8_t *cid, uint32_t size) +static int32_t EmmcServiceGetCid(struct HdfIoService *service, uint8_t *cid, uint32_t size) { int32_t ret; struct HdfSBuf *reply = NULL; @@ -161,7 +155,7 @@ int32_t EmmcGetCid(DevHandle handle, uint8_t *cid, uint32_t size) } if (cid == NULL || size < EMMC_CID_LEN) { - HDF_LOGE("EmmcGetCid: error parms!"); + HDF_LOGE("EmmcGetCid: error params!"); return HDF_ERR_INVALID_PARAM; } #ifdef __USER__ @@ -176,7 +170,7 @@ void EmmcGetHuid(uint8_t *cid, uint32_t size) DevHandle handle = NULL; if (cid == NULL || size == 0) { - HDF_LOGE("EmmcGetUdid: error parms!"); + HDF_LOGE("EmmcGetUdid: error params!"); return; } if (memset_s(cid, sizeof(uint8_t) * size, 0, sizeof(uint8_t) * size) != EOK) { @@ -186,11 +180,11 @@ void EmmcGetHuid(uint8_t *cid, uint32_t size) handle = EmmcOpen(0); if (handle == NULL) { - HDF_LOGD("EmmcGetUdid: open fail, use default value!"); + HDF_LOGW("EmmcGetUdid: open fail, use default value!"); return; } if (EmmcGetCid(handle, cid, size) != HDF_SUCCESS) { - HDF_LOGD("EmmcGetUdid: get fail, use default value!"); + HDF_LOGW("EmmcGetUdid: get fail, use default value!"); } EmmcClose(handle); } diff --git a/support/platform/src/i2c_if.c b/support/platform/src/i2c_if.c index 2da224466..596650743 100644 --- a/support/platform/src/i2c_if.c +++ b/support/platform/src/i2c_if.c @@ -267,7 +267,7 @@ int32_t I2cTransfer(DevHandle handle, struct I2cMsg *msgs, int16_t count) } if (msgs == NULL || count <= 0) { - HDF_LOGE("I2cTransfer: err parms! msgs:%s, count:%d", + HDF_LOGE("I2cTransfer: err params! msgs:%s, count:%d", (msgs == NULL) ? "0" : "x", count); return HDF_ERR_INVALID_PARAM; } diff --git a/support/platform/src/mipi_dsi_core.c b/support/platform/src/mipi_dsi_core.c index 0e2c74cb4..6a6169351 100644 --- a/support/platform/src/mipi_dsi_core.c +++ b/support/platform/src/mipi_dsi_core.c @@ -6,10 +6,10 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include "osal_time.h" -#include "osal_mem.h" -#include "hdf_log.h" #include "mipi_dsi_core.h" +#include "hdf_log.h" +#include "osal_mem.h" +#include "osal_time.h" #define HDF_LOG_TAG mipi_dsi_core @@ -36,21 +36,21 @@ int32_t MipiDsiRegisterCntlr(struct MipiDsiCntlr *cntlr) return HDF_FAILURE; } -DevHandle MipiDsiOpen(uint8_t id) +DevHandle MipiDsiOpen(uint8_t number) { - if (id >= MAX_CNTLR_CNT) { - HDF_LOGE("id invalid"); + if (number >= MAX_CNTLR_CNT) { + HDF_LOGE("invalid number"); return NULL; } - if (g_mipiDsihandle[id].cntlr == NULL) { - HDF_LOGE("no mipi_dsi %d cntlr", id); + if (g_mipiDsihandle[number].cntlr == NULL) { + HDF_LOGE("no mipi_dsi %d cntlr", number); return NULL; } - if (OsalMutexLock(&(g_mipiDsihandle[id].lock)) != HDF_SUCCESS) { + if (OsalMutexLock(&(g_mipiDsihandle[number].lock)) != HDF_SUCCESS) { HDF_LOGE("mutex lock fail"); return NULL; } - return (DevHandle)(&(g_mipiDsihandle[id])); + return (DevHandle)(&(g_mipiDsihandle[number])); } void MipiDsiClose(DevHandle handle) @@ -64,7 +64,7 @@ void MipiDsiClose(DevHandle handle) static int32_t MipiDsiSetDevCfg(struct MipiDsiCntlr *cntlr) { - /* set controler config */ + /* set controller config */ if (cntlr->setCntlrCfg == NULL) { HDF_LOGE("setCntlrCfg is NULL"); return HDF_FAILURE; @@ -137,6 +137,7 @@ void MipiDsiSetLpMode(DevHandle handle) HDF_LOGI("toLp not support!"); } } + void MipiDsiSetHsMode(DevHandle handle) { struct MipiDsiCntlr *cntlr = NULL; @@ -151,6 +152,7 @@ void MipiDsiSetHsMode(DevHandle handle) HDF_LOGI("toHs not support!"); } } + void MipiDsiEnterUlps(DevHandle handle) { struct MipiDsiCntlr *cntlr = NULL; @@ -165,6 +167,7 @@ void MipiDsiEnterUlps(DevHandle handle) HDF_LOGI("enterUlps not support!"); } } + void MipiDsiExitUlps(DevHandle handle) { struct MipiDsiCntlr *cntlr = NULL; diff --git a/support/platform/src/rtc_base.c b/support/platform/src/rtc_base.c index 9b63c970b..5e671ac06 100644 --- a/support/platform/src/rtc_base.c +++ b/support/platform/src/rtc_base.c @@ -6,9 +6,9 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "rtc_base.h" #include "hdf_log.h" #include "plat_log.h" -#include "rtc_base.h" #define HDF_LOG_TAG rtc_base @@ -21,7 +21,7 @@ uint8_t RtcGetMonthDays(const uint8_t isLeapYear, const uint8_t month) return 0; } - if (RTC_FEBRUARY == month) { + if (month == RTC_FEBRUARY) { days = RTC_TWO_MONTH_DAY + isLeapYear; } else { oddMonth = (month >= RTC_AUGUST) ? (month - RTC_UNIT_DIFF) : month; diff --git a/support/platform/src/rtc_core.c b/support/platform/src/rtc_core.c index 3df837d3a..93ae21739 100644 --- a/support/platform/src/rtc_core.c +++ b/support/platform/src/rtc_core.c @@ -6,9 +6,9 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "rtc_core.h" #include "hdf_log.h" #include "osal_mem.h" -#include "rtc_core.h" #define HDF_LOG_TAG rtc_core diff --git a/support/platform/src/rtc_if.c b/support/platform/src/rtc_if.c index 232126ca2..140f3c3f9 100644 --- a/support/platform/src/rtc_if.c +++ b/support/platform/src/rtc_if.c @@ -6,13 +6,13 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "rtc_if.h" +#include "devsvc_manager_clnt.h" #include "hdf_base.h" #include "hdf_log.h" -#include "devsvc_manager_clnt.h" #include "osal_mem.h" #include "rtc_base.h" #include "rtc_core.h" -#include "rtc_if.h" #define HDF_LOG_TAG rtc_if diff --git a/support/platform/src/sdio_core.c b/support/platform/src/sdio_core.c index 990c460d6..737480a90 100644 --- a/support/platform/src/sdio_core.c +++ b/support/platform/src/sdio_core.c @@ -6,10 +6,10 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "sdio_core.h" #include "device_resource_if.h" #include "osal_mem.h" #include "plat_log.h" -#include "sdio_core.h" #define HDF_LOG_TAG sdio_core diff --git a/support/platform/src/spi_if.c b/support/platform/src/spi_if.c index 45eb03af4..4fb01a58d 100644 --- a/support/platform/src/spi_if.c +++ b/support/platform/src/spi_if.c @@ -6,12 +6,12 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include "securec.h" +#include "spi_if.h" #include "devsvc_manager_clnt.h" #include "hdf_log.h" #include "osal_mem.h" +#include "securec.h" #include "spi_core.h" -#include "spi_if.h" #define HDF_LOG_TAG spi_if #define HOST_NAME_LEN 32 @@ -128,17 +128,19 @@ DevHandle SpiOpen(const struct SpiDevInfo *info) return NULL; } + object = (struct SpiObject *)OsalMemCalloc(sizeof(*object)); + if (object == NULL) { + HDF_LOGE("%s: object malloc error", __func__); + return NULL; + } + ret = SpiCntlrOpen(cntlr, info->csNum); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: SpiCntlrOpen error, ret is %d", __func__, ret); + OsalMemFree(object); return NULL; } - object = (struct SpiObject *)OsalMemCalloc(sizeof(*object)); - if (object == NULL) { - HDF_LOGE("%s: object malloc error", __func__); - return NULL; - } object->cntlr = cntlr; object->csNum = info->csNum; return (DevHandle)object; diff --git a/support/platform/src/uart_core.c b/support/platform/src/uart_core.c index 524ad61f9..71cfcb050 100644 --- a/support/platform/src/uart_core.c +++ b/support/platform/src/uart_core.c @@ -154,7 +154,7 @@ static int32_t UartUserSetTransMode(struct UartHost *host, struct HdfSBuf *data) size_t size; enum UartTransMode *mode = NULL; - if (!HdfSbufReadBuffer(data, (const void **)&mode, &size)) { + if (!HdfSbufReadBuffer(data, (const void **)&mode, &size) || mode == NULL) { HDF_LOGE("%s: sbuf read buffer failed", __func__); return HDF_ERR_IO; } diff --git a/support/platform/src/uart_if.c b/support/platform/src/uart_if.c index 88b1dccb1..b25b6a7c2 100644 --- a/support/platform/src/uart_if.c +++ b/support/platform/src/uart_if.c @@ -6,6 +6,7 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "uart_if.h" #include "securec.h" #ifndef __USER__ #include "devsvc_manager_clnt.h" @@ -17,7 +18,6 @@ #ifndef __USER__ #include "uart_core.h" #endif -#include "uart_if.h" #define HDF_LOG_TAG uart_if_c #define UART_HOST_NAME_LEN 32 @@ -78,12 +78,14 @@ DevHandle UartOpen(uint32_t port) return NULL; } ret = service->dispatcher->Dispatch(&service->object, UART_IO_INIT, NULL, NULL); + if (ret != HDF_SUCCESS) { + UartPutObjByPointer(handle); + } #else ret = UartHostInit((struct UartHost *)handle); #endif if (ret != HDF_SUCCESS) { HDF_LOGE("%s: UartHostInit error, ret %d", __func__, ret); - UartPutObjByPointer(handle); return NULL; } @@ -106,13 +108,13 @@ void UartClose(DevHandle handle) return; } ret = service->dispatcher->Dispatch(&service->object, UART_IO_DEINIT, NULL, NULL); + UartPutObjByPointer(handle); #else ret = UartHostDeinit((struct UartHost *)handle); #endif if (ret != HDF_SUCCESS) { HDF_LOGE("%s: UartHostDeinit error, ret %d", __func__, ret); } - UartPutObjByPointer(handle); } #ifdef __USER__ diff --git a/support/platform/test/unittest/common/hdf_emmc_test.cpp b/support/platform/test/unittest/common/hdf_emmc_test.cpp index 9e1b51dd1..6231cdf2a 100644 --- a/support/platform/test/unittest/common/hdf_emmc_test.cpp +++ b/support/platform/test/unittest/common/hdf_emmc_test.cpp @@ -56,7 +56,7 @@ static void TestUserEmmcGetCid(void) EmmcGetHuid(cid, EMMC_CID_LEN); for (i = 0; i < EMMC_CID_LEN; i++) { - printf("user interface get cid[%d] = 0x%x\n", i, cid[i]); + printf("user interface get cid[%u] = 0x%x\n", i, cid[i]); } } @@ -66,7 +66,7 @@ static void TestUserEmmcGetCid(void) * @tc.type: FUNC * @tc.require: AR000F5LSD AR000F5LV3 */ -HWTEST_F(HdfLiteEmmcTest, EmmcGetCid001, TestSize.Level1) +HWTEST_F(HdfLiteEmmcTest, EmmcGetCid001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_EMMC_TYPE, EMMC_GET_CID_01, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); diff --git a/support/platform/test/unittest/common/hdf_gpio_test.cpp b/support/platform/test/unittest/common/hdf_gpio_test.cpp index f6800ef96..7584fc107 100644 --- a/support/platform/test/unittest/common/hdf_gpio_test.cpp +++ b/support/platform/test/unittest/common/hdf_gpio_test.cpp @@ -61,7 +61,7 @@ void HdfLiteGpioTest::TearDown() * @tc.type: FUNC * @tc.require: AR000F868H */ -HWTEST_F(HdfLiteGpioTest, GpioTestSetGetDir001, TestSize.Level1) +HWTEST_F(HdfLiteGpioTest, GpioTestSetGetDir001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_SET_GET_DIR, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -73,7 +73,7 @@ HWTEST_F(HdfLiteGpioTest, GpioTestSetGetDir001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868H */ -HWTEST_F(HdfLiteGpioTest, GpioTestWriteRead001, TestSize.Level1) +HWTEST_F(HdfLiteGpioTest, GpioTestWriteRead001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_WRITE_READ, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -85,7 +85,7 @@ HWTEST_F(HdfLiteGpioTest, GpioTestWriteRead001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868H */ -HWTEST_F(HdfLiteGpioTest, GpioTestIrqLevel001, TestSize.Level1) +HWTEST_F(HdfLiteGpioTest, GpioTestIrqLevel001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_IRQ_LEVEL, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -97,7 +97,7 @@ HWTEST_F(HdfLiteGpioTest, GpioTestIrqLevel001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868H */ -HWTEST_F(HdfLiteGpioTest, GpioTestIrqEdge001, TestSize.Level1) +HWTEST_F(HdfLiteGpioTest, GpioTestIrqEdge001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_IRQ_EDGE, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -109,7 +109,7 @@ HWTEST_F(HdfLiteGpioTest, GpioTestIrqEdge001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868H */ -HWTEST_F(HdfLiteGpioTest, GpioTestIrqThread001, TestSize.Level1) +HWTEST_F(HdfLiteGpioTest, GpioTestIrqThread001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_IRQ_THREAD, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -121,7 +121,7 @@ HWTEST_F(HdfLiteGpioTest, GpioTestIrqThread001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868H */ -HWTEST_F(HdfLiteGpioTest, GpioTestReliability001, TestSize.Level1) +HWTEST_F(HdfLiteGpioTest, GpioTestReliability001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_RELIABILITY, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); diff --git a/support/platform/test/unittest/common/hdf_i2c_test.cpp b/support/platform/test/unittest/common/hdf_i2c_test.cpp index 05a5f15fb..3bc5b21ef 100644 --- a/support/platform/test/unittest/common/hdf_i2c_test.cpp +++ b/support/platform/test/unittest/common/hdf_i2c_test.cpp @@ -69,7 +69,7 @@ void HdfLiteI2cTest::TearDown() * @tc.type: FUNC * @tc.require: AR000F8688 */ -HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestTransfer001, TestSize.Level1) +HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestTransfer001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_I2C_TYPE, I2C_TEST_CMD_TRANSFER, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -84,7 +84,7 @@ HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestTransfer001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F8688 */ -HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestWriteRead001, TestSize.Level1) +HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestWriteRead001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_I2C_TYPE, I2C_TEST_CMD_WRITE_READ, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -99,7 +99,7 @@ HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestWriteRead001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F8688 */ -HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestMultiThread001, TestSize.Level1) +HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestMultiThread001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_I2C_TYPE, I2C_TEST_CMD_MULTI_THREAD, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -114,7 +114,7 @@ HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestMultiThread001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F8688 */ -HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestReliability001, TestSize.Level1) +HWTEST_F(HdfLiteI2cTest, HdfLiteI2cTestReliability001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_I2C_TYPE, I2C_TEST_CMD_RELIABILITY, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); diff --git a/support/platform/test/unittest/common/hdf_mipi_dsi_test.cpp b/support/platform/test/unittest/common/hdf_mipi_dsi_test.cpp index 4f394ec38..db7e2bf68 100644 --- a/support/platform/test/unittest/common/hdf_mipi_dsi_test.cpp +++ b/support/platform/test/unittest/common/hdf_mipi_dsi_test.cpp @@ -67,7 +67,7 @@ static void MipiDsiTest(enum MipiDsiTestCmd cmd) * @tc.type: FUNC * @tc.require: AR000F868F */ -HWTEST_F(HdfLiteMipiDsiTest, MipiDsiSetCfgTest001, TestSize.Level1) +HWTEST_F(HdfLiteMipiDsiTest, MipiDsiSetCfgTest001, TestSize.Level0) { MipiDsiTest(MIPI_DSI_TEST_SET_CFG); } @@ -78,7 +78,7 @@ HWTEST_F(HdfLiteMipiDsiTest, MipiDsiSetCfgTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868F */ -HWTEST_F(HdfLiteMipiDsiTest, MipiDsiGetCfgTest001, TestSize.Level1) +HWTEST_F(HdfLiteMipiDsiTest, MipiDsiGetCfgTest001, TestSize.Level0) { MipiDsiTest(MIPI_DSI_TEST_GET_CFG); } @@ -89,7 +89,7 @@ HWTEST_F(HdfLiteMipiDsiTest, MipiDsiGetCfgTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868F */ -HWTEST_F(HdfLiteMipiDsiTest, MipiDsiTxRxTest001, TestSize.Level1) +HWTEST_F(HdfLiteMipiDsiTest, MipiDsiTxRxTest001, TestSize.Level0) { MipiDsiTest(MIPI_DSI_TEST_TX_RX); } @@ -100,7 +100,7 @@ HWTEST_F(HdfLiteMipiDsiTest, MipiDsiTxRxTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868F */ -HWTEST_F(HdfLiteMipiDsiTest, MipiDsiLpHsTest001, TestSize.Level1) +HWTEST_F(HdfLiteMipiDsiTest, MipiDsiLpHsTest001, TestSize.Level0) { MipiDsiTest(MIPI_DSI_TEST_TO_LP_TO_HS); } diff --git a/support/platform/test/unittest/common/hdf_pwm_test.cpp b/support/platform/test/unittest/common/hdf_pwm_test.cpp index 3a439a5ea..bf8d33b5c 100644 --- a/support/platform/test/unittest/common/hdf_pwm_test.cpp +++ b/support/platform/test/unittest/common/hdf_pwm_test.cpp @@ -61,7 +61,7 @@ void HdfLitePwmTest::TearDown() * @tc.type: FUNC * @tc.require: AR000F868C */ -HWTEST_F(HdfLitePwmTest, PwmSetPeriodTest001, TestSize.Level1) +HWTEST_F(HdfLitePwmTest, PwmSetPeriodTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_PWM_TYPE, PWM_SET_PERIOD_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -73,7 +73,7 @@ HWTEST_F(HdfLitePwmTest, PwmSetPeriodTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868C */ -HWTEST_F(HdfLitePwmTest, PwmSetDutyTest001, TestSize.Level1) +HWTEST_F(HdfLitePwmTest, PwmSetDutyTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_PWM_TYPE, PWM_SET_DUTY_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -85,7 +85,7 @@ HWTEST_F(HdfLitePwmTest, PwmSetDutyTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868C */ -HWTEST_F(HdfLitePwmTest, PwmSetPolarityTest001, TestSize.Level1) +HWTEST_F(HdfLitePwmTest, PwmSetPolarityTest001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_PWM_TYPE, PWM_SET_POLARITY_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -97,7 +97,7 @@ HWTEST_F(HdfLitePwmTest, PwmSetPolarityTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868D */ -HWTEST_F(HdfLitePwmTest, PwmSetConfigTest001, TestSize.Level1) +HWTEST_F(HdfLitePwmTest, PwmSetConfigTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_PWM_TYPE, PWM_SET_CONFIG_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -109,7 +109,7 @@ HWTEST_F(HdfLitePwmTest, PwmSetConfigTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868D */ -HWTEST_F(HdfLitePwmTest, PwmGetConfigTest001, TestSize.Level1) +HWTEST_F(HdfLitePwmTest, PwmGetConfigTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_PWM_TYPE, PWM_GET_CONFIG_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -121,7 +121,7 @@ HWTEST_F(HdfLitePwmTest, PwmGetConfigTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868D */ -HWTEST_F(HdfLitePwmTest, PwmEnableTest001, TestSize.Level1) +HWTEST_F(HdfLitePwmTest, PwmEnableTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_PWM_TYPE, PWM_ENABLE_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -133,7 +133,7 @@ HWTEST_F(HdfLitePwmTest, PwmEnableTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868D */ -HWTEST_F(HdfLitePwmTest, PwmDisableTest001, TestSize.Level1) +HWTEST_F(HdfLitePwmTest, PwmDisableTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_PWM_TYPE, PWM_DISABLE_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); diff --git a/support/platform/test/unittest/common/hdf_rtc_test.cpp b/support/platform/test/unittest/common/hdf_rtc_test.cpp index f6d326292..f55ae5656 100644 --- a/support/platform/test/unittest/common/hdf_rtc_test.cpp +++ b/support/platform/test/unittest/common/hdf_rtc_test.cpp @@ -78,7 +78,7 @@ void HdfRtcTest::TearDown() * @tc.type: FUNC * @tc.require: AR000F868I */ -HWTEST_F(HdfRtcTest, testRtcReadWriteTime001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcReadWriteTime001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_TIME, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -90,7 +90,7 @@ HWTEST_F(HdfRtcTest, testRtcReadWriteTime001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868I */ -HWTEST_F(HdfRtcTest, testRtcReadWriteMaxTime001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcReadWriteMaxTime001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_MAX_TIME, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -102,7 +102,7 @@ HWTEST_F(HdfRtcTest, testRtcReadWriteMaxTime001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868I */ -HWTEST_F(HdfRtcTest, testRtcReadWriteMinTime001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcReadWriteMinTime001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_MIN_TIME, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -114,7 +114,7 @@ HWTEST_F(HdfRtcTest, testRtcReadWriteMinTime001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868I */ -HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmTime001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmTime001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_ALARM_TIME, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -126,7 +126,7 @@ HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmTime001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868I */ -HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmMaxTime001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmMaxTime001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_ALARM_MAX_TIME, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -137,7 +137,7 @@ HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmMaxTime001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868I */ -HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmMinTime001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmMinTime001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_ALARM_MIN_TIME, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -150,7 +150,7 @@ HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmMinTime001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868I */ -HWTEST_F(HdfRtcTest, testRtcAlarmEnable001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcAlarmEnable001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_ALARM_ENABLE, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -164,7 +164,7 @@ HWTEST_F(HdfRtcTest, testRtcAlarmEnable001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000EKRKU */ -HWTEST_F(HdfRtcTest, testRtcAlarmIqr001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcAlarmIqr001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_ALARM_IRQ, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -176,7 +176,7 @@ HWTEST_F(HdfRtcTest, testRtcAlarmIqr001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000EKRKU */ -HWTEST_F(HdfRtcTest, testRtcRegCallback001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcRegCallback001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_REGISTER_CALLBACK, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -188,7 +188,7 @@ HWTEST_F(HdfRtcTest, testRtcRegCallback001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000EKRKU */ -HWTEST_F(HdfRtcTest, testRtcRegCallbackNull001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcRegCallbackNull001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_REGISTER_CALLBACK_NULL, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -200,7 +200,7 @@ HWTEST_F(HdfRtcTest, testRtcRegCallbackNull001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000EKRKU */ -HWTEST_F(HdfRtcTest, testRtcFreq001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcFreq001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_FREQ, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -212,7 +212,7 @@ HWTEST_F(HdfRtcTest, testRtcFreq001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000EKRKU */ -HWTEST_F(HdfRtcTest, testRtcMaxFreq001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcMaxFreq001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_MAX_FREQ, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -224,7 +224,7 @@ HWTEST_F(HdfRtcTest, testRtcMaxFreq001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000EKRKU */ -HWTEST_F(HdfRtcTest, testRtcMinFreq001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcMinFreq001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_MIN_FREQ, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -236,7 +236,7 @@ HWTEST_F(HdfRtcTest, testRtcMinFreq001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000EKRKU */ -HWTEST_F(HdfRtcTest, testRtcUserReg001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcUserReg001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_USER_REG, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -248,7 +248,7 @@ HWTEST_F(HdfRtcTest, testRtcUserReg001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000EKRKU */ -HWTEST_F(HdfRtcTest, testRtcUserRegMaxIndex001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcUserRegMaxIndex001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_USER_REG_MAX_INDEX, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -260,7 +260,7 @@ HWTEST_F(HdfRtcTest, testRtcUserRegMaxIndex001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000EKRKU */ -HWTEST_F(HdfRtcTest, testRtcReliability001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcReliability001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_WR_RELIABILITY, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -273,7 +273,7 @@ HWTEST_F(HdfRtcTest, testRtcReliability001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000EKRKU */ -HWTEST_F(HdfRtcTest, testRtcModule001, TestSize.Level1) +HWTEST_F(HdfRtcTest, testRtcModule001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_FUNCTION_TEST, -1 }; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); diff --git a/support/platform/test/unittest/common/hdf_sdio_test.cpp b/support/platform/test/unittest/common/hdf_sdio_test.cpp index 8fa564b3b..c2ae82dc5 100644 --- a/support/platform/test/unittest/common/hdf_sdio_test.cpp +++ b/support/platform/test/unittest/common/hdf_sdio_test.cpp @@ -60,7 +60,7 @@ void HdfLiteSdioTest::TearDown() * @tc.type: FUNC * @tc.require: AR000F868B */ -HWTEST_F(HdfLiteSdioTest, SdioDisableFunc001, TestSize.Level1) +HWTEST_F(HdfLiteSdioTest, SdioDisableFunc001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_DISABLE_FUNC_01, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -72,7 +72,7 @@ HWTEST_F(HdfLiteSdioTest, SdioDisableFunc001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868B */ -HWTEST_F(HdfLiteSdioTest, SdioEnableFunc001, TestSize.Level1) +HWTEST_F(HdfLiteSdioTest, SdioEnableFunc001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_ENABLE_FUNC_01, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -84,7 +84,7 @@ HWTEST_F(HdfLiteSdioTest, SdioEnableFunc001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868B */ -HWTEST_F(HdfLiteSdioTest, SdioSetBlockSize001, TestSize.Level1) +HWTEST_F(HdfLiteSdioTest, SdioSetBlockSize001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_SET_BLOCK_SIZE_01, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -96,7 +96,7 @@ HWTEST_F(HdfLiteSdioTest, SdioSetBlockSize001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868B */ -HWTEST_F(HdfLiteSdioTest, SdioIncrAddrReadAndWriteBytes001, TestSize.Level1) +HWTEST_F(HdfLiteSdioTest, SdioIncrAddrReadAndWriteBytes001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_INCR_ADDR_READ_AND_WRITE_BYTES_01, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -108,7 +108,7 @@ HWTEST_F(HdfLiteSdioTest, SdioIncrAddrReadAndWriteBytes001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868B */ -HWTEST_F(HdfLiteSdioTest, SdioFixedAddrReadAndWriteBytes001, TestSize.Level1) +HWTEST_F(HdfLiteSdioTest, SdioFixedAddrReadAndWriteBytes001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_FIXED_ADDR_READ_AND_WRITE_BYTES_01, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -120,7 +120,7 @@ HWTEST_F(HdfLiteSdioTest, SdioFixedAddrReadAndWriteBytes001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868B */ -HWTEST_F(HdfLiteSdioTest, SdioFunc0ReadAndWriteBytes001, TestSize.Level1) +HWTEST_F(HdfLiteSdioTest, SdioFunc0ReadAndWriteBytes001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_SDIO_TYPE, SDIO_FUNC0_READ_AND_WRITE_BYTES_01, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -132,7 +132,7 @@ HWTEST_F(HdfLiteSdioTest, SdioFunc0ReadAndWriteBytes001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868B */ -HWTEST_F(HdfLiteSdioTest, SdioSetAndGetCommonInfo001, TestSize.Level1) +HWTEST_F(HdfLiteSdioTest, SdioSetAndGetCommonInfo001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_SET_AND_GET_COMMON_INFO_01, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); diff --git a/support/platform/test/unittest/common/hdf_spi_test.cpp b/support/platform/test/unittest/common/hdf_spi_test.cpp index 1a9eef0f3..7f4fd3f94 100644 --- a/support/platform/test/unittest/common/hdf_spi_test.cpp +++ b/support/platform/test/unittest/common/hdf_spi_test.cpp @@ -60,7 +60,7 @@ void HdfLiteSpiTest::TearDown() * @tc.type: FUNC * @tc.require: SR000DQ0VO */ -HWTEST_F(HdfLiteSpiTest, SpiSetCfgTest001, TestSize.Level1) +HWTEST_F(HdfLiteSpiTest, SpiSetCfgTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_SET_CFG_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -72,7 +72,7 @@ HWTEST_F(HdfLiteSpiTest, SpiSetCfgTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: SR000DQ0VO */ -HWTEST_F(HdfLiteSpiTest, SpiTransferTest001, TestSize.Level1) +HWTEST_F(HdfLiteSpiTest, SpiTransferTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_TRANSFER_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -84,7 +84,7 @@ HWTEST_F(HdfLiteSpiTest, SpiTransferTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: SR000DQ0VO */ -HWTEST_F(HdfLiteSpiTest, SpiWriteTest001, TestSize.Level1) +HWTEST_F(HdfLiteSpiTest, SpiWriteTest001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_SPI_TYPE, SPI_WRITE_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -96,7 +96,7 @@ HWTEST_F(HdfLiteSpiTest, SpiWriteTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: SR000DQ0VO */ -HWTEST_F(HdfLiteSpiTest, SpiReadTest001, TestSize.Level1) +HWTEST_F(HdfLiteSpiTest, SpiReadTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_READ_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -108,7 +108,7 @@ HWTEST_F(HdfLiteSpiTest, SpiReadTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: SR000DQ0VO */ -HWTEST_F(HdfLiteSpiTest, SpiReliabilityTest001, TestSize.Level1) +HWTEST_F(HdfLiteSpiTest, SpiReliabilityTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_RELIABILITY_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); diff --git a/support/platform/test/unittest/common/hdf_uart_test.cpp b/support/platform/test/unittest/common/hdf_uart_test.cpp index 083b0ea7c..f12a6b5e2 100644 --- a/support/platform/test/unittest/common/hdf_uart_test.cpp +++ b/support/platform/test/unittest/common/hdf_uart_test.cpp @@ -66,7 +66,7 @@ void HdfLiteUartTest::TearDown() * @tc.type: FUNC * @tc.require: AR000F8689 */ -HWTEST_F(HdfLiteUartTest, UartSetTransModeTest001, TestSize.Level1) +HWTEST_F(HdfLiteUartTest, UartSetTransModeTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_SET_TRANSMODE_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -79,7 +79,7 @@ HWTEST_F(HdfLiteUartTest, UartSetTransModeTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F8689 */ -HWTEST_F(HdfLiteUartTest, UartWriteTest001, TestSize.Level1) +HWTEST_F(HdfLiteUartTest, UartWriteTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UAER_WRITE_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -91,7 +91,7 @@ HWTEST_F(HdfLiteUartTest, UartWriteTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F8689 */ -HWTEST_F(HdfLiteUartTest, UartReadTest001, TestSize.Level1) +HWTEST_F(HdfLiteUartTest, UartReadTest001, TestSize.Level0) { struct HdfTestMsg msg = { TEST_PAL_UART_TYPE, UART_READ_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -103,7 +103,7 @@ HWTEST_F(HdfLiteUartTest, UartReadTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F8689 */ -HWTEST_F(HdfLiteUartTest, UartSetBaudTest001, TestSize.Level1) +HWTEST_F(HdfLiteUartTest, UartSetBaudTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_SET_BAUD_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -115,7 +115,7 @@ HWTEST_F(HdfLiteUartTest, UartSetBaudTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F8689 */ -HWTEST_F(HdfLiteUartTest, UartGetBaudTest001, TestSize.Level1) +HWTEST_F(HdfLiteUartTest, UartGetBaudTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_GET_BAUD_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -127,7 +127,7 @@ HWTEST_F(HdfLiteUartTest, UartGetBaudTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F8689 */ -HWTEST_F(HdfLiteUartTest, UartSetAttributeTest001, TestSize.Level1) +HWTEST_F(HdfLiteUartTest, UartSetAttributeTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_SET_ATTRIBUTE_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -139,7 +139,7 @@ HWTEST_F(HdfLiteUartTest, UartSetAttributeTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F8689 */ -HWTEST_F(HdfLiteUartTest, UartGetAttributeTest001, TestSize.Level1) +HWTEST_F(HdfLiteUartTest, UartGetAttributeTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_GET_ATTRIBUTE_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -151,7 +151,7 @@ HWTEST_F(HdfLiteUartTest, UartGetAttributeTest001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F8689 */ -HWTEST_F(HdfLiteUartTest, UartReliabilityTest001, TestSize.Level1) +HWTEST_F(HdfLiteUartTest, UartReliabilityTest001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_RELIABILITY_TEST, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); diff --git a/support/platform/test/unittest/common/hdf_watchdog_test.cpp b/support/platform/test/unittest/common/hdf_watchdog_test.cpp index 201c8cbc5..6b6f8061b 100644 --- a/support/platform/test/unittest/common/hdf_watchdog_test.cpp +++ b/support/platform/test/unittest/common/hdf_watchdog_test.cpp @@ -60,7 +60,7 @@ void HdfLiteWatchdogTest::TearDown() * @tc.type: FUNC * @tc.require: AR000F868G */ -HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestSetGetTimeout001, TestSize.Level1) +HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestSetGetTimeout001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_WDT_TYPE, WATCHDOG_TEST_SET_GET_TIMEOUT, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -72,7 +72,7 @@ HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestSetGetTimeout001, TestSize.Leve * @tc.type: FUNC * @tc.require: AR000F868G */ -HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestStartStop001, TestSize.Level1) +HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestStartStop001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_WDT_TYPE, WATCHDOG_TEST_START_STOP, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -84,7 +84,7 @@ HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestStartStop001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868G */ -HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestFeed001, TestSize.Level1) +HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestFeed001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_WDT_TYPE, WATCHDOG_TEST_FEED, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); @@ -96,7 +96,7 @@ HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestFeed001, TestSize.Level1) * @tc.type: FUNC * @tc.require: AR000F868G */ -HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestReliability001, TestSize.Level1) +HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestReliability001, TestSize.Level0) { struct HdfTestMsg msg = {TEST_PAL_WDT_TYPE, WATCHDOG_TEST_RELIABILITY, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); -- Gitee