📄 main.c
字号:
frameDescriptorCh1 = (volatile LCD_FRAME_DESCRIPTOR *)(DMA_CHANNEL_1_FRAME_DESCRIPTOR_BASE_VIRTUAL);
frameDescriptorPalette = (volatile LCD_FRAME_DESCRIPTOR *)(PALETTE_FRAME_DESCRIPTOR_BASE_VIRTUAL);
v_pPaletteBuffer=(volatile LCD_PALETTE *)(PALETTE_BUFFER_BASE_VIRTUAL);
XllpLCD.GPIO = (XLLP_VUINT32_T *) ((UINT32)OALPAtoUA(BULVERDE_BASE_REG_PA_PERIPH) + GPIO_OFFSET);
XllpLCD.CLKMan = (XLLP_VUINT32_T *) ((UINT32)OALPAtoUA(BULVERDE_BASE_REG_PA_PERIPH) + CLKMGR_OFFSET);
XllpLCD.LCDC = (XLLP_VUINT32_T *) ((UINT32)OALPAtoUA(BULVERDE_BASE_REG_PA_LCD));
EdbgOutputDebugString("GPIO = %x\r\n", (UINT32)OALPAtoUA(BULVERDE_BASE_REG_PA_PERIPH) + GPIO_OFFSET);
EdbgOutputDebugString("CLKMan = %x\r\n", ((UINT32)OALPAtoUA(BULVERDE_BASE_REG_PA_PERIPH) + CLKMGR_OFFSET));
EdbgOutputDebugString("LCDC = %x\r\n", (UINT32)OALPAtoUA(BULVERDE_BASE_REG_PA_LCD));
XllpLCD.DisplayType = LTM04C380K;
XllpLCD.FrameBufferWidth = 640;
XllpLCD.FrameBufferHeight = 480;
XllpLCD.BPP = BPP_24;
XllpLCD.CurrentPage = 0;
XllpLCD.PixelDataFormat = PDFOR_11; //PDFOR_11
XllpLCD._FRAME_BUFFER_BASE_PHYSICAL = FRAME_BUFFER_0_BASE_PHYSICAL;
XllpLCD._PALETTE_BUFFER_BASE_PHYSICAL = PALETTE_BUFFER_BASE_PHYSICAL;
XllpLCD._DMA_CHANNEL_0_FRAME_DESCRIPTOR_BASE_PHYSICAL = DMA_CHANNEL_0_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD._DMA_CHANNEL_1_FRAME_DESCRIPTOR_BASE_PHYSICAL = DMA_CHANNEL_1_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD._DMA_CHANNEL_0_ALT_FRAME_DESCRIPTOR_BASE_PHYSICAL = DMA_CHANNEL_0_ALT_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD._PALETTE_FRAME_DESCRIPTOR_BASE_PHYSICAL = PALETTE_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD.frameDescriptorCh0fd1 = frameDescriptorCh0fd1;
XllpLCD.frameDescriptorCh0fd2 = frameDescriptorCh0fd2;
XllpLCD.frameDescriptorCh1 = frameDescriptorCh1;
XllpLCD.frameDescriptorPalette = frameDescriptorPalette;
XllpLCD.frameDescriptorTemp = frameDescriptorTemp;
// Initialize the LCD Controller
EdbgOutputDebugString(" +XllpLCDInit\r\n");
XllpLCDInit(&XllpLCD);
EdbgOutputDebugString(" -XllpLCDInit\r\n");
// turn off overlays...
pu32Pointer = (UINT32 *) OALPAtoUA(BULVERDE_BASE_REG_PA_LCD) + 50;
*pu32Pointer = 0x0;
pu32Pointer = (UINT32 *) OALPAtoUA(BULVERDE_BASE_REG_PA_LCD) + 70;
*pu32Pointer = 0x0;
pu32Pointer = (UINT32 *) OALPAtoUA(BULVERDE_BASE_REG_PA_LCD) + 90;
*pu32Pointer = 0x0;
EdbgOutputDebugString(" +SetBacklightMarathonDrive\r\n");
EdbgOutputDebugString(" OALPAtoUA(BULVERDE_BASE_REG_PA_LCD) = %x\r\n", OALPAtoUA(BULVERDE_BASE_REG_PA_LCD));
// Turn on backlight
SetBacklightMarathonDrive(TRUE);
EdbgOutputDebugString(" -SetBacklightMarathonDrive\r\n");
// passthru for 18 bit mode.
pu32Pointer = pu32MarathonBase + (MARATHON_LCD_CONFIG / sizeof(*pu32MarathonBase));
*pu32Pointer = 0x50090009; // Set 18bpp passthrough mode on both LCDs
// Clear the display
ClearFrameBuffer18();
EdbgOutputDebugString(" -ClearFrameBuffer18\r\n");
ColorBars18(); // Change to BPP_18 and PDFOR_11
EdbgOutputDebugString(" -ColorBars18\r\n");
EdbgOutputDebugString("Virt LCD Base: %x\r\n", OALPAtoUA(BULVERDE_BASE_REG_PA_LCD));
}
static void SixteenBPPCheck(void)
{
XLLP_LCD_T XllpLCD;
volatile LCD_FRAME_DESCRIPTOR *frameDescriptorCh0fd1=NULL;
volatile LCD_FRAME_DESCRIPTOR *frameDescriptorCh0fd2=NULL;
volatile LCD_FRAME_DESCRIPTOR *frameDescriptorCh1=NULL;
volatile LCD_FRAME_DESCRIPTOR *frameDescriptorPalette=NULL;
volatile LCD_FRAME_DESCRIPTOR *frameDescriptorTemp=NULL;
volatile LCD_PALETTE *v_pPaletteBuffer=NULL;
volatile UINT32 *pu32Pointer;
// First, set up the memory controller to get the Marathon alive
XScaleMMCSetup(CPU_SYSCLOCK);
// Setup DMA
frameDescriptorCh0fd1 = (volatile LCD_FRAME_DESCRIPTOR *)(DMA_CHANNEL_0_FRAME_DESCRIPTOR_BASE_VIRTUAL);
frameDescriptorCh0fd2 = (volatile LCD_FRAME_DESCRIPTOR *)(DMA_CHANNEL_0_ALT_FRAME_DESCRIPTOR_BASE_VIRTUAL);
frameDescriptorCh1 = (volatile LCD_FRAME_DESCRIPTOR *)(DMA_CHANNEL_1_FRAME_DESCRIPTOR_BASE_VIRTUAL);
frameDescriptorPalette = (volatile LCD_FRAME_DESCRIPTOR *)(PALETTE_FRAME_DESCRIPTOR_BASE_VIRTUAL);
v_pPaletteBuffer=(volatile LCD_PALETTE *)(PALETTE_BUFFER_BASE_VIRTUAL);
XllpLCD.GPIO = (XLLP_VUINT32_T *) ((UINT32)OALPAtoUA(BULVERDE_BASE_REG_PA_PERIPH) + GPIO_OFFSET);
XllpLCD.CLKMan = (XLLP_VUINT32_T *) ((UINT32)OALPAtoUA(BULVERDE_BASE_REG_PA_PERIPH) + CLKMGR_OFFSET);
XllpLCD.LCDC = (XLLP_VUINT32_T *) ((UINT32)OALPAtoUA(BULVERDE_BASE_REG_PA_LCD));
XllpLCD.DisplayType = LTM04C380K;
XllpLCD.FrameBufferWidth = 640;
XllpLCD.FrameBufferHeight = 480;
XllpLCD.BPP = BPP_16;
XllpLCD.CurrentPage = 0;
XllpLCD.PixelDataFormat = PDFOR_00;
XllpLCD._FRAME_BUFFER_BASE_PHYSICAL = FRAME_BUFFER_0_BASE_PHYSICAL;
XllpLCD._PALETTE_BUFFER_BASE_PHYSICAL = PALETTE_BUFFER_BASE_PHYSICAL;
XllpLCD._DMA_CHANNEL_0_FRAME_DESCRIPTOR_BASE_PHYSICAL = DMA_CHANNEL_0_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD._DMA_CHANNEL_1_FRAME_DESCRIPTOR_BASE_PHYSICAL = DMA_CHANNEL_1_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD._DMA_CHANNEL_0_ALT_FRAME_DESCRIPTOR_BASE_PHYSICAL = DMA_CHANNEL_0_ALT_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD._PALETTE_FRAME_DESCRIPTOR_BASE_PHYSICAL = PALETTE_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD.frameDescriptorCh0fd1 = frameDescriptorCh0fd1;
XllpLCD.frameDescriptorCh0fd2 = frameDescriptorCh0fd2;
XllpLCD.frameDescriptorCh1 = frameDescriptorCh1;
XllpLCD.frameDescriptorPalette = frameDescriptorPalette;
XllpLCD.frameDescriptorTemp = frameDescriptorTemp;
// Initialize the LCD Controller
XllpLCDInit(&XllpLCD);
// turn off overlays...
pu32Pointer = (UINT32 *) OALPAtoUA(BULVERDE_BASE_REG_PA_LCD) + 50;
*pu32Pointer = 0x0;
pu32Pointer = (UINT32 *) OALPAtoUA(BULVERDE_BASE_REG_PA_LCD) + 70;
*pu32Pointer = 0x0;
pu32Pointer = (UINT32 *) OALPAtoUA(BULVERDE_BASE_REG_PA_LCD) + 90;
*pu32Pointer = 0x0;
// backlight enable
SetBacklightMarathonDrive(TRUE);
// passthru to LCD 1 and 2
MarathonSetPassthroughMode(PASSTHROUGH_BOTH);
// Clear the display
ClearFrameBuffer16();
ColorBars16(); // Change to BPP_16 and PDFOR_00
EdbgOutputDebugString("Virt LCD Base: %x\r\n",OALPAtoUA(BULVERDE_BASE_REG_PA_LCD));
}
//------------------------------------------------------------------------------
//
// Function: main
//
// Bootloader main routine.
//
void main(void)
{
// Common boot loader (blcommon) main routine.
//
BootloaderMain();
// Should never get here.
//
SpinForever();
}
//------------------------------------------------------------------------------
//
// Function: OEMDebugInit
//
// Initialize debug serial UART.
//
BOOL OEMDebugInit(void)
{
// Initialize the flash interface (needed so we can determine which serial
// port to use for bootloader and OS debug message output).
//
if (!FlashInit((UINT32) OALPAtoVA(MAINSTONEII_BASE_PA_BOOT_FLASH, FALSE), MAINSTONEII_SIZE_BOOT_FLASH))
{
// Load default bootloader configuration settings.
//
EdbgOutputDebugString("ERROR: flash initialization failed - loading bootloader defaults...\r\n");
ResetDefaultEBootCFG(&g_EbootCFG);
}
else
{
// Load the bootloader configuration from flash (menu settings).
//
LoadEBootCFG(&g_EbootCFG);
}
// Initialize the debug UART.
//
InitDebugSerial(g_EbootCFG.dwDbgSerPhysAddr);
// Clear the hex LEDs.
//
OEMWriteDebugLED(0, 0);
// Set up optional bootloader function pointers.
//
g_pOEMVerifyMemory = OEMVerifyMemory;
return(TRUE);
}
//------------------------------------------------------------------------------
//
// Function: OEMPlatformInit
//
// Initialize the Mainstone II platform.
//
BOOL OEMPlatformInit(void)
{
UINT32 AutoBootDelay = 0;
BOOLEAN bXIPMode = TRUE;
BOOLEAN bCFGChanged = FALSE;
SYSTEMTIME SysTime;
UINT32 StartTime, CurrTime, PrevTime;
UINT32 Selection;
UINT32 EthDevice;
// This table describes the boot order for a given configuration.
//
ETH_DEVICE_TYPE BootOrder[] = { ETH_DEVICE_SMSC, ETH_DEVICE_PCMCIA0, ETH_DEVICE_PCMCIA1, // pEbootCFG->bootDeviceOrder = 0.
ETH_DEVICE_SMSC, ETH_DEVICE_PCMCIA1, ETH_DEVICE_PCMCIA0, // pEbootCFG->bootDeviceOrder = 1.
ETH_DEVICE_PCMCIA0, ETH_DEVICE_PCMCIA1, ETH_DEVICE_SMSC, // pEbootCFG->bootDeviceOrder = 2.
ETH_DEVICE_PCMCIA0, ETH_DEVICE_SMSC, ETH_DEVICE_PCMCIA1, // pEbootCFG->bootDeviceOrder = 3.
ETH_DEVICE_PCMCIA1, ETH_DEVICE_SMSC, ETH_DEVICE_PCMCIA0, // pEbootCFG->bootDeviceOrder = 4.
ETH_DEVICE_PCMCIA1, ETH_DEVICE_PCMCIA0, ETH_DEVICE_SMSC }; // pEbootCFG->bootDeviceOrder = 5.
#ifndef DEBUG
displayStartUpImage();
#endif
EdbgOutputDebugString("Microsoft Windows CE Ethernet Bootloader %d.%d for the Intel MainstoneII Development Platform Built %s\r\n", \
EBOOT_VERSION_MAJOR, EBOOT_VERSION_MINOR, __DATE__);
//
memset((LPVOID)g_pBSPArgs, 0, sizeof(BSP_ARGS));
g_pBSPArgs->header.signature = OAL_ARGS_SIGNATURE;
g_pBSPArgs->header.oalVersion = OAL_ARGS_VERSION;
g_pBSPArgs->header.bspVersion = BSP_ARGS_VERSION;
// Initialize the global XLLP device handle for the PC Card interface.
//
memset((void *) &strEbtPCCardSocketHandle, 0, sizeof(XLLP_PCCARDSOCKET_T));
strEbtPCCardSocketHandle.pstrGpioRegsHandle = (XLLP_GPIO_T *) OALPAtoVA(BULVERDE_BASE_REG_PA_GPIO, FALSE);
XllpPCCardConfigureGPIOs(&strEbtPCCardSocketHandle);
// Read the current wall-clock time.
// NOTE: At reset, the RTC value is set to 1/1/1980 at 0:0:0.
//
OEMGetRealTime(&SysTime);
// Print out clock settings.
EdbgOutputDebugString("*******Clock Frequency Settings*******\r\n");
PrintClockSettings();
// Enable/Disable Marathon based on the saved settings.
MarathonICSet(g_EbootCFG.eMarathonICEnable);
// User menu code...
//
AutoBootDelay = g_EbootCFG.delay;
if (g_EbootCFG.autoDownloadImage)
{
g_DownloadImage = TRUE;
EdbgOutputDebugString ( "\r\nPress [ENTER] to download now or [SPACE] to cancel.\r\n");
EdbgOutputDebugString ( "\r\nInitiating image download in %d seconds. ", AutoBootDelay--);
}
else
{
g_DownloadImage = FALSE;
EdbgOutputDebugString ( "\r\nPress [ENTER] to launch image stored in flash or [SPACE] to cancel.\r\n");
EdbgOutputDebugString ( "\r\nInitiating image launch in %d seconds. ", AutoBootDelay--);
}
// Get a snapshot of the RTC seconds count.
//
StartTime = OEMEthGetSecs();
PrevTime = StartTime;
CurrTime = StartTime;
Selection = 0;
// Allow the user an amount of time to halt the auto boot/download process.
// Count down to 0 before proceeding with default operation.
//
while ((CurrTime - StartTime) < g_EbootCFG.delay)
{
UINT8 i=0;
UINT8 j;
UINT8 x,y,z;
Selection = OEMReadDebugByte();
if ((Selection == 0x20) || (Selection == 0x0d))
{
break;
}
CurrTime = OEMEthGetSecs();
if (CurrTime > PrevTime)
{
PrevTime = CurrTime;
if (AutoBootDelay < 9)
i = 11;
else if (AutoBootDelay < 99)
i = 12;
else if (AutoBootDelay < 999)
i = 13;
for (j = 0; j < i; j++)
{
OEMWriteDebugByte((BYTE)0x08); // print back space
}
x = AutoBootDelay / 100;
y = (AutoBootDelay % 100) / 10;
z = ((AutoBootDelay % 100) % 10);
OEMWriteDebugLED(0, ((x << 8) | (y << 4) | (z)));
EdbgOutputDebugString ( "%d seconds. ", AutoBootDelay--);
}
}
switch (Selection)
{
case 0x00: // fall through if nothing typed
case 0x0d: // user canceled wait
{
if (g_EbootCFG.autoDownloadImage)
{
EdbgOutputDebugString ( "\r\nStarting auto download ... \r\n");
}
else
{
EdbgOutputDebugString ( "\r\nLaunching flash image ... \r\n");
}
break;
}
case 0x20:
{
Selection = 0;
while (1)
{
// Show menu
EdbgOutputDebugString ( "\r\n\r\nEthernet Boot Loader Configuration:\r\n\r\n");
EdbgOutputDebugString ( "0) IP address: %s\r\n",inet_ntoa(g_EbootCFG.IP));
EdbgOutputDebugString ( "1) Subnet mask: %s\r\n", inet_ntoa(g_EbootCFG.subnetMask));
EdbgOutputDebugString ( "2) Boot delay: %d seconds\r\n", g_EbootCFG.delay);
EdbgOutputDebugString ( "3) DHCP: %s\r\n", (g_EbootCFG.DHCPEnable == TRUE?"(Enabled)":"(Disabled)"));
EdbgOutputDebugString ( "4) Reset to factory default configuration\r\n");
EdbgOutputDebugString ( "5) %s image at startup\r\n", g_EbootCFG.autoDownloadImage?"Download new":"Launch existing flash resident");
EdbgOutputDebugString ( "6) Boot device order: ");
switch (g_EbootCFG.bootDeviceOrder)
{
case 0:
EdbgOutputDebugString ( "SMSC -> PCMCIA0 -> PCMCIA1\r\n");
break;
case 1:
EdbgOutputDebugString ( "SMSC -> PCMCIA1 -> PCMCIA0\r\n");
break;
case 2:
EdbgOutputDebugString ( "PCMCIA0 -> PCMCIA1 -> SMSC\r\n");
break;
case 3:
EdbgOutputDebugString ( "PCMCIA0 -> SMSC -> PCMCIA1\r\n");
break;
case 4:
EdbgOutputDebugString ( "PCMCIA1 -> SMSC -> PCMCIA0\r\n");
break;
case 5:
EdbgOutputDebugString ( "PCMCIA1 -> PCMCIA0 -> SMSC\r\n");
break;
default:
EdbgOutputDebugString ( "SMSC -> PCMCIA0 -> PCMCIA1\r\n");
g_EbootCFG.bootDeviceOrder = 0;
break;
}
EdbgOutputDebugString ( "7) Debug serial port: ");
switch (g_EbootCFG.dwDbgSerPhysAddr)
{
case BULVERDE_BASE_REG_PA_FFUART:
EdbgOutputDebugString ( "FFUART\r\n");
break;
case BULVERDE_BASE_REG_PA_BTUART:
default:
EdbgOutputDebugString ( "BTUART\r\n");
break;
}
EdbgOutputDebugString ( "B) Enter eBoot debugger\r\n");
EdbgOutputDebugString ( "D) Download image now\r\n");
EdbgOutputDebugString ( "I) Marathon IC (");
if (MARATHON_IC_ENABLED == g_EbootCFG.eMarathonICEnable)
{
EdbgOutputDebugString("Enabled)\r\n");
}
else
{
EdbgOutputDebugString("Disabled)\r\n");
}
EdbgOutputDebugString ( "L) Launch existing flash resident image now\r\n");
EdbgOutputDebugString ( "M) Marathon presence check/register test\r\n");
EdbgOutputDebugString ( "P) Marathon passthrough mode (%s)\r\n", sg_pu8MarathonPassthroughText[g_EbootCFG.eMarathonPassthrough]);
EdbgOutputDebugString ( "Y) 18bpp Marathon passthrough check\r\n");
EdbgOutputDebugString ( "Z) 16bpp Marathon passthrough check\r\n");
EdbgOutputDebugString ( "\r\n\r\nEnter your selection: ");
Selection = 0;
while (! ( ( (Selection >= '0') && (Selection <= '7') ) ||
( (Selection == 'B') || (Selection == 'b') ) ||
( (Selection == 'D') || (Selection == 'd') ) ||
( (Selection == 'L') || (Selection == 'l') ) ||
( (Selection == 'I') || (Selection == 'i') ) ||
( (Selection == 'M') || (Selection == 'm') ) ||
( (Selection == 'P') || (Selection == 'p') ) ||
( (Selection == 'Y') || (Selection == 'y') ) ||
( (Selection == 'Z') || (Selection == 'z') )))
{
Selection = OEMReadDebugByte();
}
EdbgOutputDebugString ( "%c\r\n", Selection);
switch (Selection)
{
case '0':
SetIP(&g_EbootCFG);
bCFGChanged=TRUE;
break;
case '1':
SetMask(&g_EbootCFG);
bCFGChanged=TRUE;
break;
case '2':
SetDelay(&g_EbootCFG);
bCFGChanged=TRUE;
break;
case '3':
if (g_EbootCFG.DHCPEnable == TRUE)
g_EbootCFG.DHCPEnable = FALSE;
else
g_EbootCFG.DHCPEnable = TRUE;
bCFGChanged=TRUE;
break;
case '4':
ResetDefaultEBootCFG(&g_EbootCFG);
bCFGChanged=TRUE;
break;
case '5':
if (g_EbootCFG.autoDownloadImage == TRUE)
g_EbootCFG.autoDownloadImage = FALSE;
else
g_EbootCFG.autoDownloadImage = TRUE;
bCFGChanged=TRUE;
break;
case '6':
g_EbootCFG.bootDeviceOrder++;
if (g_EbootCFG.bootDeviceOrder > 5)
g_EbootCFG.bootDeviceOrder = 0;
bCFGChanged=TRUE;
break;
case '7':
if ((g_EbootCFG.dwDbgSerPhysAddr == 0) || (g_EbootCFG.dwDbgSerPhysAddr == BULVERDE_BASE_REG_PA_BTUART))
{
g_EbootCFG.dwDbgSerPhysAddr = BULVERDE_BASE_REG_PA_FFUART;
}
else
{
g_EbootCFG.dwDbgSerPhysAddr = BULVERDE_BASE_REG_PA_BTUART;
}
bCFGChanged=TRUE;
break;
case 'B':
case 'b':
{
Debugger();
break;
}
case 'D':
case 'd':
if (bCFGChanged == TRUE)
{
StoreEBootCFG(&g_EbootCFG);
}
g_DownloadImage = TRUE;
goto CONTINUE;
case 'I':
case 'i':
if (MARATHON_IC_ENABLED == g_EbootCFG.eMarathonICEnable)
{
g_EbootCFG.eMarathonICEnable = MARATHON_IC_DISABLED;
}
else
{
g_EbootCFG.eMarathonICEnable = MARATHON_IC_ENABLED;
}
MarathonICSet(g_EbootCFG.eMarathonICEnable);
bCFGChanged
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -