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