This post covers accessing Memory Mapped Register from Windows Compact 7 BSP
For this we have followed below steps
For RegRead
VOID RegRead
(
OAL_BLMENU_ITEM *pMenu
)
{
WCHAR szVal[9];
UINT32 u32RegAddr;
OALLog(L"\r\n Enter Register Address: ");
if (OALBLMenuReadLine(szVal, dimof(szVal)) == 0)
{
goto cleanUp;
}
u32RegAddr = OALStringToHex(szVal);
OALMSG (1,(L"\r\n\tReg Addr:0x%08x Val:0x%08x\r\n",
u32RegAddr, *((DWORD *)u32RegAddr)));
cleanUp:
return;
}
For RegWrite
For this function we need to take two inputs. The first one is Register Address and the second input is Register Value. The source code for the same is given below.
VOID RegWrite
(
OAL_BLMENU_ITEM *pMenu
)
{
WCHAR szVal[9];
UINT32 u32RegAddr;
UINT32 u32RegVal;
OALLog(L"\r\n Enter Register Address: ");
if (OALBLMenuReadLine(szVal, dimof(szVal)) == 0)
{
goto cleanUp;
}
u32RegAddr = OALStringToHex(szVal);
OALLog(L"\r\n Enter Register Value: ");
if (OALBLMenuReadLine(szVal, dimof(szVal)) == 0)
{
goto cleanUp;
}
u32RegVal = OALStringToHex(szVal);
OALMSG (1,(L"\r\n\tWriting to Register Addr:0x%08x Val:0x%08x\r\n",
u32RegAddr, u32RegVal));
*((DWORD *)u32RegAddr) = u32RegVal;
cleanUp:
return;
}
OALStringtoHex
The String to hex conversion function has to convert string to hex and it is left for the readers to write themselves.
Creating Menu for Register Utility
static OAL_BLMENU_ITEM g_menuRegisterUtilities[] = {
{
L'1', L"Write Reg", RegWrite,
NULL, NULL, NULL
}, {
L'2', L"Read Reg", RegRead,
NULL, NULL, NULL
}, {
L'0', L"Exit and Continue", NULL,
NULL, NULL, NULL
}, {
0, NULL, NULL,
NULL, NULL, NULL
}
};
Adding Register Utility Menu to Main Menu
Please add below lines before Exit and Continue of the Eboot Main Menu
}, {
L'R', L"Register Utility Menu", OALBLMenuShow,
L"Register Utility Menu", &g_menuRegisterUtilities, NULL
Note: Please do remember to remove this option while shipping the products.
Thank You for reading the post.
When I was debugging one of the peripheral in Eboot, we are not sure about the sequence of initialization as the documentation on the hardware is little and we also had very little support from the vendor.
Given this scenario if we modify a single bit in a register do the following for each iteration
Then we thought of having a Eboot menu in which we can read and write to Memory Mapped Registers.
Given this scenario if we modify a single bit in a register do the following for each iteration
- Build the EBoot Module
- Insert SD Card into Card Reader
- Copy binaries to SD Card
- Safe Remove from PC
- Reinsert into target Micro-SD Slot
- Wait for Eboot to boot
- Check the Register Values by dumping them
Then we thought of having a Eboot menu in which we can read and write to Memory Mapped Registers.
For this we have followed below steps
- Implement RegRead function
- Implement RegWrite funciton
- Implement OALStringToHex
- Create a menu for the Register Utility
- Add the Utility to Eboot Main Menu
For RegRead
VOID RegRead
(
OAL_BLMENU_ITEM *pMenu
)
{
WCHAR szVal[9];
UINT32 u32RegAddr;
OALLog(L"\r\n Enter Register Address: ");
if (OALBLMenuReadLine(szVal, dimof(szVal)) == 0)
{
goto cleanUp;
}
u32RegAddr = OALStringToHex(szVal);
OALMSG (1,(L"\r\n\tReg Addr:0x%08x Val:0x%08x\r\n",
u32RegAddr, *((DWORD *)u32RegAddr)));
cleanUp:
return;
}
For RegWrite
For this function we need to take two inputs. The first one is Register Address and the second input is Register Value. The source code for the same is given below.
VOID RegWrite
(
OAL_BLMENU_ITEM *pMenu
)
{
WCHAR szVal[9];
UINT32 u32RegAddr;
UINT32 u32RegVal;
OALLog(L"\r\n Enter Register Address: ");
if (OALBLMenuReadLine(szVal, dimof(szVal)) == 0)
{
goto cleanUp;
}
u32RegAddr = OALStringToHex(szVal);
OALLog(L"\r\n Enter Register Value: ");
if (OALBLMenuReadLine(szVal, dimof(szVal)) == 0)
{
goto cleanUp;
}
u32RegVal = OALStringToHex(szVal);
OALMSG (1,(L"\r\n\tWriting to Register Addr:0x%08x Val:0x%08x\r\n",
u32RegAddr, u32RegVal));
*((DWORD *)u32RegAddr) = u32RegVal;
cleanUp:
return;
}
OALStringtoHex
The String to hex conversion function has to convert string to hex and it is left for the readers to write themselves.
Creating Menu for Register Utility
static OAL_BLMENU_ITEM g_menuRegisterUtilities[] = {
{
L'1', L"Write Reg", RegWrite,
NULL, NULL, NULL
}, {
L'2', L"Read Reg", RegRead,
NULL, NULL, NULL
}, {
L'0', L"Exit and Continue", NULL,
NULL, NULL, NULL
}, {
0, NULL, NULL,
NULL, NULL, NULL
}
};
Adding Register Utility Menu to Main Menu
Please add below lines before Exit and Continue of the Eboot Main Menu
}, {
L'R', L"Register Utility Menu", OALBLMenuShow,
L"Register Utility Menu", &g_menuRegisterUtilities, NULL
Note: Please do remember to remove this option while shipping the products.
Thank You for reading the post.