summaryrefslogtreecommitdiff
path: root/common/include/asm/arch/spid_img_desc.h
blob: cf2f86df9a068ee0ce9c036bb6b109dff1e1510d (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
112
113
114
115
116
117
118
/*
 *  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 0x8fffffff
#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 )     )

/**
 * List of image type supported.
 */
typedef enum {
    SPIDCOM_IMG_DESC_IMAGE_TYPE_200,
    SPIDCOM_IMG_DESC_IMAGE_TYPE_300,
    SPIDCOM_IMG_DESC_IMAGE_TYPE_NB,
    SPIDCOM_IMG_DESC_IMAGE_TYPE_UNKNOWN,
} spidcom_image_desc_image_type_t;

/**
 * Image descriptor for SPC300 (and MSE500-300).
 * All values are in 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_300_t;

/**
 * Image descriptor for SPC200 (and MSE500-200).
 * All values are in 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 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[64];      /* Image version string */
    char     description[64];  /* Image description string */
    uint32_t arch;	     /* spc200e, spc200c or unknown */
    char     reserved[852];
    char     image[0];         /* Used in bootloader */
} spidcom_image_desc_200_t;

/* For more information on ARCH_IS_POLUX, see polux/include/image_desc.h. */
#ifdef ARCH_IS_POLUX
typedef spidcom_image_desc_200_t spidcom_image_desc_t;
#else
typedef spidcom_image_desc_300_t spidcom_image_desc_t;
#endif

#endif /* __ASM_ARCH_SPID_IMG_DESC_H */