📄 universal-load.h
字号:
/******************************************************************* MX1-Loader - DragonBall M9328/MX1 loader universal-load.h - definition of universal loader methods (C) Copyright 2004 by Pavel Pisa - project originator http://cmp.felk.cvut.cz/~pisa (C) Copyright 2004 PiKRON Ltd. http://www.pikron.com USB support based on work of Roman Bartosinski (bartosr@centrum.cz) The MX1-Loader project can be used and distributed in compliance with any of next licenses - GPL - GNU Public License See file COPYING for details. - LGPL - Lesser GNU Public License - MPL - Mozilla Public License - and other licenses added by project originator Code can be modified and re-distributed under any combination of the above listed licenses. If contributor does not agree with some of the licenses, he/she can delete appropriate line. WARNING: if you delete all lines, you are not allowed to distribute code or sources in any form. *******************************************************************/#define UNILOAD_WITH_USB#ifdef UNILOAD_WITH_USB#include <usb.h>#endif /*UNILOAD_WITH_USB*/#define DEBUG 1#define HAS_GETOPT_LONG 1#if DEBUG#define dbprintf(s ...) fprintf(stderr, s)#else#define dbprintf(...)#endiftypedef struct uniload_alg_info uniload_alg_info_t;typedef struct uniload_alg_extprop { struct uniload_alg_extprop *next; char *key; char *val; void *private_ptr;} uniload_alg_extprop_t;typedef struct uniload_alg_ops { int (*setup)(uniload_alg_info_t *algi); int (*release)(uniload_alg_info_t *algi); int (*mem_write)(uniload_alg_info_t *algi, int mem_type, unsigned long start, unsigned long len, const char *buff); int (*mem_read)(uniload_alg_info_t *algi, int mem_type, unsigned long start, unsigned long len, char *buff); int (*go_addr)(uniload_alg_info_t *algi, unsigned long addr); int (*regerase)(uniload_alg_info_t *algi, unsigned long start, unsigned long len); int (*masserase)(uniload_alg_info_t *algi, unsigned long mode);} uniload_alg_ops_t;struct uniload_alg_info { uniload_alg_ops_t *alg_ops; int dev_fd; char *dev_name; #ifdef UNILOAD_WITH_USB usb_dev_handle *usb_hdev; #endif /*UNILOAD_WITH_USB*/ int def_mem_type; long mem_offs; long max_blksize; uniload_alg_extprop_t *extprop;};static inlineint uniload_setup(uniload_alg_info_t *algi){ return algi->alg_ops->setup? algi->alg_ops->setup(algi):-1; }static inlineint uniload_release(uniload_alg_info_t *algi){ return algi->alg_ops->release? algi->alg_ops->release(algi):-1; }static inlineint uniload_mem_write(uniload_alg_info_t *algi, int mem_type, unsigned long start, unsigned long len, const char *buff){ return algi->alg_ops->mem_write? algi->alg_ops->mem_write(algi,mem_type,start,len,buff):-1;}static inlineint uniload_mem_read(uniload_alg_info_t *algi, int mem_type, unsigned long start, unsigned long len, char *buff){ return algi->alg_ops->mem_read? algi->alg_ops->mem_read(algi,mem_type,start,len,buff):-1;}static inlineint uniload_go_addr(uniload_alg_info_t *algi, unsigned long addr){ return algi->alg_ops->go_addr? algi->alg_ops->go_addr(algi,addr):-1;}static inlineint uniload_regerase(uniload_alg_info_t *algi, unsigned long start, unsigned long len){ return algi->alg_ops->regerase? algi->alg_ops->regerase(algi,start,len):-1;}static inlineint uniload_masserase(uniload_alg_info_t *algi, unsigned long mode){ return algi->alg_ops->masserase? algi->alg_ops->masserase(algi,mode):-1;}/* Extended properties keyval management */int uniload_extprop_add(uniload_alg_info_t *algi, uniload_alg_extprop_t *extprop);uniload_alg_extprop_t *uniload_extprop_find(uniload_alg_info_t *algi, char *key);int uniload_extprop_get_ulong(uniload_alg_info_t *algi, char *key, unsigned long *pval);/*Initialization of specific transfer layers*/int mx1_usb_open(uniload_alg_info_t *algi, char *dev_name);int mx1_rs232_open(uniload_alg_info_t *algi, char *sdev, int baud, int mode, int flowc);int mx1_tagimage_open(uniload_alg_info_t *algi, char *fname, int mode);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -