⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 6410BSP3
💻 C
📖 第 1 页 / 共 5 页
字号:
                    continue;
                }
            }            
            break;
        case 'H':    // Toggle 
        case 'h':
            pBootCfg->ConfigFlags= (pBootCfg->ConfigFlags ^ BOOT_OPTION_HIVECLEAN);
            bConfigChanged = TRUE;
            break;
        case 'K':           // Toggle Kitl Enable
        case 'k':
            pBootCfg->ConfigFlags = (pBootCfg->ConfigFlags ^ CONFIG_FLAGS_KITL);
            g_bWaitForConnect = (pBootCfg->ConfigFlags & CONFIG_FLAGS_KITL) ? TRUE : FALSE;
            bConfigChanged = TRUE;
            break;
        case 'I':           // Toggle Kitl Mode
        case 'i':
            pBootCfg->ConfigFlags = (pBootCfg->ConfigFlags ^ CONFIG_FLAGS_KITLPOLL);
            bConfigChanged = TRUE;
            break;
        case 'L':           // Download? No.
        case 'l':
            bDownload = FALSE;
            goto MENU_DONE;
        case 'N':
        case 'n':
            {
                FlashInfo flashInfo;
                
                #define READ_LB_NAND_M_SIZE 2048
                #define READ_LB_NAND_S_SIZE 64
                #define READ_SB_NAND_M_SIZE 512
                #define READ_SB_NAND_S_SIZE 16
 
                UINT8  pMBuf[READ_LB_NAND_M_SIZE], pSBuf[READ_LB_NAND_S_SIZE];
                UINT32 SectorStartAddress;
                UINT32 nMainloop, nSpareloop;

                FMD_GetInfo(&flashInfo);
                EdbgOutputDebugString ( "%s Flash Info:: Blocks:[%d] x BlockSize:[%d]KB = [%d]MB\r\n",
                                        (flashInfo.flashType == NAND) ? "NAND" : " NOR", wNUM_BLOCKS, flashInfo.dwBytesPerBlock,
                                                (wNUM_BLOCKS*flashInfo.dwBytesPerBlock/1024) );
                EdbgOutputDebugString ( "               :: SectorsPerBlock:[%d], Sector size:[%d]\r\n",
                                                        flashInfo.wSectorsPerBlock, flashInfo.wDataBytesPerSector);
                TOC_Print();
                
 
                SectorStartAddress = SetBlockPage();
                if(SectorStartAddress == -1)
                {
                    break;
                }
                EdbgOutputDebugString("\r\n Sector Start Address : 0x%x\r\n", SectorStartAddress);
                memset(pMBuf, 0xff, READ_LB_NAND_M_SIZE);
                memset(pSBuf, 0xff, READ_LB_NAND_S_SIZE);
 
                if (IS_LB)
                {
                    nMainloop  
                        = READ_LB_NAND_M_SIZE;
                    nSpareloop = READ_LB_NAND_S_SIZE;
 
                    RAW_LB_ReadSector(SectorStartAddress, pMBuf, pSBuf);
                }
                else
                {
                    nMainloop  = READ_SB_NAND_M_SIZE;
                    nSpareloop = READ_SB_NAND_S_SIZE;
 
                    RAW_SB_ReadSector(SectorStartAddress, pMBuf, pSBuf);
                }
 
                PrintPageData(nMainloop, nSpareloop, pMBuf, pSBuf);
            }
            break;            
        case 'P':    // Toggle image storage to Smart Media.
        case 'p':
            pBootCfg->ConfigFlags= (pBootCfg->ConfigFlags ^ BOOT_OPTION_FORMATPARTITION);
            bConfigChanged = TRUE;
            break;
            
        case 'R':
        case 'r':
            TOC_Read();
            TOC_Print();
            // TODO
            break;
        case 'S':           // Switch Boot Device
        case 's':
            pBootCfg->BootDevice++;
            if (pBootCfg->BootDevice > NUM_BOOT_DEVICES - 1)
            {
                pBootCfg->BootDevice = 0;
            }
            bConfigChanged = TRUE;
            break;
        case 'T':           // Toggle image storage to Smart Media.
        case 't':                 
            pBootCfg->ConfigFlags = (pBootCfg->ConfigFlags ^ TARGET_TYPE_NAND);
            bConfigChanged = TRUE;
            break;
        case 'W':           // Configuration Write
        case 'w':
            if (!TOC_Write())
            {
                OALMSG(OAL_WARN, (TEXT("WARNING: MainMenu: Failed to store updated eboot configuration in flash.\r\n")));
            }
            else
            {
                OALMSG(OAL_INFO, (TEXT("Successfully Written\r\n")));
                bConfigChanged = FALSE;
            }
            break;
        default:
            break;
        }
    }

MENU_DONE:

    // If eboot settings were changed by user, save them to flash.
    //
    if (bConfigChanged && !TOC_Write())
    {
        OALMSG(OAL_WARN, (TEXT("WARNING: MainMenu: Failed to store updated bootloader configuration to flash.\r\n")));
    }

    return(bDownload);
}

