1/*  *********************************************************************
2    *  Broadcom Common Firmware Environment (CFE)
3    *
4    *  Flash partition manipulation		File: ptable.h
5    *
6    *  Definitions and prototypes for flash partitioning.
7    *
8    *********************************************************************
9    *
10    *  Copyright 2005
11    *  Broadcom Corporation. All rights reserved.
12    *
13    *  This software is furnished under license and may be used and
14    *  copied only in accordance with the following terms and
15    *  conditions.  Subject to these conditions, you may download,
16    *  copy, install, use, modify and distribute modified or unmodified
17    *  copies of this software in source and/or binary form.  No title
18    *  or ownership is transferred hereby.
19    *
20    *  1) Any source code used, modified or distributed must reproduce
21    *     and retain this copyright notice and list of conditions
22    *     as they appear in the source file.
23    *
24    *  2) No right is granted to use any trade name, trademark, or
25    *     logo of Broadcom Corporation.  The "Broadcom Corporation"
26    *     name may not be used to endorse or promote products derived
27    *     from this software without the prior written permission of
28    *     Broadcom Corporation.
29    *
30    *  3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
31    *     IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
32    *     WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
33    *     PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
34    *     SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
35    *     PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
36    *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37    *     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38    *     GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
39    *     BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
40    *     OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
41    *     TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
42    *     THE POSSIBILITY OF SUCH DAMAGE.
43    ********************************************************************* */
44
45
46#ifndef _PTABLE_H
47#define _PTABLE_H
48
49/*  *********************************************************************
50    *  Constants
51    ********************************************************************* */
52
53#define PTABLE_MAGIC           0x5054424C     /* 'PTBL' (big-endian) */
54
55#define PTABLE_PNAME_MAX       16
56#define PTABLE_MAX_PARTITIONS  8
57
58/*  *********************************************************************
59    *  Data structures.
60    ********************************************************************* */
61
62typedef struct partition_s {
63    char        name[PTABLE_PNAME_MAX];
64    uint32_t    offset;
65    uint32_t    size;
66    uint32_t    type;
67    uint32_t    flags;
68} partition_t;
69
70typedef struct ptable_s {
71    uint32_t    magic;
72    uint32_t    version;
73    uint32_t    chksum;
74    uint32_t    reserved;
75    partition_t part[PTABLE_MAX_PARTITIONS];
76} ptable_t;
77
78typedef struct ptable_drv_s {
79    int         (*pt_read)(ptable_t *ptbl);
80    int         (*pt_write)(ptable_t *ptbl);
81} ptable_drv_t;
82
83/*  *********************************************************************
84    *  Prototypes
85    ********************************************************************* */
86
87/* Initialize and provide access functions */
88int         ptable_init(ptable_drv_t *ptbl_drv);
89
90/* Calculate checksum across entire partition table */
91uint32_t    ptable_check(ptable_t *ptbl);
92
93/* Read/write partition table */
94int         ptable_read(ptable_t *ptbl);
95int         ptable_write(ptable_t *ptbl);
96
97#endif /* _PTABLE_H */
98