annotate packages/hal/arm/xscale/ixp425/current/src/ixp425_redboot.c @ 1820:fdf22faea84c

* src/ixp425_redboot.c: Put #ifdef CYGPKG_IO_FLASH around flash functions so a RedBoot without flash support can be built.
author asl
date Tue, 09 Nov 2004 18:29:08 +0000
parents 484ae5c1cbf1
children 74dbf4c3f2e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1744
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
1 //==========================================================================
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
2 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
3 // ixp425_redboot.c
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
4 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
5 // RedBoot board support code for Intel IXP425 Network Processor
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
6 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
7 //==========================================================================
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
8 //####ECOSGPLCOPYRIGHTBEGIN####
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
9 // -------------------------------------------
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
12 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
14 // the terms of the GNU General Public License as published by the Free
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later version.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
16 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
20 // for more details.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
21 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
22 // You should have received a copy of the GNU General Public License along
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
25 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
26 // As a special exception, if other files instantiate templates or use macros
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
27 // or inline functions from this file, or you compile this file and link it
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
28 // with other works to produce a work based on this file, this file does not
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
29 // by itself cause the resulting work to be covered by the GNU General Public
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
30 // License. However the source code for this file must still be made available
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
31 // in accordance with section (3) of the GNU General Public License.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
32 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
33 // This exception does not invalidate any other reasons why a work based on
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
34 // this file might be covered by the GNU General Public License.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
35 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
37 // at http://sources.redhat.com/ecos/ecos-license/
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
38 // -------------------------------------------
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
39 //####ECOSGPLCOPYRIGHTEND####
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
40 //==========================================================================
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
41 //#####DESCRIPTIONBEGIN####
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
42 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
43 // Author(s): msalter
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
44 // Contributors: msalter
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
45 // Date: 2004-08-30
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
46 // Purpose: RedBoot board-specific support
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
47 // Description: Implementations of board-specic RedBoot support.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
48 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
49 //####DESCRIPTIONEND####
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
50 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
51 //========================================================================*/
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
52
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
53 #include <redboot.h>
1820
fdf22faea84c * src/ixp425_redboot.c: Put #ifdef CYGPKG_IO_FLASH around flash
asl
parents: 1744
diff changeset
54 #ifdef CYGPKG_IO_FLASH
1744
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
55 #include <cyg/io/flash.h>
1820
fdf22faea84c * src/ixp425_redboot.c: Put #ifdef CYGPKG_IO_FLASH around flash
asl
parents: 1744
diff changeset
56 #endif
1744
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
57
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
58 #ifdef CYGOPT_REDBOOT_FIS
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
59 extern void *fis_addr;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
60 #endif
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
61
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
62 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
63 extern void *cfg_base;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
64 #endif
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
65
1820
fdf22faea84c * src/ixp425_redboot.c: Put #ifdef CYGPKG_IO_FLASH around flash
asl
parents: 1744
diff changeset
66 #ifdef CYGPKG_IO_FLASH
fdf22faea84c * src/ixp425_redboot.c: Put #ifdef CYGPKG_IO_FLASH around flash
asl
parents: 1744
diff changeset
67
1744
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
68 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
69 // Little endian mode requires some trickery due to the way the IXP4xx
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
70 // AHB and expansion busses work.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
71 //
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
72 int
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
73 hal_flash_read(void *addr, void *data, int len, void **err)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
74 {
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
75 int retval;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
76
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
77 retval = flash_read(addr, data, len, err);
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
78
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
79 if (0
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
80 #if (CYG_BYTEORDER == CYG_LSBFIRST) && defined(CYGOPT_REDBOOT_FLASH_BYTEORDER_MSBFIRST)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
81 #ifdef CYGOPT_REDBOOT_FIS
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
82 || addr == fis_addr
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
83 #endif
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
84 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
85 || addr == cfg_base
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
86 #endif
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
87 #endif
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
88 ) {
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
89 cyg_uint32 *p;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
90 int i;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
91
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
92 for (i = 0, p = data; i < len; i += 4, ++p)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
93 *p = CYG_SWAP32(*p);
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
94 }
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
95 return retval;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
96 }
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
97
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
98 // Try to figure out if RedBoot is re-flashing a RedBoot with
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
99 // a different endianess. This is obviously not foolproof, but
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
100 // should be good enough.
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
101 static inline int
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
102 is_swabbed_redboot(void *faddr, cyg_uint32 *p)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
103 {
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
104 if (faddr == (void *)0x50000000
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
105 && (CYG_SWAP32(p[1]) == 0xe59ff018)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
106 && (CYG_SWAP32(p[2]) == 0xe59ff018)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
107 && (CYG_SWAP32(p[3]) == 0xe59ff018)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
108 && (CYG_SWAP32(p[4]) == 0xe59ff018)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
109 && (p[5] == 0))
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
110 return 1;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
111 return 0;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
112 }
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
113
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
114 int
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
115 hal_flash_program(void *addr, void *data, int len, void **err)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
116 {
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
117 int swabbed = 0;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
118 cyg_uint32 *p;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
119 int i, retval;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
120
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
121 if (is_swabbed_redboot(addr, data)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
122 #if (CYG_BYTEORDER == CYG_LSBFIRST) && defined(CYGOPT_REDBOOT_FLASH_BYTEORDER_MSBFIRST)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
123 #ifdef CYGOPT_REDBOOT_FIS
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
124 || addr == fis_addr
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
125 #endif
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
126 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
127 || addr == cfg_base
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
128 #endif
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
129 #endif
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
130 ) {
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
131 swabbed = 1;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
132 for (i = 0, p = data; i < len; i += 4, ++p)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
133 *p = CYG_SWAP32(*p);
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
134 }
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
135
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
136 retval = flash_program(addr, data, len, err);
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
137
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
138 if (swabbed) {
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
139 for (i = 0, p = data; i < len; i += 4, ++p)
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
140 *p = CYG_SWAP32(*p);
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
141 }
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
142
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
143 return retval;
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
144 }
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
145
1820
fdf22faea84c * src/ixp425_redboot.c: Put #ifdef CYGPKG_IO_FLASH around flash
asl
parents: 1744
diff changeset
146 #endif // CYGPKG_IO_FLASH
fdf22faea84c * src/ixp425_redboot.c: Put #ifdef CYGPKG_IO_FLASH around flash
asl
parents: 1744
diff changeset
147
1744
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
148
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
149 /*------------------------------------------------------------------------*/
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
150 // EOF ixp425_redboot.c
484ae5c1cbf1 little-endian support for ixdp425 and grg
msalter
parents:
diff changeset
151