static UINT8 WaitForInitialSelection()
{
    UINT8 KeySelect;
    ULONG BootDelay;
    UINT32 dwStartTime, dwPrevTime, dwCurrTime;

    BootDelay = g_pBootCfg->BootDelay;

    if (g_pBootCfg->ConfigFlags & BOOT_TYPE_DIRECT)
    {
        EdbgOutputDebugString("\r\nPress [ENTER] to launch image stored on boot media, or [SPACE] to enter boot monitor.\r\n");
        EdbgOutputDebugString("\r\nInitiating image launch in %d seconds. ",BootDelay--);
    }
    else
    {
        EdbgOutputDebugString("\r\nPress [ENTER] to download image, or [SPACE] to enter boot monitor.\r\n");
        EdbgOutputDebugString("\r\nInitiating image download in %d seconds. ",BootDelay--);
    }
    
    dwStartTime = OEMEthGetSecs();
    dwPrevTime  = dwStartTime;
    dwCurrTime  = dwStartTime;
    KeySelect   = 0;

    // Allow the user to break into the bootloader menu.
    while((dwCurrTime - dwStartTime) < g_pBootCfg->BootDelay)
    {
        KeySelect = OEMReadDebugByte();

        if ((KeySelect == 0x20) || (KeySelect == 0x0d))
        {
            break;
        }

        dwCurrTime = OEMEthGetSecs();

        if (dwCurrTime > dwPrevTime)
        {
            int i, j;

            // 1 Second has elapsed - update the countdown timer.
            dwPrevTime = dwCurrTime;

            // for text alignment
            if (BootDelay < 9)
            {
                i = 11;
            }
            else if (BootDelay < 99)
            {
                i = 12;
            }
            else if (BootDelay < 999)
            {
                i = 13;
            }
            else 
            {
                i = 14;     //< we don't care about this value when BootDelay over 1000 (1000 seconds)
            }
                

            for(j = 0; j < i; j++)
            {
                OEMWriteDebugByte((BYTE)0x08); // print back space
            }

            EdbgOutputDebugString ( "%d seconds. ", BootDelay--);
        }
    }

    EdbgOutputDebugString("\r\n");
    return KeySelect;
}


/*
    @func   BOOL | OEMPlatformInit | Initialize the Samsung SMD6410 platform hardware.
    @rdesc  TRUE = Success, FALSE = Failure.
    @comm
    @xref
*/
void SetKITLConfigAndBootOptions()
{
    //Update  Argument Area Value(KITL, Clean Option)
    if(g_pBootCfg->ConfigFlags &  BOOT_OPTION_CLEAN)
    {
        *g_bCleanBootFlag =TRUE;
    }
    else
    {
        *g_bCleanBootFlag =FALSE;
    }
    if(g_pBootCfg->ConfigFlags &  BOOT_OPTION_HIVECLEAN)
    {
        *g_bHiveCleanFlag =TRUE;
    }
    else
    {
        *g_bHiveCleanFlag =FALSE;
    }
    if(g_pBootCfg->ConfigFlags &  BOOT_OPTION_FORMATPARTITION)
    {
        *g_bFormatPartitionFlag = TRUE;
    }
    else
    {
        *g_bFormatPartitionFlag =FALSE;
    }

    if(g_pBootCfg->ConfigFlags & CONFIG_FLAGS_KITL)
    {
        g_KITLConfig->flags=OAL_KITL_FLAGS_ENABLED;
    }
    else
    {
        g_KITLConfig->flags&=~OAL_KITL_FLAGS_ENABLED;
    }
    if(g_pBootCfg->ConfigFlags & CONFIG_FLAGS_KITLPOLL)
    {
        g_KITLConfig->flags|= OAL_KITL_FLAGS_POLL;
    }
    else
    {
        g_KITLConfig->flags&=~OAL_KITL_FLAGS_POLL;
    }
    

    g_KITLConfig->ipAddress = g_pBootCfg->EdbgAddr.dwIP;
    g_KITLConfig->ipMask    = g_pBootCfg->SubnetMask;

    memcpy(g_KITLConfig->mac, g_pBootCfg->EdbgAddr.wMAC, 6);

    OALKitlCreateName(BSP_DEVICE_PREFIX, g_KITLConfig->mac, g_DevID);

    switch(g_pBootCfg->BootDevice)
    {
        case BOOT_DEVICE_ETHERNET:
            {
                // Configure Ethernet controller.
                g_KITLConfig->devLoc.IfcType    = Internal;
                g_KITLConfig->devLoc.BusNumber  = 0;
                g_KITLConfig->devLoc.LogicalLoc = BSP_BASE_REG_PA_CS8900A_IOBASE;
                g_KITLConfig->flags |= OAL_KITL_FLAGS_VMINI;
            }
            break;
        case BOOT_DEVICE_USB_SERIAL:
            {
                g_KITLConfig->devLoc.IfcType    = Internal;
                g_KITLConfig->devLoc.BusNumber  = 0;
                g_KITLConfig->devLoc.LogicalLoc = S3C6410_BASE_REG_PA_USBOTG_LINK;
            }
            break;

        case BOOT_DEVICE_USB_RNDIS:
            {
                g_KITLConfig->devLoc.IfcType    = InterfaceTypeUndefined; // Using InterfaceTypeUndefined will differentiate between USB RNDIS and USB Serial
                g_KITLConfig->devLoc.BusNumber  = 0;
                g_KITLConfig->devLoc.LogicalLoc = S3C6410_BASE_REG_PA_USBOTG_LINK;
                g_KITLConfig->devLoc.Pin        = IRQ_OTG;
                g_KITLConfig->flags |= OAL_KITL_FLAGS_VMINI;
            }
            break;
        case BOOT_DEVICE_USB_DNW:
            // Use USB Serial transport for KITL in this case
            g_KITLConfig->devLoc.IfcType    = Internal;
            g_KITLConfig->devLoc.BusNumber  = 0;
            g_KITLConfig->devLoc.LogicalLoc = S3C6410_BASE_REG_PA_USBOTG_LINK;
            break;
        default: 
            EdbgOutputDebugString("%s: ERROR: unknown Boot device: 0x%x \r\n", __FUNCTION__, g_pBootCfg->BootDevice);            
            g_KITLConfig->devLoc.IfcType    = InterfaceTypeUndefined;
            g_KITLConfig->devLoc.BusNumber  = 0;
            g_KITLConfig->devLoc.LogicalLoc = 0;
            break;
    }
                
}

