aboutsummaryrefslogtreecommitdiffstats
path: root/src/download.h
blob: 4117e7c8fb43cd15cd19dd3a6e8ce11815b23ebe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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