2021-08-02 17:29:22 +08:00
|
|
|
#ifndef __ROCK_H__
|
|
|
|
#define __ROCK_H__
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <x.h>
|
|
|
|
#include <rc4.h>
|
|
|
|
#include <crc16.h>
|
2021-08-05 19:53:20 +08:00
|
|
|
#include <crc32.h>
|
2024-08-24 11:03:03 +08:00
|
|
|
#include <misc.h>
|
2024-09-04 10:16:24 +08:00
|
|
|
#include <loader.h>
|
2021-08-02 17:29:22 +08:00
|
|
|
#include <progress.h>
|
|
|
|
|
|
|
|
struct chip_t {
|
|
|
|
uint16_t pid;
|
|
|
|
char * name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct xrock_ctx_t {
|
2024-08-23 14:15:14 +08:00
|
|
|
libusb_context * context;
|
2021-08-02 17:29:22 +08:00
|
|
|
libusb_device_handle * hdl;
|
|
|
|
struct chip_t * chip;
|
|
|
|
int epout;
|
|
|
|
int epin;
|
2021-08-03 18:34:22 +08:00
|
|
|
int maskrom;
|
|
|
|
};
|
|
|
|
|
2021-08-04 23:26:24 +08:00
|
|
|
struct flash_info_t {
|
2021-08-06 12:28:51 +08:00
|
|
|
uint32_t sector_total;
|
2021-08-04 23:26:24 +08:00
|
|
|
uint16_t block_size;
|
|
|
|
uint8_t page_size;
|
|
|
|
uint8_t ecc_bits;
|
|
|
|
uint8_t access_time;
|
|
|
|
uint8_t manufacturer_id;
|
|
|
|
uint8_t chip_select;
|
|
|
|
uint8_t id[5];
|
|
|
|
};
|
|
|
|
|
2021-08-02 17:29:22 +08:00
|
|
|
int xrock_init(struct xrock_ctx_t * ctx);
|
2024-09-03 21:05:06 +08:00
|
|
|
void rock_maskrom_upload_memory(struct xrock_ctx_t * ctx, uint32_t code, void * buf, uint64_t len, int rc4);
|
|
|
|
void rock_maskrom_upload_file(struct xrock_ctx_t * ctx, uint32_t code, const char * filename, int rc4);
|
2024-08-24 20:01:05 +08:00
|
|
|
int rock_ready(struct xrock_ctx_t * ctx);
|
2021-08-04 10:43:56 +08:00
|
|
|
int rock_version(struct xrock_ctx_t * ctx, uint8_t * buf);
|
2021-08-04 23:57:10 +08:00
|
|
|
int rock_capability(struct xrock_ctx_t * ctx, uint8_t * buf);
|
2021-08-04 09:47:18 +08:00
|
|
|
int rock_reset(struct xrock_ctx_t * ctx, int maskrom);
|
2024-08-30 18:42:42 +08:00
|
|
|
int rock_exec(struct xrock_ctx_t * ctx, uint32_t addr, uint32_t dtb);
|
2021-08-05 01:17:33 +08:00
|
|
|
int rock_read(struct xrock_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
|
|
|
|
int rock_write(struct xrock_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
|
|
|
|
int rock_read_progress(struct xrock_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
|
|
|
|
int rock_write_progress(struct xrock_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
|
2021-08-04 23:26:24 +08:00
|
|
|
int rock_flash_detect(struct xrock_ctx_t * ctx, struct flash_info_t * info);
|
2021-08-05 01:58:09 +08:00
|
|
|
int rock_flash_erase_lba(struct xrock_ctx_t * ctx, uint32_t sec, uint32_t cnt);
|
2021-08-05 01:13:22 +08:00
|
|
|
int rock_flash_read_lba(struct xrock_ctx_t * ctx, uint32_t sec, uint32_t cnt, void * buf);
|
2021-08-05 01:44:03 +08:00
|
|
|
int rock_flash_write_lba(struct xrock_ctx_t * ctx, uint32_t sec, uint32_t cnt, void * buf);
|
2021-08-05 01:58:09 +08:00
|
|
|
int rock_flash_erase_lba_progress(struct xrock_ctx_t * ctx, uint32_t sec, uint32_t cnt);
|
2021-08-05 01:13:22 +08:00
|
|
|
int rock_flash_read_lba_progress(struct xrock_ctx_t * ctx, uint32_t sec, uint32_t cnt, void * buf);
|
2021-08-05 01:44:03 +08:00
|
|
|
int rock_flash_write_lba_progress(struct xrock_ctx_t * ctx, uint32_t sec, uint32_t cnt, void * buf);
|
2021-08-03 18:34:22 +08:00
|
|
|
|
2021-08-02 17:29:22 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __ROCK_H__ */
|