/*
    @func   BOOL | OEMPlatformInit | Initialize the Samsung SMD6410 platform hardware.
    @rdesc  TRUE = Success, FALSE = Failure.
    @comm
    @xref
*/
BOOL OEMPlatformInit(void)
{
    UINT8 KeySelect;
    BOOL bResult = FALSE;
    FlashInfo flashInfo;
    // This is actually not PCI bus, but we use this structure to share FMD library code with FMD driver
    PCI_REG_INFO    RegInfo;    

    OALMSG(OAL_FUNC, (TEXT("+OEMPlatformInit.\r\n")));

    // Check if Current ARM speed is not matched to Target Arm speed
    // then To get speed up, set Voltage
#if (APLL_CLK == CLK_1332MHz)
    LTC3714_Init();
    LTC3714_VoltageSet(1,1200,100);     // ARM
    LTC3714_VoltageSet(2,1300,100);     // INT
#endif
#if (TARGET_ARM_CLK == CLK_800MHz)
    LTC3714_Init();
    LTC3714_VoltageSet(1,1300,100);     // ARM
    LTC3714_VoltageSet(2,1200,100);     // INT
#endif

    EdbgOutputDebugString("Microsoft Windows CE Bootloader for the Samsung SMDK6410 Version %d.%d Built %s\r\n\r\n",
    EBOOT_VERSION_MAJOR, EBOOT_VERSION_MINOR, __DATE__);

    // Set OTG Device's Phy clock
//    InitializeOTGCLK();
               
    // Initialize the display.
    InitializeDisplay();

    // Initialize BCD registers in RTC to known values
    InitializeRTC();

    // Initialize the BSP args structure.
    OALArgsInit(pBSPArgs);

    g_bCleanBootFlag = (BOOL*)OALArgsQuery(BSP_ARGS_QUERY_CLEANBOOT) ;
    g_bHiveCleanFlag = (BOOL*)OALArgsQuery(BSP_ARGS_QUERY_HIVECLEAN);
    g_bFormatPartitionFlag = (BOOL*)OALArgsQuery(BSP_ARGS_QUERY_FORMATPART);
    g_KITLConfig = (OAL_KITL_ARGS *)OALArgsQuery(OAL_ARGS_QUERY_KITL);
    g_DevID = (UCHAR *)OALArgsQuery( OAL_ARGS_QUERY_DEVID);

//    InitializeInterrupt();

    // Try to initialize the boot media block driver and BinFS partition.
    //
    OALMSG(OAL_INFO, (TEXT("BP_Init\r\n")));

    memset(&RegInfo, 0, sizeof(PCI_REG_INFO));
    RegInfo.MemBase.Num = 2;
    RegInfo.MemBase.Reg[0] = (DWORD)OALPAtoVA(S3C6410_BASE_REG_PA_NFCON, FALSE);
    RegInfo.MemBase.Reg[1] = (DWORD)OALPAtoVA(S3C6410_BASE_REG_PA_SYSCON, FALSE);

    if (!BP_Init((LPBYTE)BINFS_RAM_START, BINFS_RAM_LENGTH, NULL, &RegInfo, NULL) )
    {
        OALMSG(OAL_WARN, (TEXT("WARNING: OEMPlatformInit failed to initialize Boot Media.\r\n")));
        g_bBootMediaExist = FALSE;
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -