//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
//------------------------------------------------------------------------------
//
// File: main.c
//
// Core routines for the Intel Mainstone bootloader.
//
#include <windows.h>
#include <nkintr.h>
#include <bulverde.h>
#include <mainstoneii.h>
#include <oal_memory.h>
#include <pcireg.h>
#include <fmd.h>
#include <xllp_pccardsocket.h>
#include <bsp.h>
#include "loader.h"
#include <eboot.h>
#include <fmd_mdoc.h>
#include <flashmenu.h>
#include <mdoc_defs.h>
#define NUM_BOOT_DEVICES 5
#define NUM_BOOT_ORDERS 6
#define SDBG_USB_SERIAL 101
//------------------------------------------------------------------------------
// Local variables.
//
static PCI_REG_INFO g_FlashAddress;
EBOOT_CFG g_EbootCFG;
EBOOT_CONTEXT g_eboot;
BOOLEAN g_DownloadImage = TRUE;
BOOLEAN g_SerialUSBDownload = FALSE;
DWORD flDocBaseAddress = 0xBAA00000;
// This table describes the boot order for a given configuration.
//
static BOOT_DEVICE_TYPE BootOrder[NUM_BOOT_ORDERS][NUM_BOOT_DEVICES] = {
{ ETH_DEVICE_SMSC, ETH_DEVICE_USB, ETH_DEVICE_PCMCIA0, ETH_DEVICE_PCMCIA1, SER_DEVICE_USB }, // pEbootCFG->bootDeviceOrder = 0.
{ ETH_DEVICE_PCMCIA0, ETH_DEVICE_PCMCIA1, ETH_DEVICE_SMSC, ETH_DEVICE_USB, SER_DEVICE_USB }, // pEbootCFG->bootDeviceOrder = 1.
{ ETH_DEVICE_PCMCIA1, ETH_DEVICE_PCMCIA0, ETH_DEVICE_SMSC, ETH_DEVICE_USB, SER_DEVICE_USB }, // pEbootCFG->bootDeviceOrder = 2.
{ ETH_DEVICE_USB, ETH_DEVICE_SMSC, ETH_DEVICE_PCMCIA0, ETH_DEVICE_PCMCIA1, SER_DEVICE_USB }, // pEbootCFG->bootDeviceOrder = 3.
{ SER_DEVICE_USB, ETH_DEVICE_SMSC, ETH_DEVICE_USB, ETH_DEVICE_PCMCIA0, ETH_DEVICE_PCMCIA1 }, // pEbootCFG->bootDeviceOrder = 4.
{ SER_DEVICE_USB, ETH_DEVICE_USB, ETH_DEVICE_SMSC, ETH_DEVICE_PCMCIA0, ETH_DEVICE_PCMCIA1 }, // pEbootCFG->bootDeviceOrder = 5.
};
static char* BootOrderString[NUM_BOOT_ORDERS] =
{
"SMSC, USB RNDIS, PCMCIA0, PCMCIA1, USB SERIAL (DL Only)",
"PCMCIA0, PCMCIA1, SMSC, USB RNDIS, USB SERIAL (DL Only)",
"PCMCIA1, PCMCIA0, SMSC, USB RNDIS, USB SERIAL (DL Only)",
"USB RNDIS, SMSC, PCMCIA0, PCMCIA1, USB SERIAL (DL Only)",
"USB SERIAL (DL Only), SMSC, USB RNDIS, PCMCIA0, PCMCIA1",
"USB SERIAL (DL Only), USB RNDIS, SMSC, PCMCIA0, PCMCIA1",
};
//------------------------------------------------------------------------------
// Global variables.
//
FlashInfo g_FlashInfo;
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.
XLLP_PCCARDSOCKET_T strEbtPCCardSocketHandle;
IMAGE_TYPE g_ImageType;
extern BSP_ARGS *g_pBSPArgs;
//------------------------------------------------------------------------------
// Local function prototypes.
//
static BOOL LoadEBootCFG(EBOOT_CFG *EBootCFG);
static BOOL StoreEBootCFG(EBOOT_CFG *EBootCFG);
static void ResetDefaultEBootCFG(EBOOT_CFG *pEbootCFG);
static void SetMAC(unsigned char *mac);
static void SetIP(EBOOT_CFG *pEbootCFG);
static void SetMask(EBOOT_CFG *pEbootCFG);
static void SetBootMe(EBOOT_CFG *pEbootCFG);
static void SetDelay(EBOOT_CFG *pEbootCFG);
BOOL OEMVerifyMemory(DWORD dwStartAddr, DWORD dwLength);
//------------------------------------------------------------------------------
// External function prorotypes.
//
extern void Launch(unsigned int uAddr);
extern BOOL SerialSendBlockAck(DWORD uBlockNumber);
extern BOOL SerialSendBootRequest(const char * platformString);
extern BOOL SerialWaitForBootAck(BOOL *pfJump);
extern DWORD SerialWaitForJump(VOID);
extern BOOL USBSerialInit();
//------------------------------------------------------------------------------
//
// Function: main
//
// Bootloader main routine.
//
void main(void)
{
// Common boot loader (blcommon) main routine.
//
BootloaderMain();
// Should never get here.
//
SpinForever();
}
//------------------------------------------------------------------------------
//
// Function: OEMDownloadFileNotify
//
// This routine receives a download manifest from blcommon describing the .bin
// and/or .nb0 file(s) being downloaded from the host. It's purpose is to
// assign an address (typically flash address) where the .nb0 file(s) should be
// placed (since .nb0 files aren't self-describing like .bin files are) and to
// display the manifest information to the user (over serial).
//
void OEMDownloadFileNotify(PDownloadManifest pInfo)
{
DWORD dwCount;
DWORD dwNumNB0Files = 0;
UINT32 base = IMAGE_EBOOT_IMAGE_PA;
if (!pInfo) return;
EdbgOutputDebugString("\r\nDownload file information:\r\n");
EdbgOutputDebugString("-------------------------------------------------------------------------------\r\n");
for (dwCount = 0 ; dwCount < pInfo->dwNumRegions ; dwCount++)
{
EdbgOutputDebugString("[%d]: Address=0x%x Length=0x%x Name=%s\r\n", dwCount,
pInfo->Region[dwCount].dwRegionStart,
pInfo->Region[dwCount].dwRegionLength,
pInfo->Region[dwCount].szFileName);
g_eboot.region[dwCount].start = pInfo->Region[dwCount].dwRegionStart;
g_eboot.region[dwCount].length = pInfo->Region[dwCount].dwRegionLength;
g_eboot.region[dwCount].base = base;
base += g_eboot.region[dwCount].length;
OALMSG(OAL_INFO, (
L"[%d]: Address=0x%08x Length=0x%08x Save=0x%08x\r\n",
dwCount, g_eboot.region[dwCount].start, g_eboot.region[dwCount].length,
g_eboot.region[dwCount].base
));
// .nb0 files will have a start address of 0 because Platform Builder
// won't know where to place them. We'll support only one .nb0 file
// download (this is an Image Update disk image). If we need to
// support more than one .nb0 file download in the future, we'll need
// to differentiate them by filename.
//
if (pInfo->Region[dwCount].dwRegionStart == 0)
{
// We only support one raw binary file (disk image).
if (dwNumNB0Files++)
{
EdbgOutputDebugString("ERROR: This bootloader doesn't support downloading a second .nb0 binary image.\r\n");
SpinForever();
}
// The disk image .nb0 file should be placed immediately after the
// bootloader image in flash (we'll assume that the disk image has the IPL prepended to it).
pInfo->Region[dwCount].dwRegionStart = (DWORD)OALPAtoVA(IMAGE_BOOT_IPL_FLASH_PA_START, FALSE);
EdbgOutputDebugString("INFO: This bootloader assumes any .nb0 file is an Image Update disk image.\r\n");
EdbgOutputDebugString("INFO: Storing file \"%s\" in flash after boot loader.\r\n", pInfo->Region[dwCount].szFileName);
EdbgOutputDebugString("INFO: Changed start address for %s to 0x%x.\r\n", pInfo->Region[dwCount].szFileName,
pInfo->Region[dwCount].dwRegionStart);
}
}
EdbgOutpu
没有合适的资源?快使用搜索试试~ 我知道了~
BOOTLOADER.Ddoc.rar
共93个文件
obj:27个
c:26个
h:7个
需积分: 0 13 下载量 126 浏览量
2007-11-13
12:18:57
上传
评论 1
收藏 443KB RAR 举报
温馨提示
剩余的牛逼东东 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
资源推荐
资源详情
资源评论
收起资源包目录
BOOTLOADER.Ddoc.rar (93个子文件)
BOOTLOADER.Ddoc
dirs 667B
Build.log 92KB
Build.wrn 4KB
FMD
dirs 2KB
doclib
sources 1KB
i_fatfilt.c 23B
i_doch_api.c 23B
flcustom.c 5KB
flsystem.c 8KB
flcustom.h 5KB
i_dochtl.c 21B
i_dochstub.c 23B
i_geometry.c 23B
obj
ARMV4I
debug
i_dosformt.obj 14KB
i_tffs_api.obj 179KB
i_flioctl.obj 9KB
i_hal_nor.obj 20KB
i_defs.obj 16KB
flsystem.obj 15KB
i_docdrv.obj 18KB
i_fatfilt.obj 37KB
i_flmalloc.obj 18KB
flcustom.obj 11KB
i_docsys.obj 57KB
i_doch_ata.obj 77KB
_objects.mac 639B
i_dochtl.obj 30KB
i_dochstub.obj 12KB
i_flbase.obj 11KB
i_doch_api.obj 168KB
i_geometry.obj 10KB
i_flmalloc.c 23B
makefile 252B
i_dosformt.c 23B
Build.log 12KB
Build.wrn 733B
i_doch_ata.c 23B
i_flbase.c 21B
i_docsys.c 21B
i_tffs_api.c 23B
flsystem.h 17KB
i_hal_nor.c 22B
i_flioctl.c 22B
i_defs.c 19B
i_docdrv.c 21B
Build.log 40KB
Build.wrn 2KB
mdoc
sources 2KB
obj
ARMV4I
debug
fmd.obj 87KB
_objects.mac 43B
fmd.c 35KB
makefile 1KB
fmd_mdoc.h 438B
i_ReservedRegions.c 28B
i_OsServices.c 23B
EBOOT
sources 3KB
main.c 52KB
flashmenu.c 18KB
loader.h 3KB
flash.c 26KB
utils.c 5KB
obj
ARMV4I
debug
flash.obj 67KB
flashmenu.obj 49KB
ether.obj 33KB
main.obj 90KB
_objects.mac 215B
utils.obj 19KB
startup.obj 2KB
makefile 845B
eboot.h 998B
Build.log 36KB
Build.wrn 2KB
eboot.bib 2KB
flashmenu.h 397B
ether.c 17KB
startup.s 14KB
makefile.inc 1KB
XLDR
sources 793B
launch.s 587B
obj
ARMV4I
debug
launch.lst 14KB
launch.obj 464B
startup.lst 60KB
ipl.obj 7KB
_objects.mac 112B
startup.obj 2KB
ipl.c 14KB
ipl.h 9KB
xldrmdoc.bib 1013B
Build.log 22KB
Build.wrn 160B
Makefile 250B
startup.s 37KB
makefile.inc 192B
共 93 条
- 1
资源评论
numenshane1
- 粉丝: 54
- 资源: 122
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功