diff options
Diffstat (limited to 'src/download.h')
-rw-r--r-- | src/download.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/download.h b/src/download.h new file mode 100644 index 0000000..4117e7c --- /dev/null +++ b/src/download.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef _DOWNLOAD_H_ +#define _DOWNLOAD_H_ + +#include "lg-downloader.h" + +/* + * Values + */ + +#define DOWNLOAD_START_FLASH_WRITE 0x01 +#define DOWNLOAD_WRITE 0x02 +#define DOWNLOAD_COMPLETE_FLASH_WRITE 0x03 +#define DOWNLOAD_ERASE 0x04 +#define DOWNLOAD_READ 0x05 +#define DOWNLOAD_INITIALIZE_PARTITION 0x06 +#define DOWNLOAD_WRITE_ROM_COPY 0x07 +#define DOWNLOAD_READY_READ 0x08 +#define DOWNLOAD_WRITE_ASYNC 0x09 +#define DOWNLOAD_GO 0x20 +#define DOWNLOAD_NO_OP 0x21 +#define DOWNLOAD_RESET 0x22 +#define DOWNLOAD_POWERDOWN 0x23 +#define DOWNLOAD_PRE_RESET 0x24 +#define DOWNLOAD_CP_USB_SWITCH 0x25 +#define DOWNLOAD_SOFTWARE_VER 0x40 +#define DOWNLOAD_NOTIFY_START_DL 0x41 + +#define DOWNLOAD_ACK 0x50 +#define DOWNLOAD_NACK 0x51 + +#define DOWNLOAD_BUFFER_SIZE 1024 + +/* + * Structures + */ + +struct download_request { + unsigned char command; +} __attribute__((__packed__)); + +struct download_write_request { + unsigned char command; + unsigned char binary_type; + unsigned short reserved; + unsigned int address; + unsigned int length; +} __attribute__((__packed__)); + +struct download_erase_request { + unsigned char command; + unsigned char reserved[3]; + unsigned int address; + unsigned int length; +} __attribute__((__packed__)); + +struct download_read_request { + unsigned char command; + unsigned char reserved; + unsigned int length; +} __attribute__((__packed__)); + +struct download_initialize_partition_request { + unsigned char command; + unsigned char binary_type; + unsigned int address; + unsigned int length; +} __attribute__((__packed__)); + +struct download_ready_read_request { + unsigned char command; + unsigned char reserved; + unsigned int address; + unsigned int length; +} __attribute__((__packed__)); + +struct download_response { + unsigned char ack; +} __attribute__((__packed__)); + +/* + * Functions + */ + +int download_start_flash_write(struct context *context); +int download_write(struct context *context, void *buffer, unsigned int address, unsigned int length); +int download_erase(struct context *context, unsigned int address, unsigned int length); +int download_read(struct context *context, void *buffer, unsigned int length); +int download_initialize_partition(struct context *context, unsigned int address, unsigned int length); +int download_ready_read(struct context *context, unsigned int address, unsigned int length); +int download_reset(struct context *context); +int download_notify_start_dl(struct context *context); + + +#endif |