dl_flashdrv.h
来自「在高通的手机平台下,一个下载手机.bin文件到手机的flash中的工具,包含PC」· C头文件 代码 · 共 211 行
H
211 行
/*===========================================================================
when who what, where, why
-------- --- ----------------------------------------------------------
02/09/06 wufei.lin create to dynamic flash support
06/10/05 nony.wu add TV00579002 support
01/25/05 nony.wu Added AMD S71PL032
=============================================================================*/
#ifndef __DL_FLASHDRV_H__
#define __DL_FLASHDRV_H__
#include"dl_proc.h"
typedef volatile word *flash_ptr_type;
/*the flash block descriptor*/
typedef struct
{
dword start; /* First address of the block */
dword len; /* Length of the block in bytes */
word write_protected; /* Flag: 1 if block is write protected */
} block_descriptor;
/* flash device type*/
typedef struct
{
word device_id[4];
byte num_id;
block_descriptor *flash_block_descriptor;
word block_num;
response_code_type(*erase_flash)(flash_ptr_type baseaddr,dword addr,dword len);
response_code_type(*write_flash)(byte *buf,flash_ptr_type baseaddr,dword addr,word len);
}flash_device_type;
extern flash_device_type *current_flash_device;
extern flash_device_type* amd_flash_probe(flash_ptr_type baseaddr);
extern flash_device_type* intel_flash_probe(flash_ptr_type baseaddr);
/* Return type for checks of the Intelligent ID */
typedef enum
{
IID_OK, /* Intelligent ID checked successfully. */
IID_FAILED /* Failure of any kind while checking the IID. */
} iid_check_type;
/*===========================================================================
FUNCTION amd_29dl162_do_write
DESCRIPTION
This function writes a provided string of bytes into a specified
block of Flash memory.
Since the data book recommends resetting the device after a write
that attempts to change a 0 to a 1, we will avoid doing that by
checking the old data first.
Once the write has been attempted, the updated memory will be
verified to confirm that the write operation succeeded. It might
fail because the area had not been erased, or because it has worn
out, or because it is in a protected sector and the temporary
unlock voltage has not been applied.
DEPENDENCIES
Writes to RAM are not supported.
RETURN VALUE
Returns a response_code_type enum indicating what happened. This
code can be used directly to select a response packet to send back.
SIDE EFFECTS
This operation can take a bit of time, around 10ms per kilobyte
(11us per word write, plus overhead).
The watchdog is reset.
===========================================================================*/
extern response_code_type amd_29dl162_do_write
(
byte *buf,
/* Pointer to the string of bytes to write */
flash_ptr_type baseaddr,
/* Linear physical address of the first byte of the flash part */
dword addr,
/* offset from baseaddr of the first byte of memory to write */
word len
/* Count of bytes to write */
);
extern response_code_type amd_29dl162_do_erase
(
flash_ptr_type baseaddr,
/* Linear physical address of the first byte of the flash part */
dword addr,
/* offset from baseaddr of the first byte of memory to erase */
dword len
/* Count of bytes to erase */
);
/*===========================================================================
FUNCTION amd_29dl162_do_erase
DESCRIPTION
This function erases a specified block of Flash memory.
The memory address and block size must exactly match the address and
size of one of the 18 separate accessible blocks in the 29LV800T Flash
memory device, or of two or more adjacent blocks. The Flash memory
is erased to a device-specific value, in this case FLASH_ERASED_VALUE.
DEPENDENCIES
Erasing blocks of RAM is not supported.
RETURN VALUE
Returns a response_code_type enum indicating what happened. This
code can be used directly to select a response packet to send back.
SIDE EFFECTS
This operation can take quite a bit of time. The data book says
1 second typical, 10 seconds maximum, but it doesn't say whether
that's per block or not and it warns that these times "do not
include the preprogramming time".
The watchdog is reset.
Interrupts are off very briefly.
===========================================================================*/
extern response_code_type amd_SST_do_erase
(
flash_ptr_type baseaddr,
/* Linear physical address of the first byte of the flash part */
dword addr,
/* offset from baseaddr of the first byte of memory to erase */
dword len
/* Count of bytes to erase */
);
extern response_code_type amd_SST_do_write
(
byte *buf,
/* Pointer to the string of bytes to write */
flash_ptr_type baseaddr,
/* Linear physical address of the first byte of the flash part */
dword addr,
/* offset from baseaddr of the first byte of memory to write */
word len
/* Count of bytes to write */
);
extern response_code_type intel_do_write
(
byte *buf,
/* Pointer to the string of bytes to write */
flash_ptr_type baseaddr,
/* Linear physical address of the first byte of the flash part */
dword addr,
/* offset from baseaddr of the first byte of memory to write */
word len
/* Count of bytes to write */
);
extern response_code_type intel_do_erase
(
flash_ptr_type baseaddr,
/* Linear physical address of the first byte of the flash part */
dword addr,
/* offset from baseaddr of the first byte of memory to write */
dword len
/* Count of bytes to write */
);
#endif /* __DL_FLASHDRV_H__ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?