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

📄 brom.h

📁 MTK 最新的flashtool工具的源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifdef	__cplusplus
extern "C" {
#endif

// The magic value to stop boot process 
#define BOOT_STOP	9876

// boot infinitely
#define BOOT_INFINITE	0xFFFFFFF

// default start cmd retry count 
#define DEFAULT_BROM_START_CMD_RETRY_COUNT	1

//------------------------------------------------------------------------------
// prototype of BootROM stage callback                                          
//------------------------------------------------------------------------------
typedef int (__stdcall *CALLBACK_IN_BROM_STAGE)(unsigned int brom_handle, HANDLE hCOM, void *usr_arg);

//------------------------------------------------------------------------------
// prototype of write buf progress callback                                     
//------------------------------------------------------------------------------
typedef int (__stdcall *CALLBACK_WRITE_BUF_PROGRESS_INIT)(void *usr_arg);
typedef int (__stdcall *CALLBACK_WRITE_BUF_PROGRESS)(unsigned char finished_percentage, unsigned int finished_bytes, unsigned int total_bytes, void *usr_arg);

//------------------------------------------------------------------------------
// prototype of Serial-Link-Authentication challenge callback                   
//------------------------------------------------------------------------------
typedef int (__stdcall *CALLBACK_SLA_CHALLENGE)(void *usr_arg, const unsigned char  *p_challenge_in, unsigned int  challenge_in_len, unsigned char  **pp_challenge_out, unsigned int  *p_challenge_out_len);
typedef int (__stdcall *CALLBACK_SLA_CHALLENGE_END)(void *usr_arg, unsigned char  *p_challenge_out);

//------------------------------------------------------------------------------
// runtime debug trace                                                          
//------------------------------------------------------------------------------
int __stdcall Brom_DebugOn(void);
int __stdcall Brom_DebugOff(void);
int __stdcall Brom_DebugClear(void);

//------------------------------------------------------------------------------
// translate enum to string                                                     
//------------------------------------------------------------------------------
const char * __stdcall BBChipTypeToName(const BBCHIP_TYPE  bbchip);
const char * __stdcall ExtClockToName(const EXT_CLOCK  ext_clock);
const char * __stdcall StatusToString(int status);

//------------------------------------------------------------------------------
// Windows message to notify application ready to power on target               
//------------------------------------------------------------------------------
#define WM_BROM_READY_TO_POWER_ON_TGT		(0x8888)
int __stdcall GetReadyToPowerOnWinAppMsgID(unsigned int *p_wm_app_id);
int __stdcall SetReadyToPowerOnWinAppMsgID(unsigned int wm_app_id);

//------------------------------------------------------------------------------
// boot-up result                                                               
//------------------------------------------------------------------------------
typedef struct {

	BBCHIP_TYPE		m_bbchip_type;
	char			m_bbchip_name[32];
	unsigned short	m_bbchip_hw_ver;
	unsigned short	m_bbchip_sw_ver;
	unsigned short	m_bbchip_hw_code;
	EXT_CLOCK		m_ext_clock;
	unsigned char	m_bbchip_secure_ver;

	unsigned char	m_msp_err_code;

} BOOT_RESULT;

//------------------------------------------------------------------------------
// boot META mode                                                               
//------------------------------------------------------------------------------
typedef struct {

	BBCHIP_TYPE		m_bbchip_type;
	EXT_CLOCK		m_ext_clock;

	unsigned int	m_ms_boot_timeout;
	unsigned int	m_max_start_cmd_retry_count;

	// This callback function will be invoke after BootROM start cmd is passed. 
	// You can issue other BootROM command by brom_handle and hCOM which provides callback arguments, 
	// or do whatever you want otherwise. 
	CALLBACK_IN_BROM_STAGE		m_cb_in_brom_stage;
	void *						m_cb_in_brom_stage_arg;

	// speed-up BootROM stage baudrate 
	_BOOL	m_speedup_brom_baudrate;

	// Application's window handle to send WM_BROM_READY_TO_POWER_ON_TGT message 
	HWND	m_ready_power_on_wnd_handle;
	void *	m_ready_power_on_wparam;
	void *	m_ready_power_on_lparam;

	// Serial Link Authentication 
	AUTH_HANDLE_T		m_auth_handle;			// AUTH file handle 
	CALLBACK_SLA_CHALLENGE			m_cb_sla_challenge;
	void *							m_cb_sla_challenge_arg;
	CALLBACK_SLA_CHALLENGE_END		m_cb_sla_challenge_end;
	void *							m_cb_sla_challenge_end_arg;

} BOOT_META_ARG;

int  __stdcall Boot_META(
		HANDLE hCOM,
		const BOOT_META_ARG  *p_arg,
		BOOT_RESULT  *p_result,
		int *p_bootstop);

//------------------------------------------------------------------------------
// boot FlashTool download mode                                                 
//------------------------------------------------------------------------------

#define	WAIT_STATE_AUTO_DETECT_BY_FREQUENCY		NULL

typedef struct {

	BBCHIP_TYPE		m_bbchip_type;
	EXT_CLOCK		m_ext_clock;

	unsigned int	m_ms_boot_timeout;
	unsigned int	m_max_start_cmd_retry_count;

	// This callback function will be invoke after BootROM start cmd is passed. 
	// You can issue other BootROM command by brom_handle and hCOM which provides callback arguments, 
	// or do whatever you want otherwise. 
	CALLBACK_IN_BROM_STAGE		m_cb_in_brom_stage;
	void *						m_cb_in_brom_stage_arg;

	// speed-up BootROM stage baudrate 
	_BOOL	m_speedup_brom_baudrate;

	// Application's window handle to send WM_BROM_READY_TO_POWER_ON_TGT message 
	HWND	m_ready_power_on_wnd_handle;
	void *	m_ready_power_on_wparam;
	void *	m_ready_power_on_lparam;

	// Serial Link Authentication 
	AUTH_HANDLE_T		m_auth_handle;			// AUTH file handle 
	CALLBACK_SLA_CHALLENGE			m_cb_sla_challenge;
	void *							m_cb_sla_challenge_arg;
	CALLBACK_SLA_CHALLENGE_END		m_cb_sla_challenge_end;
	void *							m_cb_sla_challenge_end_arg;

	// EMI Control for Bank0 and Bank1 
	unsigned int	*m_p_bank0_mem_cfg;		// bank0 memory config 
	unsigned int	*m_p_bank1_mem_cfg;		// bank0 memory config 

	// Download Agent 
	_BOOL			m_enable_da_start_addr;	// Old parameter, no use now. Use DA_SetDefaultStartAddr instead. 
	unsigned int	m_da_start_addr;		// Old parameter, no use now. Use DA_SetDefaultStartAddr instead. 
	DA_HANDLE_T		m_da_handle;

	// da download progress callack 
	CALLBACK_WRITE_BUF_PROGRESS_INIT	m_cb_download_da_init;
	void *								m_cb_download_da_init_arg;
	CALLBACK_WRITE_BUF_PROGRESS			m_cb_download_da;
	void *								m_cb_download_da_arg;

} BOOT_FLASHTOOL_ARG;

int  __stdcall Boot_FlashTool(
		HANDLE hCOM,
		const BOOT_FLASHTOOL_ARG  *p_arg,
		BOOT_RESULT  *p_result,
		int *p_bootstop);

//------------------------------------------------------------------------------
// get brom.dll version                                                         
//------------------------------------------------------------------------------
int __stdcall Brom_GetDLLVer(unsigned int *major_ver, unsigned int *minor_ver, unsigned int *build_num, unsigned int *patch_num);
int __stdcall Brom_GetDLLInfo(const char **pp_version, const char **pp_release_type, const char **pp_build_date, const char **pp_load_path);

//------------------------------------------------------------------------------
// BootROM Command                                                              
//------------------------------------------------------------------------------
int __stdcall Brom_Create(unsigned int *p_brom_handle, BBCHIP_TYPE  bbchip_type, EXT_CLOCK  ext_clock, int *p_bootstop, unsigned int ms_boot_timeout, unsigned int max_start_cmd_retry_count);
int __stdcall Brom_Destroy(unsigned int *p_brom_handle);
int __stdcall Brom_StartCmd(unsigned int brom_handle, HANDLE hCOM, BOOT_RESULT  *p_result);
int __stdcall Brom_Write16Cmd(unsigned int brom_handle, HANDLE hCOM, unsigned int write_addr, unsigned short *data, unsigned int num_of_word);
int __stdcall Brom_Read16Cmd(unsigned int brom_handle, HANDLE hCOM, unsigned int read_addr, unsigned short *data, unsigned int num_of_word);
int __stdcall Brom_Write32Cmd(unsigned int brom_handle, HANDLE hCOM, unsigned int write_addr, unsigned int *data, unsigned int num_of_dword);
int __stdcall Brom_Read32Cmd(unsigned int brom_handle, HANDLE hCOM, unsigned int read_addr, unsigned int *data, unsigned int num_of_dword);
int __stdcall Brom_Checksum16Cmd(unsigned int brom_handle, HANDLE hCOM, unsigned int chksum_addr, unsigned int num_of_word, unsigned short *chksum);
int __stdcall Brom_JumpCmd(unsigned int brom_handle, HANDLE hCOM, unsigned int jump_addr, unsigned char bWaitForAck);

typedef struct {
	unsigned int	m_baseaddr;
	unsigned char * m_data;
	unsigned int	m_data_len; // in byte 
} _DataBlock;

#define BROM_MAX_DATA_BLOCKS	10

typedef struct {
	unsigned short	m_block_count;
	_DataBlock		m_blocks[BROM_MAX_DATA_BLOCKS];
} BromWriteDataBlocks;

int __stdcall Brom_DownloadData(unsigned int brom_handle, HANDLE hCOM, const BromWriteDataBlocks *p_data_blocks, CALLBACK_WRITE_BUF_PROGRESS_INIT  cb_init,  void *cb_init_arg, CALLBACK_WRITE_BUF_PROGRESS  cb,  void *cb_arg);

#ifdef	__cplusplus
}
#endif

#endif


⌨️ 快捷键说明

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