OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/rtos/ecos-2.0/packages/devs/flash/arm/at91
    from Rev 27 to Rev 174
    Reverse comparison

Rev 27 → Rev 174

/v2_0/cdl/flash_at91.cdl
0,0 → 1,93
# ====================================================================
#
# flash_at91.cdl
#
# FLASH memory - Hardware support on Atmel At91/EB40
#
# ====================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
# ====================================================================
######DESCRIPTIONBEGIN####
#
# Author(s): gthomas
# Original data: gthomas
# Contributors:
# Date: 2001-07-17
#
#####DESCRIPTIONEND####
#
# ====================================================================
 
cdl_package CYGPKG_DEVS_FLASH_AT91 {
display "Atmel At91/EB40 FLASH memory support"
 
parent CYGPKG_IO_FLASH
active_if CYGPKG_IO_FLASH
requires CYGPKG_HAL_ARM_AT91
 
implements CYGHWR_IO_FLASH_DEVICE
implements CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM
 
include_dir .
include_files ; # none _exported_ whatsoever
 
description "FLASH memory device support for Atmel At91/EB40 boards"
compile at91_flash.c
 
make -priority 1 {
flash_erase_block.o: $(REPOSITORY)/$(PACKAGE)/src/flash_erase_block.c
$(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -mcpu=strongarm -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_erase_block.c
echo " .globl flash_erase_block_end" >>flash_erase_block.s
echo "flash_erase_block_end:" >>flash_erase_block.s
$(CC) -c -o flash_erase_block.o flash_erase_block.s
$(AR) rcs $(PREFIX)/lib/libtarget.a flash_erase_block.o
}
make -priority 1 {
flash_program_buf.o: $(REPOSITORY)/$(PACKAGE)/src/flash_program_buf.c
$(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -mcpu=strongarm -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_program_buf.c
echo " .globl flash_program_buf_end" >>flash_program_buf.s
echo "flash_program_buf_end:" >>flash_program_buf.s
$(CC) -c -o flash_program_buf.o flash_program_buf.s
$(AR) rcs $(PREFIX)/lib/libtarget.a flash_program_buf.o
}
make -priority 1 {
flash_query.o: $(REPOSITORY)/$(PACKAGE)/src/flash_query.c
$(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -mcpu=strongarm -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_query.c
echo " .globl flash_query_end" >>flash_query.s
echo "flash_query_end:" >>flash_query.s
$(CC) -c -o flash_query.o flash_query.s
$(AR) rcs $(PREFIX)/lib/libtarget.a flash_query.o
}
}
 
/v2_0/src/flash_program_buf.c
0,0 → 1,127
//==========================================================================
//
// flash_program_buf.c
//
// Flash programming
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): gthomas
// Contributors: gthomas
// Date: 2001-07-17
// Purpose:
// Description:
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#include "flash.h"
 
#include <pkgconf/hal.h>
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/hal_cache.h>
 
//
// CAUTION! This code must be copied to RAM before execution. Therefore,
// it must not contain any code which might be position dependent!
//
 
int
flash_program_buf(volatile unsigned short *addr, unsigned short *data, int len)
{
volatile unsigned short *PAGE, *ROM;
int timeout = 50000;
int cache_on;
int i, offset;
unsigned short hold[FLASH_PAGE_SIZE/2];
 
HAL_DCACHE_IS_ENABLED(cache_on);
if (cache_on) {
HAL_DCACHE_SYNC();
HAL_DCACHE_DISABLE();
}
 
if (len != FLASH_PAGE_SIZE) {
return FLASH_LENGTH_ERROR;
}
 
ROM = (volatile unsigned short *)((unsigned long)addr & 0xFFFF0000);
PAGE = (volatile unsigned short *)((unsigned long)addr & FLASH_PAGE_MASK);
 
// Copy current contents (allows for partial updates)
for (i = 0; i < FLASH_PAGE_SIZE/2; i++) {
hold[i] = PAGE[i];
}
 
// Merge data into holding buffer
offset = (unsigned long)addr & FLASH_PAGE_OFFSET;
for (i = 0; i < (len/2); i++) {
hold[offset+i] = data[i];
}
 
// Now write the data
 
// Send lead-in sequence
ROM[FLASH_Key_Addr0] = FLASH_Key0;
ROM[FLASH_Key_Addr1] = FLASH_Key1;
 
// Send 'write' command
ROM[FLASH_Key_Addr0] = FLASH_Program;
 
// Send one page/sector of data
for (i = 0; i < FLASH_PAGE_SIZE/2; i++) {
PAGE[i] = hold[i];
}
 
// Wait for data to be programmed
while (timeout-- > 0) {
if (PAGE[(FLASH_PAGE_SIZE/2)-1] == hold[(FLASH_PAGE_SIZE/2)-1]) {
break;
}
}
 
if (timeout <= 0) {
return FLASH_PROGRAM_ERROR;
}
 
if (cache_on) {
HAL_DCACHE_ENABLE();
}
 
return FLASH_PROGRAM_OK;
}
/v2_0/src/flash_query.c
0,0 → 1,109
//==========================================================================
//
// flash_query.c
//
// Flash programming - query device
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): gthomas
// Contributors: gthomas
// Date: 2001-07-17
// Purpose:
// Description:
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#include "flash.h"
 
#include <pkgconf/hal.h>
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/hal_cache.h>
#include CYGHWR_MEMORY_LAYOUT_H
 
//
// CAUTION! This code must be copied to RAM before execution. Therefore,
// it must not contain any code which might be position dependent!
//
 
#define CNT 2000*1000*10 // At least 20ms
 
int
flash_query(unsigned short *data)
{
volatile unsigned short *ROM;
int cnt, cache_on;
 
HAL_DCACHE_IS_ENABLED(cache_on);
if (cache_on) {
HAL_DCACHE_SYNC();
HAL_DCACHE_DISABLE();
}
 
ROM = (volatile unsigned short *)0x01010000;
 
// Send lead-in sequence
ROM[FLASH_Key_Addr0] = FLASH_Key0;
ROM[FLASH_Key_Addr1] = FLASH_Key1;
 
// Send 'identify' command
ROM[FLASH_Key_Addr0] = FLASH_Read_ID;
 
// Need a delay of 20ms!
for (cnt = 0; cnt < 50000; cnt++) ;
 
data[0] = ROM[0]; // Manufacturer code
data[1] = ROM[1]; // Device identifier
 
// Send lead-in sequence
ROM[FLASH_Key_Addr0] = FLASH_Key0;
ROM[FLASH_Key_Addr1] = FLASH_Key1;
 
// Send 'reset' command
ROM[FLASH_Key_Addr0] = FLASH_Reset;
 
// Need a delay of 20ms!
for (cnt = 0; cnt < 50000; cnt++) ;
 
if (cache_on) {
HAL_DCACHE_ENABLE();
}
 
return 0;
}
/v2_0/src/flash.h
0,0 → 1,78
//==========================================================================
//
// flash.h
//
// Flash programming - device constants, etc.
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): gthomas
// Contributors: gthomas
// Date: 2001-07-17
// Purpose:
// Description:
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#ifndef _FLASH_HWR_H_
#define _FLASH_HWR_H_
 
// Atmel AT29LV1024
 
#define FLASH_Read_ID 0x9090
#define FLASH_Program 0xA0A0
#define FLASH_Reset 0xF0F0
 
#define FLASH_Key_Addr0 0x5555
#define FLASH_Key_Addr1 0x2AAA
#define FLASH_Key0 0xAAAA
#define FLASH_Key1 0x5555
 
#define FLASH_Atmel_code 0x1F
#define FLASH_ATMEL_29LV1024 0x26
 
#define FLASH_PROGRAM_OK 0x0000
#define FLASH_LENGTH_ERROR 0x0001
#define FLASH_PROGRAM_ERROR 0x0002
 
#define FLASH_PAGE_SIZE 0x100
#define FLASH_PAGE_MASK ~(FLASH_PAGE_SIZE-1)
#define FLASH_PAGE_OFFSET (FLASH_PAGE_SIZE-1)
 
#endif // _FLASH_HWR_H_
/v2_0/src/flash_erase_block.c
0,0 → 1,71
//==========================================================================
//
// flash_erase_block.c
//
// Flash programming
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): gthomas
// Contributors: gthomas
// Date: 2001-07-17
// Purpose:
// Description:
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#include "flash.h"
 
#include <pkgconf/hal.h>
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/hal_cache.h>
 
