Mercurial > flash_v2
comparison packages/devs/flash/intel/strata/current/src/flash_query.c @ 156:b939e9cada46
Merge from eCos master repository on 2001-03-29-21:44:39-BST
| author | jlarmour |
|---|---|
| date | Fri, 06 Apr 2001 17:20:13 +0000 |
| parents | |
| children | 42f843b391aa |
comparison
equal
deleted
inserted
replaced
| 155:70a4cc6d69d2 | 156:b939e9cada46 |
|---|---|
| 1 //========================================================================== | |
| 2 // | |
| 3 // flash_query.c | |
| 4 // | |
| 5 // Flash programming - query device | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Red Hat eCos Public License | |
| 12 // Version 1.1 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://www.redhat.com/ | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Configurable Operating System, | |
| 22 // released September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Red Hat. | |
| 25 // Portions created by Red Hat are | |
| 26 // Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. | |
| 27 // All Rights Reserved. | |
| 28 // ------------------------------------------- | |
| 29 // | |
| 30 //####COPYRIGHTEND#### | |
| 31 //========================================================================== | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 34 // Author(s): gthomas, hmt | |
| 35 // Contributors: gthomas | |
| 36 // Date: 2001-02-14 | |
| 37 // Purpose: | |
| 38 // Description: | |
| 39 // | |
| 40 //####DESCRIPTIONEND#### | |
| 41 // | |
| 42 //========================================================================== | |
| 43 | |
| 44 #include "strata.h" | |
| 45 | |
| 46 #include <pkgconf/hal.h> | |
| 47 #include <cyg/hal/hal_arch.h> | |
| 48 #include <cyg/hal/hal_cache.h> | |
| 49 #include CYGHWR_MEMORY_LAYOUT_H | |
| 50 | |
| 51 // | |
| 52 // CAUTION! This code must be copied to RAM before execution. Therefore, | |
| 53 // it must not contain any code which might be position dependent! | |
| 54 // | |
| 55 | |
| 56 #define CNT 20*1000*10 // Approx 20ms | |
| 57 | |
| 58 int | |
| 59 flash_query(unsigned char *data) | |
| 60 { | |
| 61 volatile flash_t *ROM; | |
| 62 int i, cnt; | |
| 63 int cache_on; | |
| 64 | |
| 65 HAL_DCACHE_IS_ENABLED(cache_on); | |
| 66 if (cache_on) { | |
| 67 HAL_DCACHE_SYNC(); | |
| 68 HAL_DCACHE_DISABLE(); | |
| 69 } | |
| 70 | |
| 71 // Get base address and map addresses to virtual addresses | |
| 72 ROM = FLASH_P2V( CYGNUM_FLASH_BASE ); | |
| 73 #ifdef CYGOPT_FLASH_IS_BOOTBLOCK | |
| 74 // BootBlock flash does not support full Read_Query - we have do a | |
| 75 // table oriented thing above, after getting just two bytes of results: | |
| 76 ROM[0] = FLASH_Read_ID; | |
| 77 i = 2; | |
| 78 #else | |
| 79 // StrataFlash supports the full Read_Query op: | |
| 80 ROM[0] = FLASH_Read_Query; | |
| 81 i = sizeof(struct FLASH_query); | |
| 82 #endif // Not CYGOPT_FLASH_IS_BOOTBLOCK | |
| 83 | |
| 84 for (cnt = CNT; cnt > 0; cnt--) ; | |
| 85 for ( /* i */; i > 0; i-- ) { | |
| 86 // It is very deliberate that data is chars NOT flash_t: | |
| 87 // The info comes out in bytes regardless of device. | |
| 88 *data++ = (unsigned char) (*ROM++); | |
| 89 } | |
| 90 ROM[0] = FLASH_Reset; | |
| 91 | |
| 92 if (cache_on) { | |
| 93 HAL_DCACHE_ENABLE(); | |
| 94 } | |
| 95 | |
| 96 return 0; | |
| 97 } |
