diff -bBruN old/ecos-2.0/packages/devs/eth/smsc/lan91cxx/v2_0/src/if_lan91cxx.c new/ecos-2.0/packages/devs/eth/smsc/lan91cxx/v2_0/src/if_lan91cxx.c --- old/ecos-2.0/packages/devs/eth/smsc/lan91cxx/v2_0/src/if_lan91cxx.c Wed Aug 28 19:12:26 2002 +++ new/ecos-2.0/packages/devs/eth/smsc/lan91cxx/v2_0/src/if_lan91cxx.c Thu Jul 22 17:13:00 2004 @@ -773,6 +773,10 @@ CYG_ASSERT(0 == (len & 1) || (i == (sg_len-1)), "odd length"); CYG_ASSERT( sdata, "No sg data pointer here" ); while(len >= sizeof(*sdata)) { +#ifdef LEON_CYC_WITH_LAN91C111 + // for some unknown reason the real data is mirrored, swap them + *sdata = ((*sdata << 8)&0xff00) | ((*sdata >> 8)&0x00ff); +#endif put_data(sc, *sdata++); len -= sizeof(*sdata); } @@ -1052,6 +1056,10 @@ if (data) { while (mlen >= sizeof(*data)) { *data++ = get_data(sc); +#ifdef LEON_CYC_WITH_LAN91C111 + // for some unknown reason the real data is mirrored, swap them + *(data-1) = ((*(data-1) << 8)&0xff00) | ((*(data-1) >> 8)&0x00ff); +#endif mlen -= sizeof(*data); plen -= sizeof(*data); } diff -bBruN old/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/ChangeLog new/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/ChangeLog --- old/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/ChangeLog Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/ChangeLog Thu Jul 15 11:46:41 2004 @@ -0,0 +1,43 @@ +2004-06-08 Tom Tierens + + * Initial version of support for LAN91CXX ethernet controller + on the Leon SPARC implemented on the Altera NIOS development board, + cyclone edition: + Copied the source tree from flexanet LAN91CXX ethernet controller + and made a few adjustements + + +//=========================================================================== +//####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#### +//=========================================================================== diff -bBruN old/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/cdl/leon_eth_drivers.cdl new/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/cdl/leon_eth_drivers.cdl --- old/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/cdl/leon_eth_drivers.cdl Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/cdl/leon_eth_drivers.cdl Thu Jul 15 11:46:41 2004 @@ -0,0 +1,118 @@ +# ==================================================================== +# +# leon_eth_drivers.cdl +# +# Ethernet drivers - support for LAN91C111 ethernet controller +# for Leon SPARC on the Altera Nios development board, cyclone edition. +# +# ==================================================================== +#####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): Jordi Colomer +# Contributors: Jordi Colomer, Tom Tierens +# Date: 2004-06-06 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVS_ETH_SPARC_LEON { + + display "Leon SPARC SMC91C111 ethernet driver" + + parent CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_HAL_SPARC_LEON_CYC + + # chip connected as SRAM, 32-bit mode, no EEPROM + implements CYGHWR_NET_DRIVERS + implements CYGHWR_NET_DRIVER_ETH0 + implements CYGINT_DEVS_ETH_SMSC_LAN91CXX_REQUIRED + #implements CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE + + implements CYGINT_DEVS_ETH_SMSC_LAN91CXX_STATIC_ESA + + requires CYGPKG_DEVS_ETH_SMSC_LAN91CXX + description "Ethernet driver for Leon SPARC." + + include_dir cyg/io + compile if_leon.c + + define_proc { + puts $::cdl_system_header "/***** ethernet driver proc output start *****/" + puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_SMSC_LAN91CXX_INL " + puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_SMSC_LAN91CXX_CFG " + puts $::cdl_system_header "/***** ethernet driver proc output end *****/" + } + + # Arguably this should do in the generic package + # but then there is a logic loop so you can never enable it. + + cdl_interface CYGINT_DEVS_ETH_SMSC_LAN91CXX_REQUIRED { + display "SMSC LAN91CXX driver required" + } + + cdl_option CYGDAT_DEVS_ETH_SPARC_LEON_NAME { + display "Device name for the ethernet driver" + flavor data + default_value {"\"eth0\""} + description " + This option sets the name of the ethernet device for the + ethernet port." + } + + cdl_option CYGDAT_DEVS_ETH_SPARC_LEON_ESA { + display "The ethernet station address (MAC)" + flavor data + default_value {"{0x12, 0x13, 0x14, 0x15, 0x16, 0x17}"} + description "A static ethernet station address. + Caution: Booting two systems with the same MAC on the same + network, will cause severe conflicts." + active_if !CYGSEM_DEVS_ETH_SPARC_LEON_REDBOOT_ESA + } + + cdl_option CYGSEM_DEVS_ETH_SPARC_LEON_REDBOOT_ESA { + display "Use the RedBoot ESA (MAC address)" + default_value 0 + flavor bool + description " + Use the ESA that is stored as a RedBoot variable instead of + a static ESA." + } + +} + +# EOF leon_eth_drivers.cdl diff -bBruN old/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/include/devs_eth_leon.inl new/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/include/devs_eth_leon.inl --- old/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/include/devs_eth_leon.inl Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/include/devs_eth_leon.inl Thu Jul 22 15:59:54 2004 @@ -0,0 +1,122 @@ +//========================================================================== +// +// devs/eth/sparc/leon/..../include/devs_eth_leon.inl +// +// Leon SPARC ethernet I/O definitions. +// +//========================================================================== +//####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): Jordi Colomer +// Contributors: Jordi Colomer, Tom Tierens +// Date: 2004-06-06 +// Purpose: Leon SPARC ethernet definitions +//####DESCRIPTIONEND#### +//========================================================================== + +#include +#include +#include + +#define LAN91CXX_IS_LAN91C111 +#define LEON_CYC_WITH_LAN91C111 +#define HAL_DELAY_US(n) CYGACC_CALL_IF_DELAY_US(n); +#define CYGNUM_DEVS_ETH_SMSC_LAN91CXX_SHIFT_ADDR 0 +// MAC address is stored as a Redboot config option +#ifdef CYGPKG_REDBOOT +#include +#ifdef CYGSEM_REDBOOT_FLASH_CONFIG +#include +#include + +RedBoot_config_option("Network hardware address [MAC]", + leon_esa, + ALWAYS_ENABLED, true, + CONFIG_ESA, 0 + ); +#endif +#endif + +// ESA address fetch function +static void leon_get_ESA(struct lan91cxx_priv_data *cpd) +{ + // Fetch hardware address from RedBoot config +#if defined(CYGSEM_DEVS_ETH_SPARC_LEON_REDBOOT_ESA) +#if defined(CYGPKG_REDBOOT) && \ + defined(CYGSEM_REDBOOT_FLASH_CONFIG) + flash_get_config("leon_esa", cpd->enaddr, CONFIG_ESA); +#else +#error "No RedBoot flash configuration to store ESA" +#endif +#else + unsigned char static_esa[] = CYGDAT_DEVS_ETH_SPARC_LEON_ESA; + memcpy(cpd->enaddr, static_esa, 6); +#endif +} + +static lan91cxx_priv_data lan91cxx_eth0_priv_data = { + + config_enaddr : leon_get_ESA, +#ifndef CYGSEM_DEVS_ETH_SPARC_LEON_REDBOOT_ESA + enaddr: CYGDAT_DEVS_ETH_SPARC_LEON_ESA, +#endif + base : (unsigned short *) LEON_FHH_ETH_IOBASE, + //attbase : (unsigned char *) LEON_FHH_ETH_MMBASE, + interrupt : LEON_IRQ_GPIO_ETH +}; + +ETH_DRV_SC(lan91cxx_sc, + &lan91cxx_eth0_priv_data, // Driver specific data + CYGDAT_DEVS_ETH_SPARC_LEON_NAME, // Name for device + lan91cxx_start, + lan91cxx_stop, + lan91cxx_control, + lan91cxx_can_send, + lan91cxx_send, + lan91cxx_recv, + lan91cxx_deliver, + lan91cxx_poll, + lan91cxx_int_vector +); + +NETDEVTAB_ENTRY(lan91cxx_netdev, + "lan91cxx_" CYGDAT_DEVS_ETH_SPARC_LEON_NAME, + smsc_lan91cxx_init, + &lan91cxx_sc); + +//EOF devs_eth_leon.inl + + diff -bBruN old/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/src/if_leon.c new/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/src/if_leon.c --- old/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/src/if_leon.c Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/devs/eth/sparc/leon/v2_0/src/if_leon.c Thu Jul 15 11:46:41 2004 @@ -0,0 +1,81 @@ +//========================================================================== +// +// devs/eth/sparc/leon/if_leon.c +// +// Ethernet device driver for Leon SPARC using SMSC LAN91C111 +// +//========================================================================== +//####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#### +//####BSDCOPYRIGHTBEGIN#### +// +// ------------------------------------------- +// +// Portions of this software may have been derived from OpenBSD or other sources, +// and are covered by the appropriate copyright disclaimers included herein. +// +// ------------------------------------------- +// +//####BSDCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): Jordi Colomer +// Contributors: jco, Tom Tierens +// Date: 2004-06-06 +// Purpose: +// Description: hardware driver for Leon SPARC/SMSC LAN91CXX ethernet +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#if defined(CYGPKG_REDBOOT) +#include +#endif + +#include +#include + +// ESA (Ethernet Station Address), when constant +#ifndef CYGSEM_DEVS_ETH_SPARC_LEON_REDBOOT_ESA +static unsigned char static_esa[] = CYGDAT_DEVS_ETH_SPARC_LEON_ESA; +#endif + + + diff -bBruN old/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/cdl/flash_amd_am29xxxxx.cdl new/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/cdl/flash_amd_am29xxxxx.cdl --- old/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/cdl/flash_amd_am29xxxxx.cdl Wed Jan 22 05:45:53 2003 +++ new/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/cdl/flash_amd_am29xxxxx.cdl Thu Jul 15 11:46:41 2004 @@ -67,6 +67,16 @@ display "Number of included variants" } + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29F010 { + display "AMD AM29F010 flash memory support" + default_value 0 + implements CYGINT_DEVS_FLASH_AMD_VARIANTS + description " + When this option is enabled, the AMD flash driver will be + able to recognize and handle the AMD29F010 + part in the family." + } + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29F040B { display "AMD AM29F040B flash memory support" default_value 0 @@ -77,6 +87,16 @@ part in the family." } + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV128 { + display "AMD AM29LV128 flash memory support" + default_value 0 + implements CYGINT_DEVS_FLASH_AMD_VARIANTS + description " + When this option is enabled, the AMD flash driver will be + able to recognize and handle the AMD29LV128 + part in the family." + } + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV160 { display "AMD AM29LV160 flash memory support" default_value 0 @@ -87,6 +107,16 @@ part in the family." } + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29PL160 { + display "AMD AM29PL160 flash memory support" + default_value 0 + implements CYGINT_DEVS_FLASH_AMD_VARIANTS + description " + When this option is enabled, the AMD flash driver will be + able to recognize and handle the AMD29PL160 + part in the family." + } + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV320D { display "AMD AM29LV320 flash memory support" default_value 0 @@ -158,6 +188,16 @@ part in the family." } + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV400 { + display "AMD AM29LV400 flash memory support" + default_value 0 + implements CYGINT_DEVS_FLASH_AMD_VARIANTS + description " + When this option is enabled, the AMD flash driver will be + able to recognize and handle the AM29LV400 + part in the family." + } + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29DL640D { display "AMD AM29DL640D flash memory support" default_value 0 @@ -195,5 +235,45 @@ description " When this option is enabled, the AMD flash driver will be able to recognize and handle the Toshiba TC58FVB800." + } + + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV081B { + display "AMD AM29LV081B flash memory support" + default_value 0 + implements CYGINT_DEVS_FLASH_AMD_VARIANTS + description " + When this option is enabled, the AMD flash driver will be + able to recognize and handle the AMD29LV081B + part in the family." + } + + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV017D { + display "AMD AM29LV017D flash memory support" + default_value 0 + implements CYGINT_DEVS_FLASH_AMD_VARIANTS + description " + When this option is enabled, the AMD flash driver will be + able to recognize and handle the AMD29LV017D + part in the family." + } + + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV033C { + display "AMD AM29LV033C flash memory support" + default_value 0 + implements CYGINT_DEVS_FLASH_AMD_VARIANTS + description " + When this option is enabled, the AMD flash driver will be + able to recognize and handle the AMD29LV033C + part in the family." + } + + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV065D { + display "AMD AM29LV065D flash memory support" + default_value 0 + implements CYGINT_DEVS_FLASH_AMD_VARIANTS + description " + When this option is enabled, the AMD flash driver will be + able to recognize and handle the AMD29LV065D + part in the family." } } diff -bBruN old/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/include/flash_am29xxxxx.inl new/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/include/flash_am29xxxxx.inl --- old/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/include/flash_am29xxxxx.inl Tue Nov 26 00:19:57 2002 +++ new/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/include/flash_am29xxxxx.inl Thu Jul 15 11:46:41 2004 @@ -11,7 +11,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. -// Copyright (C) 2002 Gary Thomas +// Copyright (C) 2002, 2004 Gary Thomas // // 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 @@ -68,6 +68,7 @@ #include #include #include +#include #include CYGHWR_MEMORY_LAYOUT_H #define _FLASH_PRIVATE_ @@ -80,6 +81,8 @@ #define FLASH_Reset FLASHWORD( 0xF0 ) #define FLASH_Program FLASHWORD( 0xA0 ) #define FLASH_Block_Erase FLASHWORD( 0x30 ) +#define FLASH_Load_Buffer FLASHWORD( 0x25 ) +#define FLASH_Flush_Buffer FLASHWORD( 0x29 ) #define FLASH_Data FLASHWORD( 0x80 ) // Data complement #define FLASH_Busy FLASHWORD( 0x40 ) // "Toggle" bit @@ -121,6 +124,23 @@ // #define CYGNUM_FLASH_WIDTH : Width of devices on platform // #define CYGNUM_FLASH_BASE : Address of first device +// Platform code may define some or all of the below, to provide +// timeouts appropriate to the target hardware. The timeout +// values depend partly on the flash part being used, partly +// on the target (including bus and cpu speeds). +#ifndef CYGNUM_FLASH_TIMEOUT_QUERY +# define CYGNUM_FLASH_TIMEOUT_QUERY 500000 +#endif +#ifndef CYGNUM_FLASH_TIMEOUT_ERASE_TIMER +# define CYGNUM_FLASH_TIMEOUT_ERASE_TIMER 10000000 +#endif +#ifndef CYGNUM_FLASH_TIMEOUT_ERASE_COMPLETE +# define CYGNUM_FLASH_TIMEOUT_ERASE_COMPLETE 10000000 +#endif +#ifndef CYGNUM_FLASH_TIMEOUT_PROGRAM +# define CYGNUM_FLASH_TIMEOUT_PROGRAM 10000000 +#endif + #define CYGNUM_FLASH_BLANK (1) #ifndef FLASH_P2V @@ -152,6 +172,7 @@ cyg_uint32 banks[8]; // bank offsets, highest to lowest (lowest should be 0) // (only one entry for now, increase to support devices // with more banks). + cyg_uint32 bufsiz; // write buffer size in units of flash_data_t } flash_dev_info_t; static const flash_dev_info_t* flash_dev_info; @@ -168,11 +189,13 @@ __attribute__ ((section (".2ram.flash_erase_block"))); int flash_program_buf(void* addr, void* data, int len) __attribute__ ((section (".2ram.flash_program_buf"))); -static void _flash_query(void* data) __attribute__ ((section (".2ram._flash_query"))); -static int _flash_erase_block(void* block, unsigned int size) - __attribute__ ((section (".2ram._flash_erase_block"))); -static int _flash_program_buf(void* addr, void* data, int len) - __attribute__ ((section (".2ram._flash_program_buf"))); + +//---------------------------------------------------------------------------- +// Auxiliary functions +static volatile flash_data_t * find_bank(volatile flash_data_t * base, void * addr, CYG_ADDRWORD * bo) + __attribute__ ((section (".2ram.find_bank"))); +static flash_data_t * find_sector(volatile flash_data_t * addr, unsigned long *remain_size) + __attribute__ ((section (".2ram.find_sector"))); //---------------------------------------------------------------------------- // Flash Query @@ -181,14 +204,18 @@ // device(s) in series. It is assumed that any devices in series // will be of the same type. -static void -_flash_query(void* data) +void +flash_query(void* data) { volatile flash_data_t *ROM; volatile flash_data_t *f_s1, *f_s2; flash_data_t* id = (flash_data_t*) data; flash_data_t w; - long timeout = 500000; + long timeout = CYGNUM_FLASH_TIMEOUT_QUERY; + + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000b00)); + #endif ROM = (flash_data_t*) CYGNUM_FLASH_BASE; f_s1 = FLASH_P2V(ROM+FLASH_Setup_Addr1); @@ -216,24 +243,13 @@ // Stall, waiting for flash to return to read mode. while ((--timeout != 0) && (w != *(FLASH_P2V(ROM)))) ; -} -void -flash_query(void* data) -{ - int cache_on; - - HAL_DCACHE_IS_ENABLED(cache_on); - if (cache_on) { - HAL_DCACHE_SYNC(); - HAL_DCACHE_DISABLE(); - } - _flash_query(data); - if (cache_on) { - HAL_DCACHE_ENABLE(); - } + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000800)); + #endif } + //---------------------------------------------------------------------------- // Initialize driver details int @@ -242,6 +258,10 @@ flash_data_t id[4]; int i; + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000b00)); + #endif + CYGHWR_FLASH_AM29XXXXX_PLF_INIT(); flash_dev_query(id); @@ -259,14 +279,20 @@ } // Did we find the device? If not, return error. - if (NUM_DEVICES == i) - return FLASH_ERR_DRV_WRONG_PART; + if (NUM_DEVICES == i) { + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000800)); + #endif + return FLASH_ERR_DRV_WRONG_PART; } // Hard wired for now flash_info.block_size = flash_dev_info->block_size; flash_info.blocks = flash_dev_info->block_count * CYGNUM_FLASH_SERIES; flash_info.start = (void *)CYGNUM_FLASH_BASE; flash_info.end = (void *)(CYGNUM_FLASH_BASE+ (flash_dev_info->device_size * CYGNUM_FLASH_SERIES)); + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000800)); + #endif return FLASH_ERR_OK; } @@ -295,14 +321,14 @@ //---------------------------------------------------------------------------- // Erase Block -static int -_flash_erase_block(void* block, unsigned int size) +int +flash_erase_block(void* block, unsigned int size) { volatile flash_data_t* ROM, *BANK; volatile flash_data_t* b_p = (flash_data_t*) block; volatile flash_data_t *b_v; volatile flash_data_t *f_s0, *f_s1, *f_s2; - int timeout = 50000; + int timeout = CYGNUM_FLASH_TIMEOUT_QUERY; int len = 0; int res = FLASH_ERR_OK; flash_data_t state; @@ -310,22 +336,12 @@ cyg_uint32 *bootblocks = (cyg_uint32 *)0; CYG_ADDRWORD bank_offset; - BANK = ROM = (volatile flash_data_t*)((unsigned long)block & flash_dev_info->base_mask); + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000b00)); + #endif - // If this is a banked device, find the bank where commands should - // be addressed to. - if (flash_dev_info->banked) { - int b = 0; - bank_offset = (unsigned long)block & ~(flash_dev_info->block_size-1); - bank_offset -= (unsigned long) ROM; - for(;;) { - if (bank_offset >= flash_dev_info->banks[b]) { - BANK = (volatile flash_data_t*) ((unsigned long)ROM + flash_dev_info->banks[b]); - break; - } - b++; - } - } + ROM = (volatile flash_data_t*)((unsigned long)block & flash_dev_info->base_mask); + BANK = find_bank(ROM, block, &bank_offset); f_s0 = FLASH_P2V(BANK); f_s1 = FLASH_P2V(BANK + FLASH_Setup_Addr1); @@ -360,8 +376,11 @@ state = *FLASH_P2V(b_p+FLASH_WP_Addr); *f_s0 = FLASH_Reset; - if (FLASH_unlocked != state) - return FLASH_ERR_PROTECT; + if (FLASH_unlocked != state) { + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000800)); + #endif + return FLASH_ERR_PROTECT;} #endif b_v = FLASH_P2V(b_p); @@ -375,7 +394,7 @@ *b_v = FLASH_Block_Erase; // Now poll for the completion of the sector erase timer (50us) - timeout = 10000000; // how many retries? + timeout = CYGNUM_FLASH_TIMEOUT_ERASE_TIMER; // how many retries? while (true) { state = *b_v; if ((state & FLASH_Sector_Erase_Timer) @@ -389,7 +408,7 @@ // Then wait for erase completion. if (FLASH_ERR_OK == res) { - timeout = 10000000; + timeout = CYGNUM_FLASH_TIMEOUT_ERASE_COMPLETE; while (true) { state = *b_v; if (FLASH_BlankValue == state) { @@ -418,6 +437,9 @@ if (*b_v != FLASH_BlankValue) { // Only update return value if erase operation was OK if (FLASH_ERR_OK == res) res = FLASH_ERR_DRV_VERIFY; + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000800)); + #endif return res; } len -= sizeof(*b_p); @@ -427,77 +449,99 @@ len = *bootblocks++; } } + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000800)); + #endif return res; } -int -flash_erase_block(void* block, unsigned int size) -{ - int ret, cache_on; - HAL_DCACHE_IS_ENABLED(cache_on); - if (cache_on) { - HAL_DCACHE_SYNC(); - HAL_DCACHE_DISABLE(); - } - ret = _flash_erase_block(block, size); - if (cache_on) { - HAL_DCACHE_ENABLE(); - } - return ret; -} //---------------------------------------------------------------------------- // Program Buffer -static int -_flash_program_buf(void* addr, void* data, int len) +int +flash_program_buf(void* addr, void* data, int len) { volatile flash_data_t* ROM; volatile flash_data_t* BANK; + volatile flash_data_t* SECT=NULL; volatile flash_data_t* data_ptr = (volatile flash_data_t*) data; - volatile flash_data_t* addr_v; volatile flash_data_t* addr_p = (flash_data_t*) addr; + volatile flash_data_t* addr_v = FLASH_P2V(addr_p); volatile flash_data_t *f_s1, *f_s2; CYG_ADDRWORD bank_offset; int timeout; int res = FLASH_ERR_OK; + const CYG_ADDRWORD mask = + flash_dev_info->bufsiz * sizeof (flash_data_t) - 1; + unsigned long rem_sect_size; + + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000b00)); + #endif // check the address is suitably aligned - if ((unsigned long)addr & (CYGNUM_FLASH_INTERLEAVE * CYGNUM_FLASH_WIDTH / 8 - 1)) - return FLASH_ERR_INVALID; + if ((unsigned long)addr & (CYGNUM_FLASH_INTERLEAVE * CYGNUM_FLASH_WIDTH / 8 - 1)) { + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000800)); + #endif + return FLASH_ERR_INVALID;} - // Base address of device(s) being programmed. - BANK = ROM = (volatile flash_data_t*)((unsigned long)addr_p & flash_dev_info->base_mask); - // If this is a banked device, find the bank where commands should - // be addressed to. - if (flash_dev_info->banked) { - int b = 0; - bank_offset = (unsigned long)addr & ~(flash_dev_info->block_size-1); - bank_offset -= (unsigned long) ROM; - for(;;) { - if (bank_offset >= flash_dev_info->banks[b]) { - BANK = (volatile flash_data_t*) ((unsigned long)ROM + flash_dev_info->banks[b]); - break; - } - b++; - } - } + + // Base address of device(s) being programmed. + ROM = (volatile flash_data_t*)((unsigned long)addr_p & flash_dev_info->base_mask); + BANK = find_bank(ROM, addr, &bank_offset); f_s1 = FLASH_P2V(BANK + FLASH_Setup_Addr1); f_s2 = FLASH_P2V(BANK + FLASH_Setup_Addr2); + rem_sect_size = 0; + len /= sizeof (flash_data_t); while (len > 0) { flash_data_t state; + unsigned int nwords; + + addr_v = FLASH_P2V(addr_p); + + if (flash_dev_info->bufsiz > 1) { + // Assume buffer size is power of two + unsigned int i; + + if (rem_sect_size == 0) { + SECT = find_sector(addr_v, &rem_sect_size); + rem_sect_size /= sizeof (flash_data_t); + } - addr_v = FLASH_P2V(addr_p++); + // Compute word count to write + nwords = flash_dev_info->bufsiz + - (((CYG_ADDRWORD) addr_v & mask) / sizeof (flash_data_t)); + if (nwords > len) + nwords = len; + // Initiate buffered write + *f_s1 = FLASH_Setup_Code1; + *f_s2 = FLASH_Setup_Code2; + *SECT = FLASH_Load_Buffer; + *SECT = FLASHWORD(nwords - 1); // All devices need to see this + + // Load data into write buffer, flush buffer + for(i = 0; i < nwords; i++) + *addr_v++ = *data_ptr++; + --addr_v; --data_ptr; + *SECT = FLASH_Flush_Buffer; + rem_sect_size -= nwords; + } else { // Program data [byte] - 4 step sequence *f_s1 = FLASH_Setup_Code1; *f_s2 = FLASH_Setup_Code2; *f_s1 = FLASH_Program; *addr_v = *data_ptr; - timeout = 10000000; + nwords = 1; + } + + addr_p += nwords; + timeout = CYGNUM_FLASH_TIMEOUT_PROGRAM; while (true) { state = *addr_v; if (*data_ptr == state) { @@ -521,27 +565,68 @@ if (FLASH_ERR_OK == res) res = FLASH_ERR_DRV_VERIFY; break; } - len -= sizeof(*data_ptr); + len -= nwords; } // Ideally, we'd want to return not only the failure code, but also // the address/device that reported the error. + #ifdef CHANGE_LEON_FLASH_BUS_SIZE + *((volatile CYG_WORD32 *)(0x80000000)) = ((*((volatile CYG_WORD32 *)(0x80000000))&0xfffff0ff) | (0x00000800)); + #endif return res; } -int -flash_program_buf(void* addr, void* data, int len) +static volatile flash_data_t * +find_bank(volatile flash_data_t * base, void * addr, CYG_ADDRWORD * bo) { - int ret, cache_on; - HAL_DCACHE_IS_ENABLED(cache_on); - if (cache_on) { - HAL_DCACHE_SYNC(); - HAL_DCACHE_DISABLE(); - } - ret = _flash_program_buf(addr, data, len); - if (cache_on) { - HAL_DCACHE_ENABLE(); + volatile flash_data_t * res = base; + + if (flash_dev_info->banked) { + int b = 0; + *bo = (unsigned long)addr & ~(flash_dev_info->block_size-1); + *bo -= (unsigned long) base; + for(;;) { + if (*bo >= flash_dev_info->banks[b]) { + res = (volatile flash_data_t*) ((unsigned long)base + flash_dev_info->banks[b]); + break; + } + b++; + } } - return ret; + + return res; } + +static flash_data_t * +find_sector(volatile flash_data_t * addr, unsigned long *remain_size) +{ + const CYG_ADDRESS mask = flash_dev_info->block_size - 1; + const CYG_ADDRESS a = (CYG_ADDRESS) addr; + const CYG_ADDRESS base = a & flash_dev_info->base_mask; + CYG_ADDRESS res = a & ~mask; + + *remain_size = flash_dev_info->block_size - (a & mask); + + if (flash_dev_info->bootblock) { + cyg_uint32 * bootblocks = flash_dev_info->bootblocks; + while (*bootblocks != _LAST_BOOTBLOCK) { + int ls = flash_dev_info->block_size; + + if (*bootblocks++ == (res - base)) { + while (res + *bootblocks < a) { + res += *bootblocks++; + } + } else { + // Skip over segment + while ((ls -= *bootblocks++) > 0) ; + } + } + + if (*bootblocks != _LAST_BOOTBLOCK) + *remain_size = *bootblocks - (a - res); + } + + return (flash_data_t *) res; +} + #endif // CYGONCE_DEVS_FLASH_AMD_AM29XXXXX_INL diff -bBruN old/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/include/flash_am29xxxxx_parts.inl new/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/include/flash_am29xxxxx_parts.inl --- old/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/include/flash_am29xxxxx_parts.inl Tue Feb 11 16:02:19 2003 +++ new/ecos-2.0/packages/devs/flash/amd/am29xxxxx/v2_0/include/flash_am29xxxxx_parts.inl Thu Jul 15 11:46:41 2004 @@ -80,6 +80,17 @@ #define _LAST_BOOTBLOCK (-1) #if CYGNUM_FLASH_WIDTH == 8 +#ifdef CYGHWR_DEVS_FLASH_AMD_AM29F010 + { // AM29F010 + device_id : FLASHWORD(0x20), + block_size : 0x4000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 8, + device_size: 0x20000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x20000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : false, + banked : false + }, +#endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29F040B { // AM29F040B device_id : FLASHWORD(0xa4), @@ -88,7 +99,8 @@ device_size: 0x80000 * CYGNUM_FLASH_INTERLEAVE, base_mask : ~(0x80000 * CYGNUM_FLASH_INTERLEAVE - 1), bootblock : false, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV160 @@ -106,7 +118,8 @@ 0x004000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // MBM29LV160-B | AM29LV160-B device_id : FLASHWORD(0x49), @@ -122,7 +135,8 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV200 @@ -140,7 +154,8 @@ 0x004000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // AM29LV200-B device_id : FLASHWORD(0xbf), @@ -156,7 +171,8 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV320D @@ -178,7 +194,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // AM29LV320D device_id : FLASHWORD(0xF9), @@ -198,7 +215,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL322D @@ -223,7 +241,8 @@ banked : true, banks : { 0x380000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, { // AM29DL322D-B device_id : FLASHWORD(0x56), @@ -246,7 +265,8 @@ banked : true, banks : { 0x80000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL323D @@ -271,7 +291,8 @@ banked : true, banks : { 0x300000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, { // AM29DL323D-B device_id : FLASHWORD(0x53), @@ -294,7 +315,8 @@ banked : true, banks : { 0x100000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL324D @@ -319,7 +341,8 @@ banked : true, banks : { 0x200000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, { // AM29DL324D-B device_id : FLASHWORD(0x5f), @@ -342,7 +365,8 @@ banked : true, banks : { 0x200000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL640D @@ -381,7 +405,8 @@ 0x0400000 * CYGNUM_FLASH_INTERLEAVE, 0x0100000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 } #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29F800 @@ -399,7 +424,8 @@ 0x04000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // AM29F800-B device_id : FLASHWORD(0x58), @@ -415,7 +441,8 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV800 @@ -433,7 +460,8 @@ 0x04000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // AM29LV800-B device_id : FLASHWORD(0x5b), @@ -449,7 +477,8 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_TC58FVB800 @@ -467,12 +496,85 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 + }, +#endif + +#ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV081B + { // AM29LV081B + device_id : FLASHWORD(0x38), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 16, + device_size: 0x100000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x100000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : false, + banked : false, + bufsiz : 1 + }, +#endif + +#ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV017D + { // AM29LV017D + device_id : FLASHWORD(0xC8), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 32, + device_size: 0x200000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x200000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : false, + banked : false, + bufsiz : 1 + }, +#endif + +#ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV033C + { // AM29LV033C + device_id : FLASHWORD(0xA3), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 64, + device_size: 0x400000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x400000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : false, + // Although this device is not a true banked device, we + // treat the device as having two banks to get the + // Sector Protect Verify to work for the upper half of + // the device. Reference Note 9 for Table 9 in the + // AMD data sheet. + banked : true, + banks : { 0x200000 * CYGNUM_FLASH_INTERLEAVE, + 0 + }, + bufsiz : 1 + }, +#endif + +#ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV065D + { // AM29LV065D + device_id : FLASHWORD(0x93), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 128, + device_size: 0x800000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x800000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : false, + banked : false, + bufsiz : 1 }, #endif #else // 16 bit devices +#ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV128 + { // AM29LV128 + device_id : FLASHWORD(0x227e), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 256, + device_size: 0x1000000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x1000000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : false, + banked : false, + bufsiz : 16 + }, +#endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV160 { // MBM29LV160-T | AM29LV160-T device_id : FLASHWORD(0x22c4), @@ -488,7 +590,8 @@ 0x004000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // MBM29LV160-B | AM29LV160-B device_id : FLASHWORD(0x2249), @@ -504,7 +607,44 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 + }, +#endif +#ifdef CYGHWR_DEVS_FLASH_AMD_AM29PL160 + { // AM29PL160-T + device_id : FLASHWORD(0x2227), + block_size : 0x00040000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 8, + device_size: 0x00200000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x00200000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : true, + bootblocks : { 0x1c0000 * CYGNUM_FLASH_INTERLEAVE, + 0x038000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x004000 * CYGNUM_FLASH_INTERLEAVE, + _LAST_BOOTBLOCK + }, + banked : false, + bufsiz : 1 + }, + { // AM29PL160-B + device_id : FLASHWORD(0x2245), + block_size : 0x00040000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 8, + device_size: 0x00200000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x00200000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : true, + bootblocks : { 0x000000 * CYGNUM_FLASH_INTERLEAVE, + 0x004000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x038000 * CYGNUM_FLASH_INTERLEAVE, + _LAST_BOOTBLOCK + }, + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV200 @@ -522,7 +662,8 @@ 0x004000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // AM29LV200-B device_id : FLASHWORD(0x22bf), @@ -538,7 +679,8 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_ST_M29W200B @@ -556,7 +698,8 @@ 0x004000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // ST M29W200BB device_id : FLASHWORD(0x0057), @@ -572,7 +715,8 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV320D @@ -594,7 +738,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // AM29LV320D device_id : FLASHWORD(0x22F9), @@ -614,7 +759,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL322D @@ -639,7 +785,8 @@ banked : true, banks : { 0x380000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, { // AM29DL322D-B device_id : FLASHWORD(0x2256), @@ -662,7 +809,8 @@ banked : true, banks : { 0x80000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL323D @@ -687,7 +835,8 @@ banked : true, banks : { 0x300000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, { // AM29DL323D-B device_id : FLASHWORD(0x2253), @@ -710,7 +859,8 @@ banked : true, banks : { 0x100000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL324D @@ -735,7 +885,8 @@ banked : true, banks : { 0x200000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, { // AM29DL324D-B device_id : FLASHWORD(0x225f), @@ -758,7 +909,8 @@ banked : true, banks : { 0x200000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL640D @@ -797,8 +949,45 @@ 0x400000 * CYGNUM_FLASH_INTERLEAVE, 0x100000 * CYGNUM_FLASH_INTERLEAVE, 0 - } - } + }, + bufsiz : 1 + }, +#endif +#ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV400 + { // AM29LV400-T + device_id : FLASHWORD(0x22b9), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 8, + device_size: 0x80000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x80000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : true, + bootblocks : { 0xf0000 * CYGNUM_FLASH_INTERLEAVE, + 0x08000 * CYGNUM_FLASH_INTERLEAVE, + 0x02000 * CYGNUM_FLASH_INTERLEAVE, + 0x02000 * CYGNUM_FLASH_INTERLEAVE, + 0x04000 * CYGNUM_FLASH_INTERLEAVE, + _LAST_BOOTBLOCK + }, + banked : false, + bufsiz : 1 + }, + { // AM29LV400-B + device_id : FLASHWORD(0x22ba), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 8, + device_size: 0x80000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x80000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : true, + bootblocks : { 0x000000 * CYGNUM_FLASH_INTERLEAVE, + 0x004000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x008000 * CYGNUM_FLASH_INTERLEAVE, + _LAST_BOOTBLOCK + }, + banked : false, + bufsiz : 1 + }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29F800 { // AM29F800-T @@ -815,7 +1004,8 @@ 0x04000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // AM29F800-B device_id : FLASHWORD(0x2258), @@ -831,7 +1021,8 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV800 @@ -849,7 +1040,8 @@ 0x04000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, { // AM29LV800-B device_id : FLASHWORD(0x225b), @@ -865,7 +1057,8 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV640 @@ -876,7 +1069,8 @@ device_size: 0x800000 * CYGNUM_FLASH_INTERLEAVE, base_mask : ~(0x800000 * CYGNUM_FLASH_INTERLEAVE - 1), bootblock : false, - banked : false + banked : false, + bufsiz : 1 }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_TC58FVB800 @@ -894,7 +1088,8 @@ 0x008000 * CYGNUM_FLASH_INTERLEAVE, _LAST_BOOTBLOCK }, - banked : false + banked : false, + bufsiz : 1 }, #endif diff -bBruN old/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/ChangeLog new/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/ChangeLog --- old/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/ChangeLog Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/ChangeLog Thu Jul 15 11:46:41 2004 @@ -0,0 +1,34 @@ +//=========================================================================== +//####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#### +//=========================================================================== diff -bBruN old/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/cdl/flash_sparc_leon.cdl new/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/cdl/flash_sparc_leon.cdl --- old/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/cdl/flash_sparc_leon.cdl Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/cdl/flash_sparc_leon.cdl Thu Jul 15 11:46:41 2004 @@ -0,0 +1,71 @@ +# ==================================================================== +# +# flash_sparc_leon.cdl +# +# FLASH memory - Hardware support on Leon SPARC +# +# ==================================================================== +#####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): jskov, gthomas +# Original data: jskov, Tom Tierens +# Contributors: +# Date: 2004-06-06 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVS_FLASH_SPARC_LEON { + display "LEON SPARC FLASH memory support" + + parent CYGPKG_IO_FLASH + active_if CYGPKG_IO_FLASH + requires CYGPKG_HAL_SPARC_LEON_CYC + + implements CYGHWR_IO_FLASH_DEVICE + + compile leon_flash.c + + # Arguably this should do in the generic package + # but then there is a logic loop so you can never enable it. + cdl_interface CYGINT_DEVS_FLASH_AMD_AM29XXXXX_REQUIRED { + display "Generic AMD flash driver required" + } + + implements CYGINT_DEVS_FLASH_AMD_AM29XXXXX_REQUIRED + requires CYGHWR_DEVS_FLASH_AMD_AM29LV065D +} diff -bBruN old/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/src/leon_flash.c new/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/src/leon_flash.c --- old/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/src/leon_flash.c Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/devs/flash/sparc/leon/v2_0/src/leon_flash.c Thu Jul 15 11:46:41 2004 @@ -0,0 +1,75 @@ +//========================================================================== +// +// leon_flash.c +// +// Flash programming for Fujitsu/AMD device on leon sparc +// +//========================================================================== +//####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): jskov, gthomas +// Contributors: jskov, Tom Tierens +// Date: 2004-06-06 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include + +//-------------------------------------------------------------------------- +// Device properties + +#define CYGNUM_FLASH_INTERLEAVE (1) +#define CYGNUM_FLASH_SERIES (1) +#define CYGNUM_FLASH_WIDTH (8) +#define CYGNUM_FLASH_BASE (0x00000000) +#define CHANGE_LEON_FLASH_BUS_SIZE + +//static cyg_uint32 plf_flash_base; + +//-------------------------------------------------------------------------- +// Platform specific extras +#define CYGHWR_FLASH_AM29XXXXX_NO_WRITE_PROTECT // This feature fails :-( + +//-------------------------------------------------------------------------- +// Now include the driver code. +#include "cyg/io/flash_am29xxxxx.inl" + +// ------------------------------------------------------------------------ +// EOF leon_flash.c diff -bBruN old/ecos-2.0/packages/ecos.db new/ecos-2.0/packages/ecos.db --- old/ecos-2.0/packages/ecos.db Mon Feb 24 00:01:26 2003 +++ new/ecos-2.0/packages/ecos.db Thu Jul 15 11:46:41 2004 @@ -599,6 +599,17 @@ on the Fujitsu FRV400 platform." } +package CYGPKG_DEVS_FLASH_SPARC_LEON { + alias { "Leon FLASH memory support" flash_leon } + directory devs/flash/sparc/leon + script flash_sparc_leon.cdl + hardware + description " + This package contains hardware support for FLASH memory + on the Leon sparc platform." +} + + package CYGPKG_DEVS_TOUCH_IPAQ { alias { "Touch screen support for iPAQ" touch_ipaq } directory devs/touch/arm/ipaq @@ -1242,6 +1253,15 @@ description "Ethernet driver for Intel EBSA285 with PRO/100+ boards." } +package CYGPKG_DEVS_ETH_SPARC_LEON { + alias { "Leon Sparc ethernet support" devs_eth_sparc_leon } + hardware + directory devs/eth/sparc/leon + script leon_eth_drivers.cdl + description "This package contains hardware support for the SMC91C111 + ethernet device on the cyclone board." +} + package CYGPKG_DEVS_ETH_ARM_FLEXANET { alias { "SA11x0/Flexanet onboard ethernet support" devs_eth_arm_flexanet } hardware @@ -2549,6 +2569,16 @@ with both real hardware and the TSIM/LEON simulator." } +package CYGPKG_HAL_SPARC_LEON_CYC { + alias { "LEON processor for cyclone" hal_sparc_leon_cyc sparc_leon_cyc_hal } + directory hal/sparc/leon_cyc + script hal_sparc_leon_cyc.cdl + hardware + description " + The LEON processor HAL package is provided for use + with both real hardware and the TSIM/LEON simulator." +} + # -------------------------------------------------------------------------- # PowerPC packages package CYGPKG_HAL_POWERPC { @@ -3876,6 +3906,20 @@ description " The sparc_erc32 target provides the packages need to run eCos on the ERC32 processor or TSIM/ERC32 simulator." +} + +target sparc_leon_cyc { + alias { "LEON processor for cyclone" leon_cyc } + packages { CYGPKG_HAL_SPARC + CYGPKG_HAL_SPARC_LEON_CYC + CYGPKG_DEVS_ETH_SPARC_LEON + CYGPKG_DEVS_ETH_SMSC_LAN91CXX + CYGPKG_DEVS_FLASH_SPARC_LEON + CYGPKG_DEVS_FLASH_AMD_AM29XXXXX + } + description " + The sparc_leon target provides the packages need to run eCos + on the LEON processor or TSIM/LEON simulator." } target sparc_leon { diff -bBruN old/ecos-2.0/packages/hal/sparc/arch/v2_0/src/hal_boot.c new/ecos-2.0/packages/hal/sparc/arch/v2_0/src/hal_boot.c --- old/ecos-2.0/packages/hal/sparc/arch/v2_0/src/hal_boot.c Fri May 24 01:05:08 2002 +++ new/ecos-2.0/packages/hal/sparc/arch/v2_0/src/hal_boot.c Thu Jul 15 11:46:41 2004 @@ -167,6 +167,10 @@ LED( 0xf8 ); + hal_platform_init(); + + LED( 0xf8 ); + /* Call cyg_start */ cyg_start(); /* does not return */ } diff -bBruN old/ecos-2.0/packages/hal/sparc/arch/v2_0/src/hal_intr.c new/ecos-2.0/packages/hal/sparc/arch/v2_0/src/hal_intr.c --- old/ecos-2.0/packages/hal/sparc/arch/v2_0/src/hal_intr.c Fri May 24 01:05:08 2002 +++ new/ecos-2.0/packages/hal/sparc/arch/v2_0/src/hal_intr.c Thu Jul 15 11:46:41 2004 @@ -60,7 +60,7 @@ //static int count = 0; -cyg_uint32 hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data) +cyg_uint32 hal_arch_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data) { return 0; // 0x1def0000 + vector + (count += 0x0100); } diff -bBruN old/ecos-2.0/packages/hal/sparc/arch/v2_0/src/sparc.ld new/ecos-2.0/packages/hal/sparc/arch/v2_0/src/sparc.ld --- old/ecos-2.0/packages/hal/sparc/arch/v2_0/src/sparc.ld Wed Apr 16 19:55:12 2003 +++ new/ecos-2.0/packages/hal/sparc/arch/v2_0/src/sparc.ld Thu Jul 15 11:46:41 2004 @@ -116,7 +116,7 @@ _GOT_START = ABSOLUTE (.); _GLOBAL_OFFSET_TABLE_ = ABSOLUTE (.) + 32768; \ _SDA_BASE_ = ABSOLUTE (.); \ *(.got.plt) *(.got) _GOT_END_ = ABSOLUTE (.); \ - *(.dynamic) *(.sdata*) *(.sbss*) *(.eh_frame) } \ + *(.dynamic) *(.sdata*) *(.sbss*) *(.eh_frame) *(.2ram.*) } \ > _region_ \ __rom_data_start = LOADADDR (.data); \ . = ALIGN (8); \ @@ -147,6 +147,8 @@ .debug_funcnames 0 : { *(.debug_funcnames) } \ .debug_typenames 0 : { *(.debug_typenames) } \ .debug_varnames 0 : { *(.debug_varnames) } + +hal_virtual_vector_table = 0x40020000; #include #include CYGHWR_MEMORY_LAYOUT_LDI diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/ChangeLog new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/ChangeLog --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/ChangeLog Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/ChangeLog Thu Jul 15 11:46:41 2004 @@ -0,0 +1,60 @@ +2004-06-06 Tom Tierens + + * added leon_cyc tree for the Leon SPARC on the Altera Nios board, Cyclone Edition + * added RedBoot support for Leon SPARC + + +2002-10-19 Jonathan Larmour + + Patch from Jiri Gaisler: + * cdl/hal_sparc_leon.cdl: -msoft-float needn't be used in local package + since it's defined globally. + * include/hal_diag.h: Fix UART TX mask. + +2002-03-15 Hugo Tyson + + * cdl/hal_sparc_leon.cdl: Add -msoft-cloat to CYGBLD_GLOBAL_CFLAGS + (as well as LDFLAGS) - this gives perfect test coverage in minimal + build with the sim. NB pro tem the tools are called + sparc-rtems-gcc et al, but sparc-elf-gcc et al should be OK. + +2002-03-14 Jiri Gaisler + + * Initial version based on the SPARClite SIM HAL. + +//=========================================================================== +//####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#### +//=========================================================================== + +//EOF ChangeLog diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/cdl/hal_sparc_leon_cyc.cdl new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/cdl/hal_sparc_leon_cyc.cdl --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/cdl/hal_sparc_leon_cyc.cdl Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/cdl/hal_sparc_leon_cyc.cdl Thu Jul 22 17:17:33 2004 @@ -0,0 +1,231 @@ +# ==================================================================== +# +# hal_sparc_leon_cyc.cdl +# +# SPARC LEON target HAL package configuration data +# +# ==================================================================== +#####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): jskov +# Original data: hmt +# Contributors: Tom Tierens +# Date: 2004-06-06 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_HAL_SPARC_LEON_CYC { + display "LEON processor for cyclone" + parent CYGPKG_HAL_SPARC + define_header hal_sparc_leon_cyc.h + include_dir cyg/hal + description " + The LEON HAL package is provided for both simulator (TSIM) + and real hardware use" + + compile hal_priv.c plf_misc.c + + implements CYGINT_HAL_VIRTUAL_VECTOR_SUPPORT + + define_proc { + puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H " + puts $::cdl_system_header "#define CYGBLD_HAL_PLATFORM_H " + puts $::cdl_header "#define CYGHWR_HAL_SPARC_MULTIPLE_VECTOR_TRAPPING /* true for LEON */" + puts $::cdl_header "#define HAL_IDLE_THREAD_ACTION hal_idle_thread_action /* true for LEON */" + } + + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS { + display "Number of communication channels on the board" + flavor data + calculated 1 + } + + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL { + display "Debug serial port" + flavor data + legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1 + default_value 0 + description " + The board has only one serial port. This option + chooses which port will be used to connect to a host + running GDB." + } + + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL { + display "Diagnostic serial port" + flavor data + legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1 + default_value 0 + description " + The board has only one serial port. This option + chooses which port will be used for diagnostic output." + } + + + cdl_component CYG_HAL_STARTUP { + display "Startup type" + flavor data + legal_values {"RAM"} + default_value {"RAM"} + no_define + define -file system.h CYG_HAL_STARTUP + description " + When targetting the LEON processor only the RAM startup type + is usable." + } + + # Real-time clock/counter specifics + cdl_component CYGNUM_HAL_RTC_CONSTANTS { + display "Real-time clock constants." + flavor none + + cdl_option CYGNUM_HAL_RTC_NUMERATOR { + display "Real-time clock numerator" + flavor data + calculated 1000000000 + } + cdl_option CYGNUM_HAL_RTC_DENOMINATOR { + display "Real-time clock denominator" + flavor data + calculated 100 + } + cdl_option CYGNUM_HAL_RTC_PERIOD { + display "Real-time clock period" + flavor data + calculated 9999 + } + } + + cdl_component CYGBLD_GLOBAL_OPTIONS { + display "Global build options" + flavor none + description " + Global build options including control over + compiler flags, linker flags and choice of toolchain." + + + parent CYGPKG_NONE + + cdl_option CYGBLD_GLOBAL_COMMAND_PREFIX { + display "Global command prefix" + flavor data + no_define + default_value { "sparc-rtems" } + description " + This option specifies the command prefix used when + invoking the build tools." + } + + cdl_option CYGBLD_GLOBAL_CFLAGS { + display "Global compiler flags" + flavor data + no_define + default_value { "-msoft-float -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority" } + description " + This option controls the global compiler flags which + are used to compile all packages by + default. Individual packages may define + options which override these global flags." + } + + cdl_option CYGBLD_GLOBAL_LDFLAGS { + display "Global linker flags" + flavor data + no_define + default_value { "-msoft-float -g -nostdlib -Wl,--gc-sections -Wl,-static" } + description " + This option controls the global linker flags. Individual + packages may define options which override these global flags." + } + } + + cdl_component CYGPKG_HAL_SPARC_LEON_OPTIONS { + display "LEON processor build options" + flavor none + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_HAL_SPARC_LEON_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the LEON processor HAL. These flags are + used in addition to the set of global flags." + } + + cdl_option CYGPKG_HAL_SPARC_LEON_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the LEON processor HAL. These flags are + removed from the set of global flags if present." + } + } + + cdl_component CYGHWR_MEMORY_LAYOUT { + display "Memory layout" + flavor data + no_define + calculated { "sparc_leon_ram" } + + cdl_option CYGHWR_MEMORY_LAYOUT_LDI { + display "Memory layout linker script fragment" + flavor data + no_define + define -file system.h CYGHWR_MEMORY_LAYOUT_LDI + calculated { "" } + } + + cdl_option CYGHWR_MEMORY_LAYOUT_H { + display "Memory layout header file" + flavor data + no_define + define -file system.h CYGHWR_MEMORY_LAYOUT_H + calculated { "" } + } + } +} diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_cache.h new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_cache.h --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_cache.h Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_cache.h Thu Jul 15 11:46:41 2004 @@ -0,0 +1,190 @@ +#ifndef CYGONCE_HAL_CACHE_H +#define CYGONCE_HAL_CACHE_H + +//============================================================================= +// +// hal_cache.h +// +// HAL Cache control support (such as it is in the simulator) +// +//============================================================================= +//####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): nickg, gthomas, hmt +// Contributors: nickg, gthomas, hmt +// Date: 1999-01-28 +// Purpose: Define Interrupt support +// Description: The macros defined here provide the HAL APIs for handling +// the caches. +// +// Usage: +// #include +// ... +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include + +#include + +//----------------------------------------------------------------------------- +// LEON cache macros + +//----------------------------------------------------------------------------- +// Cache dimensions + +// Data cache +#define HAL_DCACHE_SIZE 0x1000 // Size of data cache in bytes +#define HAL_DCACHE_LINE_SIZE 32 // Size of a data cache line +#define HAL_DCACHE_WAYS 2 // Associativity of the cache + +// Instruction cache +#define HAL_ICACHE_SIZE 0x1000 // Size of cache in bytes +#define HAL_ICACHE_LINE_SIZE 32 // Size of a cache line +#define HAL_ICACHE_WAYS 2 // Associativity of the cache + +#define HAL_DCACHE_SETS (HAL_DCACHE_SIZE/(HAL_DCACHE_LINE_SIZE*HAL_DCACHE_WAYS)) +#define HAL_ICACHE_SETS (HAL_ICACHE_SIZE/(HAL_ICACHE_LINE_SIZE*HAL_ICACHE_WAYS)) + +//----------------------------------------------------------------------------- +// Global control of data cache + +// Enable the data cache +#define HAL_DCACHE_ENABLE() //*((int *)0x80000014) |= (int)0x0000000c +// Disable the data cache +#define HAL_DCACHE_DISABLE() //*((int *)0x80000014) &= ~(int)0x0000000c +// Invalidate the entire cache +#define HAL_DCACHE_INVALIDATE_ALL() //*((int *)0x80000014) |= (int)0x00400000 +// Synchronize the contents of the cache with memory. +#define HAL_DCACHE_SYNC() + +//emsys +// Query the state of the data cache +#define HAL_DCACHE_IS_ENABLED(_state_) CYG_MACRO_START \ + int _v_; \ + (_state_) = (0); \ +CYG_MACRO_END +//emsys + +// Set the data cache refill burst size +//#define HAL_DCACHE_BURST_SIZE(_size_) + +// Set the data cache write mode +//#define HAL_DCACHE_WRITE_MODE( _mode_ ) + +//#define HAL_DCACHE_WRITETHRU_MODE 0 +//#define HAL_DCACHE_WRITEBACK_MODE 1 + +// Load the contents of the given address range into the data cache +// and then lock the cache so that it stays there. +//#define HAL_DCACHE_LOCK(_base_, _size_) + +// Undo a previous lock operation +//#define HAL_DCACHE_UNLOCK(_base_, _size_) + +// Unlock entire cache +//#define HAL_DCACHE_UNLOCK_ALL() + +//----------------------------------------------------------------------------- +// Data cache line control + +// Allocate cache lines for the given address range without reading its +// contents from memory. +//#define HAL_DCACHE_ALLOCATE( _base_ , _size_ ) + +// Write dirty cache lines to memory and invalidate the cache entries +// for the given address range. +//#define HAL_DCACHE_FLUSH( _base_ , _size_ ) + +// Invalidate cache lines in the given range without writing to memory. +//#define HAL_DCACHE_INVALIDATE( _base_ , _size_ ) + +// Write dirty cache lines to memory for the given address range. +//#define HAL_DCACHE_STORE( _base_ , _size_ ) + +// Preread the given range into the cache with the intention of reading +// from it later. +//#define HAL_DCACHE_READ_HINT( _base_ , _size_ ) + +// Preread the given range into the cache with the intention of writing +// to it later. +//#define HAL_DCACHE_WRITE_HINT( _base_ , _size_ ) + +// Allocate and zero the cache lines associated with the given range. +//#define HAL_DCACHE_ZERO( _base_ , _size_ ) + +//----------------------------------------------------------------------------- +// Global control of Instruction cache - use Data cache controls since they +// are not separatable. + +// Enable the instruction cache +#define HAL_ICACHE_ENABLE() HAL_DCACHE_ENABLE() + +// Disable the instruction cache +#define HAL_ICACHE_DISABLE() HAL_DCACHE_DISABLE() + +// Invalidate the entire cache +#define HAL_ICACHE_INVALIDATE_ALL() HAL_DCACHE_SYNC(); HAL_DCACHE_INVALIDATE_ALL() + +// Synchronize the contents of the cache with memory. +#define HAL_ICACHE_SYNC() + +// Set the instruction cache refill burst size +//#define HAL_ICACHE_BURST_SIZE(_size_) + +// Load the contents of the given address range into the instruction cache +// and then lock the cache so that it stays there. +//#define HAL_ICACHE_LOCK(_base_, _size_) + +// Undo a previous lock operation +//#define HAL_ICACHE_UNLOCK(_base_, _size_) + +// Unlock entire cache +//#define HAL_ICACHE_UNLOCK_ALL() + +//----------------------------------------------------------------------------- +// Instruction cache line control + +// Invalidate cache lines in the given range without writing to memory. +//#define HAL_ICACHE_INVALIDATE( _base_ , _size_ ) + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_HAL_CACHE_H +// End of hal_cache.h diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_clock.h new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_clock.h --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_clock.h Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_clock.h Thu Jul 15 11:46:41 2004 @@ -0,0 +1,128 @@ +#ifndef CYGONCE_HAL_CLOCK_H +#define CYGONCE_HAL_CLOCK_H + +//============================================================================= +// +// hal_clock.h +// +// HAL clock support +// +//============================================================================= +//####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): nickg, gthomas, hmt +// Contributors: nickg, gthomas, hmt +// Date: 1999-01-28 +// Purpose: Define clock support +// Description: The macros defined here provide the HAL APIs for handling +// the clock. +// +// Usage: +// #include // which includes this file +// ... +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include + +//----------------------------------------------------------------------------- +// Clock control + +// in erc32 simulator: +// 4 = UART A +// 5 = UART B +// 7 = UART error +// 12 = GPT (general purpose timer) +// 13 = TI1 (realtime clock) +// 15 = watchdog + +// in erc32 simulator: + +// The vector used by the Real time clock is defined in hal_xpic.h + +// We could place conditional code here to choose one clock or the other +// depending on the selected interrupt vector... but pro tem: (pun intended) + +#define SPARC_LEON_TIMER_SCALE (24) + +/* These must be accessed word-wide to work! */ + +#define SPARC_LEON_REG (0x80000000) + +#define SPARC_LEON_TI1_COUNTER (SPARC_LEON_REG + 0x40) +#define SPARC_LEON_TI1_CRELOAD (SPARC_LEON_REG + 0x44) +#define SPARC_LEON_SCALER (SPARC_LEON_REG + 0x60) +#define SPARC_LEON_SRELOAD (SPARC_LEON_REG + 0x64) + +/* LEON timer control register bits */ +#define SPARC_LEON_TI1_EN 1 /* System Enable */ +#define SPARC_LEON_TI1_RL 2 /* Continuous Running */ +#define SPARC_LEON_TI1_LD 4 /* Counter Load */ + +#define SPARC_LEON_TI1_CONTROL (SPARC_LEON_REG + 0x48) + +externC cyg_int32 cyg_hal_sparc_clock_period; + +#define HAL_CLOCK_INITIALIZE( _period_ ) CYG_MACRO_START \ + cyg_hal_sparc_clock_period = (_period_); \ + HAL_WRITE_UINT32( SPARC_LEON_TI1_CRELOAD, (_period_) ); \ + HAL_WRITE_UINT32( SPARC_LEON_TI1_COUNTER, (_period_) ); \ + HAL_WRITE_UINT32( SPARC_LEON_TI1_CONTROL, \ + (SPARC_LEON_TI1_EN | \ + SPARC_LEON_TI1_RL | \ + SPARC_LEON_TI1_LD) ); \ +CYG_MACRO_END + +#define HAL_CLOCK_RESET( _vector_, _period_ ) /* nowt, it is freerunning */ + +#define HAL_CLOCK_READ( _pvalue_ ) CYG_MACRO_START \ + cyg_uint32 _read_; \ + HAL_READ_UINT32( SPARC_LEON_TI1_COUNTER, _read_ ); \ + *((cyg_uint32 *)(_pvalue_)) = \ + (cyg_hal_sparc_clock_period - _read_ ); \ +CYG_MACRO_END + + +#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY +#define HAL_CLOCK_LATENCY( _pvalue_ ) HAL_CLOCK_READ( _pvalue_ ) +#endif + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_HAL_CLOCK_H +// End of hal_clock.h diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_diag.h new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_diag.h --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_diag.h Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_diag.h Thu Jul 22 16:29:33 2004 @@ -0,0 +1,171 @@ +#ifndef CYGONCE_HAL_HAL_DIAG_H +#define CYGONCE_HAL_HAL_DIAG_H + +/*============================================================================= +// +// hal_diag.h +// +// HAL Support for Kernel Diagnostic Routines +// +//============================================================================= +//####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): hmt +// Contributors: hmt +// Date: 1999-01-11 +// Purpose: HAL Support for Kernel Diagnostic Routines +// Description: Diagnostic routines for use during kernel development. +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//===========================================================================*/ + +#include +#include + +#include CYGBLD_HAL_PLATFORM_H + +#include // base types +#include // assertion macros + +#include // basic machine info +#include // interrupt macros +#include // IO macros +#include + +#include // target_register_t +#include // Calling interface definitions +#include // Helper functions +#include // CYG_ISR_HANDLED + +//---------------------------------------------------------------------------- +// Reset - dummy routine for now +#define HAL_PLATFORM_RESET() + //asm volatile ("ldc %0,sr;trapa #0x00;" : : "r" (CYGARC_REG_SR_BL)) + +#define HAL_PLATFORM_RESET_ENTRY 0x40000000 + + +//---------------------------------------------------------------------------- +// Microsecond delay support. + +//#define HAL_DELAY_US(n) CYGACC_CALL_IF_DELAY_US(n); + +/*---------------------------------------------------------------------------*/ + +#define CYG_DIAG_USE_LEON + +/*---------------------------------------------------------------------------*/ + +#ifdef CYG_DIAG_USE_LEON + +/*---------------------------------------------------------------------------*/ +/* Register addresses */ + +#define SPARC_LEON_REG (0x80000000) + +/* These must be accessed word-wide to work! */ +#define SPARC_LEON_UART_IO( x ) ((cyg_uint32)(x)) + +#define SPARC_LEON_UART_A_RX ((volatile cyg_uint32 *)(SPARC_LEON_REG + 0x70)) +#define SPARC_LEON_UART_A_TX ((volatile cyg_uint32 *)(SPARC_LEON_REG + 0x70)) +#define SPARC_LEON_UART_STATUS ((volatile cyg_uint32 *)(SPARC_LEON_REG + 0x74)) +#define SPARC_LEON_UART_RXAMASK (0x00001) +#define SPARC_LEON_UART_TXAMASK (0x00004) +#define LEON_INTERRUPT_UART_1_RX_TX 3 +#define LEON_FHH_ETH_IOBASE 0x20000000 +#define LEON_FHH_ETH_MMBASE 0x00800000 +#define LEON_IRQ_GPIO_ETH 12 + + +/*---------------------------------------------------------------------------*/ + +#define HAL_DIAG_INIT() + +#define HAL_DIAG_WRITE_CHAR(_c_) \ +{ \ + if( 1 || _c_ != '\r' ) \ + { \ + while( (SPARC_LEON_UART_TXAMASK & *SPARC_LEON_UART_STATUS) == 0 ) \ + continue; \ + *SPARC_LEON_UART_A_TX = SPARC_LEON_UART_IO(_c_); \ + } \ +} + +#define HAL_DIAG_READ_CHAR(_c_) \ +{ \ + while( (SPARC_LEON_UART_RXAMASK & *SPARC_LEON_UART_STATUS) == 0 ) \ + continue; \ + _c_ = (char)*SPARC_LEON_UART_A_TX; \ +} + + +#define XHAL_DIAG_WRITE_CHAR(_c_) \ +{ \ + if( _c_ != '\r' ) \ + { \ + *SPARC_LEON_UART_A_TX = SPARC_LEON_UART_IO(_c_); \ + } \ +} + +#define XHAL_DIAG_READ_CHAR(_c_) \ +{ \ + _c_ = (char)*SPARC_LEON_UART_A_TX; \ +} + + + +//#define HAL_DIAG_INIT() hal_if_diag_init() +//#define HAL_DIAG_WRITE_CHAR(_c_) hal_if_diag_write_char(_c_) +//#define HAL_DIAG_READ_CHAR(_c_) hal_if_diag_read_char(&_c_) + + +#else +/*---------------------------------------------------------------------------*/ +/* There is no diagnostic output on LEON processor */ + +#define HAL_DIAG_INIT() + +#define HAL_DIAG_WRITE_CHAR(_c_) + +#define HAL_DIAG_READ_CHAR(_c_) (_c_) = 0 + +#endif + +/*---------------------------------------------------------------------------*/ +/* end of hal_diag.h */ +#endif /* CYGONCE_HAL_HAL_DIAG_H */ diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_xpic.h new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_xpic.h --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_xpic.h Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/hal_xpic.h Thu Jul 15 11:46:41 2004 @@ -0,0 +1,122 @@ +#ifndef CYGONCE_HAL_XPIC_H +#define CYGONCE_HAL_XPIC_H + +//============================================================================= +// +// hal_xpic.h +// +// HAL eXternal Programmable Interrupt Controller support +// +//============================================================================= +//####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): nickg, gthomas, hmt +// Contributors: nickg, gthomas, hmt +// Date: 1999-01-28 +// Purpose: Define Interrupt support +// Description: The macros defined here provide the HAL APIs for handling +// an external interrupt controller, and which interrupt is +// used for what. +// +// Usage: +// #include // which includes this file +// ... +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include + +//----------------------------------------------------------------------------- +// Interrupt controller access + +// in leon simulator: +// 2 = UART B +// 3 = UART A +// 1 = AHB error +// 9 = TI2 (general purpose timer) +// 8 = TI1 (realtime clock) + +// The vector used by the Real time clock +#define CYGNUM_HAL_INTERRUPT_RTC CYGNUM_HAL_INTERRUPT_8 + + +/* These must be accessed word-wide to work! */ +#define SPARC_LEON_REG (0x80000000) + +#define SPARC_LEON_INTCON_PENDING (SPARC_LEON_REG + 0x94) +#define SPARC_LEON_INTCON_MASK (SPARC_LEON_REG + 0x90) +#define SPARC_LEON_INTCON_CLEAR (SPARC_LEON_REG + 0x9C) +#define SPARC_LEON_INTCON_FORCE (SPARC_LEON_REG + 0x98) + + +#define HAL_INTERRUPT_MASK( _vector_ ) CYG_MACRO_START \ + cyg_uint32 _traps_, _mask_; \ + HAL_DISABLE_TRAPS( _traps_ ); \ + HAL_READ_UINT32( SPARC_LEON_INTCON_MASK, _mask_ ); \ + _mask_ &= ~( 1 << (_vector_) ); \ + HAL_WRITE_UINT32(SPARC_LEON_INTCON_MASK, _mask_ ); \ + HAL_RESTORE_INTERRUPTS( _traps_ ); \ +CYG_MACRO_END + +#define HAL_INTERRUPT_UNMASK( _vector_ ) CYG_MACRO_START \ + cyg_uint32 _traps_, _mask_; \ + HAL_DISABLE_TRAPS( _traps_ ); \ + HAL_READ_UINT32( SPARC_LEON_INTCON_MASK, _mask_ ); \ + _mask_ |= ( 1 << (_vector_) ); \ + HAL_WRITE_UINT32( SPARC_LEON_INTCON_MASK, _mask_ ); \ + HAL_RESTORE_INTERRUPTS( _traps_ ); \ +CYG_MACRO_END + +#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ ) +/* Interrupts are automatically acknowledged by hardware, not needed ... +#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ ) CYG_MACRO_START \ + cyg_uint32 _traps_; \ + HAL_DISABLE_TRAPS( _traps_ ); \ + HAL_WRITE_UINT32( SPARC_LEON_INTCON_CLEAR, ( 1 << (_vector_) ) ); \ + HAL_RESTORE_INTERRUPTS( _traps_ ); \ +CYG_MACRO_END +*/ + +#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ ) /* nothing */ + +#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ ) /* nothing */ + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_HAL_XPIC_H +// End of hal_xpic.h diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/halboot.si new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/halboot.si --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/halboot.si Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/halboot.si Thu Jul 22 16:29:23 2004 @@ -0,0 +1,165 @@ +#ifndef CYGONCE_HAL_HALBOOT_SI /* -*-asm-*- */ +#define CYGONCE_HAL_HALBOOT_SI +// ==================================================================== +// +// /halboot.si +// +// HAL bootup platform-oriented code (assembler) +// +// ==================================================================== +//####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): hmt +// Contributors: hmt +// Date: 1999-02-01 +// Purpose: Bootup code, platform oriented. +// Description: +// +//####DESCRIPTIONEND#### +// +// ==================================================================== + +#define MCFG1 0x10180833 +#define MCFG2 0xe1004e60 + +// External Platform Initial Setup +// +// This should set up RAM and caches, and calm down any external +// interrupt sources. +// +// It is just plain included in vectors.S +// +// RAM has not yet been touched at all; in fact all you have is a +// register window selected. + + + ! Empty macro for debugging vectors.S + .macro led val + .endm + + ! Set memory according to simulator config + + set 0x80000000, %l0 ! LEON register base address + + set MCFG1, %l1 + st %l1, [%l0 + 0x00] ! set MCFG1 + + set MCFG2, %l1 + st %l1, [%l0 + 0x04] ! set MCFG2 + + !set 7, %l1 + !st %l1, [%l0 + 0x78] ! enable UARTS + + ld [%l0 + 0x14], %l1 ! chech if we have been initialized + andcc %l1, 0x1, %g0 + bne 4f + nop + + flush ! if we are here, we are running on + set 0x1000f, %l1 ! the simulator.... + + st %l1, [%l0 + 0x14] ! enable caches + + st %g0, [%l0 + 0x1c] ! clear LEON registers + st %g0, [%l0 + 0x20] ! + st %g0, [%l0 + 0x90] ! + st %g0, [%l0 + 0x94] ! + st %g0, [%l0 + 0x98] ! + st %g0, [%l0 + 0x9C] ! + st %g0, [%l0 + 0xA0] ! + st %g0, [%l0 + 0xA4] ! + st %g0, [%l0 + 0xA4] ! + st %g0, [%l0 + 0x78] ! + st %g0, [%l0 + 0x88] ! + + ld [%l0 + 0xF8], %g1 ! load simulator rom size + clr %l2 + subcc %g1, 0, %g0 + be 3f + srl %g1, 13, %g1 ! calculate appropriate rom size +1: + srl %g1, 1, %g1 + tst %g1 + bne,a 1b + inc %l2 + sll %l2, 14, %l2 + st %l2, [%l0 + 0x00] ! set prom size in memcfg1 + + set 0, %l2 + ld [%l0 + 0xF4], %g2 ! load simulator ram size + srl %g2, 13, %g1 ! calculate appropriate ram size +1: + srl %g1, 1, %g1 + tst %g1 + bne,a 1b + inc %l2 + sll %l2, 9, %l2 + or %l2, 0x20, %l2 + st %l2, [%l0 + 0x04] ! set ram size in memcfg2 + set 0x40000000, %l2 + add %g2, %l2, %fp + sub %fp, 96*4, %sp +3: + st %g0, [%sp] !probe for FPU +! ld [%sp], %fsr + set 49, %l1 + st %l1, [%l0 + 0x64] ! scaler = 49 + st %l1, [%l0 + 0x60] ! scaler = 49 + + 2: + + set -1, %l1 + st %l1, [%l0 + 0x44] ! timer 1 = 0xffffff + set 7, %l1 + st %l1, [%l0 + 0x48] ! start timer 1 + st %l1, [%l0 + 0x78] ! enable UARTS + st %l1, [%l0 + 0x88] + + 4: + ! then copy the branch instructions into the vector + rd %tbr, %g1 + andn %g1, 0xfff, %g1 ! clear non-address bits + sethi %hi(real_vector_instructions), %l0 + or %l0, %lo(real_vector_instructions), %l0 + ld [ %l0 ], %l1 + st %l1, [ %g1 ] ! into the vector + ld [ %l0 + 4 ], %l1 + st %l1, [ %g1 + 4 ] ! into the vector + + + +#endif /* CYGONCE_HAL_HALBOOT_SI */ +/* EOF halboot.si */ diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.h new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.h --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.h Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.h Thu Jul 22 17:18:43 2004 @@ -0,0 +1,25 @@ +// eCos memory layout - Fri Oct 20 08:18:20 2000 + +// This is a generated file - do not edit + +#ifndef __ASSEMBLER__ +#include +#include + +#endif +#define CYGMEM_REGION_rom (0x00000000) +#define CYGMEM_REGION_rom_SIZE (0x800000) +#define CYGMEM_REGION_rom_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) +#define CYGMEM_REGION_ram (0x40000000) +#define CYGMEM_REGION_ram_SIZE (0x100000) +#define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) +#define CYGMEM_REGION_sdram (0x60000000) +#define CYGMEM_REGION_sdram_SIZE (0x1000000) +#define CYGMEM_REGION_sdram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) +#ifndef __ASSEMBLER__ +extern char CYG_LABEL_NAME (__heap1) []; +#endif +#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1)) +#define CYGMEM_SECTION_heap1_SIZE (0x40100000 - (size_t) CYG_LABEL_NAME (__heap1)) + +#define CYGHWR_HAL_SPARC_MULTIPLE_VECTOR_TRAPPING diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.ldi new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.ldi --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.ldi Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.ldi Thu Jul 15 11:46:41 2004 @@ -0,0 +1,28 @@ +// eCos memory layout - Fri Oct 20 08:18:20 2000 + +// This is a generated file - do not edit + +#include + +MEMORY +{ + rom : ORIGIN = 0x00000000, LENGTH = 0x800000 + ram : ORIGIN = 0x40000000, LENGTH = 0x100000 + sdram : ORIGIN = 0x60000000, LENGTH = 0x1000000 +} + +SECTIONS +{ + SECTIONS_BEGIN + SECTION_rom_vectors (ram, 0x40000000, LMA_EQ_VMA) + SECTION_text (ram, ALIGN (0x1), LMA_EQ_VMA) + SECTION_fini (ram, ALIGN (0x1), LMA_EQ_VMA) + SECTION_rodata (ram, ALIGN (0x1), LMA_EQ_VMA) + SECTION_rodata1 (ram, ALIGN (0x1), LMA_EQ_VMA) + SECTION_fixup (ram, ALIGN (0x1), LMA_EQ_VMA) + SECTION_gcc_except_table (ram, ALIGN (0x1), LMA_EQ_VMA) + SECTION_data (ram, ALIGN (0x1), LMA_EQ_VMA) + SECTION_bss (ram, ALIGN (0x8), LMA_EQ_VMA) + CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); + SECTIONS_END +} diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.mlt new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.mlt --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.mlt Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/include/pkgconf/mlt_sparc_leon_ram.mlt Thu Jul 22 17:19:08 2004 @@ -0,0 +1,14 @@ +version 0 +region rom 00000000 100000 1 ! +region ram 40000000 800000 0 ! +region sdram 00000000 1000000 2 ! +section rom_vectors 0 1 0 1 1 1 1 1 40000000 40000000 text text ! +section text 0 1 0 1 0 1 0 1 fini fini ! +section fini 0 1 0 1 0 1 0 1 rodata rodata ! +section rodata 0 1 0 1 0 1 0 1 rodata1 rodata1 ! +section rodata1 0 1 0 1 0 1 0 1 fixup fixup ! +section fixup 0 1 0 1 0 1 0 1 gcc_except_table gcc_except_table ! +section gcc_except_table 0 1 0 1 0 1 0 1 data data ! +section data 0 1 0 1 0 1 0 1 bss bss ! +section bss 0 8 0 1 0 1 0 1 heap1 heap1 ! +section heap1 0 8 0 0 0 0 0 0 ! diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/src/hal_priv.c new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/src/hal_priv.c --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/src/hal_priv.c Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/src/hal_priv.c Thu Jul 15 11:46:41 2004 @@ -0,0 +1,102 @@ +//=========================================================================== +// +// hal_priv.c +// +// SPARC Architecture LEON-specific private variables +// +//=========================================================================== +//####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): hmt +// Contributors: hmt +// Date: 1999-02-20 +// Purpose: private vars for LEON processor. +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + + +#include +#include + +// ------------------------------------------------------------------------ +// Clock static to keep period recorded. +cyg_int32 cyg_hal_sparc_clock_period = 0; + +// ------------------------------------------------------------------------ +// Board specific startups. + +extern void hal_board_prestart( void ); +extern void hal_board_poststart( void ); + +void hal_board_prestart( void ) +{ +} + +void hal_board_poststart( void ) +{ + HAL_ENABLE_INTERRUPTS(); + // OK to do this post constructors, and good for testing. +} + +cyg_uint32 +hal_lsbit_index(cyg_uint32 mask) +{ + int i; + for (i = 0; i < 32; i++) { + if (mask & (1<= 0; i--) { + if (mask & (1< +#include +#include // interfacing API + +//-------------------------------------------------------------------------- +cyg_uint8 cyg_hal_plf_serial_getc(void* __ch_data) +{ + cyg_uint8 ch; + CYGARC_HAL_SAVE_GP(); + HAL_DIAG_READ_CHAR(ch); + CYGARC_HAL_RESTORE_GP(); + return ch; +} + +void cyg_hal_plf_serial_putc(void* __ch_data, cyg_uint8 c) +{ + + CYGARC_HAL_SAVE_GP(); + HAL_DIAG_WRITE_CHAR(c); + CYGARC_HAL_RESTORE_GP(); +} + +static void cyg_hal_plf_serial_write(void* __ch_data, const cyg_uint8* __buf, + cyg_uint32 __len) +{ + CYGARC_HAL_SAVE_GP(); + while(__len-- > 0) + cyg_hal_plf_serial_putc(__ch_data, *__buf++); + CYGARC_HAL_RESTORE_GP(); +} + +static void +cyg_hal_plf_serial_read(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len) +{ + CYGARC_HAL_SAVE_GP(); + while(__len-- > 0) + *__buf++ = cyg_hal_plf_serial_getc(__ch_data); + CYGARC_HAL_RESTORE_GP(); +} + +static int +cyg_hal_plf_serial_control(void *__ch_data, __comm_control_cmd_t __func, ...) +{ + static int irq_state = 0; + int ret = 0; + CYGARC_HAL_SAVE_GP(); + + switch (__func) { + case __COMMCTL_IRQ_ENABLE: + HAL_INTERRUPT_UNMASK(LEON_INTERRUPT_UART_1_RX_TX); + irq_state = 1; + break; + case __COMMCTL_IRQ_DISABLE: + ret = irq_state; + irq_state = 0; + HAL_INTERRUPT_MASK(LEON_INTERRUPT_UART_1_RX_TX); + break; + case __COMMCTL_DBG_ISR_VECTOR: + ret = LEON_INTERRUPT_UART_1_RX_TX; + break; + case __COMMCTL_SET_TIMEOUT: + { + /* not yet implemented + va_list ap; + + va_start(ap, __func); + + ret = msec_timeout; + msec_timeout = va_arg(ap, cyg_uint32); + + va_end(ap);*/ + } + default: + break; + } + CYGARC_HAL_RESTORE_GP(); + return ret; +} + +static int +cyg_hal_plf_serial_isr(void *__ch_data, int* __ctrlc, + CYG_ADDRWORD __vector, CYG_ADDRWORD __data) +{ + char c; + int res = 0; + CYGARC_HAL_SAVE_GP(); + + HAL_DIAG_READ_CHAR(c); + + *__ctrlc = 0; + if( cyg_hal_is_break( &c , 1 ) ) + *__ctrlc = 1; + + cyg_drv_interrupt_acknowledge( LEON_INTERRUPT_UART_1_RX_TX); + + res = CYG_ISR_HANDLED; + + CYGARC_HAL_RESTORE_GP(); + return res; +} + +static cyg_bool +cyg_hal_plf_serial_getc_nonblock(void* __ch_data, cyg_uint8* ch) +{ + char read_char; + + if( (SPARC_LEON_UART_RXAMASK & *SPARC_LEON_UART_STATUS) == 0 ) + return false; + + HAL_DIAG_READ_CHAR((cyg_uint8)(read_char)); + *ch=(char)read_char; + + return true; +} + +cyg_bool +cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch) +{ + int delay_count = 1000; // delay in .1 ms steps + cyg_bool res; + CYGARC_HAL_SAVE_GP(); + + for(;;) { + res = cyg_hal_plf_serial_getc_nonblock(__ch_data, ch); + if (res || 0 == delay_count--) + break; + + CYGACC_CALL_IF_DELAY_US(100); + } + return res; +} + + +void cyg_hal_plf_serial_init(void) +{ + hal_virtual_comm_table_t* comm; + + //setup interrupt system + + //setup chanel 0 of the vector table + int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT); + CYGACC_CALL_IF_SET_CONSOLE_COMM(0); + comm = CYGACC_CALL_IF_CONSOLE_PROCS(); + CYGACC_COMM_IF_CH_DATA_SET(*comm, 0); + CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_serial_write); + CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_serial_read); + CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_serial_putc); + CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_serial_getc); + CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_serial_control); + CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_serial_isr); + CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout); + CYGACC_CALL_IF_SET_CONSOLE_COMM(cur); +} + +void cyg_hal_plf_comms_init(void) +{ + static int initialized = 0; + + if (initialized) + return; + + initialized = 1; + + cyg_hal_plf_serial_init(); +} + +void +hal_platform_init(void) +{ + hal_if_init(); +} + +//-------------------------------------------------------------------------- +// eof plf_misc.c diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/support/README new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/support/README --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/support/README Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/support/README Thu Jul 15 11:46:41 2004 @@ -0,0 +1,32 @@ + +LEON/TSIM Support +================= + +See for information about the TSIM +simulator and Leon project per se. + +The simulator TSIM can be run "as one" with GDB by using the +script do-gdb-sim in this directory. The script can be used in +automated testing systems to run as if it were embedded within +GDB. It contains: + +---------------------------------------------------------------- +#! /bin/csh +tsim-leon -nfp -gdb >& /dev/stdout & +sparc-rtems-gdb -nw -nx $*:q +---------------------------------------------------------------- + +which simply runs tsim in background, directing its output to the +common stdout. + +The command to connect to the simulator target will be + + (gdb) target remote localhost:1234 + +This fully described in the TSIM documentation from + (home) + (flyer) + (doc) + + + diff -bBruN old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/support/do-gdb-sim new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/support/do-gdb-sim --- old/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/support/do-gdb-sim Thu Jan 1 01:00:00 1970 +++ new/ecos-2.0/packages/hal/sparc/leon_cyc/v2_0/support/do-gdb-sim Thu Jul 15 11:46:41 2004 @@ -0,0 +1,3 @@ +#! /bin/csh +tsim-leon -nfp -gdb >& /dev/stdout & +sparc-rtems-gdb -nw -nx $*:q