📄 main.c.ori
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#include <windows.h>
#include <bsp.h>
#include <ethdbg.h>
#include <fmd.h>
#include "loader.h"
extern void LedBlink(DWORD loop_cnt, BYTE Led1, BYTE Led2);
void Mark_BadBlock(DWORD StartBlock, DWORD EndBlock);
// For USB Download function.
extern BOOL UbootReadData (DWORD cbData, LPBYTE pbData);
extern BOOL InitUSB ();
extern void Isr_Init();
// For USB Download function.
char *inet_ntoa(DWORD dwIP);
DWORD inet_addr( char *pszDottedD );
BOOL EbootInitEtherTransport (EDBG_ADDR *pEdbgAddr, LPDWORD pdwSubnetMask,
BOOL *pfJumpImg,
DWORD *pdwDHCPLeaseTime,
UCHAR VersionMajor, UCHAR VersionMinor,
char *szPlatformString, char *szDeviceName,
UCHAR CPUId, DWORD dwBootFlags);
BOOL EbootEtherReadData (DWORD cbData, LPBYTE pbData);
EDBG_OS_CONFIG_DATA *EbootWaitForHostConnect (EDBG_ADDR *pDevAddr, EDBG_ADDR *pHostAddr);
// End ***************************************
// Globals
//
DWORD g_ImageType;
MultiBINInfo g_BINRegionInfo;
PBOOT_CFG g_pBootCfg;
UCHAR g_TOC[SECTOR_SIZE];
const PTOC g_pTOC = (PTOC)&g_TOC;
DWORD g_dwImageStartBlock;
DWORD g_dwTocEntry;
BOOL g_bBootMediaExist = FALSE;
BOOL g_bDownloadImage = TRUE;
BOOL g_bWaitForConnect = TRUE;
BOOLEAN g_bUSBDownload = FALSE;
EDBG_ADDR g_DeviceAddr; // NOTE: global used so it remains in scope throughout download process
// since eboot library code keeps a global pointer to the variable provided.
WORD wNUM_BLOCKS; // for supporting both SMALL and LARGE Block NAND
// External definitions.
//
//extern const BYTE ScreenBitmap[];
#ifdef DEBUG
DWORD EdbgDebugZone = 0;//ZONE_WARNING|ZONE_INIT; //ZONE_DHCP;
#endif
/*
@func void | SpinForever | Halts execution (used in error conditions).
@rdesc
@comm
@xref
*/
static void SpinForever(void)
{
EdbgOutputDebugString("SpinForever...\r\n");
while(1)
{
;
}
}
/*
@func void | main | Samsung bootloader C routine entry point.
@rdesc N/A.
@comm
@xref
*/
void main(void)
{
// Common boot loader (blcommon) main routine.
// Have to call Bootloaderamin first.
BootloaderMain();
// Should never get here.
//
SpinForever();
}
//=============================================================
// For LCD display......
void SetGPIOforLDI(void)
{
volatile S3C2413_IOPORT_REG *s2413IOP = (S3C2413_IOPORT_REG *)OALPAtoVA(S3C2413_BASE_REG_PA_IOPORT, FALSE);
//GPIO Configuration for setting LDI
s2413IOP->GPEDN |= (0x3<<12);
s2413IOP->GPGDN |= (0x1<<2);
s2413IOP->GPEDAT |= (0x3<<12);
s2413IOP->GPGDAT |= (0x1<<2);
s2413IOP->GPECON = (s2413IOP->GPECON & ~(0xf<<24))|(0x5<<24);
s2413IOP->GPGCON = (s2413IOP->GPGCON & ~(0x3<<4))|(0x1<<4);
}
void delayLoop(int count)
{
volatile int j;
for(j = 0; j < count; j++) ;
}
#define LCD_DEN (1<<2) //GPG2, nSS
#define LCD_DSERI (1<<12) //GPE12, SPIMOSI
#define LCD_DCLK (1<<13) //GPE13, SPICLK
#define LCD_RESET (0)
#define LCD_DEN_Lo (s2413IOP->GPGDAT &= ~LCD_DEN)
#define LCD_DEN_Hi (s2413IOP->GPGDAT |= LCD_DEN)
#define LCD_DCLK_Lo (s2413IOP->GPEDAT &= ~LCD_DCLK)
#define LCD_DCLK_Hi (s2413IOP->GPEDAT |= LCD_DCLK)
#define LCD_DSERI_Lo (s2413IOP->GPEDAT &= ~LCD_DSERI)
#define LCD_DSERI_Hi (s2413IOP->GPEDAT |= LCD_DSERI)
#define LCD_RESET_Lo (0)
#define LCD_RESET_Hi (1)
#if WIDE_LCD==1
//================================================================
// Init for Wide LCD...
void WriteLDI_LTS350(int address, int data)
{
volatile S3C2413_IOPORT_REG *s2413IOP = (S3C2413_IOPORT_REG *)OALPAtoVA(S3C2413_BASE_REG_PA_IOPORT, FALSE);
unsigned char dev_id_code=0x1D;
int j;
unsigned char DELAY=50;
LCD_DEN_Hi; // EN = High CS high
LCD_DCLK_Hi; // SCL High
LCD_DSERI_Hi; // Data Low
delayLoop(DELAY);
LCD_DEN_Lo; // EN = Low CS Low
delayLoop(DELAY);
for (j = 5; j >= 0; j--)
{
LCD_DCLK_Lo; // SCL Low
if ((dev_id_code >> j) & 0x0001) // DATA HIGH or LOW
{
LCD_DSERI_Hi;
}
else
{
LCD_DSERI_Lo;
}
delayLoop(DELAY);
LCD_DCLK_Hi; // CLOCK = High
delayLoop(DELAY);
}
// RS = "0" : index data
LCD_DCLK_Lo; // CLOCK = Low
LCD_DSERI_Lo;
delayLoop(DELAY);
LCD_DCLK_Hi; // CLOCK = High
delayLoop(DELAY);
// Write
LCD_DCLK_Lo; // CLOCK = Low
LCD_DSERI_Lo;
delayLoop(DELAY);
LCD_DCLK_Hi; // CLOCK = High
delayLoop(DELAY);
for (j = 15; j >= 0; j--)
{
LCD_DCLK_Lo; // SCL Low
if ((address >> j) & 0x0001) // DATA HIGH or LOW
{
LCD_DSERI_Hi;
}
else
{
LCD_DSERI_Lo;
}
delayLoop(DELAY);
LCD_DCLK_Hi; // CLOCK = High
delayLoop(DELAY);
}
LCD_DSERI_Hi;
delayLoop(DELAY);
LCD_DEN_Hi; // EN = High
delayLoop(DELAY*10);
LCD_DEN_Lo; // EN = Low CS Low
delayLoop(DELAY);
for (j = 5; j >= 0; j--)
{
LCD_DCLK_Lo; // SCL Low
if ((dev_id_code >> j) & 0x0001) // DATA HIGH or LOW
{
LCD_DSERI_Hi;
}
else
{
LCD_DSERI_Lo;
}
delayLoop(DELAY);
LCD_DCLK_Hi; // CLOCK = High
delayLoop(DELAY);
}
// RS = "1" instruction data
LCD_DCLK_Lo; // CLOCK = Low
LCD_DSERI_Hi;
delayLoop(DELAY);
LCD_DCLK_Hi; // CLOCK = High
delayLoop(DELAY);
// Write
LCD_DCLK_Lo; // CLOCK = Low
LCD_DSERI_Lo;
delayLoop(DELAY);
LCD_DCLK_Hi; // CLOCK = High
delayLoop(DELAY);
for (j = 15; j >= 0; j--)
{
LCD_DCLK_Lo; // SCL Low
if ((data >> j) & 0x0001) // DATA HIGH or LOW
{
LCD_DSERI_Hi;
}
else
{
LCD_DSERI_Lo;
}
delayLoop(DELAY);
LCD_DCLK_Hi; // CLOCK = High
delayLoop(DELAY);
}
LCD_DEN_Hi; // EN = High
delayLoop(DELAY);
}
void InitLDI_LTV350(void)
{
volatile S3C2413_IOPORT_REG *s2413IOP = (S3C2413_IOPORT_REG *)OALPAtoVA(S3C2413_BASE_REG_PA_IOPORT, FALSE);
SetGPIOforLDI();
LCD_DEN_Hi;
LCD_DCLK_Hi;
LCD_DSERI_Hi;
LCD_RESET_Hi;
LCD_RESET_Hi;
delayLoop(10);
//delayLoopLoop(1800000);
///////////////////////////////////////////////////////////////////
// Init_Lcd_Function
//////////////////////////////////////////////////////////////////
WriteLDI_LTS350(0x01,0x001d);
WriteLDI_LTS350(0x02,0x0000);
WriteLDI_LTS350(0x03,0x0000);
WriteLDI_LTS350(0x04,0x0000);
WriteLDI_LTS350(0x05,0x50a3);
WriteLDI_LTS350(0x06,0x0000);
WriteLDI_LTS350(0x07,0x0000);
WriteLDI_LTS350(0x08,0x0000);
WriteLDI_LTS350(0x09,0x0000);
WriteLDI_LTS350(0x0a,0x0000);
WriteLDI_LTS350(0x10,0x0000);
WriteLDI_LTS350(0x11,0x0000);
WriteLDI_LTS350(0x12,0x0000);
WriteLDI_LTS350(0x13,0x0000);
WriteLDI_LTS350(0x14,0x0000);
WriteLDI_LTS350(0x15,0x0000);
WriteLDI_LTS350(0x16,0x0000);
WriteLDI_LTS350(0x17,0x0000);
WriteLDI_LTS350(0x18,0x0000);
WriteLDI_LTS350(0x19,0x0000);
delayLoop(100);
//delayLoopLoop(1800000);
///////////////////////////////////////////////////////////////////
// Set_PwrOn_Function1
//////////////////////////////////////////////////////////////////
WriteLDI_LTS350(0x09,0x4055);
WriteLDI_LTS350(0x0a,0x0000);
delayLoop(500);
//delayLoopLoop(1800000);
///////////////////////////////////////////////////////////////////
// Set_PwrOn_Function2
//////////////////////////////////////////////////////////////////
WriteLDI_LTS350(0x0a,0x2000);
delayLoop(1000);
//delayLoopLoop(50*180000);
///////////////////////////////////////////////////////////////////
// Set_Disp_Function
//////////////////////////////////////////////////////////////////
WriteLDI_LTS350(0x01,0x409d); // note 1
WriteLDI_LTS350(0x02,0x0204); // note 2
WriteLDI_LTS350(0x03,0x2100);
WriteLDI_LTS350(0x04,0x1000);
WriteLDI_LTS350(0x05,0x5003);
WriteLDI_LTS350(0x06,0x0009); // note 3
WriteLDI_LTS350(0x07,0x000f); // note 3
WriteLDI_LTS350(0x08,0x0800);
WriteLDI_LTS350(0x10,0x0000);
WriteLDI_LTS350(0x11,0x0000);
WriteLDI_LTS350(0x12,0x000f);
WriteLDI_LTS350(0x13,0x1f00);
WriteLDI_LTS350(0x14,0x0000);
WriteLDI_LTS350(0x15,0x0000);
WriteLDI_LTS350(0x16,0x0000);
WriteLDI_LTS350(0x17,0x0000);
WriteLDI_LTS350(0x18,0x0000);
WriteLDI_LTS350(0x19,0x0000);
delayLoop(100);
//delayLoopLoop(50*180000);
///////////////////////////////////////////////////////////////////
// On_Disp_Function
//////////////////////////////////////////////////////////////////
WriteLDI_LTS350(0x09,0x4a55);
WriteLDI_LTS350(0x0a,0x2000);
}
#else
void WriteLDI_LTS222(int address, int data)
{
volatile S3C2413_IOPORT_REG *s2413IOP = (S3C2413_IOPORT_REG *)OALPAtoVA(S3C2413_BASE_REG_PA_IOPORT, FALSE);
int j;
//unsigned char DELAY=100;
unsigned char DELAY=10;
LCD_DEN_Hi; // EN = High CS high
// LCD_DCLK_Lo;
LCD_DCLK_Hi; // SCL High
LCD_DSERI_Lo; // Data Low
delayLoop(DELAY);
LCD_DEN_Lo; // EN = Low CS Low
delayLoop(DELAY);
LCD_DCLK_Lo; // SCL Low
delayLoop(DELAY);
for (j = 7; j >= 0; j--)
{
if ((address >> j) & 0x0001) // DATA HIGH or LOW
LCD_DSERI_Hi;
else
LCD_DSERI_Lo;
delayLoop(DELAY);
LCD_DCLK_Hi; // CLOCK = High
delayLoop(DELAY);
if(j != 0)
{
LCD_DCLK_Lo;
delayLoop(DELAY); // CLOCK = Low
}
}
LCD_DSERI_Lo; // Data Low
delayLoop(DELAY);
LCD_DEN_Hi; // EN = High
delayLoop(DELAY);
LCD_DEN_Lo; // EN = Low
delayLoop(DELAY);
LCD_DCLK_Lo;
delayLoop(DELAY); // CLOCK = Low
for (j = 7; j >= 0; j--)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -