source: umon/main/common/flash.h @ b987a75

Last change on this file since b987a75 was b987a75, checked in by Jarielle Catbagan <jcatbagan93@…>, on 06/19/15 at 21:32:43

Removed execution mode file attribute from all ASCII text files

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/**************************************************************************
2 *
3 * Copyright (c) 2013 Alcatel-Lucent
4 *
5 * Alcatel Lucent licenses this file to You under the Apache License,
6 * Version 2.0 (the "License"); you may not use this file except in
7 * compliance with the License.  A copy of the License is contained the
8 * file LICENSE at the top level of this repository.
9 * You may also obtain a copy of the License at:
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 **************************************************************************
20 *
21 * flash.h:
22 *
23 * Device-independent macros and data structures used by flash driver.
24 *
25 * Original author:     Ed Sutter (ed.sutter@alcatel-lucent.com)
26 *
27 */
28#ifndef _FLASH_H_
29#define _FLASH_H_
30
31#define FLASH_PROTECT_WINDOW_CLOSED     0
32#define ALL_SECTORS -1
33
34#ifndef FLASH_LOOP_TIMEOUT
35#define FLASH_LOOP_TIMEOUT 1000000
36#endif
37
38#define FLASH_LOCK                      1
39#define FLASH_UNLOCK            2
40#define FLASH_LOCKDWN           3
41#define FLASH_LOCKQRY           4
42#define FLASH_LOCKABLE          5               /* query driver for lock support */
43
44/* Device ID used for ram that is "pretending" to be a flash bank. */
45#define FLASHRAM        0x9999
46
47struct  flashdesc {
48        unsigned long   id;                     /* manufacturer & device id */
49        char            *desc;                  /* ascii string */
50};
51
52struct  sectorinfo {
53        long    size;                           /* size of sector */
54        int             snum;                   /* number of sector (amongst possibly */
55                                                /* several devices) */
56        int             protected;              /* if set, sector is protected by window */
57        unsigned char   *begin;                 /* base address of sector */
58        unsigned char   *end;                   /* end address of sector */
59};
60
61struct  flashinfo {
62        unsigned long   id;                     /* manufacturer & device id */
63        unsigned char   *base;                  /* base address of device */
64        unsigned char   *end;                   /* end address of device */
65        int             sectorcnt;              /* number of sectors */
66        int             width;                  /* 1, 2, or 4 */
67        int             (*fltype)(struct flashinfo *);
68        int             (*flerase)(struct flashinfo *, int);
69#if INCLUDE_FLASHREAD
70        int             (*flread)(struct flashinfo *,unsigned char *,\
71                        unsigned char *,long);
72#endif
73        int             (*flwrite)(struct flashinfo *,unsigned char *,\
74                        unsigned char *,long);
75        int             (*flewrite)(struct flashinfo *,unsigned char *,\
76                        unsigned char *,long);
77        int             (*fllock)(struct flashinfo *,int,int);
78        struct sectorinfo *sectors;
79};
80
81extern int              FlashTrace;
82extern int              FlashProtectWindow;
83extern int              FlashCurrentBank;
84extern struct   flashinfo FlashBank[FLASHBANKS];
85extern int              flashopload(unsigned long *begin,unsigned long *end, \
86                                unsigned long *copy,int size);
87
88extern int showflashtype(unsigned long, int);
89extern int showflashinfo(char *);
90extern int flashopload(unsigned long *,unsigned long *,unsigned long *,int);
91extern int flashtype(struct flashinfo *);
92extern int flasherase(int snum);
93extern int flashwrite(struct flashinfo *,unsigned char *,unsigned char *,long);
94extern int flashewrite(unsigned char *,unsigned char *,long);
95extern int flasherased(unsigned char *,unsigned char *);
96extern int flashlock(int, int);
97extern int flashlocked(int, int);
98extern int addrtosector(unsigned char *,int *,int *,unsigned char **);
99extern struct flashinfo *snumtofdev(int);
100extern struct flashinfo *addrtobank(unsigned char *);
101extern int sectortoaddr(int,int *,unsigned char **);
102extern int flashbankinfo(int,unsigned char **,unsigned char **,int *);
103extern void LowerFlashProtectWindow(void);
104extern int AppFlashWrite(unsigned char *,unsigned char *,long);
105extern int AppFlashEraseAll(void);
106extern int AppFlashErase(int);
107extern int srange(char *,int *,int *);
108extern int sectorProtect(char *,int);
109extern int FlashOpNotSupported(void);
110extern int FlashLockNotSupported(struct flashinfo *,int,int);
111extern int lastlargesector(int,unsigned char *,int,int *,int *,unsigned char **);
112extern int lastflashsector(void);
113extern int FlashRamInit(int, int, struct flashinfo *,struct sectorinfo *,int *);
114extern int InFlashSpace(unsigned char *begin, int size);
115extern int FlashOpOverride(void *flashinfo,int get,int bank);
116
117#define NotAligned16(add)       ((long)add & 1)
118#define NotAligned32(add)       ((long)add & 3)
119
120#ifdef FLASHRAM_BASE
121extern int ramSectors[];
122extern struct sectorinfo sinfoRAM[];
123#endif
124
125#endif
Note: See TracBrowser for help on using the repository browser.