loader.h
来自「SAMSUNG S3C6410 CPU BSP for winmobile6」· C头文件 代码 · 共 345 行
H
345 行
//
// 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.
//
#ifndef _LOADER_H_
#define _LOADER_H_
#include <blcommon.h>
#include <bootpart.h>
#include <XSR.h>
#define USE_TRACE32_DOWNLOAD (0)
// Bootloader version.
//
#define EBOOT_VERSION_MAJOR 2
#define EBOOT_VERSION_MINOR 5
#define EBOOT_ONENAND_RW_TEST 0 // DBG Message enable flag for OneNAND test
//------------------------------------------------------------------------------
//
// Section Name: Memory Configuration
// Description.: The constants defining memory layout below must match
// those defined in the .bib files.
//
//------------------------------------------------------------------------------
#define CACHED_TO_UNCACHED_OFFSET 0x20000000
#define STEPLDR_RAM_IMAGE_BASE 0x00000000
#define STEPLDR_RAM_IMAGE_SIZE 0x00001000 //stepldr.nb0 only use 0x00001000
#define BLOCK0_RAM_IMAGE_BASE 0x00000000
#define BLOCK0_RAM_IMAGE_SIZE 0x00020000 //block0img.nb0(nbl1.nb0 + nbl2.nb0) only use 0x00020000
#define IPL_RAM_IMAGE_BASE 0x80138000
#define IPL_RAM_IMAGE_SIZE 0x00040000 //ipl.bin
#define SUPERIPL_RAM_IMAGE_BASE 0x00000000
#define SUPERIPL_RAM_IMAGE_SIZE 0x00060000 //superipl.nb0(block0img.nb0 + ipl.nb0)
#define UPLDR_RAM_IMAGE_BASE 0x00000000
#define UPLDR_RAM_IMAGE_SIZE 0x00200000 //only use 0x00200000
#define EBOOT_RAM_IMAGE_BASE 0x80038000 // changed for magneto...DonGo
#define EBOOT_RAM_IMAGE_SIZE 0x00080000 // eboot.bin
#define NAND_ROM_IMAGE_BASE 0x00000000
#define NAND_ROM_IMAGE_SIZE 0x03000000
#define DIONB0_RAM_IMAGE_BASE 0x00000000
#define FLASHBIN_RAM_IMAGE_BASE 0x00000000
#define EBOOT_STORE_OFFSET 0
#define EBOOT_STORE_ADDRESS (EBOOT_RAM_IMAGE_BASE + EBOOT_STORE_OFFSET)
#define EBOOT_STORE_MAX_LENGTH EBOOT_RAM_IMAGE_SIZE
// BinFS work area defined in boot.bib
#define BINFS_RAM_START (0x800C0000 | CACHED_TO_UNCACHED_OFFSET) // uncached, changed for magneto...DonGo
#define BINFS_RAM_LENGTH 0x25000
// Nk Memory reigions defined in config.bib...
#define ROM_RAMIMAGE_START 0x80000000
#define ROM_RAMIMAGE_SIZE 0x03000000
#define FILE_CACHE_START (0x80200000 | CACHED_TO_UNCACHED_OFFSET) // Start of file cache (temporary store
#define FILE_CACHE_LENGTH 0x03000000
// Driver globals pointer (parameter sharing memory used by bootloader and OS).
//
#define pBSPArgs ((BSP_ARGS *) IMAGE_SHARE_ARGS_UA_START)
// Platform "BOOTME" root name.
//
#define PLATFORM_STRING "SMDK6410"
#ifndef SECTOR_SIZE
#define SECTOR_SIZE (512)
#endif
#define NAND_SECTOR_SIZE (SECTOR_SIZE<<2)
#ifndef PAGES_PER_BLOCK
#define PAGES_PER_BLOCK (256)
#endif
#define NAND_PAGES_PER_BLOCK (256>>2)
#ifndef BADBLOCKMARK
#define BADBLOCKMARK (0x00)
#endif
#define SECTOR_TO_BLOCK(sector) ((sector) >> 8 )
#define BLOCK_TO_SECTOR(block) ((block) << 8 )
// fs: sector number
// returns block aligned value
__inline DWORD SECTOR_TO_BLOCK_SIZE(DWORD sn) {
return ( (sn / NAND_PAGES_PER_BLOCK) + ( (sn % NAND_PAGES_PER_BLOCK) ? 1 : 0) );
}
// fs: file size in bytes
// returns sector aligned value
__inline DWORD FILE_TO_SECTOR_SIZE(DWORD fs) {
return ( (fs / NAND_SECTOR_SIZE) + ( (fs % NAND_SECTOR_SIZE) ? 1 : 0) );
}
// ns: number of sectors
// N.B: returns sector aligned value since we can't tell
__inline DWORD SECTOR_TO_FILE_SIZE(DWORD ns) {
return ( ns * NAND_SECTOR_SIZE );
}
//
// Boot Config Flags...
//
// BOOT_MODE_ flags indicate where we are booting from
#define BOOT_MODE_NAND 0x00000001
#define BOOT_MODE_NOR_AMD 0x00000002
#define BOOT_MODE_NOR_STRATA 0x00000004
#define BOOT_MODE_TEST 0x00000008
#define BOOT_MODE_MASK(dw) (0x0000000F & (dw))
// BOOT_TYPE_ flags indicate whether we are booting directly off media, or downloading an image
#define BOOT_TYPE_DIRECT 0x00000010 // boot off media?
#define BOOT_TYPE_MULTISTAGE 0x00000020 // multi-stage bootloaders?
#define BOOT_TYPE_MASK(dw) (0x000000F0 & (dw))
// TARGET_TYPE_ flags indicate where the image is to be written to.
#define TARGET_TYPE_RAMIMAGE 0x00000100 // Directly to SDRAM
#define TARGET_TYPE_CACHE 0x00000200 // FLASH_CACHE
#define TARGET_TYPE_NOR 0x00000400 // NOR Flash
#define TARGET_TYPE_NAND 0x00000800 // NAND Flash
//...
#define TARGET_TYPE_MASK(dw) (0x00000F00 & (dw))
#define CONFIG_FLAGS_DHCP 0x00001000
#define CONFIG_FLAGS_DEBUGGER 0x00002000
#define CONFIG_FLAGS_MASK(dw) (0x0000F000 & (dw))
#define CONFIG_FLAGS_KITL 0x00008000
#define CONFIG_BOOTDELAY_DEFAULT 5
//
// Bootloader configuration parameters.
//
typedef struct _BOOTCFG {
ULONG ImageIndex;
ULONG ConfigFlags;
ULONG BootDelay;
EDBG_ADDR EdbgAddr;
ULONG SubnetMask;
} BOOT_CFG, *PBOOT_CFG;
//
// On disk structures for NAND bootloaders...
//
//
// OEM Reserved (Nand) Blocks for TOC and various bootloaders
//
//
// OEM Defined TOC...
//
#define MAX_SG_SECTORS 14
#define IMAGE_STRING_LEN 16 // chars
#define MAX_TOC_DESCRIPTORS 3 // per sector
#define TOC_SIGNATURE 0x434F544E // (NAND TOC)
// Default image descriptor to load.
// We store Eboot as image 0, nk.nb0 as image 1
#define DEFAULT_IMAGE_DESCRIPTOR 1
// IMAGE_TYPE_ flags indicate whether the image is a Bootloader,
// RAM image, supports BinFS, Multiple XIP, ...
//
#define IMAGE_TYPE_LOADER 0x00000001 // eboot.bin
#define IMAGE_TYPE_RAMIMAGE 0x00000002 // nk.bin
#define IMAGE_TYPE_BINFS 0x00000004
#define IMAGE_TYPE_MXIP 0x00000008
#define IMAGE_TYPE_IPL 0x00000010 // ipl.bin
#define IMAGE_TYPE_SUPERIPL 0x00000020 // ipl.bin
#define IMAGE_TYPE_RAWBIN 0x00000040 // raw bin .nb0
#define IMAGE_TYPE_STEPLDR 0x00000080 // stepldr.bin, stepldr.nb0, block0img.nb0
#define IMAGE_TYPE_UPLDR 0x00000100 // upld.nb0
#define IMAGE_TYPE_DIO 0x00000200 // dio image
#define IMAGE_TYPE_DIONB0 0x00000400 // dio.nb0 image
#define IMAGE_TYPE_FLASHBIN 0x00000800 // flash.bin image
#define IMAGE_TYPE_MASK(dw) (0x00000FFF & (dw))
// SG_SECTOR: supports chained (scatter gather) sectors.
// This structure equates to a sector-based MXIP RegionInfo in blcommon.
//
typedef struct _SG_SECTOR {
DWORD dwSector; // Starting sector of the image segment
DWORD dwLength; // Image length of this segment, in contigious sectors.
} SG_SECTOR, *PSG_SECTOR;
// IMAGE_DESCRIPTOR: describes the image to load.
// The image can be anything: bootloaders, RAMIMAGE, MXIP, ...
// Note: Our NAND uses H/W ECC, so no checksum needed.
//
typedef struct _IMAGE_DESCRIPTOR {
// File version info
DWORD dwVersion; // e.g: build number
DWORD dwSignature; // e.g: "EBOT", "CFSH", etc
UCHAR ucString[IMAGE_STRING_LEN]; // e.g: "PocketPC_2002"
DWORD dwImageType; // IMAGE_TYPE_ flags
DWORD dwTtlSectors; // TTL image size in sectors.
// We store size in sectors instead of bytes
// to simplify sector reads in Nboot.
DWORD dwLoadAddress; // Virtual address to load image (ImageStart)
DWORD dwJumpAddress; // Virtual address to jump (StartAddress/LaunchAddr)
// This array equates to a sector-based MXIP MultiBINInfo in blcommon.
// Unused entries are zeroed.
// You could chain image descriptors if needed.
SG_SECTOR sgList[MAX_SG_SECTORS];
// BinFS support to load nk region only
//struct
//{
ULONG dwStoreOffset; // byte offset - not needed - remove!
//ULONG RunAddress; // nk dwRegionStart address
//ULONG Length; // nk dwRegionLength in bytes
//ULONG LaunchAddress; // nk dwLaunchAddr
//} NKRegion;
} IMAGE_DESCRIPTOR, *PIMAGE_DESCRIPTOR;
//
// IMAGE_DESCRIPTOR signatures we know about
//
#define IMAGE_EBOOT_SIG 0x45424F54 // "EBOT", eboot.nb0
#define IMAGE_RAM_SIG 0x43465348 // "CFSH", nk.nb0
#define IMAGE_BINFS_SIG (IMAGE_RAM_SIG + 1)
__inline BOOL VALID_IMAGE_DESCRIPTOR(PIMAGE_DESCRIPTOR pid) {
return ( (pid) &&
((IMAGE_EBOOT_SIG == (pid)->dwSignature) ||
(IMAGE_RAM_SIG == (pid)->dwSignature) ||
(IMAGE_BINFS_SIG == (pid)->dwSignature)));
}
// This is for MXIP chain.bin, which needs to be loaded into the SDRAM
// during the start up.
typedef struct _CHAININFO {
DWORD dwLoadAddress; // Load address in SDRAM
DWORD dwFlashAddress; // Start location on the NAND
DWORD dwLength; // The length of the image
} CHAININFO, *PCHAININFO;
//
// TOC: Table Of Contents, OEM on disk structure.
// sizeof(TOC) = SECTOR_SIZE.
// Consider the g_TOC_BLOCK to contain an array of
// TOC entries, since the entire block is reserved.
//
typedef struct _TOC {
DWORD dwSignature;
// How to boot the images in this TOC.
// This could be moved into the image descriptor if desired,
// but I prefer to conserve space.
BOOT_CFG BootCfg;
// Array of Image Descriptors.
IMAGE_DESCRIPTOR id[MAX_TOC_DESCRIPTORS];
CHAININFO chainInfo;
} TOC, *PTOC; // 512 bytes
__inline BOOL VALID_TOC(PTOC ptoc) {
return ((ptoc) && (TOC_SIGNATURE == (ptoc)->dwSignature));
}
// Loader function prototypes.
//
BOOL InitEthDevice(PBOOT_CFG pBootCfg);
int OEMReadDebugByte(void);
BOOL OEMVerifyMemory(DWORD dwStartAddr, DWORD dwLength);
void Launch(DWORD dwLaunchAddr);
PVOID GetKernelExtPointer(DWORD dwRegionStart, DWORD dwRegionLength);
void OEMWriteDebugLED(WORD wIndex, DWORD dwPattern);
BOOL WriteOSImageToBootMedia(DWORD dwImageStart, DWORD dwImageLength, DWORD dwLaunchAddr);
BOOL ReadOSImageFromBootMedia(void);
BOOL WriteRawImageToBootMedia(DWORD dwImageStart, DWORD dwImageLength, DWORD dwLaunchAddr);
BOOL TOC_Init(DWORD dwEntry, DWORD dwImageType, DWORD dwImageStart, DWORD dwImageLength, DWORD dwLaunchAddr);
BOOL TOC_Read(void);
BOOL TOC_Write(void);
void TOC_Print(void);
BOOL PocketStoreInitialize(void);
BOOL PocketStoreII_STL_Format(UINT32 nPartID);
BOOL FMD_EraseBlock_BML(DWORD/*BLOCK_ID*/ blockID);
UINT32 SetBlockPage(void);
void OneNANDTest(void);
void PrintPageData(DWORD nMData, DWORD nSData, UINT8 * pMBuf, UINT8 * pSBuf);
INT32 ONLD_GetDevInfo(UINT32 nDev, LLDSpec * pstFILDev);
INT32 ONLD_Erase(UINT32 nDev, UINT32 nPbn, UINT32 nFlag);
UINT32 _SetRWBlock(UINT32 nDev, UINT32 nSUbn, UINT32 nUBlks);
#if EBOOT_ONENAND_RW_TEST
BOOL OneNAND_RWTest(void);
BOOL OneNAND_LLD_ReadAgingTest();
BOOL OneNAND_STL_ReadAgingTest();
#endif
#endif // _LOADER_H_.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?