From 8445c54f01777513912d4c6d36c28e92a0ff33a0 Mon Sep 17 00:00:00 2001
From: chenlh <2008get@163.com>
Date: 星期四, 18 九月 2025 14:40:53 +0800
Subject: [PATCH] 首轮测试代码提交

---
 src/tob.cpp |  128 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 111 insertions(+), 17 deletions(-)

diff --git a/src/tob.cpp b/src/tob.cpp
index 0a3fce0..6a5e14d 100644
--- a/src/tob.cpp
+++ b/src/tob.cpp
@@ -24,21 +24,21 @@
 #define dbg_printf
 #endif
 
-static ToB* tob = NULL;
+//static ToB* tob = NULL;
 
-ToB* ToB::GetInstance()
-{
-	return tob;
-}
+//ToB* ToB::GetInstance()
+//{
+//	return tob;
+//}
 
 ToB::ToB(ubool dualDsp, u32 dspIndex )
-	: dual_dsp(dualDsp), dsp_index(dspIndex),mList(32)
+	: dual_dsp(dualDsp), dsp_index(dspIndex)
 {
-	if(tob != NULL) {
-		delete tob;
-	}
-	tob = this;
-	frames = NULL;
+//	if(tob != NULL) {
+//		delete tob;
+//	}
+//	tob = this;
+	frames = nullptr;
 	processed = ufalse;
 	mModuleNum =0;
 	mModuleIndex.resize(0);
@@ -48,7 +48,11 @@
 ToB::~ToB()
 {
 	toClear();
+<<<<<<< HEAD
+//	tob = NULL;
+=======
 	tob = NULL;
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 	delete paramset;
 }
 
@@ -59,16 +63,23 @@
 ErrStatus ToB::toClear()
 {
 	processed = ufalse;
+	int i = 0;
 
-	for (std::vector<IModule*>::iterator iter = mList.begin();
-		iter != mList.end() ;iter++) {
-		delete *iter;
+//	for (std::vector<IModule*>::iterator iter = mList.begin(); iter != mList.end(); iter++, ++i) {
+//		delete *iter;
+//		*iter = nullptr;
+//	}
+	for (auto iter : mList) {
+		delete iter;
+		iter = nullptr;
 	}
+
 	mList.clear();
 	mModuleIndex.clear();
 
 	if(frames != NULL) {
 		delete frames;
+		frames = nullptr;
 	}
 	mModuleNum = 0;
 
@@ -192,7 +203,11 @@
 
 	return 	ErrStatus::SUCCESS;
 }
+<<<<<<< HEAD
+#define DEBUG 0
+=======
 
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 #if 1//DEBUG
 	const s8* type_string[ModuleType::PROC_COUNT] = {
 			"none"
@@ -243,7 +258,7 @@
 		const Module* pmod = (Module*)(bin+ size);  size += sizeof(Module);
 		const u16* mRxbufID = (u16*)(bin + size);	size += pmod->mRxNum * sizeof(u16);
 		const u16* mTxbufID = (u16*)(bin + size);	size += pmod->mTxNum * sizeof(u16);
-		PhyPort* mPhyID ;
+		PhyPort* mPhyID;
 		ubool bInput=ufalse,bOutput=ufalse;
 		u16 mRxNum = pmod->mRxNum, mTxNum = pmod->mTxNum;
 
@@ -263,8 +278,14 @@
 
 		if (pmod->mDsp != dsp_index)  continue;
 
+<<<<<<< HEAD
+#if DEBUG
+		//if (PROC_FIR == pmod->mType)
+			printf("Module ID %d type %d %s rxnum %d txnum %d tag %d. \n",pmod->mID ,pmod->mType, type_string[pmod->mType], pmod->mRxNum,pmod->mTxNum,pmod->mTag);
+=======
 #ifdef DEBUG
 		printf("Module ID %d type %d %s rxnum %d txnum %d tag %d. \n",pmod->mID ,pmod->mType, type_string[pmod->mType], pmod->mRxNum,pmod->mTxNum,pmod->mTag);
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 #endif
 
 		IModule* m = CreateBaseModule(pmod->mType, pmod->mTag, mRxNum, mTxNum);
@@ -273,11 +294,14 @@
 			continue;
 		}
 
+<<<<<<< HEAD
+=======
 //		int ddr = sram_free_space(SRAM_DDR,mem_any);
 //		int ccm = sram_free_space(SRAM_L2,mem_any);
 //		int l1 = sram_free_space(SRAM_L1,mem_heap);
 //		printf("ddr %d ccm %d l1 %d.\n",ddr, ccm ,l1);
 
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 		m->SetModuleInfo(pmod->mID ,pmod->mType, pmod->mTag);
 		mList.push_back(m);
 
@@ -288,7 +312,11 @@
 
 //		printf("Module id:%d, Tx buffer id:", pmod->mID);
 		for (size_t i = 0; i < mTxNum && !bOutput; i++){
+<<<<<<< HEAD
+//			printf("bid %d, ", mTxbufID[i]);
+=======
 			printf("bid %d, ", mTxbufID[i]);
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 			if (mTxbufID[i] > 0) {
 				Frame* pcm = frames->GetFrame(mTxbufID[i]-1);
 				m->SetOutputChannelDataPtr(i, pcm);
@@ -298,7 +326,11 @@
 						nPhyInput[mPhyID[i].mIntType] = mPhyID[i].mPhyID;
 					m->SetInputChannelDataPtr(i, pcm);
 					SetRxChannelPtr(static_cast<IntDataType>(mPhyID[i].mIntType), mPhyID[i].mPhyID-1, pcm->Data());
+<<<<<<< HEAD
+//					printf("phy_id %d\n", mPhyID[i].mPhyID);
+=======
 					printf("phy_id %d\n", mPhyID[i].mPhyID);
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 				}
 			}
 			else {
@@ -307,7 +339,11 @@
 		}
 //		printf(";Rx buffer id:");
 		for (size_t i = 0; i < mRxNum && !bInput; i++) {
+<<<<<<< HEAD
+//			printf("mID %d,bid %d\n", pmod->mID, mRxbufID[i]);
+=======
 //			printf("bid %d", mRxbufID[i]);
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 			if (mRxbufID[i] > 0) {
 				Frame* pcm = frames->GetFrame(mRxbufID[i]-1 );
 				m->SetInputChannelDataPtr(i, pcm);
@@ -316,10 +352,15 @@
 					if(nPhyOutput[mPhyID[i].mIntType] < mPhyID[i].mPhyID)
 						nPhyOutput[mPhyID[i].mIntType] = mPhyID[i].mPhyID;
 
-					pcm = frames->AllocFrame();
+					//pcm = frames->AllocFrame(); // It is not necessary to be compatible with the AXE1208 series here, because the TOP architecture is different.
 					m->SetOutputChannelDataPtr(i, pcm);
 					SetTxChannelPtr(static_cast<IntDataType>(mPhyID[i].mIntType), mPhyID[i].mPhyID-1, pcm->Data());
+<<<<<<< HEAD
+//					printf("mID %d,bid %d\n", pmod->mID, mPhyID[i].mPhyID-1);
+//					printf("phy_type %d, _id %d\n", mPhyID[i].mIntType, mPhyID[i].mPhyID);
+=======
 //					printf("phy_id %d", mPhyID[i].mPhyID);
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 				}
 			}
 			else {
@@ -329,6 +370,16 @@
 //		printf("\n");
 
 		m->Init();
+<<<<<<< HEAD
+
+		// 从 paramset 中获取对应的参数控制函数指针
+		ParamCtrl_fn paramEntry = paramset->GetParamEntry( m->GetModuleType());
+		if(paramEntry == NULL) {
+			printf("paramEntry is NULL!\n");
+		}
+		// 调用参数控制函数
+		u32 result = paramEntry(m, (uvoid*)pmod->mParamaddr, len);
+=======
 //		paramset->GetParamEntry(m->GetModuleType())(m, (uvoid*)pmod->mParamaddr, len);
 		// 获取模块类型
 		u32 moduleType = m->GetModuleType();
@@ -338,8 +389,20 @@
 		void* paramAddr = (uvoid*)pmod->mParamaddr;
 		// 调用参数控制函数
 		u32 result = paramEntry(m, paramAddr, len);
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 
 	} while (size < nbytes);
+
+//	int ddr = sram_free_space(SRAM_DDR,mem_any);
+//	int ccm = sram_free_space(SRAM_L2,mem_any);
+//	int l1 = sram_free_space(SRAM_L1,mem_heap);
+//	printf("mListAdd:0x%x, ddr %d ccm %d l1 %d.\n", &mList, ddr, ccm ,l1);
+
+//for (auto pl : mList) {
+//	delete pl;
+//	int l2mem = sram_free_space(SRAM_L2, mem_any);
+//	printf("L2mem %d\n", l2mem);
+//}
 
 	if (size != nbytes) {
 		dbg_printf("check flowchart some error!\n");
@@ -385,7 +448,11 @@
 {
 	if(processed) {
 		for (auto iter = mList.begin(); iter < mList.end(); iter++) {
+<<<<<<< HEAD
+//			if(((*iter)->GetModuleType() >= 6) && ((*iter)->GetModuleType() <= 6)) {
+=======
 //			if(((*iter)->GetModuleType() >= 9) && ((*iter)->GetModuleType() <= 9)) {
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 //				printf("%d ", (*iter)->GetModuleID());
 				(*iter)->Proc();
 //			}
@@ -410,6 +477,28 @@
 	return 0;
 }
 
+/*ErrStatus ToB::toCtrl(u32 mID, u32 pID, const s16* val, u32 num)
+{
+    if(mID >= mModuleIndex.size() || mModuleIndex[mID] == 0) {
+    	printf("ToB::toCtrl mID Error!\n");
+        return ErrStatus::ERR_PARAM;
+    }
+
+    IModule* m = mList[mModuleIndex[mID]-1];
+    if(!m) {
+    	printf("ToB::toCtrl m Error!\n");
+        return ErrStatus::ERR_PARAM;
+    }
+
+    auto entries  = paramset->GetEntries(m->GetModuleType());
+    if(!entries.second) {
+    	printf("ToB::toCtrl entries Error!\n");
+        return ErrStatus::ERR_METHOD;
+    }
+
+    entries.second(m, pID, const_cast<s16*>(val), num);
+    return ErrStatus::SUCCESS;
+}*/
 ErrStatus ToB::toCtrl(u32 mID, u32 pID, const s16* val, u32 num)
 {
 	if(mID >= mModuleIndex.size() || mModuleIndex[mID] == 0) {
@@ -418,10 +507,15 @@
 
 	IModule* m = mList[mModuleIndex[mID]-1];
 	if( m != NULL) {
+<<<<<<< HEAD
+//		m->Ctrl(pID, val, num);
+		paramset->GetCtrlEntry(m->GetModuleType())(m, pID, (s16*)val, num);
+=======
 		//m->Ctrl(pID, val, num);
 		paramset->GetCtrlEntry(m->GetModuleType())(m, pID, (s16*)val);
+>>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 	}
-
+//	printf("mID:%d pID:%d val[0]:%d val[1]:%d\n",mID, pID, val[0], val[1]);
 	return ErrStatus::SUCCESS;
 }
 

--
Gitblit v1.9.3