/* * Copyright (C) 2016 Paul Kocialkowski * * 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 . */ #ifndef _DOWNLOAD_H_ #define _DOWNLOAD_H_ #include #include #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 { uint8_t command; } __attribute__((__packed__)); struct download_write_request { uint8_t command; uint8_t binary_type; uint16_t reserved; uint32_t address; uint32_t length; } __attribute__((__packed__)); struct download_erase_request { uint8_t command; uint8_t reserved[3]; uint32_t address; uint32_t length; } __attribute__((__packed__)); struct download_read_request { uint8_t command; uint8_t reserved; uint32_t length; } __attribute__((__packed__)); struct download_initialize_partition_request { uint8_t command; uint8_t binary_type; uint32_t address; uint32_t length; } __attribute__((__packed__)); struct download_ready_read_request { uint8_t command; uint8_t reserved; uint32_t address; uint32_t length; } __attribute__((__packed__)); struct download_response { uint8_t ack; } __attribute__((__packed__)); /* * Functions */ int download_start_flash_write(struct context *context); int download_write(struct context *context, void *buffer, off_t address, size_t length); int download_erase(struct context *context, off_t address, size_t length); int download_read(struct context *context, void *buffer, size_t length); int download_initialize_partition(struct context *context, off_t address, size_t length); int download_ready_read(struct context *context, off_t address, size_t length); int download_reset(struct context *context); int download_notify_start_dl(struct context *context); #endif