~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/skiboot/libflash/ffs.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2013-2014 IBM Corp.
 
2
 *
 
3
 * Licensed under the Apache License, Version 2.0 (the "License");
 
4
 * you may not use this file except in compliance with the License.
 
5
 * You may obtain a copy of the License at
 
6
 *
 
7
 *      http://www.apache.org/licenses/LICENSE-2.0
 
8
 *
 
9
 * Unless required by applicable law or agreed to in writing, software
 
10
 * distributed under the License is distributed on an "AS IS" BASIS,
 
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
12
 * implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
/*
 
17
 * Copyright (c) International Business Machines Corp., 2012
 
18
 *
 
19
 * FSP Flash Structure
 
20
 *
 
21
 * This header defines the layout for the FSP Flash Structure.
 
22
 */
 
23
 
 
24
#ifndef __FFS_H__
 
25
#define __FFS_H__
 
26
 
 
27
/* Pull in the correct header depending on what is being built */
 
28
#if defined(__KERNEL__)
 
29
#include <linux/types.h>
 
30
#else
 
31
#include <stdint.h>
 
32
#endif
 
33
 
 
34
/* The version of this partition implementation */
 
35
#define FFS_VERSION_1   1
 
36
 
 
37
/* Magic number for the partition header (ASCII 'PART') */
 
38
#define FFS_MAGIC       0x50415254
 
39
 
 
40
/* The maximum length of the partition name */
 
41
#define PART_NAME_MAX   15
 
42
 
 
43
/*
 
44
 * Sizes of the data structures
 
45
 */
 
46
#define FFS_HDR_SIZE   sizeof(struct ffs_hdr)
 
47
#define FFS_ENTRY_SIZE sizeof(struct ffs_entry)
 
48
 
 
49
/*
 
50
 * Sizes of the data structures w/o checksum
 
51
 */
 
52
#define FFS_HDR_SIZE_CSUM   (FFS_HDR_SIZE - sizeof(uint32_t))
 
53
#define FFS_ENTRY_SIZE_CSUM (FFS_ENTRY_SIZE - sizeof(uint32_t))
 
54
 
 
55
/* pid of logical partitions/containers */
 
56
#define FFS_PID_TOPLEVEL   0xFFFFFFFF
 
57
 
 
58
/*
 
59
 * Type of image contained w/in partition
 
60
 */
 
61
enum type {
 
62
        FFS_TYPE_DATA      = 1,
 
63
        FFS_TYPE_LOGICAL   = 2,
 
64
        FFS_TYPE_PARTITION = 3,
 
65
};
 
66
 
 
67
/*
 
68
 * Flag bit definitions
 
69
 */
 
70
#define FFS_FLAGS_PROTECTED     0x0001
 
71
#define FFS_FLAGS_U_BOOT_ENV    0x0002
 
72
 
 
73
/* Data integrity flags */
 
74
#define FFS_ENRY_INTEG_ECC 0x8000
 
75
 
 
76
/**
 
77
 * struct ffs_entry_user - User data enties
 
78
 *
 
79
 *  @chip:              Chip Select (0,1)
 
80
 *  @compressType:      Compression Indication/alg (0=not compressed)
 
81
 *  @dataInteg:         Indicates Data Integrity mechanism
 
82
 *  @verCheck:          Indicates Version check type
 
83
 *  @miscFlags:         Misc Partition related Flags
 
84
 *  @freeMisc[2]:       Unused Miscellaneious Info
 
85
 *  @freeUser[14]:      Unused User Data
 
86
 */
 
87
struct ffs_entry_user {
 
88
        uint8_t  chip;
 
89
        uint8_t  compresstype;
 
90
        uint16_t datainteg;
 
91
        uint8_t  vercheck;
 
92
        uint8_t  miscflags;
 
93
        uint8_t  freemisc[2];
 
94
        uint32_t reserved[14];
 
95
};
 
96
 
 
97
/**
 
98
 * struct ffs_entry - Partition entry
 
99
 *
 
100
 * @name:       Opaque null terminated string
 
101
 * @base:       Starting offset of partition in flash (in hdr.block_size)
 
102
 * @size:       Partition size (in hdr.block_size)
 
103
 * @pid:        Parent partition entry (FFS_PID_TOPLEVEL for toplevel)
 
104
 * @id:         Partition entry ID [1..65536]
 
105
 * @type:       Describe type of partition
 
106
 * @flags:      Partition attributes (optional)
 
107
 * @actual:     Actual partition size (in bytes)
 
108
 * @resvd:      Reserved words for future use
 
109
 * @user:       User data (optional)
 
110
 * @checksum:   Partition entry checksum (includes all above)
 
111
 */
 
112
struct ffs_entry {
 
113
        char     name[PART_NAME_MAX + 1];
 
114
        uint32_t base;
 
115
        uint32_t size;
 
116
        uint32_t pid;
 
117
        uint32_t id;
 
118
        uint32_t type;
 
119
        uint32_t flags;
 
120
        uint32_t actual;
 
121
        uint32_t resvd[4];
 
122
        struct ffs_entry_user user;
 
123
        uint32_t checksum;
 
124
} __attribute__ ((packed));
 
125
 
 
126
/**
 
127
 * struct ffs_hdr - FSP Flash Structure header
 
128
 *
 
129
 * @magic:              Eye catcher/corruption detector
 
130
 * @version:            Version of the structure
 
131
 * @size:               Size of partition table (in block_size)
 
132
 * @entry_size:         Size of struct ffs_entry element (in bytes)
 
133
 * @entry_count:        Number of struct ffs_entry elements in @entries array
 
134
 * @block_size:         Size of block on device (in bytes)
 
135
 * @block_count:        Number of blocks on device
 
136
 * @resvd:              Reserved words for future use
 
137
 * @checksum:           Header checksum
 
138
 * @entries:            Pointer to array of partition entries
 
139
 */
 
140
struct ffs_hdr {
 
141
        uint32_t         magic;
 
142
        uint32_t         version;
 
143
        uint32_t         size;
 
144
        uint32_t         entry_size;
 
145
        uint32_t         entry_count;
 
146
        uint32_t         block_size;
 
147
        uint32_t         block_count;
 
148
        uint32_t         resvd[4];
 
149
        uint32_t         checksum;
 
150
        struct ffs_entry entries[];
 
151
} __attribute__ ((packed));
 
152
 
 
153
 
 
154
#endif /* __FFS_H__ */