tyax.h
来自「该BSP是基于PXA270+WINCE的BSP」· C头文件 代码 · 共 190 行
H
190 行
//
// 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.
//
/*++
Module Name: strata.h
Date Created: 6/21/2002
Abstract: Flash media driver (FMD) interface for Intel StrataFlash memory chips.
Functions:
Notes: As noted, this media driver works on behalf of the FAL to directly
access the underlying FLASH hardware. Consquently, this module
needs to be linked with FAL.LIB to produce the device driver
named FLASHDRV.DLL. It may also be used directly in a boot loader image.
--*/
#ifndef _STRATA_H_
#define _STRATA_H_
#define READ_ULONG(ptr) (*(volatile ULONG * const)ptr)
#define WRITE_ULONG(ptr,ul) (*(volatile ULONG * const)ptr) = (ul)
// Flash read/write macros.
// We assume the StrataFlash part is in 16-bit mode (as opposed to 8-bit mode).
#define WRITE_FLASH(ptr, val) WRITE_ULONG(ptr, (ULONG)val)
#define READ_FLASH(ptr) READ_ULONG((ULONG)(ptr))
#define READ_FLASH_INDEXED(ptr, offset) READ_ULONG(((ULONG)(ptr) + 4*(offset)))
// Write a command to the flash part.
#define WRITE_COMMAND(ptr, cmd) WRITE_ULONG(ptr, (ULONG)((cmd << 16) | cmd))
// Check for expected status.
#define CHECK_STATUS(ptr, stat) ((READ_ULONG((ULONG)ptr) & ((stat << 16) | stat)) == ((stat << 16) | stat))
#define CHECK_STATUS_INDEXED(ptr, offset, stat) (((READ_ULONG(((ULONG)(ptr) + 4*(offset)))) & ((stat << 16) | stat)) == ((stat << 16) | stat))
// Is specified address block-aligned?
#define IS_BLOCK_ALIGNED(ptr) (((ULONG)ptr % g_FMDInfo.BlockSize) ? FALSE : TRUE)
#define CREATE_MASK(flag) ((flag << 16) | flag)
#define UPPER(flag) (flag << 16)
// We sign the last 32 bytes of each flash block so we can verify that the block
// is valid at boot time. OEMs should feel free to modify gc_dwBlockSig
const DWORD gc_dwBlockSig[8] = {0xC1552106, 0xDF9C29D5, 0xBAB8EAB8, 0x82D3F9F3,
0x3B438A47, 0xA9D92AE6, 0x09396731, 0x12BF6753};
#define BLOCK_SIG_BYTES 32
#define BLOCK_SIG_LOC(bs, bl) (bs + bl - BLOCK_SIG_BYTES)
//
//
// Intel 28F320 flash commands and status definitions.
//
// Commands.
#define READ_QUERY_CMD 0x0098
#define READ_IDENT_CMD 0x0090
#define READ_ARRAY_CMD 0x00FF
#define BYTEWORD_PROGRAM_CMD 0x0040
#define CLEAR_STATUS_CMD 0x5050
#define READ_STATUS_CMD 0x7070
#define BLOCK_LOCK_CMD 0x0060
#define BLOCK_PROCEED_CMD 0x00D0
#define BLOCK_SETLOCK_CMD 0x0001
#define BLOCK_ERASE_CMD 0x0020
#define BUFFER_WRITE_CMD 0x00E8
// Status.
#define STATUS_ERROR_LOCKED 0x0002
#define STATUS_ERROR_VOLTAGE 0x0008
#define STATUS_ERROR_SR4 0x0010 // Can mean either erase or set lock bit error
#define STATUS_ERROR_SR5 0x0020 // Can mean either program or clear lock bit error
#define STATUS_ERROR_COMMAND 0x0030
#define STATUS_READY_MASK 0x0080
#define CHECK_STATUS_TIMEOUT 0xffffff
// Flash CFI query structure offsets.
#define QS_MFGCODE_OFFSET 0x0
#define QS_DEVCODE_OFFSET 0x1
#define QS_IDSTRING_OFFSET 0x10
#define QS_SYSINTF_OFFSET 0x1B
#define QS_DEVGEOM_OFFSET 0x27
#define REGION_SIZE_MULT 256
#define SECTOR_SIZE 512 // Number of data bytes in a sector
#define MFGCODE_INTEL 0x0089 // Intel's flash manufacturing code.
#define IDSTRING_Q 0x0051 // ASCII 'Q'.
#define IDSTRING_R 0x0052 // ASCII 'R'.
#define IDSTRING_Y 0x0059 // ASCII 'Y'.
//
// Tyax part configuration device info. Size and Parameter Partition location (top -vs- bottom)
//
#define DEVICEID_L18_64MBIT_TOP 0x880B
#define DEVICEID_L18_64MBIT_BOTTOM 0x880E
#define DEVICEID_L18_128MBIT_TOP 0x880C
#define DEVICEID_L18_128MBIT_BOTTOM 0x880F
#define DEVICEID_L18_256MBIT_TOP 0x880D
#define DEVICEID_L18_256MBIT_BOTTOM 0x8810
#define DEVICEID_L30_64MBIT_TOP 0x8811
#define DEVICEID_L30_64MBIT_BOTTOM 0x8814
#define DEVICEID_L30_128MBIT_TOP 0x8812
#define DEVICEID_L30_128MBIT_BOTTOM 0x8815
#define DEVICEID_L30_256MBIT_TOP 0x8813
#define DEVICEID_L30_256MBIT_BOTTOM 0x8816
#define FLASH_INFO_TOP_PARAMETER 1
#define FLASH_INFO_BOTTOM_PARAMETER 0
#define NUM_SMALL_BLKS 4 // 4 small blocks per device
// Tyax Macros for top or bottom parameter determination
//
#define IS_BOTTOM_PARAM ((g_FMDInfo.ParameterLocation == FLASH_INFO_BOTTOM_PARAMETER) ? TRUE : FALSE)
#define IS_TOP_PARAM ((g_FMDInfo.ParameterLocation == FLASH_INFO_TOP_PARAMETER) ? TRUE : FALSE)
#pragma pack(1)
// Flash-system interface characteristics.
typedef struct _FLASH_SYSINTERFACE_INFO
{
UCHAR VccMinProgV; // Vcc logic supply minimum program/erase voltage.
UCHAR VccMaxProgV; // Vcc logic supply maximum program/erase voltage.
UCHAR VppMinProgV; // Vpp logic supply minimum program/erase voltage.
UCHAR VppMaxProgV; // Vpp logic supply maximum program/erase voltage.
struct
{
UCHAR SnglWordProgTO_us; // Typical single word program time-out (in us).
UCHAR WriteBuffTO_us; // Typical buffer write time-out (in us).
UCHAR BlockEraseTO_ms; // Typical block erase time-out (in ms).
UCHAR ChipEraseTO_ms; // Typical full-chip erase time-out (in ms).
} Typical;
struct
{
UCHAR SnglWordProgTO_us; // Max single word program time-out (in us).
UCHAR WriteBuffTO_us; // Max buffer write time-out (in us).
UCHAR BlockEraseTO_ms; // Max block erase time-out (in ms).
UCHAR ChipEraseTO_ms; // Max full-chip erase time-out (in ms).
} Max;
} FLASH_SYSINTERFACE_INFO, *PFLASH_INTERFACE_INFO;
// Flash geometry characteristics.
typedef struct _FLASH_GEOMETRY_INFO
{
UCHAR DevSize; // Flash size (n = 2^n bytes).
USHORT DevInterface; // Interface type (8/16).
USHORT WriteBuffSize; // Write buffer size (n = 2^n bytes).
UCHAR NumEraseBlocks; // Number of flash blocks in an erase region.
USHORT NumIdentEraseBlocks1; // Number of identical-sized erase blocks (number of blocks) in region 1.
USHORT EraseRegionSize1; // Size of an erase region in region 1.
USHORT NumIdentEraseBlocks2; // Number of identical-sized erase blocks (number of blocks) in region 2.
USHORT EraseRegionSize2; // Size of an erase region in region 2.
} FLASH_GEOMETRY_INFO, *PFLASH_GEOMETRY_INFO;
// All flash information.
typedef struct _FMD_FLASH_INFO
{
ULONG BaseAddress; // Flash base address.
ULONG FlashLength; // Length of flash to be managed.
ULONG BlockSize; // Block size (computed from CFI data).
ULONG TotalFlashBlocks; // Number of flash blocks.
ULONG SectorSize; // Sector size
FLASH_SYSINTERFACE_INFO SysInt; // Flash-system interface information.
FLASH_GEOMETRY_INFO Geometry; // Flash geometry information.
// new
USHORT ParameterLocation; // 0: Bottom Parameter part, 1: Top Parameter part.
ULONG SmallBlockSize; // Size (#B) of the small blocks
ULONG TotalFlashSizeMB; // The actual size of the Flash device.
ULONG ActualFlashBase; // The real KVA base of Flash. *TODO* flash parts oin series
ULONG StartSmallBlockAddress; // The base address of the start of the small block region
ULONG EndSmallBlockAddress; // The address (+1) of the end of the small block region
ULONG CompositeBlockSize; // The size (#B) of the composite block region
} FMD_FLASH_INFO, *PFMD_FLASH_INFO;
#pragma pack()
#endif //_STRATA_H_.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?