地址映射错误。报错如下:
ERROR: C:\WINCE600\PLATFORM\SBC8100\SRC\DRIVERS\TOUCH\.\touchscreen.cpp line 182
: For PRCMregs: VirtualAlloc failed!
物理地址映射虚拟地址程序如下:为什么其他的没有问题,就v_pPRCMregs寄存器映射出错?
- TSP_RegAlloc(PVOID addr, INT sz)
- {
- PVOID reg;
- reg = (PVOID)VirtualAlloc(0, sz, MEM_RESERVE, PAGE_NOACCESS);
- if (reg)
- {
- if (!VirtualCopy(reg, (PVOID)((UINT32)addr >> 8), sz, PAGE_PHYSICAL | PAGE_READWRITE | PAGE_NOCACHE ))
- {
- VirtualFree(reg, 0, MEM_RELEASE);
- reg = NULL;
- }
- }
- return reg;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////
- v_pIOPregs = (volatile OMAP_GPIO_REGS *)TSP_RegAlloc((PVOID)OMAP_GPIO6_REGS_PA, sizeof(OMAP_GPIO_REGS));////2
- if (v_pIOPregs == NULL)
- {
- ERRORMSG(1,(TEXT("For IOPreg: VirtualAlloc failed!\r\n")));
- break;
- }
-
- v_pIICPregs = (volatile OMAP_I2C_REGS *)TSP_RegAlloc((PVOID)OMAP_I2C3_REGS_PA, sizeof(OMAP_I2C_REGS)); /////////2
- if (v_pIICPregs == NULL)
- {
- ERRORMSG(1,(TEXT("For IICregs: VirtualAlloc failed!\r\n")));
- break;
- }
- v_pINTregs = (volatile OMAP_INTC_MPU_REGS *)TSP_RegAlloc((PVOID)OMAP_INTC_MPU_REGS_PA, sizeof(OMAP_INTC_MPU_REGS));
- if (v_pADCregs == NULL)
- {
- ERRORMSG(1,(TEXT("For INTregs: VirtualAlloc failed!\r\n")));
- break;
- }
- v_pPRCMregs = (volatile OMAP_PRCM_CORE_CM_REGS *)TSP_RegAlloc((PVOID)OMAP_PRCM_CORE_CM_REGS_PA, sizeof(OMAP_PRCM_CORE_CM_REGS));/////////2
- if (v_pPRCMregs == NULL)
- {
- ERRORMSG(1,(TEXT("For PRCMregs: VirtualAlloc failed!\r\n")));
- break;
- }
OMAP_PRCM_CORE_CM_REGS结构为:
- typedef volatile struct {
- unsigned int CM_FCLKEN1_CORE; // offset 0x0000
- unsigned int zzzReserved00[1]; // offset 0x0004
- unsigned int CM_FCLKEN3_CORE; // offset 0x0008
- unsigned int zzzReserved01[1];
- unsigned int CM_ICLKEN1_CORE; // offset 0x0010
- unsigned int CM_ICLKEN2_CORE; // offset 0x0014
- unsigned int CM_ICLKEN3_CORE; // offset 0x0018
- unsigned int zzzReserved02[1];
- unsigned int CM_IDLEST1_CORE; // offset 0x0020
- unsigned int CM_IDLEST2_CORE; // offset 0x0024
- unsigned int CM_IDLEST3_CORE; // offset 0x0028
- unsigned int zzzReserved03[1];
- unsigned int CM_AUTOIDLE1_CORE; // offset 0x0030
- unsigned int CM_AUTOIDLE2_CORE; // offset 0x0034
- unsigned int CM_AUTOIDLE3_CORE; // offset 0x0038
- unsigned int zzzReserved04[1];
- unsigned int CM_CLKSEL_CORE; // offset 0x0040
- unsigned int zzzReserved05[1]; // offset 0x0044
- unsigned int CM_CLKSTCTRL_CORE; // offset 0x0048
- unsigned int CM_CLKSTST_CORE; // offset 0x004C
- } OMAP_PRCM_CORE_CM_REGS;