summaryrefslogtreecommitdiff
path: root/common/include/asm/arch/spid_img_desc.h
blob: f04e796776a6d6c3b1d919897d6e79a83e94431e (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
/*
 *  include/asm/arch/spid_img_desc.h
 *
 *  Copyright (C) 2012 MStar Semiconductor.
 *
 * 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 2 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, write to the Free Software Foundation,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */
#ifndef __ASM_ARCH_SPID_IMG_DESC_H
#define __ASM_ARCH_SPID_IMG_DESC_H

#ifndef __KERNEL__
#include <stdint.h>
#endif /* __KERNEL__ */

#define SPIDCOM_IMG_DESC_IMG_NAME_0 "image 0"
#define SPIDCOM_IMG_DESC_IMG_NAME_1 "image 1"

#define SPIDCOM_IMG_DESC_MTD_NAME_0 "/dev/mtd3"
#define SPIDCOM_IMG_DESC_MTD_NAME_1 "/dev/mtd4"

#define SPIDCOM_IMG_DESC_SPC200E 0x00
#define SPIDCOM_IMG_DESC_SPC200C 0x01
#define SPIDCOM_IMG_DESC_SPC200_UNKNOWN 0x02

#define SPIDCOM_IMG_DESC_SPC300 0x00
#define SPIDCOM_IMG_DESC_SPC300_UNKNOWN 0x01

#define SPIDCOM_IMG_DESC_MAGIC "SPIDIMG\0"
#define SPIDCOM_IMG_DESC_SIZE  1024

#define SPIDCOM_IMG_DESC_INVALID_INDEX 0x7fffffff
#define SPIDCOM_IMG_DESC_ORIGIN_INDEX 0xffffffff

#define SPIDCOM_IMG_DESC_NORMAL_TYPE    0x0

#define SPIDCOM_IMG_DESC_PLC_RAM 0x400000 /* 4M */

#define SPIDCOM_IMG_DESC_IS_VALID(desc) (   !memcmp((desc)->magic, SPIDCOM_IMG_DESC_MAGIC, 8) && \
                                            (desc)->is_valid && \
                                            ( (desc)->index != SPIDCOM_IMG_DESC_INVALID_INDEX )     )

/* /!\ All values are LITTLE-ENDIAN */
typedef struct {
    char     magic[8];              /* Magic number = "SPIDIMG\0"
                                     * = { 0x53, 0x50, 0x49, 0x44,
                                     *     0x49, 0x4d, 0x47, 0x00 } */
    uint32_t index;                 /* The biggest one is the image to boot */
    uint32_t is_valid:1;            /* Is image valid (bootable ?) */
    uint32_t is_1st_boot:1;         /* Is first image boot ? */
    uint32_t is_not_success:1;      /* Is first boot successful ? */
    uint32_t is_not_update:1;       /* Is update process finished correctly? */
    uint32_t size;                  /* Firmware size (descriptor included) */
    uint32_t type;                  /* Image type :  0 is normal image */
    uint8_t  md5_sum[16];           /* MD5 checksum of the whole firmware */
    char     version[16];           /* Image version string */
    char     description[64];       /* Image description string */
    uint32_t arch;                  /* spc300 or unknown */
    uint32_t plc_ram;               /* RAM size needed for the PLC processor */
    char     board_type[32];        /* Board type string */
    char     reserved[864];
    char     image[0];              /* Used in bootloader  to mark beging of the payload */
} spidcom_image_desc_t;

#endif /* __ASM_ARCH_SPID_IMG_DESC_H */