xref: /utopia/UTPA2-700.0.x/modules/msos/utopia_core/nuttx/utopia_module.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 #include "MsTypes.h"
2 #include "utopia_module.h"
3 #include "utopia_dapi.h"
4 #include "MsOS.h"
5 #include "utopia_private.h"
6 #include <stdio.h>
7 
8 int lib_lowprintf(const char *fmt, ...);
9 #define printf lib_lowprintf
_UtopiaModule_Ioctl(void ** pInstant,MS_U32 u32Cmd,MS_U32 * pu32Args)10 MS_U32 _UtopiaModule_Ioctl(void** pInstant, MS_U32 u32Cmd, MS_U32* pu32Args)
11 {
12     switch(u32Cmd)
13     {
14         case CHANGE_DEBUG_LEVEL_BY_MODULE:
15         case HOOK_MODULE_IOCTL_BY_MODULE:
16         case HOOK_MODULE_CMD_BY_MODULE:
17         case DUMP_MODULE_HW_REGISTER:
18         case DUMP_MODULE_STRUCTURE:
19         case DUMP_INSTANT_STRUCTURE:
20         case DUMP2MEMORY_MODULE_HW_REGISTER:
21         case DUMP2MEMORY_MODULE_STRUCTURE:
22         case DUMP2MEMORY_INSTANT_STRUCTURE:
23         case SHOW_RESOURCE_STATUS_BY_MODULE:
24 			;
25     }
26 	return 0;
27 }
28 
29 extern char moduleNames[][40];
30 #define UTOPIA_SEM_START 0x4427 // joe's phone number
UTOPIARegisterToUtopia(FUtopiaOpen ModuleType)31 MS_U32 UTOPIARegisterToUtopia(FUtopiaOpen ModuleType)
32 {
33 	MS_U32 u32ShmId, u32Addr, u32BufSize;
34 
35 	//MsOS_Init(); // contain MsOS_SHM_Init()
36 	//MsOS_SHM_Init();
37 
38 	// return 0 for first initiaization, 1 for repeated initialization
39 	MS_U32 bInitialized = MsOS_SHM_GetId((MS_U8*)"MS_MODULE_UTOPIA", sizeof(UTOPIA_MODULE_SHM), &u32ShmId, &u32Addr, &u32BufSize, MSOS_SHM_QUERY);
40 
41 	void* pUtopiaModule = NULL;
42 	UtopiaModuleCreate(MODULE_UTOPIA, 0, &pUtopiaModule);
43 	UtopiaModuleRegister(pUtopiaModule);
44 	//TOPIA_RESOURCE* psResource = (UTOPIA_RESOURCE*)UtopiaResourceCreate("SemStartKey", sizeof(int));
45 	UTOPIA_RESOURCE* psResource = NULL;
46 	UtopiaResourceCreate("SemStartKey", sizeof(int), (void**)&psResource);
47 
48 	if (!bInitialized)
49 	{
50 		//MS_U32* pu32SemKey = (MS_U32*)shmid2va(psResource->shmid_private.ID);
51 		MS_U32* pu32SemKey = NULL;
52 		printf("\n%s, %d\n", __FUNCTION__, __LINE__); // bob.fu
53 		UtopiaResourceGetPrivate(psResource, (void**)&pu32SemKey);
54 		printf("\n%s, %d, %p\n", __FUNCTION__, __LINE__, pu32SemKey); // bob.fu
55 		*pu32SemKey = UTOPIA_SEM_START;
56 	}
57 	UtopiaResourceRegister(pUtopiaModule, psResource, UTOPIA_POOL_ID_DATA);
58 	return 1;
59 }
60