//
// CAUTION! This code must be copied to RAM before execution. Therefore,
// it must not contain any code which might be position dependent!
//
 
int flash_erase_block(volatile unsigned long *block)
{
 
// This device is implicitly erased as each sector needs to be written
// as a whole. Thus, this is a NOP
 
return 0;
}
/v2_0/src/at91_flash.c
0,0 → 1,129
//==========================================================================
//
// at91_flash.c
//
// Flash programming
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): gthomas
// Contributors: gthomas
// Date: 2001-07-17
// Purpose:
// Description:
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#include <pkgconf/hal.h>
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/hal_cache.h>
#include <cyg/hal/hal_io.h>
 
#define _FLASH_PRIVATE_
#include <cyg/io/flash.h>
 
#include "flash.h"
 
#define _si(p) ((p[0]<<8)|p[1])
 
int
flash_hwr_init(void)
{
unsigned short data[4];
extern char flash_query, flash_query_end;
typedef int code_fun(unsigned char *);
code_fun *_flash_query;
int code_len, stat, num_regions, region_size;
 
// Copy 'program' code to RAM for execution
code_len = (unsigned long)&flash_query_end - (unsigned long)&flash_query;
_flash_query = (code_fun *)flash_info.work_space;
memcpy(_flash_query, &flash_query, code_len);
HAL_DCACHE_SYNC(); // Should guarantee this code will run
 
stat = (*_flash_query)(data);
#if 0
(*flash_info.pf)("stat = %x\n", stat);
dump_buf(data, sizeof(data));
#endif
 
if (data[0] != FLASH_Atmel_code) {
(*flash_info.pf)("Not Atmel = %x\n", data[0]);
return FLASH_ERR_HWR;
}
 
if (data[1] == (unsigned short)FLASH_ATMEL_29LV1024) {
num_regions = 256;
region_size = 0x100;
} else {
(*flash_info.pf)("Unknown device type: %x\n", data[1]);
return FLASH_ERR_HWR;
}
 
// Hard wired for now
flash_info.block_size = region_size;
flash_info.blocks = num_regions;
flash_info.start = (void *)0x01010000;
flash_info.end = (void *)(0x01010000+(num_regions*region_size));
return FLASH_ERR_OK;
}
 
// Map a hardware status to a package error
int
flash_hwr_map_error(int err)
{
if (err) {
(*flash_info.pf)("Err = %x\n", err);
return FLASH_ERR_PROGRAM;
} else {
return FLASH_ERR_OK;
}
}
 
// See if a range of FLASH addresses overlaps currently running code
bool
flash_code_overlaps(void *start, void *end)
{
extern char _stext[], _etext[];
 
return ((((unsigned long)&_stext >= (unsigned long)start) &&
((unsigned long)&_stext < (unsigned long)end)) ||
(((unsigned long)&_etext >= (unsigned long)start) &&
((unsigned long)&_etext < (unsigned long)end)));
}
/v2_0/ChangeLog
0,0 → 1,49
2001-07-19 Gary Thomas <gthomas@redhat.com>
 
* src/flash_program_buf.c: Fix - needs to have A16 set.
 
* src/at91_flash.c: Remove debugging code.
 
2001-07-18 Gary Thomas <gthomas@redhat.com>
 
* src/flash_query.c:
* src/flash_program_buf.c:
* src/flash_erase_block.c:
* src/flash.h:
* src/at91_flash.c:
* cdl/flash_at91.cdl: New package - AT29LV1024 FLASH for AT91/EB40.
 
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.