Mercurial > ecos
changeset 174:38892b97b685
Merge from eCos master repository on 2001-07-28-00:17:32-BST
line wrap: on
line diff
--- a/host/ChangeLog +++ b/host/ChangeLog @@ -1,3 +1,9 @@ +2001-07-26 Julian Smart <julians@redhat.com> + + * Only use Registry functions if building a GUI Configtool. + * ecosconfig.exe doesn't now get built when building the GUI + Configtool. + 2001-07-09 Julian Smart <julians@redhat.com> * Fixed (I hope) a long-term bug in both versions of the Configtool,
--- a/host/libcdl/ChangeLog +++ b/host/libcdl/ChangeLog @@ -1,3 +1,10 @@ +2001-07-20 Bart Veer <bartv@redhat.com> + + * value.cxx (save): + Complicated "requires" expressions spread over multiple lines + were not being turned into multiline comments, leading to + illegal savefiles. + 2001-07-11 Bart Veer <bartv@redhat.com> * transact.cxx (is_preferable_to):
--- a/host/libcdl/cdl.dsp +++ b/host/libcdl/cdl.dsp @@ -124,7 +124,9 @@ BuildCmds= \ if not exist $(IntDir)\tools\configtool\standalone\common\Makefile sh -c "ECOSHOST=`echo ""puts [ file attributes [ pwd ] -shortname ]"" | cygtclsh80`/.. ; echo ""ECOSHOST=$ECOSHOST"" ; echo ""TCLHOME=$TCLHOME"" ; mkdir -p `cygpath -u ""$(IntDir)""` ; cd `cygpath -u ""$(IntDir)""` && CC=cl CXX=cl `cygpath -u ""$ECOSHOST""`/configure --prefix=`cygpath -u ""$(OutDir)""` --with-tcl=`cygpath -u ""$TCLHOME""` --with-tcl_version=82" \ cd $(IntDir) \ v: \ - make --unix install \ + cd infra && make --unix install \ + cd ..\libcdl && make --unix install \ + cd .. \ "$(OutDir)\lib\cdl.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" @@ -145,7 +147,9 @@ BuildCmds= \ if not exist $(IntDir)\tools\configtool\standalone\common\Makefile sh -c "ECOSHOST=`echo ""puts [ file attributes [ pwd ] -shortname ]"" | cygtclsh80`/.. ; echo ""ECOSHOST=$ECOSHOST"" ; echo ""TCLHOME=$TCLHOME"" ; mkdir -p `cygpath -u ""$(IntDir)""` ; cd `cygpath -u ""$(IntDir)""` && CC=cl CXX=cl `cygpath -u ""$ECOSHOST""`/configure --prefix=`cygpath -u ""$(OutDir)""` --with-tcl=`cygpath -u ""$TCLHOME""` --with-tcl_version=82d --enable-debug --enable-maintainer-mode" \ cd $(IntDir) \ v: \ - make --unix install \ + cd infra && make --unix install \ + cd ..\libcdl && make --unix install \ + cd .. \ "$(OutDir)\lib\cdl.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" @@ -166,7 +170,9 @@ BuildCmds= \ if not exist $(IntDir)\tools\configtool\standalone\common\Makefile sh -c "ECOSHOST=`echo ""puts [ file attributes [ pwd ] -shortname ]"" | cygtclsh80`/.. ; echo ""ECOSHOST=$ECOSHOST"" ; echo ""TCLHOME=$TCLHOME"" ; mkdir -p `cygpath -u ""$(IntDir)""` ; cd `cygpath -u ""$(IntDir)""` && CC=cl CXX=cl `cygpath -u ""$ECOSHOST""`/configure --prefix=`cygpath -u ""$(OutDir)""` --with-tcl=`cygpath -u ""$TCLHOME""` --with-tcl_version=82 --enable-debug --enable-maintainer-mode" \ cd $(IntDir) \ v: \ - make --unix install \ + cd infra && make --unix install \ + cd ..\libcdl && make --unix install \ + cd .. \ "$(OutDir)\lib\cdl.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" @@ -187,7 +193,9 @@ BuildCmds= \ if not exist $(IntDir)\tools\configtool\standalone\common\Makefile sh -c "ECOSHOST=`echo ""puts [ file attributes [ pwd ] -shortname ]"" | cygtclsh80`/.. ; echo ""ECOSHOST=$ECOSHOST"" ; echo ""TCLHOME=$TCLHOME"" ; mkdir -p `cygpath -u ""$(IntDir)""` ; cd `cygpath -u ""$(IntDir)""` && CC=cl CXX=cl `cygpath -u ""$ECOSHOST""`/configure --prefix=`cygpath -u ""$(OutDir)""` --with-tcl=`cygpath -u ""$TCLHOME""` --with-tcl_version=82" \ cd $(IntDir) \ v: \ - make --unix install \ + cd infra && make --unix install \ + cd ..\libcdl && make --unix install \ + cd .. \ "$(OutDir)\lib\cdl.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
--- a/host/libcdl/value.cxx +++ b/host/libcdl/value.cxx @@ -3923,7 +3923,8 @@ CdlValuableBody::save(CdlInterpreter int this->get_requires_goals(requires_goals); std::vector<CdlProperty_GoalExpression>::const_iterator expr_i; for (expr_i = requires_goals.begin(); expr_i != requires_goals.end(); expr_i++) { - data += indent_string + "# Requires: " + (*expr_i)->get_original_string() + "\n"; + data += indent_string + "# Requires: " + + CdlInterpreterBody::extend_comment((*expr_i)->get_original_string(), indentation, 4) + "\n"; CdlExpression expr = (*expr_i)->get_expression(); data += CdlInterpreterBody::multiline_comment(follow_expr_references(*expr_i, expr), indentation, 4);
--- a/host/tools/configtool/common/common/build.cxx +++ b/host/tools/configtool/common/common/build.cxx @@ -57,10 +57,20 @@ #include "build.hxx" // Two methods of generating Cygwin filenames -// CYGWIN_USE_CYGDRIVE = 0: use e.g. //c/, but this is deprecated in new versions of Cygwin -// CYGWIN_USE_CYGDRIVE = 1: use e.g. /cygdrive/c/ -// CYGWIN_USE_CYGDRIVE = 2: use e.g. c:/ notation -#define CYGWIN_USE_CYGDRIVE 1 +// ECOS_USE_CYGDRIVE = 0: use e.g. //c/, but this is deprecated in new versions of Cygwin +// ECOS_USE_CYGDRIVE = 1: use e.g. /cygdrive/c/ +// ECOS_USE_CYGDRIVE = 2: use e.g. c:/ notation +#define ECOS_USE_CYGDRIVE 1 + +// Use registry functions to find out location of /cygdrive +#define ECOS_USE_REGISTRY 1 + +// Don't use Reg... functions in command-line version until we know how +// to add advapi32.lib +#if defined(_WIN32) && !defined(__WXMSW__) && !defined(ECOS_CT) +#undef ECOS_USE_REGISTRY +#define ECOS_USE_REGISTRY 0 +#endif std::string makefile_header = "# eCos makefile\n\n# This is a generated file - do not edit\n\n"; @@ -149,9 +159,10 @@ std::string cygpath (const std::string i output = buffer; #else -#if CYGWIN_USE_CYGDRIVE == 1 +#if ECOS_USE_CYGDRIVE == 1 std::string strCygdrive("/cygdrive"); +#if ECOS_USE_REGISTRY HKEY hKey = 0; if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Cygnus Solutions\\Cygwin\\mounts v2", 0, KEY_READ, &hKey)) @@ -166,6 +177,7 @@ std::string cygpath (const std::string i RegCloseKey(hKey); } +#endif strCygdrive = strCygdrive + "/"; for (unsigned int n = 0; n < path.size (); n++) { // for each char @@ -175,7 +187,7 @@ std::string cygpath (const std::string i output += ('\\' == path [n]) ? '/' : path [n]; // convert backslash to slash } } -#elif CYGWIN_USE_CYGDRIVE == 2 +#elif ECOS_USE_CYGDRIVE == 2 // Convert to c:/foo/bar notation for (unsigned int n = 0; n < path.size (); n++) { // for each char output += ('\\' == path [n]) ? '/' : path [n]; // convert backslash to slash @@ -189,7 +201,7 @@ std::string cygpath (const std::string i } } #endif - // CYGWIN_USE_CYGDRIVE + // ECOS_USE_CYGDRIVE #endif return output; #else @@ -399,7 +411,7 @@ bool generate_makefile (const CdlConfigu fprintf (stream, "\n\n"); for (count = 0; count < info.headers.size (); count++) { // for each header fprintf (stream, "$(PREFIX)/include/%s: $(REPOSITORY)/$(PACKAGE)/%s\n", info.headers [count].destination.c_str (), info.headers [count].source.c_str ()); -#if defined(_WIN32) && (CYGWIN_USE_CYGDRIVE == 1) +#if defined(_WIN32) && (ECOS_USE_CYGDRIVE == 1) fprintf (stream, "ifeq ($(HOST),CYGWIN)\n"); fprintf (stream, "\t@mkdir -p `cygpath -w \"$(dir $@)\" | sed \"s/\\\\\\\\\\/\\\\//g\"`\n"); fprintf (stream, "else\n");
--- a/host/tools/configtool/standalone/wxwin/setup/configtool.iss +++ b/host/tools/configtool/standalone/wxwin/setup/configtool.iss @@ -4,13 +4,13 @@ [Setup] MinVersion=4.0,4.0 - AppName=eCos Configuration Tool 2.03 + AppName=eCos Configuration Tool 2.04 AppId=eCos Configuration Tool CreateUninstallRegKey=1 UsePreviousAppDir=1 UsePreviousGroup=1 - AppVersion=2.03 - AppVerName=eCos Configuration Tool 2.03 + AppVersion=2.04 + AppVerName=eCos Configuration Tool 2.04 AppCopyright=Copyright © Red Hat Inc., 2001 BackColor=$FF0000 BackColor2=$000000 @@ -186,9 +186,9 @@ Source: v:\deliver\configtool\TODO.txt; DestDir: {app}\ Source: c:\winnt\system32\tcl82.dll; DestDir: {sys}\; DestName: tcl82.dll; CopyMode: onlyifdoesntexist; Flags: uninsneveruninstall - Source: c:\winnt\system32\msvcirt.dll; DestDir: {sys}\; DestName: msvcirt.dll; CopyMode: onlyifdoesntexist; Flags: uninsneveruninstall - Source: c:\winnt\system32\msvcp60.dll; DestDir: {sys}\; DestName: msvcp60.dll; CopyMode: onlyifdoesntexist; Flags: uninsneveruninstall - Source: c:\winnt\system32\msvcrt.dll; DestDir: {sys}\; DestName: msvcrt.dll; CopyMode: onlyifdoesntexist; Flags: uninsneveruninstall + Source: c:\winnt\system32\msvcirt.dll; DestDir: {sys}\; DestName: msvcirt.dll; CopyMode: alwaysskipifsameorolder; Flags: uninsneveruninstall restartreplace + Source: c:\winnt\system32\msvcp60.dll; DestDir: {sys}\; DestName: msvcp60.dll; CopyMode: alwaysskipifsameorolder; Flags: uninsneveruninstall restartreplace + Source: c:\winnt\system32\msvcrt.dll; DestDir: {sys}\; DestName: msvcrt.dll; CopyMode: alwaysskipifsameorolder; Flags: uninsneveruninstall restartreplace [Icons] Name: {group}\Configuration Tool; Filename: {app}\configtool.exe; WorkingDir: {app}; IconFilename: {app}\configtool.exe; IconIndex: 0 @@ -217,7 +217,7 @@ ; DO NOT DELETE THEM or you may be unable to reload the script ;[ScriptSetup] -;VerNum=2.03 +;VerNum=2.04 ;InnoVer=1.3 ;AddVerTo=AppVerName ;SetupFilename=setup.exe
--- a/host/tools/configtool/standalone/wxwin/setup/innobott.txt +++ b/host/tools/configtool/standalone/wxwin/setup/innobott.txt @@ -1,7 +1,7 @@ Source: c:\winnt\system32\tcl82.dll; DestDir: {sys}\; DestName: tcl82.dll; CopyMode: onlyifdoesntexist; Flags: uninsneveruninstall - Source: c:\winnt\system32\msvcirt.dll; DestDir: {sys}\; DestName: msvcirt.dll; CopyMode: onlyifdoesntexist; Flags: uninsneveruninstall - Source: c:\winnt\system32\msvcp60.dll; DestDir: {sys}\; DestName: msvcp60.dll; CopyMode: onlyifdoesntexist; Flags: uninsneveruninstall - Source: c:\winnt\system32\msvcrt.dll; DestDir: {sys}\; DestName: msvcrt.dll; CopyMode: onlyifdoesntexist; Flags: uninsneveruninstall + Source: c:\winnt\system32\msvcirt.dll; DestDir: {sys}\; DestName: msvcirt.dll; CopyMode: alwaysskipifsameorolder; Flags: uninsneveruninstall restartreplace + Source: c:\winnt\system32\msvcp60.dll; DestDir: {sys}\; DestName: msvcp60.dll; CopyMode: alwaysskipifsameorolder; Flags: uninsneveruninstall restartreplace + Source: c:\winnt\system32\msvcrt.dll; DestDir: {sys}\; DestName: msvcrt.dll; CopyMode: alwaysskipifsameorolder; Flags: uninsneveruninstall restartreplace [Icons] Name: {group}\Configuration Tool; Filename: {app}\configtool.exe; WorkingDir: {app}; IconFilename: {app}\configtool.exe; IconIndex: 0
--- a/packages/ChangeLog +++ b/packages/ChangeLog @@ -1,3 +1,8 @@ +2001-07-27 Jonathan Larmour <jlarmour@redhat.com> + + * ecos.db: Add flexanet HAL, eth driver, flash driver and target. + Contributed by Jordi Colomer <jco@ict.es> + 2001-07-16 Bart Veer <bartv@redhat.com> * pkgconf/fixhtml.tcl:
--- a/packages/NEWS +++ b/packages/NEWS @@ -1,3 +1,8 @@ +* Added port to Bright Star Engineering SA11x0 based Flexanet handheld board, + including flash and ethernet support. + Contributed by Jordi Colomer <jco@ict.es> +* Added support for loading files from disk. Currently supports IDE drives + with Linux EXT2 filesystems. * Added wallclock driver for DS12887 * AM33 STB flash driver added. * C library now supports multiple locales with multibyte character set support,
new file mode 100644 --- /dev/null +++ b/packages/devs/eth/arm/flexanet/current/ChangeLog @@ -0,0 +1,30 @@ +2001-07-27 Jordi Colomer <jco@ict.es> + + * Initial version of support for LAN91CXX ethernet controller + on the BSE Flexanet/SA1110 board. + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//===========================================================================
new file mode 100644 --- /dev/null +++ b/packages/devs/eth/arm/flexanet/current/cdl/flexanet_eth_drivers.cdl @@ -0,0 +1,108 @@ +# ==================================================================== +# +# flexanet_eth_drivers.cdl +# +# Ethernet drivers - support for LAN91CXX ethernet controller +# on the BSE Flexanet/SA1110 board. +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): Jordi Colomer <jco@ict.es> +# Contributors: Jordi Colomer +# Date: 2001-06-18 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVS_ETH_ARM_FLEXANET { + + display "Flexanet SMC91C96 ethernet driver" + + parent CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_HAL_ARM_SA11X0_FLEXANET + + # chip wired in PCMCIA, 16-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 Flexanet boards." + + include_dir cyg/io + compile if_flexanet.c + + define_proc { + puts $::cdl_system_header "/***** ethernet driver proc output start *****/" + puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_SMSC_LAN91CXX_INL <cyg/io/devs_eth_flexanet.inl>" + puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_SMSC_LAN91CXX_CFG <pkgconf/devs_eth_arm_flexanet.h>" + 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_ARM_FLEXANET_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_ARM_FLEXANET_ESA { + display "The ethernet station address (MAC)" + flavor data + default_value {"{0x11, 0x12, 0x13, 0x14, 0x15, 0x16}"} + 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_ARM_FLEXANET_REDBOOT_ESA + } + + cdl_option CYGSEM_DEVS_ETH_ARM_FLEXANET_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 flexanet_eth_drivers.cdl
new file mode 100644 --- /dev/null +++ b/packages/devs/eth/arm/flexanet/current/include/devs_eth_flexanet.inl @@ -0,0 +1,111 @@ +//========================================================================== +// +// devs/eth/arm/flexanet/..../include/devs_eth_flexanet.inl +// +// Flexanet ethernet I/O definitions. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): Jordi Colomer <jco@ict.es> +// Contributors: Jordi Colomer +// Date: 2001-06-18 +// Purpose: Flexanet ethernet definitions +//####DESCRIPTIONEND#### +//========================================================================== + +#include <pkgconf/system.h> +#include <pkgconf/devs_eth_arm_flexanet.h> +#include <cyg/hal/hal_intr.h> +#include <cyg/hal/flexanet.h> + +#define CYGNUM_DEVS_ETH_SMSC_LAN91CXX_SHIFT_ADDR 2 + +// MAC address is stored as a Redboot config option +#ifdef CYGPKG_REDBOOT +#include <pkgconf/redboot.h> +#ifdef CYGSEM_REDBOOT_FLASH_CONFIG +#include <redboot.h> +#include <flash_config.h> + +RedBoot_config_option("Network hardware address [MAC]", + flexanet_esa, + ALWAYS_ENABLED, true, + CONFIG_ESA, 0 + ); +#endif +#endif + +// ESA address fetch function +static void flexanet_get_ESA(struct lan91cxx_priv_data *cpd) +{ + // Fetch hardware address from RedBoot config +#if defined(CYGSEM_DEVS_ETH_ARM_FLEXANET_REDBOOT_ESA) +#if defined(CYGPKG_REDBOOT) && \ + defined(CYGSEM_REDBOOT_FLASH_CONFIG) + flash_get_config("flexanet_esa", cpd->enaddr, CONFIG_ESA); +#else +#error "No RedBoot flash configuration to store ESA" +#endif +#else + memcpy(cpd->enaddr, static_esa, 6); +#endif +} + +static lan91cxx_priv_data lan91cxx_eth0_priv_data = { + + config_enaddr : flexanet_get_ESA, +#ifndef CYGSEM_DEVS_ETH_ARM_FLEXANET_REDBOOT_ESA + enaddr: CYGDAT_DEVS_ETH_ARM_FLEXANET_ESA, +#endif + base : (unsigned short *) SA1110_FHH_ETH_IOBASE, + attbase : (unsigned char *) SA1110_FHH_ETH_MMBASE, + interrupt : SA1110_IRQ_GPIO_ETH +}; + +ETH_DRV_SC(lan91cxx_sc, + &lan91cxx_eth0_priv_data, // Driver specific data + CYGDAT_DEVS_ETH_ARM_FLEXANET_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_ARM_FLEXANET_NAME, + smsc_lan91cxx_init, + &lan91cxx_sc); + +//EOF devs_eth_flexanet.inl + +
new file mode 100644 --- /dev/null +++ b/packages/devs/eth/arm/flexanet/current/src/if_flexanet.c @@ -0,0 +1,71 @@ +//========================================================================== +// +// devs/eth/arm/flexanet/if_flexanet.c +// +// Ethernet device driver for Flexanet using SMSC LAN91C96 +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//####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 <jco@ict.es> +// Contributors: jco, +// Date: 2001-07-01 +// Purpose: +// Description: hardware driver for Flexanet/SMSC LAN91CXX ethernet +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <pkgconf/system.h> +#include <pkgconf/devs_eth_arm_flexanet.h> +#if defined(CYGPKG_REDBOOT) +#include <pkgconf/redboot.h> +#endif + +#include <cyg/hal/hal_arch.h> +#include <cyg/hal/hal_intr.h> + + +// ESA (Ethernet Station Address), when constant +#ifndef CYGSEM_DEVS_ETH_ARM_FLEXANET_REDBOOT_ESA +static unsigned char static_esa[] = CYGDAT_DEVS_ETH_ARM_FLEXANET_ESA; +#endif + + +
--- a/packages/devs/eth/smsc/lan91cxx/current/ChangeLog +++ b/packages/devs/eth/smsc/lan91cxx/current/ChangeLog @@ -1,3 +1,14 @@ +2001-07-27 Jordi Colomer <jco@ict.es> + + * cdl/smsc_lan91cxx_eth_drivers.cdl: + Add interface for whether the hardware is in PCMCIA mode. + * src/if_lan91cxx.c (smsc_lan91cxx_init): + Allow for hardware shift addresses + Initialize appropriately if PCMCIA mode. + * src/smsc_lan91cxx.h: + Support address shifts in get_reg,put_Reg, get_data, put_data + Add new functions get_banksel , put_att and get_att. + 2001-07-11 Hugo Tyson <hmt@redhat.com> * src/if_lan91cxx.c (lan91cxx_stop): Clean up any pending tx both
--- a/packages/devs/eth/smsc/lan91cxx/current/cdl/smsc_lan91cxx_eth_drivers.cdl +++ b/packages/devs/eth/smsc/lan91cxx/current/cdl/smsc_lan91cxx_eth_drivers.cdl @@ -77,6 +77,13 @@ cdl_package CYGPKG_DEVS_ETH_SMSC_LAN91CX this driver with all its details." } + cdl_interface CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE { + display "Chip is wired in PCMCIA mode" + description " + If this is nonzero, then the chip is assumed to be hardware + configured in PCMCIA mode." + } + cdl_component CYGPKG_DEVS_ETH_SMSC_LAN91CXX_OPTIONS { display "LAN91CXX ethernet driver build options" flavor none
--- a/packages/devs/eth/smsc/lan91cxx/current/src/if_lan91cxx.c +++ b/packages/devs/eth/smsc/lan91cxx/current/src/if_lan91cxx.c @@ -43,7 +43,7 @@ // // Author(s): hmt, based on lan900 (for LAN91C110) driver by jskov // jskov, based on CS8900 driver by Gary Thomas -// Contributors: gthomas, jskov, hmt +// Contributors: gthomas, jskov, hmt, jco@ict.es // Date: 2001-01-22 // Purpose: // Description: hardware driver for LAN91CXX "LAN9000" ethernet @@ -57,6 +57,9 @@ // time anyway. // We may want to pingpong in future for throughput reasons. // +// <jco@ict.es> Added support for PCMCIA mode and shifted +// address buses. +// //####DESCRIPTIONEND#### // //========================================================================== @@ -68,6 +71,7 @@ #include <cyg/infra/cyg_type.h> #include <cyg/hal/hal_arch.h> #include <cyg/hal/hal_intr.h> +#include <cyg/hal/hal_diag.h> #include <cyg/infra/cyg_ass.h> #include <cyg/infra/diag.h> #include <cyg/hal/drv_api.h> @@ -167,14 +171,59 @@ smsc_lan91cxx_init(struct cyg_netdevtab_ (struct lan91cxx_priv_data *)sc->driver_private; unsigned short val; int i; +#if CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE + unsigned char ecor, ecsr; +#endif DEBUG_FUNCTION(); cpd->txbusy = cpd->within_send = 0; + +#ifdef CYGNUM_DEVS_ETH_SMSC_LAN91CXX_SHIFT_ADDR + cpd->addrsh = CYGNUM_DEVS_ETH_SMSC_LAN91CXX_SHIFT_ADDR; +#else + cpd->addrsh = 0; +#endif + +#if CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE + + // If the chip is configured in PCMCIA mode, the internal + // registers mapped in the attribute memory should be + // initialized (i.e. to enable the I/O map) + + ecor = get_att(sc, LAN91CXX_ECOR); + + // pulse SRESET on ECOR + ecor |= LAN91CXX_ECOR_RESET; + put_att(sc, LAN91CXX_ECOR, ecor); + + HAL_DELAY_US(1); + + ecor &= ~LAN91CXX_ECOR_RESET; + put_att(sc, LAN91CXX_ECOR, ecor); + + // then, enable I/O map + ecor |= LAN91CXX_ECOR_ENABLE; + put_att(sc, LAN91CXX_ECOR, ecor); + + // verify the register contents + if (ecor != get_att(sc, LAN91CXX_ECOR)) + diag_printf("LAN91CXX - Cannot access PCMCIA attribute registers\n"); + + ecsr = get_att(sc, LAN91CXX_ECSR); +#ifdef CYGSEM_DEVS_ETH_SMSC_LAN91CXX_8_BIT +#error "91CXX 8-bit mode not yet supported." + ecsr |= LAN91CXX_ECSR_IOIS8; +#else + ecsr &= ~LAN91CXX_ECSR_IOIS8; +#endif + put_att(sc, LAN91CXX_ECSR, ecsr); + +#endif // Initialize environment, setup interrupt handler cyg_drv_interrupt_create(cpd->interrupt, - 99, // Priority - what goes here? + 99, // Priority - what goes here? (cyg_addrword_t)sc, // Data item passed to interrupt handler (cyg_ISR_t *)lan91cxx_isr, (cyg_DSR_t *)eth_drv_dsr, // The logical driver DSR @@ -183,8 +232,9 @@ smsc_lan91cxx_init(struct cyg_netdevtab_ cyg_drv_interrupt_attach(lan91cxx_interrupt_handle); cyg_drv_interrupt_acknowledge(cpd->interrupt); cyg_drv_interrupt_unmask(cpd->interrupt); - - HAL_READ_UINT16(cpd->base+LAN91CXX_BS, val); + + // probe chip by reading the signature in BS register + val = get_banksel(sc); #if DEBUG & 9 diag_printf("LAN91CXX - supposed BankReg @ %x = %04x\n", cpd->base+LAN91CXX_BS, val );
--- a/packages/devs/eth/smsc/lan91cxx/current/src/smsc_lan91cxx.h +++ b/packages/devs/eth/smsc/lan91cxx/current/src/smsc_lan91cxx.h @@ -44,7 +44,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): jskov -// Contributors: jskov, hmt +// Contributors: jskov, hmt, jco // Date: 2001-01-22 // Purpose: Hardware description of LAN9000 series, LAN91C96/110. // Description: @@ -198,6 +198,20 @@ #define LAN91CXX_RX_STATUS_HASHVALMASK 0x007e // MASK #define LAN91CXX_RX_STATUS_MCAST 0x0001 + +// Attribute memory registers in PCMCIA mode +#define LAN91CXX_ECOR 0x8000 +#define LAN91CXX_ECOR_RESET (1<<7) +#define LAN91CXX_ECOR_LEVIRQ (1<<6) +#define LAN91CXX_ECOR_ATTWR (1<<2) +#define LAN91CXX_ECOR_ENABLE (1<<0) + +#define LAN91CXX_ECSR 0x8002 +#define LAN91CXX_ECSR_IOIS8 (1<<5) +#define LAN91CXX_ECSR_PWRDWN (1<<2) +#define LAN91CXX_ECSR_INTR (1<<1) + + // ------------------------------------------------------------------------ #ifdef KEEP_STATISTICS @@ -235,8 +249,12 @@ struct smsc_lan91cxx_stats { typedef struct lan91cxx_priv_data { int txbusy; // A packet has been sent unsigned long txkey; // Used to ack when packet sent - unsigned short* base; // Base address of controller + unsigned short* base; // Base I/O address of controller // (as it comes out of reset) +#if CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE + unsigned char* attbase; // Base attribute address of controller + // only used in PCMCIA mode +#endif int interrupt; // Interrupt vector used by controller unsigned char enaddr[6]; // Controller ESA // Function to configure the ESA - may fetch ESA from EPROM or @@ -245,6 +263,7 @@ typedef struct lan91cxx_priv_data { int txpacket; int rxpacket; int within_send; + int addrsh; // Address bits to shift #ifdef KEEP_STATISTICS struct smsc_lan91cxx_stats stats; #endif @@ -258,9 +277,9 @@ get_reg(struct eth_drv_sc *sc, int regno struct lan91cxx_priv_data *cpd = (struct lan91cxx_priv_data *)sc->driver_private; unsigned short val; - HAL_WRITE_UINT16(cpd->base+LAN91CXX_BS, regno>>3); - HAL_READ_UINT16(cpd->base+(regno&0x7), val); - + + HAL_WRITE_UINT16(cpd->base+(LAN91CXX_BS << cpd->addrsh), regno>>3); + HAL_READ_UINT16(cpd->base+((regno&0x7) << cpd->addrsh), val); #if DEBUG & 2 diag_printf("read reg %d val 0x%04x\n", regno, val); #endif @@ -272,8 +291,9 @@ put_reg(struct eth_drv_sc *sc, int regno { struct lan91cxx_priv_data *cpd = (struct lan91cxx_priv_data *)sc->driver_private; - HAL_WRITE_UINT16(cpd->base+LAN91CXX_BS, regno>>3); - HAL_WRITE_UINT16(cpd->base+(regno&0x7), val); + + HAL_WRITE_UINT16(cpd->base+(LAN91CXX_BS << cpd->addrsh), regno>>3); + HAL_WRITE_UINT16(cpd->base+((regno&0x7) << cpd->addrsh), val); #if DEBUG & 2 diag_printf("write reg %d val 0x%04x\n", regno, val); @@ -287,7 +307,8 @@ put_data(struct eth_drv_sc *sc, unsigned { struct lan91cxx_priv_data *cpd = (struct lan91cxx_priv_data *)sc->driver_private; - HAL_WRITE_UINT16(cpd->base+(LAN91CXX_DATA & 0x7), val); + + HAL_WRITE_UINT16(cpd->base+((LAN91CXX_DATA & 0x7) << cpd->addrsh), val); #if DEBUG & 2 diag_printf("write data 0x%04x\n", val); @@ -301,7 +322,8 @@ get_data(struct eth_drv_sc *sc) unsigned short val; struct lan91cxx_priv_data *cpd = (struct lan91cxx_priv_data *)sc->driver_private; - HAL_READ_UINT16(cpd->base+(LAN91CXX_DATA & 0x7), val); + + HAL_READ_UINT16(cpd->base+((LAN91CXX_DATA & 0x7) << cpd->addrsh), val); #if DEBUG & 2 diag_printf("read data 0x%04x\n", val); @@ -310,5 +332,52 @@ get_data(struct eth_drv_sc *sc) } // ------------------------------------------------------------------------ +// Read the bank register (this one is bank-independent) +static __inline__ unsigned short +get_banksel(struct eth_drv_sc *sc) +{ + struct lan91cxx_priv_data *cpd = + (struct lan91cxx_priv_data *)sc->driver_private; + unsigned short val; + + HAL_READ_UINT16(cpd->base+(LAN91CXX_BS << cpd->addrsh), val); +#if DEBUG & 2 + diag_printf("read bank val 0x%04x\n", regno, val); +#endif + return val; +} + + +// ------------------------------------------------------------------------ +// Write on PCMCIA attribute memory +static __inline__ void +put_att(struct eth_drv_sc *sc, int offs, unsigned char val) +{ + struct lan91cxx_priv_data *cpd = + (struct lan91cxx_priv_data *)sc->driver_private; + + HAL_WRITE_UINT8(cpd->attbase + (offs << cpd->addrsh), val); + +#if DEBUG & 2 + diag_printf("write attr %d val 0x%02x\n", offs, val); +#endif +} + +// Read from PCMCIA attribute memory +static __inline__ unsigned char +get_att(struct eth_drv_sc *sc, int offs) +{ + struct lan91cxx_priv_data *cpd = + (struct lan91cxx_priv_data *)sc->driver_private; + unsigned char val; + + HAL_READ_UINT8(cpd->attbase + (offs << cpd->addrsh), val); +#if DEBUG & 2 + diag_printf("read attr %d val 0x%02x\n", offs, val); +#endif + return val; +} + +// ------------------------------------------------------------------------ #endif CYGONCE_DEVS_ETH_SMSC_LAN91CXX_LAN91CXX_H // EOF smsc_lan91cxx.h
--- a/packages/devs/flash/amd/am29xxxxx/current/ChangeLog +++ b/packages/devs/flash/amd/am29xxxxx/current/ChangeLog @@ -1,3 +1,17 @@ +2001-07-26 Jesper Skov <jskov@redhat.com> + + * include/flash_am29xxxxx.inl: Made code deal with multiple + banks. Use flag to identify banked devices. + * include/flash_am29xxxxx_parts.inl: Updated with banked flag. + +2001-07-23 David Howells <dhowells@redhat.com> + + * include/flash_am29xxxxx.inl: Added support for chips divided + into banks, and added correct addresses for 16-bit chips + configured in 8-bit mode + * include/flash_am29xxxxx_parts.inl: Added data for chips divided + into banks + 2001-06-11 Jesper Skov <jskov@redhat.com> * include/flash_am29xxxxx.inl: Traverse by incrementing
--- a/packages/devs/flash/amd/am29xxxxx/current/include/flash_am29xxxxx.inl +++ b/packages/devs/flash/amd/am29xxxxx/current/include/flash_am29xxxxx.inl @@ -63,7 +63,6 @@ #define _FLASH_PRIVATE_ #include <cyg/io/flash.h> - //---------------------------------------------------------------------------- // Common device details. #define FLASH_Read_ID FLASHWORD( 0x90 ) @@ -79,8 +78,19 @@ #define FLASH_unlocked FLASHWORD( 0x00 ) -#define FLASH_Setup_Addr1 (0x555) -#define FLASH_Setup_Addr2 (0x2AA) +#ifndef CYGNUM_FLASH_16AS8 +# define FLASH_Setup_Addr1 (0x555) +# define FLASH_Setup_Addr2 (0x2AA) +# define FLASH_VendorID_Addr (0) +# define FLASH_DeviceID_Addr (1) +# define FLASH_WP_Addr (2) +#else +# define FLASH_Setup_Addr1 (0xAAA) +# define FLASH_Setup_Addr2 (0x555) +# define FLASH_VendorID_Addr (0) +# define FLASH_DeviceID_Addr (2) +# define FLASH_WP_Addr (4) +#endif #define FLASH_Setup_Code1 FLASHWORD( 0xAA ) #define FLASH_Setup_Code2 FLASHWORD( 0x55 ) #define FLASH_Setup_Erase FLASHWORD( 0x80 ) @@ -115,6 +125,10 @@ typedef struct flash_dev_info { cyg_uint32 device_size; cyg_bool bootblock; cyg_uint32 bootblocks[12]; // 0 is bootblock offset, 1-11 sub-sector sizes (or 0) + cyg_bool banked; + cyg_uint32 banks[2]; // bank offets, highest to lowest (lowest should be 0) + // (only one entry for now, increase to support devices + // with more banks). } flash_dev_info_t; static const flash_dev_info_t* flash_dev_info; @@ -151,16 +165,20 @@ flash_query(void* data) f_s1 = FLASH_P2V(ROM+FLASH_Setup_Addr1); f_s2 = FLASH_P2V(ROM+FLASH_Setup_Addr2); + *f_s1 = FLASH_Reset; w = *(FLASH_P2V(ROM)); *f_s1 = FLASH_Setup_Code1; *f_s2 = FLASH_Setup_Code2; *f_s1 = FLASH_Read_ID; + id[0] = -1; + id[1] = -1; + // Manufacturers' code - id[0] = *(FLASH_P2V(ROM)); + id[0] = *(FLASH_P2V(ROM+FLASH_VendorID_Addr)); // Part number - id[1] = *(FLASH_P2V(ROM+1)); + id[1] = *(FLASH_P2V(ROM+FLASH_DeviceID_Addr)); *(FLASH_P2V(ROM)) = FLASH_Reset; @@ -228,19 +246,37 @@ flash_code_overlaps(void *start, void *e int flash_erase_block(void* block, unsigned int size) { - volatile flash_data_t* ROM; + 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_s1, *f_s2; + volatile flash_data_t *f_s0, *f_s1, *f_s2; int timeout = 50000; int len, len_ix = 1; int res = FLASH_ERR_OK; flash_data_t state; cyg_bool bootblock; + CYG_ADDRWORD bank_offset; - ROM = (volatile flash_data_t*)((unsigned long)block & flash_dev_info->base_mask); - f_s1 = FLASH_P2V(ROM+FLASH_Setup_Addr1); - f_s2 = FLASH_P2V(ROM+FLASH_Setup_Addr2); + BANK = ROM = (volatile flash_data_t*)((unsigned long)block & 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)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++; + } + } + + f_s0 = FLASH_P2V(BANK); + f_s1 = FLASH_P2V(BANK + FLASH_Setup_Addr1); + f_s2 = FLASH_P2V(BANK + FLASH_Setup_Addr2); // Is this the boot sector? bootblock = (flash_dev_info->bootblock && @@ -256,8 +292,8 @@ flash_erase_block(void* block, unsigned *f_s1 = FLASH_Setup_Code1; *f_s2 = FLASH_Setup_Code2; *f_s1 = FLASH_WP_State; - state = *FLASH_P2V(b_p+2); - *FLASH_P2V(ROM) = FLASH_Reset; + state = *FLASH_P2V(b_p+FLASH_WP_Addr); + *f_s0 = FLASH_Reset; if (FLASH_unlocked != state) return FLASH_ERR_PROTECT; @@ -326,31 +362,47 @@ flash_erase_block(void* block, unsigned //---------------------------------------------------------------------------- // Program Buffer - int flash_program_buf(void* addr, void* data, int len) { volatile flash_data_t* ROM; + volatile flash_data_t* BANK; 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 *f_s1, *f_s2; - + CYG_ADDRWORD bank_offset; int timeout; int res = FLASH_ERR_OK; + // check the address is suitably aligned + if ((unsigned long)addr & (CYGNUM_FLASH_INTERLEAVE * CYGNUM_FLASH_WIDTH / 8 - 1)) + 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++; + } + } + + f_s1 = FLASH_P2V(BANK + FLASH_Setup_Addr1); + f_s2 = FLASH_P2V(BANK + FLASH_Setup_Addr2); + while (len > 0) { int state; - // Note: Should really only do the address calculations on - // section/device boundaries - but then, we're likely to be - // spinning for a while down below anyway, so no point in - // making the loop more complicated. - - // Base address of device(s) being programmed. - ROM = (volatile flash_data_t*)((unsigned long)addr_p & flash_dev_info->base_mask); - f_s1 = FLASH_P2V(ROM+FLASH_Setup_Addr1); - f_s2 = FLASH_P2V(ROM+FLASH_Setup_Addr2); addr_v = FLASH_P2V(addr_p++); // Program data [byte] - 4 step sequence
--- a/packages/devs/flash/amd/am29xxxxx/current/include/flash_am29xxxxx_parts.inl +++ b/packages/devs/flash/amd/am29xxxxx/current/include/flash_am29xxxxx_parts.inl @@ -8,27 +8,27 @@ // //========================================================================== //####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations under -// the License. -// -// The Original Code is eCos - Embedded Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are // Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// +// All Rights Reserved. +// ------------------------------------------- +// //####COPYRIGHTEND#### //========================================================================== //#####DESCRIPTIONBEGIN#### @@ -36,7 +36,7 @@ // Author(s): jskov // Contributors: jskov // Date: 2001-06-08 -// Purpose: +// Purpose: // Description: AMD AM29xxxxx part descriptors // Usage: Should be included from the flash_am29xxxxx.inl file only. // @@ -54,7 +54,8 @@ block_count: 8, device_size: 0x80000 * CYGNUM_FLASH_INTERLEAVE, base_mask : ~(0x80000 * CYGNUM_FLASH_INTERLEAVE - 1), - bootblock : false + bootblock : false, + banked : false }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV160 @@ -71,7 +72,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x004000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, { // MBM29LV160-B | AM29LV160-B device_id : FLASHWORD(0x49), @@ -86,7 +88,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x008000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL324D @@ -107,6 +110,10 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0 + }, + banked : true, + banks : { 0x200000 * CYGNUM_FLASH_INTERLEAVE, + 0 } }, { // AM29DL324D-B @@ -126,6 +133,10 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0 + }, + banked : true, + banks : { 0x200000 * CYGNUM_FLASH_INTERLEAVE, + 0 } }, #endif @@ -143,7 +154,8 @@ 0x02000 * CYGNUM_FLASH_INTERLEAVE, 0x04000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, { // AM29F800-B device_id : FLASHWORD(0x58), @@ -158,7 +170,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x008000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV800 @@ -175,7 +188,8 @@ 0x02000 * CYGNUM_FLASH_INTERLEAVE, 0x04000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, { // AM29LV800-B device_id : FLASHWORD(0x5b), @@ -190,7 +204,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x008000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, #endif @@ -210,7 +225,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x004000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, { // MBM29LV160-B | AM29LV160-B device_id : FLASHWORD(0x2249), @@ -225,7 +241,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x008000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL324D @@ -246,6 +263,10 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0 + }, + banked : true, + banks : { 0x200000 * CYGNUM_FLASH_INTERLEAVE, + 0 } }, { // AM29DL324D-B @@ -265,6 +286,10 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0 + }, + banked : true, + banks : { 0x200000 * CYGNUM_FLASH_INTERLEAVE, + 0 } }, #endif @@ -282,7 +307,8 @@ 0x02000 * CYGNUM_FLASH_INTERLEAVE, 0x04000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, { // AM29F800-B device_id : FLASHWORD(0x2258), @@ -297,7 +323,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x008000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, #endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV800 @@ -314,7 +341,8 @@ 0x02000 * CYGNUM_FLASH_INTERLEAVE, 0x04000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, { // AM29LV800-B device_id : FLASHWORD(0x225b), @@ -329,7 +357,8 @@ 0x002000 * CYGNUM_FLASH_INTERLEAVE, 0x008000 * CYGNUM_FLASH_INTERLEAVE, 0 - } + }, + banked : false }, #endif
new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/flexanet/current/ChangeLog @@ -0,0 +1,29 @@ +2001-07-27 Jordi Colomer <jco@ict.es> + + * Add SA11x0/Flexanet flash driver support + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//===========================================================================
new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/flexanet/current/cdl/flash_flexanet.cdl @@ -0,0 +1,71 @@ +# ==================================================================== +# +# flash_flexanet.cdl +# +# FLASH memory - Hardware support on Intel StrongARM SA1110 +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): gthomas +# Original data: gthomas +# Contributors: +# Date: 2000-07-26 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVS_FLASH_FLEXANET { + display "SA1110/Flexanet FLASH memory support" + + parent CYGPKG_IO_FLASH + active_if CYGPKG_IO_FLASH + requires CYGPKG_HAL_ARM_SA11X0_FLEXANET + + requires CYGPKG_DEVS_FLASH_STRATA + + implements CYGHWR_IO_FLASH_BLOCK_LOCKING + + include_dir cyg/io + + # 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_STRATA_REQUIRED { + display "Generic StrataFLASH driver required" + } + + implements CYGINT_DEVS_FLASH_STRATA_REQUIRED + + define_proc { + puts $::cdl_system_header "/***** strataflash driver proc output start *****/" + puts $::cdl_system_header "#define CYGDAT_DEVS_FLASH_STRATA_INL <cyg/io/flexanet_strataflash.inl>" + puts $::cdl_system_header "#define CYGDAT_DEVS_FLASH_STRATA_CFG <pkgconf/devs_flash_flexanet.h>" + puts $::cdl_system_header "/***** strataflash driver proc output end *****/" + } +} +
new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/flexanet/current/include/flexanet_strataflash.inl @@ -0,0 +1,59 @@ +#ifndef CYGONCE_DEVS_FLASH_FLEXANET_STRATAFLASH_INL +#define CYGONCE_DEVS_FLASH_FLEXANET_STRATAFLASH_INL +//========================================================================== +// +// flexanet_strataflash.inl +// +// Flash programming - device constants, etc. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas, hmt +// Contributors: gthomas +// Date: 2001-02-24 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +// The flexanet system has two 16-bit devices. +// Doc says: a StrataFlash 28F320J3A. The 320 means 32Mbit, so 4Mbyte. +// Reality: a StrataFlash 28F640J3A. The 640 means 64Mbit, so 8Mbyte. + +#define CYGNUM_FLASH_DEVICES (2) +#define CYGNUM_FLASH_BASE (0x50000000u) +#define CYGNUM_FLASH_BASE_MASK (0xFE000000u) // 32Mb devices +#define CYGNUM_FLASH_WIDTH (16) +#define CYGNUM_FLASH_BLANK (1) + +#endif // CYGONCE_DEVS_FLASH_FLEXANET_STRATAFLASH_INL +// ------------------------------------------------------------------------ +// EOF flexanet_strataflash.inl
--- a/packages/devs/wallclock/dallas/ds12887/current/ChangeLog +++ b/packages/devs/wallclock/dallas/ds12887/current/ChangeLog @@ -1,3 +1,9 @@ +2001-07-27 Jesper Skov <jskov@redhat.com> + + * src/ds12887.cxx (init_ds_hwclock): Use BCD mode since Century is + NA in binary mode. Force sane settings in registers if they are + undefined. + 2001-07-06 Jesper Skov <jskov@redhat.com> * src/ds12887.cxx (get_ds_hwclock): Instead of locking while
--- a/packages/devs/wallclock/dallas/ds12887/current/src/ds12887.cxx +++ b/packages/devs/wallclock/dallas/ds12887/current/src/ds12887.cxx @@ -118,10 +118,40 @@ static inline void init_ds_hwclock(void) { - // Set binary and 24H mode - DS_WRITE(DS_REG_B, DS_REG_B_DM | DS_REG_B_24H); + cyg_uint8 _regb, _tmp; + + // Set 24H mode + DS_WRITE(DS_REG_B, DS_REG_B_24H); // Enable clock DS_WRITE(DS_REG_A, DS_REG_A_ENABLE); + + // Verify that there are reasonable default settings - otherwise + // set them. + + // Stop counting + DS_READ(DS_REG_B, _regb); + _regb |= DS_REG_B_SET; + DS_WRITE(DS_REG_B, _regb); + + DS_READ(DS_CENTURY, _tmp); + if (0xff == _tmp) + DS_WRITE(DS_CENTURY, TO_BCD(20)); + + DS_READ(DS_MONTH, _tmp); + if (0x00 == _tmp) + DS_WRITE(DS_MONTH, TO_BCD(1)); + + DS_READ(DS_DOM, _tmp); + if (0x00 == _tmp) + DS_WRITE(DS_DOM, TO_BCD(1)); + + DS_READ(DS_DOM, _tmp); + if (0x00 == _tmp) + DS_WRITE(DS_DOM, TO_BCD(1)); + + // Restart counting + _regb &= ~DS_REG_B_SET; + DS_WRITE(DS_REG_B, _regb); } @@ -135,13 +165,13 @@ set_ds_hwclock(cyg_uint32 year, cyg_uint _regb |= DS_REG_B_SET; DS_WRITE(DS_REG_B, _regb); - DS_WRITE(DS_CENTURY, (cyg_uint8)(year / 100)); - DS_WRITE(DS_YEAR, (cyg_uint8)(year % 100)); - DS_WRITE(DS_MONTH, (cyg_uint8)month); - DS_WRITE(DS_DOM, (cyg_uint8)mday); - DS_WRITE(DS_HOURS, (cyg_uint8)hour); - DS_WRITE(DS_MINUTES, (cyg_uint8)minute); - DS_WRITE(DS_SECONDS, (cyg_uint8)second); + DS_WRITE(DS_CENTURY, TO_BCD((cyg_uint8)(year / 100))); + DS_WRITE(DS_YEAR, TO_BCD((cyg_uint8)(year % 100))); + DS_WRITE(DS_MONTH, TO_BCD((cyg_uint8)month)); + DS_WRITE(DS_DOM, TO_BCD((cyg_uint8)mday)); + DS_WRITE(DS_HOURS, TO_BCD((cyg_uint8)hour)); + DS_WRITE(DS_MINUTES, TO_BCD((cyg_uint8)minute)); + DS_WRITE(DS_SECONDS, TO_BCD((cyg_uint8)second)); // Restart counting _regb &= ~DS_REG_B_SET; @@ -178,22 +208,22 @@ get_ds_hwclock(cyg_uint32* year, cyg_uin DS_READ(DS_CENTURY, _t1); DS_READ(DS_YEAR, _t2); - *year = (cyg_uint32)_t1*100 + (cyg_uint32)_t2; + *year = (cyg_uint32)TO_DEC(_t1)*100 + (cyg_uint32)TO_DEC(_t2); DS_READ(DS_MONTH, _t1); - *month = (cyg_uint32)_t1; + *month = (cyg_uint32)TO_DEC(_t1); DS_READ(DS_DOM, _t1); - *mday = (cyg_uint32)_t1; + *mday = (cyg_uint32)TO_DEC(_t1); DS_READ(DS_HOURS, _t1); - *hour = (cyg_uint32)_t1; + *hour = (cyg_uint32)TO_DEC(_t1); DS_READ(DS_MINUTES, _t1); - *minute = (cyg_uint32)_t1; + *minute = (cyg_uint32)TO_DEC(_t1); DS_READ(DS_SECONDS, _t1); - *second = (cyg_uint32)_t1; + *second = (cyg_uint32)TO_DEC(_t1); // Reenable interrupts HAL_RESTORE_INTERRUPTS(_old);
--- a/packages/ecos.db +++ b/packages/ecos.db @@ -222,6 +222,17 @@ package CYGPKG_DEVS_FLASH_IPAQ { on the Intel StrongARM SA-1110 iPAQ platform." } +package CYGPKG_DEVS_FLASH_FLEXANET { + alias { "FLASH memory support for Flexanet" flash_flexanet } + directory devs/flash/arm/flexanet + script flash_flexanet.cdl + hardware + description " + This package contains hardware support for FLASH memory + on the SA-1100 Flexanet platform." +} + + package CYGPKG_DEVS_FLASH_NANO { alias { "FLASH memory support for Intel SA1110 nanoEngine" flash_nano } directory devs/flash/arm/nano @@ -636,6 +647,15 @@ package CYGPKG_DEVS_ETH_ARM_EBSA285 { description "Ethernet driver for Intel EBSA285 with PRO/100+ boards." } +package CYGPKG_DEVS_ETH_ARM_FLEXANET { + alias { "SA11x0/Flexanet onboard ethernet support" devs_eth_arm_flexanet } + hardware + directory devs/eth/arm/flexanet + script flexanet_eth_drivers.cdl + description "This package contains hardware support for onboard SMC91C96 + ethernet device on the Flexanet board." +} + package CYGPKG_DEVS_ETH_POWERPC_QUICC { alias { "QUICC ethernet driver" quicc_eth_driver } hardware @@ -1121,6 +1141,16 @@ package CYGPKG_HAL_ARM_SA11X0_IPAQ { eCos on a Intel StrongARM SA1110 pocket PC (Compaq iPAQ)." } +package CYGPKG_HAL_ARM_SA11X0_FLEXANET { + alias { "SA1110 Flexanet board" hal_arm_sa11x0_flexanet } + directory hal/arm/sa11x0/flexanet + script hal_arm_sa11x0_flexanet.cdl + hardware + description " + The FLEXANET HAL package provides the support needed to run + eCos on an SA1110 Flexanet board." +} + package CYGPKG_DEVS_ETH_SMSC_LAN91CXX { alias { "SMSC LAN91CXX ethernet driver" lan91cxx_eth_driver lan9000_eth_driver } hardware @@ -1850,6 +1880,27 @@ target nano { The nanoEngine target provides the packages needed to run eCos on a Bright Star Engineering nanoEngine StrongARM SA1110 board." } + +target flexanet { + alias { "Flexanet StrongARM SA1110 platform" flexanet } + packages { CYGPKG_HAL_ARM + CYGPKG_HAL_ARM_SA11X0 + CYGPKG_HAL_ARM_SA11X0_FLEXANET + CYGPKG_IO_SERIAL_ARM_SA11X0 + CYGPKG_DEVS_FLASH_STRATA + CYGPKG_DEVS_FLASH_FLEXANET + CYGPKG_DEVS_ETH_SMSC_LAN91CXX + CYGPKG_DEVS_ETH_ARM_FLEXANET + CYGPKG_IO_USB + CYGPKG_IO_USB_SLAVE + CYGPKG_DEVS_USB_SA11X0 + CYGPKG_DEVICES_WATCHDOG_ARM_SA11X0 + } + description " + The Flexanet target provides the packages needed to run + eCos on an SA1110 Flexanet board." +} + target brutus { alias { "Intel StrongARM SA1100 board" brutus } packages { CYGPKG_HAL_ARM
--- a/packages/fs/ram/current/ChangeLog +++ b/packages/fs/ram/current/ChangeLog @@ -1,3 +1,11 @@ +2001-07-26 Jonathan Larmour <jlarmour@redhat.com> + + * src/ramfs.c (findbuffer_indirect1): Determine correct offset in + indirect block list. + (findbuffer_indirect2): Ditto. + (findbuffer_direct): Compare block index with number of blocks + correctly. + 2000-10-05 Nick Garnett <nickg@cygnus.co.uk> * tests/fileio1.c:
--- a/packages/fs/ram/current/src/ramfs.c +++ b/packages/fs/ram/current/src/ramfs.c @@ -723,7 +723,7 @@ static int findbuffer_direct( off_t pos, *buffer = NULL; *size = 0; - if( bi > nblocks ) + if( bi >= nblocks ) return ENOERR; b = blocks[bi]; @@ -774,7 +774,7 @@ static int findbuffer_indirect1( off_t p // Use findbuffer_direct() to index and allocate // the first level indirect block. - err = findbuffer_direct( bi, + err = findbuffer_direct( bi*CYGNUM_RAMFS_BLOCK_SIZE, (ramfs_block **)blocks, nblocks, &b, @@ -827,7 +827,7 @@ static int findbuffer_indirect2( off_t p // Use findbuffer_direct() to index and allocate // the first level indirect block. - err = findbuffer_direct( bi, + err = findbuffer_direct( bi*CYGNUM_RAMFS_BLOCK_SIZE, (ramfs_block **)blocks, nblocks, &b,
--- a/packages/hal/arm/edb7xxx/current/ChangeLog +++ b/packages/hal/arm/edb7xxx/current/ChangeLog @@ -1,3 +1,11 @@ +2001-07-25 Jonathan Larmour <jlarmour@redhat.com> + + * include/pkgconf/mlt_arm_edb7211_ram.h: + * include/pkgconf/mlt_arm_edb7211_ram.ldi: + * include/pkgconf/mlt_arm_edb7211_ram.mlt: + * include/pkgconf/mlt_arm_edb7212_ram.h: + RAM size should default to 0xfd7000 consistently. + 2001-07-18 Franck Mamalet <franck.mamalet@rd.francetelecom.com> 2001-07-18 Jonathan Larmour <jlarmour@redhat.com>
--- a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.h +++ b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.h @@ -8,10 +8,10 @@ #endif #define CYGMEM_REGION_ram (0) -#define CYGMEM_REGION_ram_SIZE (0xfd8000) +#define CYGMEM_REGION_ram_SIZE (0xfd7000) #define CYGMEM_REGION_ram_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 (0xfd9000 - (size_t) CYG_LABEL_NAME (__heap1)) +#define CYGMEM_SECTION_heap1_SIZE (0xfd7000 - (size_t) CYG_LABEL_NAME (__heap1))
--- a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.ldi +++ b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.ldi @@ -6,7 +6,7 @@ MEMORY { - ram : ORIGIN = 0, LENGTH = 0xfd9000 + ram : ORIGIN = 0, LENGTH = 0xfd7000 } SECTIONS
--- a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.mlt +++ b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.mlt @@ -1,5 +1,5 @@ version 0 -region ram 0 fd9000 0 !DRAM +region ram 0 fd7000 0 !DRAM section fixed_vectors 0 1 0 1 1 0 1 0 20 20 ! section rom_vectors 0 1 0 1 1 1 1 1 20000 20000 text text ! section text 0 4 0 1 0 1 0 1 fini fini !
--- a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.h +++ b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.h @@ -8,7 +8,7 @@ #endif #define CYGMEM_REGION_ram (0) -#define CYGMEM_REGION_ram_SIZE (0xfd6000) +#define CYGMEM_REGION_ram_SIZE (0xfd7000) #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) #define CYGMEM_REGION_sram (0x60000000) #define CYGMEM_REGION_sram_SIZE (0x9c00)
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/ChangeLog @@ -0,0 +1,29 @@ +2001-07-27 Jordi Colomer <jco@ict.es> + + * Initial version of support for BSE Flexanet/SA1110 handheld board. + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//===========================================================================
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/cdl/hal_arm_sa11x0_flexanet.cdl @@ -0,0 +1,346 @@ +# ==================================================================== +# +# hal_arm_sa11x0_flexanet.cdl +# +# Flexanet handhelds core board configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): gthomas +# Original data: gthomas +# Contributors: +# Date: 2000-05-08 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== +cdl_package CYGPKG_HAL_ARM_SA11X0_FLEXANET { + display "ARM SA1110/Flexanet handheld core board" + parent CYGPKG_HAL_ARM_SA11X0 + hardware + include_dir cyg/hal + define_header hal_arm_sa11x0_flexanet.h + description " + This HAL platform package provides generic + support for the Flexanet handheld core board, + developed by Trend Communications SL in Barcelona." + + compile flexanet_misc.c + + implements CYGINT_HAL_DEBUG_GDB_STUBS + implements CYGINT_HAL_DEBUG_GDB_STUBS_BREAK + implements CYGINT_HAL_VIRTUAL_VECTOR_SUPPORT + + implements CYGHWR_HAL_ARM_SA11X0_UART1 + + define_proc { + puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H <pkgconf/hal_arm.h>" + puts $::cdl_system_header "#define CYGBLD_HAL_VARIANT_H <pkgconf/hal_arm_sa11x0.h>" + puts $::cdl_system_header "#define CYGBLD_HAL_PLATFORM_H <pkgconf/hal_arm_sa11x0_flexanet.h>" + puts $::cdl_header "#define HAL_PLATFORM_CPU \"StrongARM 1110\"" + puts $::cdl_header "#define HAL_PLATFORM_BOARD \"Flexanet HH core board\"" + puts $::cdl_header "#define HAL_PLATFORM_EXTRA \"\"" + puts $::cdl_header "#define HAL_PLATFORM_MACHINE_TYPE 54" + puts $::cdl_header "#define HAL_ARCH_PROGRAM_NEW_STACK flexanet_program_new_stack" + } + + cdl_component CYG_HAL_STARTUP { + display "Startup type" + flavor data + default_value {"RAM"} + legal_values {"RAM" "ROM"} + no_define + define -file system.h CYG_HAL_STARTUP + description " + When targetting the Flexanet core board it is possible to build + the system for either RAM bootstrap or ROM bootstrap(s). Select + 'ram' when building programs to load into RAM using eCos GDB + stubs. Select 'rom' when building a stand-alone application + which will be put into ROM, or for the special case of + building the eCos GDB stubs themselves." + } + + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD { + display "Diagnostic serial port baud rate" + flavor data + legal_values 9600 19200 57600 115200 + default_value 57600 + description " + This option selects the baud rate used for the diagnostic port. + Note: this should match the value chosen for the GDB port if the + diagnostic and GDB port are the same." + } + + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL_BAUD { + display "GDB serial port baud rate" + flavor data + legal_values 9600 19200 57600 115200 + default_value 57600 + description " + This option selects the baud rate used for the diagnostic port. + Note: this should match the value chosen for the GDB port if the + diagnostic and GDB port are the same." + } + + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS { + display "Number of communication channels on the board" + flavor data + calculated 2 + } + + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL { + display "Debug serial port" + active_if CYGPRI_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL_CONFIGURABLE + flavor data + legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1 + default_value 1 + description " + The flexanet board has two serial ports (UART1 and UART3). + 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" + active_if CYGPRI_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_CONFIGURABLE + flavor data + legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1 + default_value 0 + description " + The flexanet board has two serial ports (UART1 and UART3). + This option chooses which port will be used for diagnostic + output." + } + + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT { + display "Default console channel." + flavor data + legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1 + calculated 0 + } + + cdl_component CYGBLD_GLOBAL_OPTIONS { + display "Global build options" + flavor none + no_define + 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 { "arm-elf" } + 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 { "-mcpu=strongarm1100 -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 { "-Wl,--gc-sections -Wl,-static -g -O2 -nostdlib" } + description " + This option controls the global linker flags. Individual + packages may define options which override these global flags." + } + + cdl_option CYGBLD_BUILD_GDB_STUBS { + display "Build GDB stub ROM image" + default_value 0 + requires { CYG_HAL_STARTUP == "ROM" } + requires CYGSEM_HAL_ROM_MONITOR + requires CYGBLD_BUILD_COMMON_GDB_STUBS + requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + requires CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT + requires CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT + requires ! CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT + requires ! CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM + no_define + description " + This option enables the building of the GDB stubs for the + board. The common HAL controls takes care of most of the + build process, but the final conversion from ELF image to + binary data is handled by the platform CDL, allowing + relocation of the data if necessary." + + make -priority 320 { + <PREFIX>/bin/gdb_module.bin : <PREFIX>/bin/gdb_module.img + $(OBJCOPY) --remove-section=.fixed_vectors -O binary $< $@ + } + } + } + + cdl_component CYGPKG_HAL_ARM_SA11X0_FLEXANET_OPTIONS { + display "StrongARM SA1110/Flexanet build options" + flavor none + no_define + 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_ARM_SA11X0_FLEXANET_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the StrongARM Flexanet HAL. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_HAL_ARM_SA11X0_FLEXANET_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the StrongARM Flexanet HAL. These flags are removed from + the set of global flags if present." + } + + cdl_option CYGPKG_HAL_ARM_SA11X0_FLEXANET_TESTS { + display "StrongARM SA1110/Flexanet tests" + flavor data + no_define +# calculated { "tests/dram-test" } + calculated { "" } + description " + This option specifies the set of tests for the StrongARM Flexanet HAL." + } + } + + cdl_component CYGHWR_MEMORY_LAYOUT { + display "Memory layout" + flavor data + no_define + calculated { CYG_HAL_STARTUP == "RAM" ? "arm_sa11x0_flexanet_ram" : \ + "arm_sa11x0_flexanet_rom" } + + 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 { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_arm_sa11x0_flexanet_ram.ldi>" : \ + "<pkgconf/mlt_arm_sa11x0_flexanet_rom.ldi>" } + } + + cdl_option CYGHWR_MEMORY_LAYOUT_H { + display "Memory layout header file" + flavor data + no_define + define -file system.h CYGHWR_MEMORY_LAYOUT_H + calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_arm_sa11x0_flexanet_ram.h>" : \ + "<pkgconf/mlt_arm_sa11x0_flexanet_rom.h>" } + } + } + + cdl_option CYGSEM_HAL_ROM_MONITOR { + display "Behave as a ROM monitor" + flavor bool + default_value 0 + parent CYGPKG_HAL_ROM_MONITOR + requires { CYG_HAL_STARTUP == "ROM" } + description " + Enable this option if this program is to be used as a ROM monitor, + i.e. applications will be loaded into RAM on the board, and this + ROM monitor may process exceptions or interrupts generated from the + application. This enables features such as utilizing a separate + interrupt stack when exceptions are generated." + } + + cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + display "Work with a ROM monitor" + flavor booldata + legal_values { "Generic" "GDB_stubs" } + default_value { CYG_HAL_STARTUP == "RAM" ? "GDB_stubs" : 0 } + parent CYGPKG_HAL_ROM_MONITOR + requires { CYG_HAL_STARTUP == "RAM" } + description " + Support can be enabled for different varieties of ROM monitor. + This support changes various eCos semantics such as the encoding + of diagnostic output, or the overriding of hardware interrupt + vectors. + Firstly there is \"Generic\" support which prevents the HAL + from overriding the hardware vectors that it does not use, to + instead allow an installed ROM monitor to handle them. This is + the most basic support which is likely to be common to most + implementations of ROM monitor. + \"GDB_stubs\" provides support when GDB stubs are included in + the ROM monitor or boot ROM." + } + + cdl_component CYGPKG_REDBOOT_HAL_OPTIONS { + display "Redboot HAL options" + flavor none + no_define + parent CYGPKG_REDBOOT + active_if CYGPKG_REDBOOT + description " + This option lists the target's requirements for a valid Redboot + configuration." + + cdl_option CYGBLD_BUILD_REDBOOT_BIN { + display "Build Redboot ROM binary image" + active_if CYGBLD_BUILD_REDBOOT + default_value 1 + no_define + description "This option enables the conversion of the Redboot ELF + image to a binary image suitable for ROM programming." + + make -priority 325 { + <PREFIX>/bin/redboot.bin : <PREFIX>/bin/redboot.elf + $(OBJCOPY) --strip-debug $< $(@:.bin=.img) + $(OBJCOPY) -O srec $< $(@:.bin=.srec) + $(OBJCOPY) -O binary $< $@ + } + } + } + +}
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/include/flexanet.h @@ -0,0 +1,146 @@ +#ifndef CYGONCE_FLEXANET_H +#define CYGONCE_FLEXANET_H + +/*============================================================================= +// +// flexanet.h +// +// Platform specific support (register layout, etc) +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): Jordi Colomer <jco@ict.es> +// Contributors: Jordi Colomer <jxo@ict.es> +// Date: 2001-06-15 +// Purpose: SA1110/Flexanet platform specific support routines +// Description: +// Usage: #include <cyg/hal/flexanet.h> +// +//####DESCRIPTIONEND#### +// +//===========================================================================*/ + + +#ifndef __ASSEMBLER__ +// +// Board Control Register +// Note: This register is write-only. Thus a shadow copy is provided so that +// it may be safely updated/shared by multiple threads. +// +extern unsigned long _flexanet_BCR; // Shadow copy + +extern void flexanet_BCR(unsigned long mask, unsigned long value); + +#endif + +// +// Signal assertion levels +// +#define SA1110_LOGIC_ONE(m) (m & 0xFFFFFFFF) +#define SA1110_LOGIC_ZERO(m) (m & 0x00000000) + +// +// GPIO settings +// +#define SA1110_GPIO_DIR 0x080037FE +#define SA1110_GPIO_ALT 0x080037FE +#define SA1110_GPIO_CLR 0x080037FE +#define SA1110_GPIO_SET 0x00000000 + + +// +// Flexanet Board Control Register +// +#define SA1110_BOARD_CONTROL REG32_PTR(0x10000000) + +/* Power-up value */ +#define SA1110_BCR_MIN 0x00000000 + +/* Mandatory bits */ +#define SA1110_BCR_LED_GREEN (1<<0) /* General-purpose green LED (1 = on) */ +#define SA1110_BCR_SPARE_1 (1<<1) /* Not defined */ +#define SA1110_BCR_CF1_RST (1<<2) /* Compact Flash Slot #1 Reset (1 = reset) */ +#define SA1110_BCR_CF2_RST (1<<3) /* Compact Flash Slot #2 Reset (1 = reset) */ +#define SA1110_BCR_GUI_NRST (1<<4) /* GUI board reset (0 = reset) */ +#define SA1110_BCR_RTS1 (1<<5) /* RS232 RTS for UART-1 */ +#define SA1110_BCR_RTS3 (1<<6) /* RS232 RTS for UART-3 */ +#define SA1110_BCR_XCDBG0 (1<<7) /* Not defined. Wired to XPLA3 for debug */ + +/* BCR extension, only required by L3-bus in some audio codecs */ +#define SA1110_BCR_L3MOD (1<<8) /* L3-bus MODE signal */ +#define SA1110_BCR_L3DAT (1<<9) /* L3-bus DATA signal */ +#define SA1110_BCR_L3CLK (1<<10) /* L3-bus CLK signal */ +#define SA1110_BCR_SPARE_11 (1<<11) /* Not defined */ +#define SA1110_BCR_SPARE_12 (1<<12) /* Not defined */ +#define SA1110_BCR_SPARE_13 (1<<13) /* Not defined */ +#define SA1110_BCR_SPARE_14 (1<<14) /* Not defined */ +#define SA1110_BCR_SPARE_15 (1<<15) /* Not defined */ + +/* Board Status Register */ +#define SA1110_BSR_CTS1 (1<<0) /* RS232 CTS for UART-1 */ +#define SA1110_BSR_CTS3 (1<<1) /* RS232 CTS for UART-3 */ +#define SA1110_BSR_DSR1 (1<<2) /* RS232 DSR for UART-1 */ +#define SA1110_BSR_DSR3 (1<<3) /* RS232 DSR for UART-3 */ +#define SA1110_BSR_ID0 (1<<4) /* Board identification */ +#define SA1110_BSR_ID1 (1<<5) +#define SA1110_BSR_CFG0 (1<<6) /* Board configuration options */ +#define SA1110_BSR_CFG1 (1<<7) + +/* GPIOs for which the generic definition doesn't say much */ +#define SA1110_GPIO_CF1_NCD (1<<14) /* Card Detect from CF slot #1 */ +#define SA1110_GPIO_CF2_NCD (1<<15) /* Card Detect from CF slot #2 */ +#define SA1110_GPIO_CF1_IRQ (1<<16) /* IRQ from CF slot #1 */ +#define SA1110_SA1110_GPIO_CF2_IRQ (1<<17) /* IRQ from CF slot #2 */ +#define SA1110_GPIO_APP_IRQ (1<<18) /* Extra IRQ from application bus */ +#define SA1110_GPIO_RADIO_REF (1<<20) /* Ref. clock for UART3 (Radio) */ +#define SA1110_GPIO_CF1_BVD1 (1<<21) /* BVD1 from CF slot #1 */ +#define SA1110_GPIO_CF2_BVD1 (1<<22) /* BVD1 from CF slot #2 */ +#define SA1110_GPIO_GUI_IRQ (1<<23) /* IRQ from GUI board (i.e., UCB1300) */ +#define SA1110_GPIO_ETH_IRQ (1<<24) /* IRQ from Ethernet controller */ +#define SA1110_GPIO_INTIP_IRQ (1<<25) /* Measurement IRQ (INTIP) */ +#define SA1110_GPIO_LED_RED (1<<26) /* General-purpose red LED */ + +/* IRQ mappings from GPIOs */ +#define SA1110_IRQ_GPIO_CF1_CD CYGNUM_HAL_INTERRUPT_GPIO14 +#define SA1110_IRQ_GPIO_CF2_CD CYGNUM_HAL_INTERRUPT_GPIO15 +#define SA1110_IRQ_GPIO_CF1_IRQ CYGNUM_HAL_INTERRUPT_GPIO16 +#define SA1110_IRQ_GPIO_CF2_IRQ CYGNUM_HAL_INTERRUPT_GPIO17 +#define SA1110_IRQ_GPIO_APP CYGNUM_HAL_INTERRUPT_GPIO18 +#define SA1110_IRQ_GPIO_CF1_BVD1 CYGNUM_HAL_INTERRUPT_GPIO21 +#define SA1110_IRQ_GPIO_CF2_BVD1 CYGNUM_HAL_INTERRUPT_GPIO22 +#define SA1110_IRQ_GPIO_GUI CYGNUM_HAL_INTERRUPT_GPIO23 +#define SA1110_IRQ_GPIO_ETH CYGNUM_HAL_INTERRUPT_GPIO24 +#define SA1110_IRQ_GPIO_INTIP CYGNUM_HAL_INTERRUPT_GPIO25 + +/* On-Board Ethernet (physical addrs) */ +#define SA1110_FHH_ETH_IOBASE 0x18000000 /* I/O base */ +#define SA1110_FHH_ETH_MMBASE 0x18800000 /* Attribute-memory base */ + +/*---------------------------------------------------------------------------*/ +/* end of flexanet.h */ +#endif /* CYGONCE_FLEXANET_H */
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/include/hal_platform_setup.h @@ -0,0 +1,312 @@ +#ifndef CYGONCE_HAL_PLATFORM_SETUP_H +#define CYGONCE_HAL_PLATFORM_SETUP_H + +/*============================================================================= +// +// hal_platform_setup.h +// +// Platform specific support for HAL (assembly code) +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): Jordi Colomer <jco@ict.es> +// Contributors: Jordi Colomer <jco@ict.es> +// Date: 2001-06-15 +// Purpose: SA1110/Flexanet platform specific support routines +// Description: +// Usage: #include <cyg/hal/hal_platform_setup.h> +// Only used by "vectors.S" +// +//####DESCRIPTIONEND#### +// +//===========================================================================*/ + +#include <pkgconf/system.h> // System-wide configuration info +#include CYGBLD_HAL_VARIANT_H // Variant (SA11x0) specific configuration +#include CYGBLD_HAL_PLATFORM_H // Platform specific configuration +#include <cyg/hal/hal_sa11x0.h> // Variant specific hardware definitions +#include <cyg/hal/hal_mmu.h> // MMU definitions +#include <cyg/hal/flexanet.h> // Platform specific hardware definitions + +#if defined(CYG_HAL_STARTUP_ROM) +#define PLATFORM_SETUP1 _platform_setup1 +#define CYGHWR_HAL_ARM_HAS_MMU + +#if (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 59000) +#define SA11X0_PLL_CLOCK 0x0 +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 73700) +#define SA11X0_PLL_CLOCK 0x1 +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 88500) +#define SA11X0_PLL_CLOCK 0x2 +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 103200) +#define SA11X0_PLL_CLOCK 0x3 +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 118000) +#define SA11X0_PLL_CLOCK 0x4 +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 132700) +#define SA11X0_PLL_CLOCK 0x5 +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 147500) +#define SA11X0_PLL_CLOCK 0x6 +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 162200) +#define SA11X0_PLL_CLOCK 0x7 +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 176900) +#define SA11X0_PLL_CLOCK 0x8 +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 191700) +#define SA11X0_PLL_CLOCK 0x9 +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 206400) +#define SA11X0_PLL_CLOCK 0xA +#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 221200) +#define SA11X0_PLL_CLOCK 0xB +#else +#error Invalid processor clock speed +#endif + +// DRAM settings + +// Banks configured for 256-Mbit SDRAM devices (15 row x 9 col) +// Initially disabled. +// CAS latency = 3, 32-bit bus width, TWR = 1, TRP = 2 +#define DRAM_CONFIG_VALUE 0x72647264 + +// SMROM settings (disabled in all banks) +#define SMROM_CONFIG_VALUE 0xAFCCAFCC + +// CAS waveforms +//#define CAS0_WAVEFORM_VALUE 0xAAAAAA7F +#define CAS0_WAVEFORM_VALUE 0xAAAAAAA7 +#define CAS1_WAVEFORM_VALUE 0xAAAAAAAA +#define CAS2_WAVEFORM_VALUE 0xAAAAAAAA + +// Expansion memory (PCMCIA) settings (MECR) +#define EXPMEM_CONFIG_VALUE 0x994A994A + +// DRAM refresh configuration + +// CAS before RAS = 7 +// f(SDCLK) = f(mem) = 1/2 f(cpu) = 103 MHz, ok for PC-133 SDRAMs +// If PC-100 are installed, may be better to run the CPU at 192 MHz +// and still clock the SDRAM at 1/2 f(cpu) = 96 MHz. +// No auto-power-down, +// Refresh period for 8192 rows = 64 ms (25 memory cycles) +// DRI = 64 ms * 103 MHz / (8192 * 32) = 25 +// (longest burst access time not considered by now) +#define RFSH_CONFIG_VALUE 0x00340197 + +// Static memory configuration + +// CS0/1 : RDF=14, RDN=4 , RRR=2, 32 bits Flash +// Suitable for 128-Mbit StrataFlash (Tcyc = 150 ns) +#define STATIC_0_CONFIG_VALUE 0x44704470 + +// CS2 : RDF=0, RDN=0 , RRR=0, 32 bits SRAM +// CS3 : RDF=5, RDN=12, RRR=1, 32 bits SRAM +#define STATIC_1_CONFIG_VALUE 0x2C290001 + + + +// This macro represents the initial startup code for the platform, +// when the startup is ROM. + + .macro _platform_setup1 + + // Reset the BCR (LEDs off) + ldr r1,=SA1110_BOARD_CONTROL + ldr r2,=SA1110_BCR_MIN + str r2,[r1] + + // Set up GPIOs + ldr r1,=SA11X0_GPIO_PIN_DIRECTION + ldr r2,=SA1110_GPIO_DIR + str r2,[r1] + + ldr r1,=SA11X0_GPIO_ALTERNATE_FUNCTION + ldr r2,=SA1110_GPIO_ALT + str r2,[r1] + + ldr r1,=SA11X0_GPIO_PIN_OUTPUT_CLEAR + ldr r2,=SA1110_GPIO_CLR + str r2,[r1] + + ldr r1,=SA11X0_GPIO_PIN_OUTPUT_SET + ldr r2,=SA1110_GPIO_SET + str r2,[r1] + + // Disable clock switching + mcr p15,0,r0,\ + SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\ + SA11X0_DISABLE_CLOCK_SWITCHING_RM,\ + SA11X0_DISABLE_CLOCK_SWITCHING_OPCODE + + // Set up processor clock + ldr r1,=SA11X0_PWR_MGR_PLL_CONFIG + ldr r2,=SA11X0_PLL_CLOCK + str r2,[r1] + + // Turn clock switching back on + mcr p15,0,r0,\ + SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\ + SA11X0_ENABLE_CLOCK_SWITCHING_RM,\ + SA11X0_ENABLE_CLOCK_SWITCHING_OPCODE + nop + nop + + // Turn on the red LED on GPIO-1 + ldr r1,=SA11X0_GPIO_PIN_OUTPUT_SET + ldr r2,=(1<<1) + str r2,[r1] + + // Let the PLL settle down + ldr r1,=20000 +10: sub r1,r1,#1 + cmp r1,#0 + bne 10b + + // Initialize DRAM controller. See table below. + // The DRAM banks are set to disabled. + + ldr r1,=dram_table + ldr r2,=__exception_handlers + sub r1,r1,r2 + ldr r2,[r1],#4 // First control register +11: ldr r3,[r1],#4 + str r3,[r2] + ldr r2,[r1],#4 // Next control register + cmp r2,#0 + bne 11b + + // Enable UART + ldr r1,=SA1110_GPCLK_CONTROL_0 + ldr r2,=SA1110_GPCLK_SUS_UART + str r2,[r1] + + // Release DRAM hold (PSSR register, bit DH) + + // This bit is set upon exit from sleep mode and indicates that the + // nRAS/nSDCS 3:0 and nCAS/DQM 3:0 continue to be held low and that + // the DRAMs are still in self-refresh mode. This bit should be cleared + // by the processor (by writing a one to it) after the DRAM interface + // has been configured but before any DRAM access is attempted. + // The nRAS/nSDCS and nCAS/DQM lines are released when this bit is + // cleared. This bit is cleared on hardware reset. + + ldr r1,=SA11X0_PWR_MGR_SLEEP_STATUS + ldr r2,=SA11X0_DRAM_CONTROL_HOLD + str r2,[r1] + + // On hardware reset in systems containing DRAM or SDRAM, + // trigger a number (typically eight) of refresh cycles by attempting + // nonburst read or write accesses to any disabled DRAM bank. + // Each such access causes a simultaneous CBR for all four banks. + + ldr r1,=SA11X0_RAM_BANK0_BASE + ldr r2,[r1] + nop + nop + ldr r2,[r1] + nop + nop + ldr r2,[r1] + nop + nop + ldr r2,[r1] + nop + nop + + // Enable DRAM bank 0 + ldr r1,=SA11X0_DRAM_CONFIGURATION + ldr r2,=DRAM_CONFIG_VALUE + orr r2, r2, #0x01 + str r2,[r1] + + b 19f + + // Memory controller settings (register, value) + +dram_table: + + .word SA11X0_DRAM0_CAS_0, CAS0_WAVEFORM_VALUE + .word SA11X0_DRAM0_CAS_1, CAS1_WAVEFORM_VALUE + .word SA11X0_DRAM0_CAS_2, CAS2_WAVEFORM_VALUE + .word SA11X0_EXP_BUS_CONFIGURATION, EXPMEM_CONFIG_VALUE + .word SA11X0_REFRESH_CONFIGURATION, RFSH_CONFIG_VALUE + .word SA11X0_DRAM2_CAS_0, CAS0_WAVEFORM_VALUE + .word SA11X0_DRAM2_CAS_1, CAS1_WAVEFORM_VALUE + .word SA11X0_DRAM2_CAS_2, CAS2_WAVEFORM_VALUE + .word SA11X0_SMROM_CONFIGURATION, SMROM_CONFIG_VALUE + .word SA11X0_DRAM_CONFIGURATION, DRAM_CONFIG_VALUE + .word SA11X0_STATIC_CONTROL_0, STATIC_0_CONFIG_VALUE + .word SA11X0_STATIC_CONTROL_1, STATIC_1_CONFIG_VALUE + .word 0, 0 +19: + + // Release peripheral hold (set by RESET) + ldr r1,=SA11X0_PWR_MGR_SLEEP_STATUS + ldr r2,=SA11X0_PERIPHERAL_CONTROL_HOLD + str r2,[r1] + + // Set up a stack [for calling C code] + ldr r1,=__startup_stack + ldr r2,=SA11X0_RAM_BANK0_BASE + orr sp,r1,r2 + + // Create MMU tables + bl hal_mmu_init + + // Enable MMU + ldr r2,=10f + ldr r1,=MMU_Control_Init|MMU_Control_M + mcr MMU_CP,0,r1,MMU_Control,c0 + mov pc,r2 /* Change address spaces */ + nop + nop + nop +10: + + // Save shadow copy of BCR + ldr r1,=_flexanet_BCR + str r2,[r1] + + // Turn on green LED + ldr r1,=SA1110_BOARD_CONTROL + ldr r2,=SA1110_BCR_MIN + orr r2,r2,#SA1110_BCR_LED_GREEN + str r2,[r1] + .endm + +#else // defined(CYG_HAL_STARTUP_ROM) +#define PLATFORM_SETUP1 +#endif + +#define PLATFORM_VECTORS _platform_vectors + .macro _platform_vectors + .globl _flexanet_BCR +_flexanet_BCR: .long 0 // Board Control register shadow + .endm + +/*---------------------------------------------------------------------------*/ +/* end of hal_platform_setup.h */ +#endif /* CYGONCE_HAL_PLATFORM_SETUP_H */
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/include/pkgconf/mlt_arm_sa11x0_flexanet_ram.h @@ -0,0 +1,17 @@ +// eCos memory layout - Fri Oct 20 05:56:24 2000 + +// This is a generated file - do not edit + +#ifndef __ASSEMBLER__ +#include <cyg/infra/cyg_type.h> +#include <stddef.h> + +#endif +#define CYGMEM_REGION_ram (0) +#define CYGMEM_REGION_ram_SIZE (0x2000000) +#define CYGMEM_REGION_ram_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 (0x2000000 - (size_t) CYG_LABEL_NAME (__heap1))
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/include/pkgconf/mlt_arm_sa11x0_flexanet_ram.ldi @@ -0,0 +1,27 @@ +// eCos memory layout - Fri Oct 20 05:56:24 2000 + +// This is a generated file - do not edit + +#include <cyg/infra/cyg_type.inc> + +MEMORY +{ + ram : ORIGIN = 0, LENGTH = 0x2000000 +} + +SECTIONS +{ + SECTIONS_BEGIN + SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA) + SECTION_rom_vectors (ram, 0x20000, LMA_EQ_VMA) + SECTION_text (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_fini (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_rodata (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_rodata1 (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_fixup (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_gcc_except_table (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_data (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA) + CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); + SECTIONS_END +}
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/include/pkgconf/mlt_arm_sa11x0_flexanet_ram.mlt @@ -0,0 +1,13 @@ +version 0 +region ram 0 2000000 0 ! +section fixed_vectors 0 1 0 1 1 0 1 0 20 20 ! +section rom_vectors 0 1 0 1 1 1 1 1 20000 20000 text text ! +section text 0 4 0 1 0 1 0 1 fini fini ! +section fini 0 4 0 1 0 1 0 1 rodata rodata ! +section rodata 0 4 0 1 0 1 0 1 rodata1 rodata1 ! +section rodata1 0 4 0 1 0 1 0 1 fixup fixup ! +section fixup 0 4 0 1 0 1 0 1 gcc_except_table gcc_except_table ! +section gcc_except_table 0 4 0 1 0 1 0 1 data data ! +section data 0 4 0 1 0 1 0 1 bss bss ! +section bss 0 4 0 1 0 1 0 1 heap1 heap1 ! +section heap1 0 8 0 0 0 0 0 0 !
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/include/pkgconf/mlt_arm_sa11x0_flexanet_rom.h @@ -0,0 +1,20 @@ +// eCos memory layout - Fri Oct 20 05:56:55 2000 + +// This is a generated file - do not edit + +#ifndef __ASSEMBLER__ +#include <cyg/infra/cyg_type.h> +#include <stddef.h> + +#endif +#define CYGMEM_REGION_ram (0) +#define CYGMEM_REGION_ram_SIZE (0x2000000) +#define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) +#define CYGMEM_REGION_rom (0x50000000) +#define CYGMEM_REGION_rom_SIZE (0x40000) +#define CYGMEM_REGION_rom_ATTR (CYGMEM_REGION_ATTR_R) +#ifndef __ASSEMBLER__ +extern char CYG_LABEL_NAME (__heap1) []; +#endif +#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1)) +#define CYGMEM_SECTION_heap1_SIZE (0x2000000 - (size_t) CYG_LABEL_NAME (__heap1))
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/include/pkgconf/mlt_arm_sa11x0_flexanet_rom.ldi @@ -0,0 +1,28 @@ +// eCos memory layout - Fri Oct 20 05:56:55 2000 + +// This is a generated file - do not edit + +#include <cyg/infra/cyg_type.inc> + +MEMORY +{ + ram : ORIGIN = 0, LENGTH = 0x2000000 + rom : ORIGIN = 0x50000000, LENGTH = 0x40000 +} + +SECTIONS +{ + SECTIONS_BEGIN + SECTION_rom_vectors (rom, 0x50000000, LMA_EQ_VMA) + SECTION_text (rom, ALIGN (0x4), LMA_EQ_VMA) + SECTION_fini (rom, ALIGN (0x4), LMA_EQ_VMA) + SECTION_rodata (rom, ALIGN (0x4), LMA_EQ_VMA) + SECTION_rodata1 (rom, ALIGN (0x4), LMA_EQ_VMA) + SECTION_fixup (rom, ALIGN (0x4), LMA_EQ_VMA) + SECTION_gcc_except_table (rom, ALIGN (0x4), LMA_EQ_VMA) + SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA) + SECTION_data (ram, 0x8000, FOLLOWING (.gcc_except_table)) + SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA) + CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); + SECTIONS_END +}
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/include/pkgconf/mlt_arm_sa11x0_flexanet_rom.mlt @@ -0,0 +1,14 @@ +version 0 +region ram 0 2000000 0 ! +region rom 50000000 40000 1 ! +section fixed_vectors 0 1 0 1 1 0 1 0 20 20 ! +section data 0 1 1 1 1 1 0 0 8000 bss ! +section bss 0 4 0 1 0 1 0 1 heap1 heap1 ! +section heap1 0 8 0 0 0 0 0 0 ! +section rom_vectors 0 1 0 1 1 1 1 1 50000000 50000000 text text ! +section text 0 4 0 1 0 1 0 1 fini fini ! +section fini 0 4 0 1 0 1 0 1 rodata rodata ! +section rodata 0 4 0 1 0 1 0 1 rodata1 rodata1 ! +section rodata1 0 4 0 1 0 1 0 1 fixup fixup ! +section fixup 0 4 0 1 0 1 0 1 gcc_except_table gcc_except_table ! +section gcc_except_table 0 4 0 1 0 0 0 1 data !
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/include/plf_mmap.h @@ -0,0 +1,128 @@ +#ifndef CYGONCE_HAL_SA11X0_PLATFORM_PLF_MMAP_H +#define CYGONCE_HAL_SA11X0_PLATFORM_PLF_MMAP_H +/*============================================================================= +// +// plf_mmap.h +// +// Platform specific memory map support +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): hmt +// Contributors: hmt +// Date: 2001-01-04 +// Purpose: Intel SA11x0 series platform-specific memory mapping macros +// Description: Macros to convert a cached, virtual address to +// 1) an uncached adddress for the same memory (if available) +// 2) the equivalent physical address for giving to external +// hardware eg. DMA engines. +// +// NB: this mapping is expressed here statically, independent +// of the actual mapping installed in the MMAP table. So if +// someone changes that, or its initialisation is changed, +// then this module must change. This is intended to be +// efficient at a cost of generality. It is also intended to +// be called with constants (such as &my_struct) as input +// args, so that all the work can be done at compile time, +// with optimization on. +// +// Usage: #include <cyg/hal/hal_cache.h> +// (which includes this file itself) +// +//####DESCRIPTIONEND#### +// +//===========================================================================*/ + +#include <cyg/hal/hal_misc.h> + +// The actual DRAM or FLASH sizes don't need to match the sizes +// declared here. They are just the minimum expected quantities. +// For instance, even if more than 32MB of DRAM/FLASH are installed, +// only the first 32MB are mapped, which is enough for Redboot. + +// Get the pagesize for a particular virtual address: + +// This does not depend on the vaddr. +#define HAL_MM_PAGESIZE( vaddr, pagesize ) CYG_MACRO_START \ + (pagesize) = SZ_1M; \ +CYG_MACRO_END + +// Get the physical address from a virtual address: + +// Only RAM and ROM are mapped; we just pass through all other values, +// rather than detecting nonexistent areas here. + +#define HAL_VIRT_TO_PHYS_ADDRESS( vaddr, paddr ) CYG_MACRO_START \ + cyg_uint32 _v_ = (cyg_uint32)(vaddr); \ + if ( 32 * SZ_1M > _v_ ) /* 32Mb of SDRAM Bank 0 from 0-32Mb */ \ + _v_ += 0xc00u * SZ_1M; \ + else if ( 0x500u * SZ_1M > _v_ ) /* Space between RAM and mapped ROM */\ + /* no change */ ; \ + else if ( 0x520u * SZ_1M > _v_ ) /* Mapped boot ROM size 32Mb */ \ + _v_ -= 0x500u * SZ_1M; \ + else /* Rest of it */ \ + /* no change */ ; \ + (paddr) = _v_; \ +CYG_MACRO_END + +// Get the virtual address for a physical address: + +// Only RAM and ROM are mapped; we just pass through all other values, +// rather than detecting nonexistent areas here. + +#define HAL_PHYS_TO_VIRT_ADDRESS( paddr, vaddr ) CYG_MACRO_START \ + cyg_uint32 _p_ = (cyg_uint32)(paddr); \ + if ( 32 * SZ_1M > _p_ ) /* 32Mb Boot ROM mapped to 0x500Mb */ \ + _p_ += 0x500u * SZ_1M; \ + else if ( 0xc00u * SZ_1M > _p_ ) /* Space between ROM and SDRAM */ \ + /* no change */ ; \ + else if ( 0xc20u * SZ_1M > _p_ ) /* Raw RAM size 32Mb */ \ + _p_ -= 0xc00u * SZ_1M; \ + else /* Rest of it */ \ + /* no change */ ; \ + (vaddr) = _p_ ; \ +CYG_MACRO_END + +// Get a non-cacheable address for accessing the same store as a virtual +// (assumed cachable) address: + +// Only RAM is mapped: ROM is only available cachable, everything else is +// not cachable anyway. + +#define HAL_VIRT_TO_UNCACHED_ADDRESS( vaddr, uaddr ) CYG_MACRO_START \ + cyg_uint32 _v_ = (cyg_uint32)(vaddr); \ + if ( 32 * SZ_1M > _v_ ) /* 32Mb of SDRAM Bank 0 from 0-32Mb */ \ + _v_ += 0xc00u * SZ_1M; \ + else /* Everything else is already uncacheable or is ROM */ \ + /* no change */ ; \ + (uaddr) = _v_ ; \ +CYG_MACRO_END + +//--------------------------------------------------------------------------- +#endif // CYGONCE_HAL_SA11X0_PLATFORM_PLF_MMAP_H +// EOF plf_mmap.h
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/misc/redboot_RAM.ecm @@ -0,0 +1,77 @@ +cdl_savefile_version 1; +cdl_savefile_command cdl_savefile_version {}; +cdl_savefile_command cdl_savefile_command {}; +cdl_savefile_command cdl_configuration { description hardware template package }; +cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value }; + +cdl_configuration eCos { + description "" ; + hardware flexanet ; + template redboot ; + package -hardware CYGPKG_HAL_ARM current ; + package -hardware CYGPKG_HAL_ARM_SA11X0 current ; + package -hardware CYGPKG_HAL_ARM_SA11X0_FLEXANET current ; + package -hardware CYGPKG_IO_SERIAL_ARM_SA11X0 current ; + package -hardware CYGPKG_DEVS_PCMCIA_FLEXANET current ; + package -hardware CYGPKG_DEVS_FLASH_FLEXANET current ; + package -template CYGPKG_HAL current ; + package -template CYGPKG_INFRA current ; + package -template CYGPKG_REDBOOT current ; + package CYGPKG_IO_PCMCIA current ; + package CYGPKG_DEVS_ETH_CF current ; + package CYGPKG_IO_FLASH current ; + package CYGPKG_IO_ETH_DRIVERS current ; +}; + +cdl_option CYGBLD_BUILD_GDB_STUBS { + user_value 0 +}; + +cdl_option CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT { + user_value 0 +}; + +cdl_option CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM { + inferred_value 0 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT { + inferred_value 0 +}; + +cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + inferred_value 0 0 +}; + +cdl_component CYG_HAL_STARTUP { + user_value RAM +}; + +cdl_component CYGBLD_BUILD_REDBOOT { + user_value 1 +}; + +cdl_component CYGPKG_REDBOOT_NETWORKING { + user_value 1 +}; + +cdl_component CYGSEM_REDBOOT_FLASH_CONFIG { + user_value 1 +}; + +cdl_option CYGSEM_REDBOOT_BSP_SYSCALLS { + inferred_value 1 +}; + +
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/misc/redboot_ROM.ecm @@ -0,0 +1,77 @@ +cdl_savefile_version 1; +cdl_savefile_command cdl_savefile_version {}; +cdl_savefile_command cdl_savefile_command {}; +cdl_savefile_command cdl_configuration { description hardware template package }; +cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value }; + +cdl_configuration eCos { + description "" ; + hardware flexanet ; + template redboot ; + package -hardware CYGPKG_HAL_ARM current ; + package -hardware CYGPKG_HAL_ARM_SA11X0 current ; + package -hardware CYGPKG_HAL_ARM_SA11X0_FLEXANET current ; + package -hardware CYGPKG_IO_SERIAL_ARM_SA11X0 current ; + package -hardware CYGPKG_DEVS_PCMCIA_FLEXANET current ; + package -hardware CYGPKG_DEVS_FLASH_FLEXANET current ; + package -template CYGPKG_HAL current ; + package -template CYGPKG_INFRA current ; + package -template CYGPKG_REDBOOT current ; + package CYGPKG_IO_PCMCIA current ; + package CYGPKG_DEVS_ETH_CF current ; + package CYGPKG_IO_FLASH current ; + package CYGPKG_IO_ETH_DRIVERS current ; +}; + +cdl_option CYGBLD_BUILD_GDB_STUBS { + user_value 0 +}; + +cdl_option CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT { + user_value 0 +}; + +cdl_option CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM { + inferred_value 0 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT { + inferred_value 0 +}; + +cdl_option CYGSEM_HAL_ROM_MONITOR { + user_value 1 +}; + +cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + inferred_value 0 0 +}; + +cdl_component CYG_HAL_STARTUP { + user_value ROM +}; + +cdl_component CYGBLD_BUILD_REDBOOT { + user_value 1 +}; + +cdl_component CYGPKG_REDBOOT_NETWORKING { + user_value 1 +}; + +cdl_component CYGSEM_REDBOOT_FLASH_CONFIG { + user_value 1 +}; + +
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/src/flexanet_misc.c @@ -0,0 +1,147 @@ +//========================================================================== +// +// flexanet_misc.c +// +// HAL misc board support code for StrongARM SA1110/Flexanet +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): Jordi Colomer +// Contributors: Jordi Colomer <jco@ict.es> +// Date: 2001-06-15 +// Purpose: HAL board support +// Description: Implementations of HAL board interfaces +// +//####DESCRIPTIONEND#### +// +//========================================================================*/ + +#include <pkgconf/hal.h> +#include <pkgconf/system.h> +#include CYGBLD_HAL_PLATFORM_H + +#include <cyg/infra/cyg_type.h> // base types +#include <cyg/infra/cyg_trac.h> // tracing macros +#include <cyg/infra/cyg_ass.h> // assertion macros + +#include <cyg/hal/hal_io.h> // IO macros +#include <cyg/hal/hal_arch.h> // Register state info +#include <cyg/hal/hal_diag.h> +#include <cyg/hal/hal_intr.h> // Interrupt names +#include <cyg/hal/hal_cache.h> +#include <cyg/hal/hal_sa11x0.h> // Hardware definitions +#include <cyg/hal/flexanet.h> // Platform specifics + +#include <cyg/infra/diag.h> // diag_printf + +// All the MM table layout is here: +#include <cyg/hal/hal_mm.h> + +void +hal_mmu_init(void) +{ + unsigned long ttb_base = SA11X0_RAM_BANK0_BASE + 0x4000; + unsigned long i; + + /* + * Set the TTB register + */ + asm volatile ("mcr p15,0,%0,c2,c0,0" : : "r"(ttb_base) /*:*/); + + /* + * Set the Domain Access Control Register + */ + i = ARM_ACCESS_DACR_DEFAULT; + asm volatile ("mcr p15,0,%0,c3,c0,0" : : "r"(i) /*:*/); + + /* + * First clear all TT entries - ie Set them to Faulting + */ + memset((void *)ttb_base, 0, ARM_FIRST_LEVEL_PAGE_TABLE_SIZE); + + /* Actual Virtual Size Attributes Function */ + /* Base Base MB cached? buffered? access permissions */ + /* xxx00000 xxx00000 */ + X_ARM_MMU_SECTION(0x000, 0x500, 32, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Boot flash ROMspace */ + X_ARM_MMU_SECTION(0x100, 0x100, 128, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Core Board Registers */ + X_ARM_MMU_SECTION(0x180, 0x180, 16, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Ethernet Adaptor */ + X_ARM_MMU_SECTION(0x200, 0x200, 512, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* PCMCIA Socket A */ + X_ARM_MMU_SECTION(0x300, 0x300, 512, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* PCMCIA Sockets B */ + X_ARM_MMU_SECTION(0x800, 0x800, 0x400, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* StrongARM(R) Registers */ + X_ARM_MMU_SECTION(0xC00, 0, 32, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* DRAM Bank 0 */ + X_ARM_MMU_SECTION(0xC00, 0xC00, 32, ARM_UNCACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* DRAM Bank 0 */ + X_ARM_MMU_SECTION(0xE00, 0xE00, 128, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Zeros (Cache Clean) Bank */ + +} + +// +// Board control register support +// Update the board control register (write only). Only the bits +// specified by 'mask' are changed to 'value'. +// + +void +flexanet_BCR(unsigned long mask, unsigned long value) +{ + _flexanet_BCR = (_flexanet_BCR & ~mask) | (mask & value); + *SA1110_BOARD_CONTROL = _flexanet_BCR; +} + +// +// Platform specific initialization +// + +void +plf_hardware_init(void) +{ + // Force "alternate" use of GPIO pins used for LCD screen + *SA11X0_GPIO_ALTERNATE_FUNCTION |= 0x000003FC; // Bits 2..9 + *SA11X0_GPIO_PIN_DIRECTION |= 0x000003FC; // Bits 2..9 + *SA11X0_GPIO_PIN_OUTPUT_CLEAR = 0x000003FC; // Bits 2..9 + + // Configure the ethernet GPIO interrupt to falling-edge + HAL_INTERRUPT_CONFIGURE(SA1110_IRQ_GPIO_ETH, 0, 0); +} + +#include CYGHWR_MEMORY_LAYOUT_H +typedef void code_fun(void); +void flexanet_program_new_stack(void *func) +{ + register CYG_ADDRESS stack_ptr asm("sp"); + register CYG_ADDRESS old_stack asm("r4"); + register code_fun *new_func asm("r0"); + old_stack = stack_ptr; + stack_ptr = CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE - sizeof(CYG_ADDRESS); + new_func = (code_fun*)func; + new_func(); + stack_ptr = old_stack; + return; +} + +// ------------------------------------------------------------------------ +// EOF flexanet_misc.c
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/sa11x0/flexanet/current/support/README @@ -0,0 +1,3 @@ + +This directory should contain the "bsflash" tool, +useful to write to Flexanet's on-board flash memory.
--- a/packages/hal/arm/sa11x0/ipaq/current/ChangeLog +++ b/packages/hal/arm/sa11x0/ipaq/current/ChangeLog @@ -1,3 +1,9 @@ +2001-07-23 Gary Thomas <gthomas@redhat.com> + + * include/hal_platform_ints.h: + * cdl/hal_arm_sa11x0_ipaq.cdl: + Define sample "extended interrupt" support. + 2001-06-22 Gary Thomas <gthomas@redhat.com> * misc/redboot_WinCE.ecm:
--- a/packages/hal/arm/sa11x0/ipaq/current/cdl/hal_arm_sa11x0_ipaq.cdl +++ b/packages/hal/arm/sa11x0/ipaq/current/cdl/hal_arm_sa11x0_ipaq.cdl @@ -62,6 +62,7 @@ cdl_package CYGPKG_HAL_ARM_SA11X0_IPAQ { puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H <pkgconf/hal_arm.h>" puts $::cdl_system_header "#define CYGBLD_HAL_VARIANT_H <pkgconf/hal_arm_sa11x0.h>" puts $::cdl_system_header "#define CYGBLD_HAL_PLATFORM_H <pkgconf/hal_arm_sa11x0_ipaq.h>" + puts $::cdl_system_header "#define CYGBLD_HAL_PLF_INTS_H <cyg/hal/hal_platform_ints.h>" puts $::cdl_header "#define HAL_PLATFORM_CPU \"StrongARM 1110\"" puts $::cdl_header "#define HAL_PLATFORM_BOARD \"Compaq iPAQ Pocket PC\"" puts $::cdl_header "#define HAL_PLATFORM_EXTRA \"\""
--- a/packages/hal/arm/sa11x0/ipaq/current/include/hal_platform_ints.h +++ b/packages/hal/arm/sa11x0/ipaq/current/include/hal_platform_ints.h @@ -4,7 +4,7 @@ // // hal_platform_ints.h // -// HAL Interrupt and clock support +// HAL extended support for platform specific interrupts // //========================================================================== //####COPYRIGHTBEGIN#### @@ -47,62 +47,50 @@ // //========================================================================== -#define CYGNUM_HAL_INTERRUPT_GPIO0 0 -#define CYGNUM_HAL_INTERRUPT_GPIO1 1 -#define CYGNUM_HAL_INTERRUPT_GPIO2 2 -#define CYGNUM_HAL_INTERRUPT_GPIO3 3 -#define CYGNUM_HAL_INTERRUPT_GPIO4 4 -#define CYGNUM_HAL_INTERRUPT_GPIO5 5 -#define CYGNUM_HAL_INTERRUPT_GPIO6 6 -#define CYGNUM_HAL_INTERRUPT_GPIO7 7 -#define CYGNUM_HAL_INTERRUPT_GPIO8 8 -#define CYGNUM_HAL_INTERRUPT_GPIO9 9 -#define CYGNUM_HAL_INTERRUPT_GPIO10 10 -#define CYGNUM_HAL_INTERRUPT_GPIO 11 // Don't use directly! -#define CYGNUM_HAL_INTERRUPT_LCD 12 -#define CYGNUM_HAL_INTERRUPT_UDC 13 -#define CYGNUM_HAL_INTERRUPT_UART1 15 -#define CYGNUM_HAL_INTERRUPT_UART2 16 -#define CYGNUM_HAL_INTERRUPT_UART3 17 -#define CYGNUM_HAL_INTERRUPT_MCP 18 -#define CYGNUM_HAL_INTERRUPT_SSP 19 -#define CYGNUM_HAL_INTERRUPT_TIMER0 26 -#define CYGNUM_HAL_INTERRUPT_TIMER1 27 -#define CYGNUM_HAL_INTERRUPT_TIMER2 28 -#define CYGNUM_HAL_INTERRUPT_TIMER3 29 -#define CYGNUM_HAL_INTERRUPT_HZ 30 -#define CYGNUM_HAL_INTERRUPT_ALARM 31 +#include CYGBLD_HAL_VAR_INTS_H // Generic interrupt support + +// Define here extended support for this particular platform + +// IRQ handler for extended interrupts +#define HAL_EXTENDED_IRQ_HANDLER(index) \ +{ /* Check for extended interrupt source. If present, decode it into \ + a valid eCos interrupt number and return. Fall through if no \ + extended interrupt is present. */ \ +} + +// Mask an extended interrupt +#define HAL_EXTENDED_INTERRUPT_MASK(vector) \ +{ /* Mask an interrupt source. If 'vector' corresponds to an extended \ + interrupt, handle it and return. Otherwise, fall through for \ + normal processing. */ \ +} -// GPIO bits 31..11 can generate interrupts as well, but they all -// end up clumped into interrupt signal #11. Using the symbols -// below allow for detection of these separately. +// Unmask an extended interrupt +#define HAL_EXTENDED_INTERRUPT_UNMASK(vector) \ +{ /* Unmask an interrupt source. If 'vector' corresponds to an extended \ + interrupt, handle it and return. Otherwise, fall through for \ + normal processing. */ \ +} + +// Acknowledge an extended interrupt +#define HAL_EXTENDED_INTERRUPT_ACKNOWLEDGE(vector) \ +{ /* Ack an interrupt source. If 'vector' corresponds to an extended \ + interrupt, handle it and return. Otherwise, fall through for \ + normal processing. */ \ +} -#define CYGNUM_HAL_INTERRUPT_GPIO11 (32+11) -#define CYGNUM_HAL_INTERRUPT_GPIO12 (32+12) -#define CYGNUM_HAL_INTERRUPT_GPIO13 (32+13) -#define CYGNUM_HAL_INTERRUPT_GPIO14 (32+14) -#define CYGNUM_HAL_INTERRUPT_GPIO15 (32+15) -#define CYGNUM_HAL_INTERRUPT_GPIO16 (32+16) -#define CYGNUM_HAL_INTERRUPT_GPIO17 (32+17) -#define CYGNUM_HAL_INTERRUPT_GPIO18 (32+18) -#define CYGNUM_HAL_INTERRUPT_GPIO19 (32+19) -#define CYGNUM_HAL_INTERRUPT_GPIO20 (32+20) -#define CYGNUM_HAL_INTERRUPT_GPIO21 (32+21) -#define CYGNUM_HAL_INTERRUPT_GPIO22 (32+22) -#define CYGNUM_HAL_INTERRUPT_GPIO23 (32+23) -#define CYGNUM_HAL_INTERRUPT_GPIO24 (32+24) -#define CYGNUM_HAL_INTERRUPT_GPIO25 (32+25) -#define CYGNUM_HAL_INTERRUPT_GPIO26 (32+26) -#define CYGNUM_HAL_INTERRUPT_GPIO27 (32+27) +// Configure an extended interrupt +#define HAL_EXTENDED_INTERRUPT_CONFIGURE(vector, level, up) \ +{ /* Configure an interrupt source. If 'vector' corresponds to an extended \ + interrupt, handle it and return. Otherwise, fall through for \ + normal processing. */ \ +} -#define CYGNUM_HAL_INTERRUPT_NONE -1 - -#define CYGNUM_HAL_ISR_MIN 0 -#define CYGNUM_HAL_ISR_MAX (27+32) - -#define CYGNUM_HAL_ISR_COUNT (CYGNUM_HAL_ISR_MAX+1) - -// The vector used by the Real time clock -#define CYGNUM_HAL_INTERRUPT_RTC CYGNUM_HAL_INTERRUPT_TIMER0 +// Configure an extended interrupt +#define HAL_EXTENDED_INTERRUPT_SET_LEVEL(vector, level) \ +{ /* Configure an interrupt source. If 'vector' corresponds to an extended \ + interrupt, handle it and return. Otherwise, fall through for \ + normal processing. */ \ +} #endif // CYGONCE_HAL_PLATFORM_INTS_H
--- a/packages/hal/arm/sa11x0/var/current/ChangeLog +++ b/packages/hal/arm/sa11x0/var/current/ChangeLog @@ -1,3 +1,17 @@ +2001-07-27 Gary Thomas <gthomas@redhat.com> + + * src/redboot_linux_exec.c: Fix copyright disclaimers to satisfy + original owner (Linux kernel maintainer Russell King). + +2001-07-23 Gary Thomas <gthomas@redhat.com> + + * src/sa11x0_misc.c (hal_IRQ_handler): Support board/platform + specific [extended] interrupts. On the SA11x0, these would often + be cascaded via GPIO logic. Use of extended macros allows SA11x0 + variant code to handle the general case, with board specific code + defined by board packages. Look at the iPAQ board package for + a sample of how to use this. + 2001-05-19 Gary Thomas <gthomas@redhat.com> * src/redboot_linux_exec.c (do_exec): Protect compilation - scripting
--- a/packages/hal/arm/sa11x0/var/current/src/redboot_linux_exec.c +++ b/packages/hal/arm/sa11x0/var/current/src/redboot_linux_exec.c @@ -28,11 +28,21 @@ // ------------------------------------------- // //####COPYRIGHTEND#### +//####OTHERCOPYRIGHTBEGIN#### +// +// The structure definitions below are taken from include/asm-arm/setup.h in +// the Linux kernel, Copyright (C) 1997-1999 Russell King. Their presence +// here is for the express purpose of communication with the Linux kernel +// being booted and is considered 'fair use' by the original author and +// are included with his permission. +// +//####OTHERCOPYRIGHTEND#### //========================================================================== //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas // Contributors: gthomas +// Russell King <rmk@arm.linux.org.uk> // Date: 2001-02-20 // Purpose: // Description: @@ -76,6 +86,9 @@ typedef unsigned long u32; typedef unsigned short u16; typedef unsigned char u8; +//========================================================================= +// From Linux <asm-arm/setup.h> + #define ATAG_NONE 0x00000000 struct tag_header { u32 size; // Size of tag (hdr+data) in *longwords* @@ -193,6 +206,8 @@ struct tag { } u; }; +// End of inclusion from <asm-arm/setup.h> +//========================================================================= static void do_exec(int argc, char *argv[])
--- a/packages/hal/arm/sa11x0/var/current/src/sa11x0_misc.c +++ b/packages/hal/arm/sa11x0/var/current/src/sa11x0_misc.c @@ -196,6 +196,14 @@ int hal_IRQ_handler(void) { cyg_uint32 sources, index; +#ifdef HAL_EXTENDED_IRQ_HANDLER + // Use platform specific IRQ handler, if defined + // Note: this macro should do a 'return' with the appropriate + // interrupt number if such an extended interrupt exists. The + // assumption is that the line after the macro starts 'normal' processing. + HAL_EXTENDED_IRQ_HANDLER(index); +#endif + #if 0 // test FIQ and print alert if active - really for debugging sources = *SA11X0_ICFP; if ( 0 != sources ) @@ -251,10 +259,19 @@ int hal_IRQ_handler(void) void hal_interrupt_mask(int vector) { + +#ifdef HAL_EXTENDED_INTERRUPT_MASK + // Use platform specific handling, if defined + // Note: this macro should do a 'return' for "extended" values of 'vector' + // Normal vectors are handled by code subsequent to the macro call. + HAL_EXTENDED_INTERRUPT_MASK(vector); +#endif + // Non-GPIO interrupt sources can be masked separately. // Note: masking any non-unique GPIO signal (31..11) results in // all GPIO signals (31..11) being masked as only the "lump" // source will be changed. + if (vector >= CYGNUM_HAL_INTERRUPT_GPIO11) { vector = CYGNUM_HAL_INTERRUPT_GPIO; } @@ -263,6 +280,14 @@ void hal_interrupt_mask(int vector) void hal_interrupt_unmask(int vector) { + +#ifdef HAL_EXTENDED_INTERRUPT_UNMASK + // Use platform specific handling, if defined + // Note: this macro should do a 'return' for "extended" values of 'vector' + // Normal vectors are handled by code subsequent to the macro call. + HAL_EXTENDED_INTERRUPT_UNMASK(vector); +#endif + if (vector >= CYGNUM_HAL_INTERRUPT_GPIO11) { vector = CYGNUM_HAL_INTERRUPT_GPIO; } @@ -271,6 +296,14 @@ void hal_interrupt_unmask(int vector) void hal_interrupt_acknowledge(int vector) { + +#ifdef HAL_EXTENDED_INTERRUPT_UNMASK + // Use platform specific handling, if defined + // Note: this macro should do a 'return' for "extended" values of 'vector' + // Normal vectors are handled by code subsequent to the macro call. + HAL_EXTENDED_INTERRUPT_ACKNOWLEDGE(vector); +#endif + // GPIO interrupts are driven by an edge detection mechanism. This // is latching so these interrupts must be acknowledged directly. // All other interrupts simply go away when the interrupting unit @@ -286,6 +319,14 @@ void hal_interrupt_acknowledge(int vecto void hal_interrupt_configure(int vector, int level, int up) { + +#ifdef HAL_EXTENDED_INTERRUPT_CONFIGURE + // Use platform specific handling, if defined + // Note: this macro should do a 'return' for "extended" values of 'vector' + // Normal vectors are handled by code subsequent to the macro call. + HAL_EXTENDED_INTERRUPT_CONFIGURE(vector, level, up); +#endif + // This function can be used to configure the GPIO interrupts. All // of these pins can potentially generate an interrupt, but only // 0..10 are unique. Thus the discontinuity in the numbers. @@ -321,6 +362,14 @@ void hal_interrupt_configure(int vector, void hal_interrupt_set_level(int vector, int level) { + +#ifdef HAL_EXTENDED_INTERRUPT_SET_LEVEL + // Use platform specific handling, if defined + // Note: this macro should do a 'return' for "extended" values of 'vector' + // Normal vectors are handled by code subsequent to the macro call. + HAL_EXTENDED_INTERRUPT_SET_LEVEL(vector, level); +#endif + // Interrupt priorities are not configurable on the SA11X0. }
--- a/packages/hal/common/current/ChangeLog +++ b/packages/hal/common/current/ChangeLog @@ -1,3 +1,19 @@ +2001-07-27 Jesper Skov <jskov@redhat.com> + + * tests/intr.c: Set up interrupt ISR using driver API so it works + properly in chained mode in the presence of arbiters. + + * src/drv_api.c (chain_isr): Call default ISR when + appropriate. Return ISR return value. + + * include/hal_arbiter.h (hal_call_isr): Added version to be used + with interrupt chaining. + +2001-07-24 Mark Salter <msalter@redhat.com> + + * cdl/hal.cdl (CYGINT_HAL_PLF_IF_IDE): New interface which + indicates platform supports IDE controller I/F macros. + 2001-06-29 Jonathan Larmour <jlarmour@redhat.com> * cdl/hal.cdl (CYGPKG_HAL_TESTS): Remove redundant .c extension
--- a/packages/hal/common/current/cdl/hal.cdl +++ b/packages/hal/common/current/cdl/hal.cdl @@ -398,6 +398,15 @@ cdl_package CYGPKG_HAL { needs to be called." } + # Does platform provide IDE I/O macros? + cdl_interface CYGINT_HAL_PLF_IF_IDE { + display "Platform IDE I/O support." + description " + Platforms which provide IDE controllers can implement + this interface, indicating that IDE I/O macros are + available." + } + define_proc { puts $::cdl_header "/***** proc output start *****/" puts $::cdl_header "#include <pkgconf/system.h>"
--- a/packages/hal/common/current/include/hal_arbiter.h +++ b/packages/hal/common/current/include/hal_arbiter.h @@ -83,6 +83,8 @@ typedef cyg_uint32 cyg_ISR(cyg_uint32 ve extern void cyg_interrupt_post_dsr( CYG_ADDRWORD intr_obj ); +#ifndef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN + static inline cyg_uint32 hal_call_isr (cyg_uint32 vector) { @@ -104,6 +106,28 @@ hal_call_isr (cyg_uint32 vector) return isr_ret & ~CYG_ISR_CALL_DSR; } +#else + +// In chained mode, assume vector 0 points to the chain +// handler. Simply call it with the vector number and let it find the +// ISR to call - it will also post DSRs as required. +static inline cyg_uint32 +hal_call_isr (cyg_uint32 vector) +{ + cyg_ISR *isr; + CYG_ADDRWORD data; + cyg_uint32 isr_ret; + + isr = (cyg_ISR*) hal_interrupt_handlers[0]; + data = hal_interrupt_data[0]; + + isr_ret = (*isr) (vector, data); + + return isr_ret; +} + +#endif + //----------------------------------------------------------------------------- #endif // CYGONCE_HAL_HAL_ARBITER_H // End of hal_arbiter.h
--- a/packages/hal/common/current/src/drv_api.c +++ b/packages/hal/common/current/src/drv_api.c @@ -169,6 +169,8 @@ interrupt_end( cyg_uint32 chain_isr(cyg_vector_t vector, CYG_ADDRWORD data) { cyg_interrupt *p = *(cyg_interrupt **)data; + register cyg_uint32 isr_ret = 0; + register cyg_uint32 isr_chain_ret = 0; CYG_REPORT_FUNCTION(); @@ -176,7 +178,9 @@ cyg_uint32 chain_isr(cyg_vector_t vector { if( p->vector == vector ) { - register cyg_uint32 isr_ret = p->isr(vector, p->data); + isr_ret = p->isr(vector, p->data); + + isr_chain_ret |= isr_ret; if( isr_ret & CYG_ISR_CALL_DSR ) post_dsr(p); @@ -186,9 +190,21 @@ cyg_uint32 chain_isr(cyg_vector_t vector p = p->next; } +#ifdef HAL_DEFAULT_ISR + if( (isr_chain_ret & (CYG_ISR_CALL_DSR|CYG_ISR_HANDLED)) == 0 ) + { + // If we finished the loop for some reason other than that an + // ISR has handled the interrupt, call any default ISR to either + // report the spurious interrupt, or do some other HAL level processing + // such as GDB interrupt detection etc. + + HAL_DEFAULT_ISR( vector, 0 ); + } +#endif + CYG_REPORT_RETURN(); - return 0; + return isr_ret & CYG_ISR_CALL_DSR; } #endif
--- a/packages/hal/common/current/tests/intr.c +++ b/packages/hal/common/current/tests/intr.c @@ -42,6 +42,7 @@ #include <cyg/infra/testcase.h> #include <cyg/hal/hal_intr.h> +#include <cyg/hal/drv_api.h> // Include HAL/Platform specifics #include CYGBLD_HAL_PLATFORM_H @@ -64,6 +65,8 @@ // ------------------------------------------------------------------------- volatile cyg_count32 ticks = 0; +static cyg_interrupt intr; +static cyg_handle_t intr_handle; // ------------------------------------------------------------------------- @@ -79,20 +82,21 @@ cyg_uint32 isr( cyg_uint32 vector, CYG_A ticks++; - return 0; + return CYG_ISR_HANDLED; } // ------------------------------------------------------------------------- + void intr_main( void ) { CYG_INTERRUPT_STATE oldints; - HAL_INTERRUPT_ATTACH( CYGNUM_HAL_INTERRUPT_RTC, isr, ISR_DATA, 0 ); - + cyg_drv_interrupt_create(CYGNUM_HAL_INTERRUPT_RTC, 1, + ISR_DATA, isr, NULL, &intr_handle, &intr); + cyg_drv_interrupt_attach(intr_handle); HAL_CLOCK_INITIALIZE( CYGNUM_HAL_RTC_PERIOD ); - - HAL_INTERRUPT_UNMASK( CYGNUM_HAL_INTERRUPT_RTC ); + cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_RTC); HAL_ENABLE_INTERRUPTS(); @@ -104,7 +108,6 @@ void intr_main( void ) HAL_DISABLE_INTERRUPTS(oldints); CYG_TEST_PASS_FINISH("HAL interrupt test"); - } @@ -130,4 +133,4 @@ cyg_start( void ) // ------------------------------------------------------------------------- -/* EOF intr.c */ +// EOF intr.c
--- a/packages/hal/mips/arch/current/ChangeLog +++ b/packages/hal/mips/arch/current/ChangeLog @@ -1,4 +1,10 @@ -2001-07-19 Gary Thomas <gthomas@redhat.com> +2001-07-20 Jonathan Larmour <jlarmour@redhat.com> + + * src/redboot_linux_exec.c: Adjust below change by getting baud + rate, thus allowing for runtime baud rate changes, and no + dependency on platform CDL defines. + +a2001-07-19 Gary Thomas <gthomas@redhat.com> * src/redboot_linux_exec.c: Define DEFAULT_BAUD. The supporting CDL differs from platform to platform, so this define is used to
--- a/packages/hal/mips/arch/current/cdl/hal_mips.cdl +++ b/packages/hal/mips/arch/current/cdl/hal_mips.cdl @@ -130,7 +130,7 @@ cdl_package CYGPKG_HAL_MIPS { flavor bool default_value 1 description " - This option enables RedBoot to support booting of a Linux kernel." + This option allows RedBoot to support booting of a Linux kernel." compile -library=libextras.a redboot_linux_exec.c cdl_option CYGDAT_REDBOOT_MIPS_LINUX_BOOT_ENTRY {
--- a/packages/hal/mips/arch/current/src/redboot_linux_exec.c +++ b/packages/hal/mips/arch/current/src/redboot_linux_exec.c @@ -45,15 +45,7 @@ #include <cyg/infra/cyg_type.h> #include <cyg/hal/hal_intr.h> #include <cyg/hal/hal_cache.h> - -// Not all platforms define this the same way -#if defined(CYGNUM_HAL_VIRTUAL_VECTOR_CHANNELS_DEFAULT_BAUD) -#define DEFAULT_BAUD CYGNUM_HAL_VIRTUAL_VECTOR_CHANNELS_DEFAULT_BAUD -#elif defined(CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD) -#define DEFAULT_BAUD CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD -#else -#define DEFAULT_BAUD 38400 // Probably wrong -#endif +#include <cyg/hal/hal_if.h> #define xstr(s) str(s) #define str(s...) #s @@ -96,6 +88,8 @@ do_exec(int argc, char *argv[]) struct parmblock *pb; void (*linux)(int, char **, void *); int oldints; + hal_virtual_comm_table_t *__chan; + int baud; init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, (void **)&base_addr, &base_addr_set, "base address"); @@ -110,6 +104,9 @@ do_exec(int argc, char *argv[]) linux = (void *)entry; + __chan = CYGACC_CALL_IF_CONSOLE_PROCS(); + baud = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_GETBAUD); + printf("Now booting linux kernel:\n"); printf(" Base address 0x%08x Entry 0x%08x\n", base_addr, entry); printf(" Cmdline : %s\n", cmd_line); @@ -136,7 +133,7 @@ do_exec(int argc, char *argv[]) pb->modetty0.name = ++pcmd; pcmd += sprintf(pcmd, "modetty0"); pb->modetty0.val = ++pcmd; - pcmd += sprintf(pcmd, "%d,n,8,1,hw", DEFAULT_BAUD); + pcmd += sprintf(pcmd, "%d,n,8,1,hw", baud); #ifdef CYGPKG_REDBOOT_NETWORKING pb->ethaddr.name = ++pcmd;
--- a/packages/hal/mips/atlas/current/ChangeLog +++ b/packages/hal/mips/atlas/current/ChangeLog @@ -1,3 +1,8 @@ +2001-07-20 David Woodhouse <dwmw2@redhat.com> + + * src/redboot_cmds.c: Remove. Obsoleted by generic MIPS version. + * cdl/hal_mips_atlas.cdl: Remove reference to $1 + 2001-04-27 Mark Salter <msalter@redhat.com> * include/platform.inc (hal_intc_decode): Recognize all external
--- a/packages/hal/mips/atlas/current/cdl/hal_mips_atlas.cdl +++ b/packages/hal/mips/atlas/current/cdl/hal_mips_atlas.cdl @@ -314,8 +314,6 @@ cdl_package CYGPKG_HAL_MIPS_ATLAS { This option lists the target's requirements for a valid Redboot configuration." - compile -library=libextras.a redboot_cmds.c - cdl_option CYGBLD_BUILD_REDBOOT_BIN { display "Build Redboot ROM binary image" active_if CYGBLD_BUILD_REDBOOT
deleted file mode 100644 --- a/packages/hal/mips/atlas/current/src/redboot_cmds.c +++ /dev/null @@ -1,180 +0,0 @@ -//========================================================================== -// -// redboot_cmds.c -// -// Atlas [platform] specific RedBoot commands -// -//========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations under -// the License. -// -// The Original Code is eCos - Embedded Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): gthomas -// Contributors: gthomas, jskov -// Date: 2000-07-14 -// Purpose: -// Description: -// -// This code is part of RedBoot (tm). -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#include <redboot.h> - -#include <cyg/hal/hal_intr.h> -#include <cyg/hal/hal_cache.h> - -// Exported CLI function(s) - -// The exec command works like the go command in YAMON - that is, -// providing callee with argc, argv, and env. In addition to the -// information provided by the user, - -static void do_exec(int argc, char *argv[]); - -static char exec_usage[] = -#if 0 - "[-r <ramdisk addr> [-s <ramdisk length>]] \n" -#endif - "[-w timeout] [-c \"kernel command line\"] [<entry_point>]"; - -RedBoot_cmd("exec", - "Execute an image - with MMU off", - exec_usage, - do_exec - ); - -typedef void code_fun(void); - -#define MAX_ARGS_LEN 128 -#define _ARGC 2 - -char _cmd_str[] = "exec"; -char _arg_str[MAX_ARGS_LEN]; -char* _exec_argv[_ARGC] = { _cmd_str, _arg_str }; - -/* Environment variable */ -typedef struct -{ - char *name; - char *val; -} t_env_var; - -char _env_memsize[11]; -char _env_ttymode[32]; -char _env_ethaddr[18]; -t_env_var _exec_envp[] = { - { "memsize", _env_memsize }, - { "modetty0", _env_ttymode }, - { "ethaddr", _env_ethaddr }, - { NULL, NULL } -}; - -static void -do_exec(int argc, char *argv[]) -{ - unsigned long entry; - unsigned long oldints; - bool wait_time_set; - int wait_time, res; - bool cmd_line_set; -#if 0 - bool ramdisk_addr_set, ramdisk_size_set; - unsigned long ramdisk_addr, ramdisk_size; -#endif - struct option_info opts[4]; - char line[8]; - char *cmd_line; - int num_options; - - entry = (unsigned long)entry_address; // Default from last 'load' operation - init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM, - (void **)&wait_time, (bool *)&wait_time_set, "wait timeout"); - init_opts(&opts[1], 'c', true, OPTION_ARG_TYPE_STR, - (void **)&cmd_line, (bool *)&cmd_line_set, "kernel command line"); - num_options = 2; -#if 0 - init_opts(&opts[2], 'r', true, OPTION_ARG_TYPE_NUM, - (void **)&ramdisk_addr, (bool *)&ramdisk_addr_set, "ramdisk_addr"); - init_opts(&opts[3], 's', true, OPTION_ARG_TYPE_NUM, - (void **)&ramdisk_size, (bool *)&ramdisk_size_set, "ramdisk_size"); - num_options += 2; -#endif - - if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry, - OPTION_ARG_TYPE_NUM, "starting address")) - { - return; - } - if (cmd_line_set) { - strncpy(_arg_str, cmd_line, MAX_ARGS_LEN); - } -#if 0 - if (ramdisk_addr_set) { - params->rd_start = ramdisk_addr; - if (ramdisk_size_set) { - params->rd_size = ramdisk_size; - } else { - params->rd_size = 4096*1024; - } - } -#endif - - // Compute memory size - sprintf(_env_memsize, "0x%08x", (ram_end - ram_start + (1024*1024-1)) & ~(1024*1024-1)); - // Set enet address - sprintf(_env_ethaddr, "%02x.%02x.%02x.%02x.%02x.%02x", - __local_enet_addr[0], __local_enet_addr[1], - __local_enet_addr[2], __local_enet_addr[3], - __local_enet_addr[4], __local_enet_addr[5]); - // Set console parameters (only baud rate part configurable for now) - sprintf(_env_ttymode, "%d,n,8,1,hw", CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL_BAUD); - - if (wait_time_set) { - printf("About to start execution at %p - abort with ^C within %d seconds\n", - (void *)entry, wait_time); - res = gets(line, sizeof(line), wait_time*1000); - if (res == _GETS_CTRLC) { - return; - } - } - - HAL_DISABLE_INTERRUPTS(oldints); - HAL_DCACHE_SYNC(); - HAL_ICACHE_DISABLE(); - HAL_DCACHE_DISABLE(); - HAL_DCACHE_SYNC(); - HAL_ICACHE_INVALIDATE_ALL(); - HAL_DCACHE_INVALIDATE_ALL(); - asm volatile ("move $4,%1;" // a0 - "move $5,%2;" // a1 - "move $6,%3;" // a2 - "j %0;" - : : "r"(entry),"r"(_ARGC),"r"(_exec_argv),"r"(_exec_envp) : "$4","$5","$6"); -} - -// EOF redboot_cmds.c
--- a/packages/hal/mn10300/am33/current/ChangeLog +++ b/packages/hal/mn10300/am33/current/ChangeLog @@ -1,3 +1,13 @@ +2001-07-27 David Howells <dhowells@redhat.com> + + * cdl/hal_mn10300_am33.cdl: Added option for disabling caching + when accessing flash (CYGSEM_HAL_UNCACHED_FLASH_ACCESS). + * include/var_cache.h: Ditto. + * include/variant.inc: Initialise the cache and the trap base + register if appropriate. + * src/mn10300_am33.ld: Handle code kept in RAM for flash drivers + and permit the VSR table to reside in on-CPU RAM. + 2000-08-12 Drew Moseley <dmoseley@redhat.com> * src/var_misc.c: More rearranging of GDB regnames.
--- a/packages/hal/mn10300/am33/current/cdl/hal_mn10300_am33.cdl +++ b/packages/hal/mn10300/am33/current/cdl/hal_mn10300_am33.cdl @@ -83,4 +83,13 @@ cdl_package CYGPKG_HAL_MN10300_AM33 { calculated { "src/mn10300_am33.ld" } } + cdl_option CYGSEM_HAL_UNCACHED_FLASH_ACCESS { + display "Caching needn't be disabled to access flash" + flavor bool + default_value 0 + description " + Enable this option if the hardware is able to program the flash + without turning off CPU data caching." + } + }
--- a/packages/hal/mn10300/am33/current/include/var_cache.h +++ b/packages/hal/mn10300/am33/current/include/var_cache.h @@ -273,5 +273,19 @@ externC void cyg_hal_dcache_store(CYG_AD //#define HAL_ICACHE_INVALIDATE( _base_ , _size_ ) //----------------------------------------------------------------------------- +// flash caching control +#ifdef CYGSEM_HAL_UNCACHED_FLASH_ACCESS +#define HAL_FLASH_CACHES_OFF(_d_, _i_) \ + CYG_MACRO_START \ + _d_ = 0; /* avoids warning */ \ + _i_ = 0; /* avoids warning */ \ + CYG_MACRO_END + +#define HAL_FLASH_CACHES_ON(_d_, _i_) \ + CYG_MACRO_START \ + CYG_MACRO_END +#endif + +//----------------------------------------------------------------------------- #endif // ifndef CYGONCE_VAR_CACHE_H // End of var_cache.h
--- a/packages/hal/mn10300/am33/current/include/variant.inc +++ b/packages/hal/mn10300/am33/current/include/variant.inc @@ -25,7 +25,7 @@ # # The Initial Developer of the Original Code is Red Hat. # Portions created by Red Hat are -# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. # All Rights Reserved. # ------------------------------------------- # @@ -61,6 +61,7 @@ #define DCR 0xC0000030 // Debug control register #define ISR 0xC0000034 // Interrupt control register #define TBR 0xC0000024 // Trap Base Register +#define CHCTR 0xC0000070 // Cache Control Register #define DCR_DE 0x0001 // DE bit in DCR @@ -79,8 +80,10 @@ # Set up the PSW mov 0x00000700,d0 mov d0,epsw -# mov reset_vector,a0 # set TBR to reset address -# mov a0,(TBR) +#ifndef CYGSEM_HAL_USE_ROM_MONITOR + mov reset_vector,a0 # set TBR to vector table + mov a0,(TBR) +#endif .endm #define CYGPKG_HAL_MN10300_CPU_INIT_DEFINED @@ -128,6 +131,36 @@ #define CYGPKG_HAL_MN10300_MEMC_DEFINED #endif + +#------------------------------------------------------------------------------ +# Cache macros. + +#ifndef CYGPKG_HAL_MN10300_CACHE_DEFINED + + .macro hal_cache_init + +#if defined(CYG_HAL_STARTUP_ROM) + # Note that the hardware seems to come up with the + # caches containing random data. Hence they must be + # invalidated before being enabled. + # However, we only do this if we are in ROM. If we are + # in RAM, then we leave the caches in the state chosen + # by the ROM monitor. If we enable them when the monitor + # is not expecting it, we can end up breaking things if the + # monitor is not doing cache flushes. + mov CHCTR,a0 + mov 0x0030,d0 + mov d0,(a0) # Invalidate the ICACHE and DCACHE + mov 0x0003,d0 + mov d0,(a0) # Enable both caches +#else + nop +#endif + .endm + +#define CYGPKG_HAL_MN10300_CACHE_DEFINED + +#endif ##----------------------------------------------------------------------------- # Default interrupt decoding macros.
--- a/packages/hal/mn10300/am33/current/src/mn10300_am33.ld +++ b/packages/hal/mn10300/am33/current/src/mn10300_am33.ld @@ -22,7 +22,7 @@ // // The Initial Developer of the Original Code is Red Hat. // Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. // All Rights Reserved. // ------------------------------------------- // @@ -86,6 +86,10 @@ GROUP(libtarget.a libgcc.a) .data _vma_ : _lma_ \ { __ram_data_start = ABSOLUTE (.); *(.data*) *(.data1) \ . = ALIGN(4); \ + __s2ram = ABSOLUTE(.); \ + *(.2ram*) \ + __e2ram = ABSOLUTE(.); \ + . = ALIGN(4); \ _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.); \ _GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \ . = ALIGN (4); \ @@ -118,8 +122,10 @@ GROUP(libtarget.a libgcc.a) #if CYGHWR_HAL_MN10300_AM33_REVISION == 1 +#ifndef CYG_HAL_PLATFORM_HAL_VSR_TABLE_DEFINED _hal_vsr_table = 0x50000100; _hal_virtual_vector_table = 0x50000200; +#endif #else
--- a/packages/hal/mn10300/arch/current/ChangeLog +++ b/packages/hal/mn10300/arch/current/ChangeLog @@ -1,3 +1,11 @@ +2001-07-27 David Howells <dhowells@redhat.com> + + * include/mn10300_stub.h: set NUMREGS to be the correct value to + keep gdb happy. + * include/hal_io.h: refer to plf_io.h + * src/vectors.S: Adjusted exception handling to be able to cope + with AM33v2 exceptions. + 2001-01-18 Nick Garnett <nickg@cygnus.co.uk> * src/vectors.S: Added underscore to reference to
--- a/packages/hal/mn10300/arch/current/include/arch.inc +++ b/packages/hal/mn10300/arch/current/include/arch.inc @@ -25,7 +25,7 @@ # # The Initial Developer of the Original Code is Red Hat. # Portions created by Red Hat are -# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. # All Rights Reserved. # ------------------------------------------- #
--- a/packages/hal/mn10300/arch/current/include/hal_io.h +++ b/packages/hal/mn10300/arch/current/include/hal_io.h @@ -52,6 +52,7 @@ #ifndef __ASSEMBLER__ #include <cyg/infra/cyg_type.h> +#include <cyg/hal/plf_io.h> #endif //-----------------------------------------------------------------------------
--- a/packages/hal/mn10300/arch/current/src/vectors.S +++ b/packages/hal/mn10300/arch/current/src/vectors.S @@ -23,7 +23,7 @@ # # The Initial Developer of the Original Code is Red Hat. # Portions created by Red Hat are -# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. # All Rights Reserved. # ------------------------------------------- # @@ -32,7 +32,7 @@ #######DESCRIPTIONBEGIN#### ## ## Author(s): nickg -## Contributors: nickg, dmoseley +## Contributors: nickg, dmoseley, dhowells ## Date: 1997-10-16 ## Purpose: MN10300 exception vectors ## Description: This file defines the code placed into the exception @@ -53,6 +53,7 @@ #endif #include <cyg/hal/arch.inc> +#include <cyg/hal/basetype.h> ##----------------------------------------------------------------------------- @@ -121,35 +122,74 @@ #endif // CYGPKG_CYGMON ##----------------------------------------------------------------------------- +#define EXCEPTION_HANDLER(VECTOR,NAME,HANDLER) .org VECTOR; \ +NAME##_vector: \ +jmp HANDLER .section ".vectors","ax" - + .globl reset_vector - -reset_vector: + + .org 0x000 +reset_vector: # Reset vector jmp _start - .p2align 3 - - # NMI vector - jmp __nmi - - .p2align 3 - - # Trap vector - jmp __trap - -#ifdef CYGPKG_CYGMON -#ifdef CYGPKG_HAL_MN10300_AM33 +EXCEPTION_HANDLER(0x008, nmi ,__nmi) +EXCEPTION_HANDLER(0x010, trap ,__trap) +EXCEPTION_HANDLER(0x100, ins_tlb_miss_exception ,__unknown) +EXCEPTION_HANDLER(0x108, data_tlb_miss_exception ,__unknown) +EXCEPTION_HANDLER(0x110, ins_access_exception ,__unknown) +EXCEPTION_HANDLER(0x118, data_access_exception ,__unknown) +EXCEPTION_HANDLER(0x160, priv_ins_exception ,__unknown) +EXCEPTION_HANDLER(0x168, unimpl_ins_exception ,__unknown) +EXCEPTION_HANDLER(0x170, unimpl_ext_ins_exception ,__unknown) +EXCEPTION_HANDLER(0x180, misalignment_exception ,__unknown) +EXCEPTION_HANDLER(0x188, bus_error ,__unknown) +EXCEPTION_HANDLER(0x190, illegal_ins_access_exception ,__unknown) +EXCEPTION_HANDLER(0x198, illegal_data_access_exception ,__unknown) +EXCEPTION_HANDLER(0x1a0, iospace_ins_access_exception ,__unknown) +EXCEPTION_HANDLER(0x1a8, priv_space_ins_access_exception ,__unknown) +EXCEPTION_HANDLER(0x1b0, priv_space_data_access_exception ,__unknown) +EXCEPTION_HANDLER(0x1b8, data_space_ins_access_exception ,__unknown) +EXCEPTION_HANDLER(0x1c0, fpu_disabled_exception ,__unknown) +EXCEPTION_HANDLER(0x1c8, fpu_unimplemented_exception ,__unknown) +EXCEPTION_HANDLER(0x1d0, fpu_operation_exception ,__unknown) +EXCEPTION_HANDLER(0x200, double_fault ,__unknown) +EXCEPTION_HANDLER(0x240, wdt_overflow ,__unknown) +EXCEPTION_HANDLER(0x248, nmi_pin ,__nmi) +EXCEPTION_HANDLER(0x280, maskable_int0 ,__unknown) +EXCEPTION_HANDLER(0x288, maskable_int1 ,__unknown) +EXCEPTION_HANDLER(0x290, maskable_int2 ,__unknown) +EXCEPTION_HANDLER(0x298, maskable_int3 ,__unknown) +EXCEPTION_HANDLER(0x2a0, maskable_int4 ,__unknown) +EXCEPTION_HANDLER(0x2a8, maskable_int5 ,__unknown) +EXCEPTION_HANDLER(0x2b0, maskable_int6 ,__unknown) + // We need to put the syscall handler at 0x300 // For cygmon, we will use the am33 "syscall 0" as the syscall trap. - .p2align 8 - .rept 0x200 - nop - .endr - jmp __nmi -#endif +EXCEPTION_HANDLER(0x300, syscall0 ,__nmi) +EXCEPTION_HANDLER(0x308, syscall1 ,__unknown) +EXCEPTION_HANDLER(0x310, syscall2 ,__unknown) +EXCEPTION_HANDLER(0x318, syscall3 ,__unknown) +EXCEPTION_HANDLER(0x320, syscall4 ,__unknown) +EXCEPTION_HANDLER(0x328, syscall5 ,__unknown) +EXCEPTION_HANDLER(0x330, syscall6 ,__unknown) +EXCEPTION_HANDLER(0x338, syscall7 ,__unknown) +EXCEPTION_HANDLER(0x340, syscall8 ,__unknown) +EXCEPTION_HANDLER(0x348, syscall9 ,__unknown) +EXCEPTION_HANDLER(0x350, syscalla ,__unknown) +EXCEPTION_HANDLER(0x358, syscallb ,__unknown) +EXCEPTION_HANDLER(0x360, syscallc ,__unknown) +EXCEPTION_HANDLER(0x368, syscalld ,__unknown) +EXCEPTION_HANDLER(0x370, syscalle ,__unknown) +EXCEPTION_HANDLER(0x378, syscallf ,__unknown) + +##----------------------------------------------------------------------------- +## unknown interrupt or exception vector +__unknown: +#ifdef CYG_HAL_HANDLE_UNKNOWN_INT_DEFINED + hal_handle_unknown_int #endif ##-----------------------------------------------------------------------------
deleted file mode 100644 --- a/packages/hal/mn10300/stb/current/misc/stubrom.perm +++ /dev/null @@ -1,26 +0,0 @@ -# -# A configuration for building a GDB stub ROM for the STB board. -# -# To build the ROMs: -# 1. Create a build directory and cd into it. -# 2. Run: permtest.tcl --srcdir=<sourcedir> <sourcedir>/hal/mn10300/stb/current/misc/stubrom.perm -# Where <sourcedir> is the path to your source repository. -# 3. Run: make -# 4. Run: make -C hal/common/current/src/stubrom -# -# The file hal/common/current/src/stubrom/stubrom will be an ELF excutable of the ROM. -# Use objcopy to convert this to the appropriate format for your PROM burner. -# Enjoy! -# -# If you do not have permtest.tcl, then run the pkgconf command by hand and -# then edit pkgconf/hal.h to enable/disable the options as shown. -# - -pkgconf --target=mn10300_am33 --platform=stb --startup=rom --disable-kernel --disable-uitron --disable-libc --disable-libm --disable-io --disable-io_serial --disable-wallclock --disable-watchdog - -header hal.h { - enable CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS - enable CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT - disable CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT - enable CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT -}
--- a/packages/hal/sh/sh3/current/ChangeLog +++ b/packages/hal/sh/sh3/current/ChangeLog @@ -1,3 +1,7 @@ +2001-07-26 Jesper Skov <jskov@redhat.com> + + * include/var_cache.h: Fix cache query function. + 2001-07-18 Jesper Skov <jskov@redhat.com> * src/var_misc.c (cyg_var_enable_caches): Small hack to prevent
--- a/packages/hal/sh/sh3/current/include/var_cache.h +++ b/packages/hal/sh/sh3/current/include/var_cache.h @@ -107,10 +107,11 @@ externC void cyg_hal_cache_write_mode(in #define HAL_UCACHE_SYNC() cyg_hal_cache_sync() // Query the state of the cache (does not affect the caching) -#define HAL_UCACHE_IS_ENABLED(_state_) \ - CYG_MACRO_START \ - HAL_READ_UINT32(CYGARC_REG_CCR, (_state_)); \ - (_state_) &= ~CYGARC_REG_CCR_CE; \ +#define HAL_UCACHE_IS_ENABLED(_state_) \ + CYG_MACRO_START \ + cyg_uint32 _tmp; \ + HAL_READ_UINT32(CYGARC_REG_CCR, _tmp); \ + (_state_) = (_tmp & CYGARC_REG_CCR_CE) ? 1 : 0; \ CYG_MACRO_END // Set the cache refill burst size
--- a/packages/hal/sh/sh4/current/ChangeLog +++ b/packages/hal/sh/sh4/current/ChangeLog @@ -1,3 +1,25 @@ +2001-07-26 Jesper Skov <jskov@redhat.com> + + * include/var_cache.h: Define flash cache macros that also disable + instruction cache. Not at all clear to me why it should make a + difference, but it does. + + * src/var_misc.c (cyg_var_enable_caches): Don't allow caches to be + enabled when the flash IO driver has been included. This is a + temporary workaround for an unidentified caching problem. + (cyg_var_enable_caches): Enabled again. + + * include/var_cache.h: Fix cache enabled query macros. + +2001-07-25 Jesper Skov <jskov@redhat.com> + + * include/var_intr.h: Define CYGPRI_HAL_INTERRUPT_UPDATE_LEVEL_PLF + if the platform didn't. + +2001-07-24 Jesper Skov <jskov@redhat.com> + + * src/var_misc.c: Allow platform to handle IRL vectors. + 2001-07-18 Jesper Skov <jskov@redhat.com> * src/var_misc.c (cyg_var_enable_caches): Small hack to prevent
--- a/packages/hal/sh/sh4/current/include/var_cache.h +++ b/packages/hal/sh/sh4/current/include/var_cache.h @@ -115,10 +115,11 @@ externC void cyg_hal_dcache_write_mode(i #define HAL_DCACHE_SYNC() cyg_hal_dcache_sync() // Query the state of the cache (does not affect the caching) -#define HAL_DCACHE_IS_ENABLED(_state_) \ - CYG_MACRO_START \ - HAL_READ_UINT32(CYGARC_REG_CCR, (_state_)); \ - (_state_) &= ~CYGARC_REG_CCR_OCE; \ +#define HAL_DCACHE_IS_ENABLED(_state_) \ + CYG_MACRO_START \ + cyg_uint32 _tmp; \ + HAL_READ_UINT32(CYGARC_REG_CCR, _tmp); \ + (_state_) = (_tmp & CYGARC_REG_CCR_OCE) ? 1 : 0; \ CYG_MACRO_END // Set the cache refill burst size @@ -203,10 +204,11 @@ externC void cyg_hal_icache_invalidate_a #define HAL_ICACHE_SYNC() HAL_ICACHE_INVALIDATE_ALL() // Query the state of the cache (does not affect the caching) -#define HAL_ICACHE_IS_ENABLED(_state_) \ - CYG_MACRO_START \ - HAL_READ_UINT32(CYGARC_REG_CCR, (_state_)); \ - (_state_) &= ~CYGARC_REG_CCR_ICE; \ +#define HAL_ICACHE_IS_ENABLED(_state_) \ + CYG_MACRO_START \ + cyg_uint32 _tmp; \ + HAL_READ_UINT32(CYGARC_REG_CCR, _tmp); \ + (_state_) = (_tmp & CYGARC_REG_CCR_ICE) ? 1 : 0; \ CYG_MACRO_END // Set the instruction cache refill burst size @@ -230,5 +232,25 @@ externC void cyg_hal_icache_invalidate_a //#define HAL_ICACHE_INVALIDATE( _base_ , _size_ ) //----------------------------------------------------------------------------- +// Flash related cache macros + +#define HAL_FLASH_CACHES_OFF(_d_, _i_) \ + CYG_MACRO_START \ + HAL_ICACHE_IS_ENABLED(_i_); \ + HAL_DCACHE_IS_ENABLED(_d_); \ + HAL_DCACHE_SYNC(); \ + HAL_DCACHE_INVALIDATE_ALL(); \ + HAL_DCACHE_DISABLE(); \ + HAL_ICACHE_INVALIDATE_ALL(); \ + HAL_ICACHE_DISABLE(); \ + CYG_MACRO_END + +#define HAL_FLASH_CACHES_ON(_d_, _i_) \ + CYG_MACRO_START \ + if (_d_) HAL_DCACHE_ENABLE(); \ + if (_i_) HAL_ICACHE_ENABLE(); \ + CYG_MACRO_END + +//----------------------------------------------------------------------------- #endif // ifndef CYGONCE_VAR_CACHE_H // End of var_cache.h
--- a/packages/hal/sh/sh4/current/include/var_intr.h +++ b/packages/hal/sh/sh4/current/include/var_intr.h @@ -55,8 +55,15 @@ // More include statements below. First part of this file must be // usable for both assembly and C files, so only use defines here. + +//-------------------------------------------------------------------------- +// Optional platform overrides and fallbacks #include <cyg/hal/plf_intr.h> +#ifndef CYGPRI_HAL_INTERRUPT_UPDATE_LEVEL_PLF +# define CYGPRI_HAL_INTERRUPT_UPDATE_LEVEL_PLF(x,y) +#endif + //-------------------------------------------------------------------------- // Additional SH4 exception vectors. // These are identified with event values 0x800 and 0x820, so we need to
--- a/packages/hal/sh/sh4/current/src/var_misc.c +++ b/packages/hal/sh/sh4/current/src/var_misc.c @@ -108,12 +108,6 @@ hal_interrupt_update_level(int vector) level = cyg_hal_IMASK_table[vector] ? cyg_hal_ILVL_table[vector] : 0; switch( (vector) ) { - case CYGNUM_HAL_INTERRUPT_NMI: - /* fall through */ - case CYGNUM_HAL_INTERRUPT_LVL0 ... CYGNUM_HAL_INTERRUPT_LVL14: - /* Cannot change levels */ - break; - /* IPRA */ case CYGNUM_HAL_INTERRUPT_TMU0_TUNI0: HAL_READ_UINT16(CYGARC_REG_IPRA, iprX); @@ -206,6 +200,13 @@ hal_interrupt_update_level(int vector) case CYGNUM_HAL_INTERRUPT_RESERVED_6E0: /* Do nothing for these reserved vectors. */ break; + + // Platform extensions + CYGPRI_HAL_INTERRUPT_UPDATE_LEVEL_PLF(vector, level) + + default: + CYG_FAIL("Unknown interrupt vector"); + break; } } @@ -226,10 +227,12 @@ hal_interrupt_mask(int vector) { switch( vector ) { case CYGNUM_HAL_INTERRUPT_NMI: - /* fall through */ + break; case CYGNUM_HAL_INTERRUPT_LVL0 ... CYGNUM_HAL_INTERRUPT_LVL14: - /* Can only be masked by fiddling Imask in SR. */ - break; + /* Normally can only be masked by fiddling Imask in SR, + but some platforms use external interrupt controller, + so allow regular handling. */ + // fall through case CYGNUM_HAL_INTERRUPT_TMU0_TUNI0 ... CYGNUM_HAL_ISR_MAX: cyg_hal_IMASK_table[vector] = 0; hal_interrupt_update_level(vector); @@ -249,10 +252,12 @@ hal_interrupt_unmask(int vector) { switch( (vector) ) { case CYGNUM_HAL_INTERRUPT_NMI: - /* fall through */ + break; case CYGNUM_HAL_INTERRUPT_LVL0 ... CYGNUM_HAL_INTERRUPT_LVL14: - /* Can only be unmasked by fiddling Imask in SR. */ - break; + /* Normally can only be masked by fiddling Imask in SR, + but some platforms use external interrupt controller, + so allow regular handling. */ + // fall through case CYGNUM_HAL_INTERRUPT_TMU0_TUNI0 ... CYGNUM_HAL_ISR_MAX: cyg_hal_IMASK_table[vector] = 1; hal_interrupt_update_level(vector);
--- a/packages/io/fileio/current/ChangeLog +++ b/packages/io/fileio/current/ChangeLog @@ -1,3 +1,8 @@ +2001-07-26 Jonathan Larmour <jlarmour@redhat.com> + + * cdl/fileio.cdl: Implements select(). + * src/select.cxx: Include <sys/select.h> from isoinfra. + 2001-07-19 Jonathan Larmour <jlarmour@redhat.com> * src/devfs.cxx (dev_fo_read): Treat non-blocking reads returning
--- a/packages/io/fileio/current/cdl/fileio.cdl +++ b/packages/io/fileio/current/cdl/fileio.cdl @@ -55,6 +55,7 @@ cdl_package CYGPKG_IO_FILEIO { implements CYGINT_ISO_FCNTL implements CYGINT_ISO_OPEN implements CYGINT_ISO_DIRENT + implements CYGINT_ISO_SELECT requires { CYGBLD_ISO_DIRENT_HEADER == "<cyg/fileio/dirent.h>" } requires { CYGBLD_ISO_OPEN_MAX_HEADER == "<cyg/fileio/limits.h>" }
--- a/packages/io/fileio/current/src/select.cxx +++ b/packages/io/fileio/current/src/select.cxx @@ -52,10 +52,12 @@ #include <cyg/infra/cyg_trac.h> // tracing macros #include <cyg/infra/cyg_ass.h> // assertion macros -#include <stdarg.h> // for fcntl() +#include <stdarg.h> // for fcntl() #include "fio.h" // Private header +#include <sys/select.h> // select header + #include <cyg/kernel/sched.hxx> // scheduler definitions #include <cyg/kernel/thread.hxx> // thread definitions #include <cyg/kernel/mutex.hxx> // mutex definitions
--- a/packages/io/flash/current/ChangeLog +++ b/packages/io/flash/current/ChangeLog @@ -1,3 +1,17 @@ +2001-07-23 David Howells <dhowells@redhat.com> + + * cdl/io_flash.cdl: Added software write protect option. + * include/flash.h: Ditto. + * src/flash.c: Added software write protect option and bank + support, and prevented low-level writes from being handed + cross-block data chunks. + +2001-07-20 Gary Thomas <gthomas@redhat.com> + + * include/flash.h: + * cdl/io_flash.cdl: Name convention: CYGINT_FLASH_WORKSPACE_SIZE + renamed to be CYGNUM_FLASH_WORKSPACE_SIZE. + 2001-07-19 Gary Thomas <gthomas@redhat.com> * include/flash.h:
--- a/packages/io/flash/current/cdl/io_flash.cdl +++ b/packages/io/flash/current/cdl/io_flash.cdl @@ -23,7 +23,7 @@ # # The Initial Developer of the Original Code is Red Hat. # Portions created by Red Hat are -# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. # All Rights Reserved. # ------------------------------------------- # @@ -51,13 +51,13 @@ cdl_package CYGPKG_IO_FLASH { compile flash.c define_proc { - puts $::cdl_header "#include <pkgconf/system.h>" - puts $::cdl_header "#ifdef CYGDAT_IO_FLASH_DEVICE_HEADER" - puts $::cdl_header "# include CYGDAT_IO_FLASH_DEVICE_HEADER" - puts $::cdl_header "#endif " + puts $::cdl_header "#include <pkgconf/system.h>" + puts $::cdl_header "#ifdef CYGDAT_IO_FLASH_DEVICE_HEADER" + puts $::cdl_header "# include CYGDAT_IO_FLASH_DEVICE_HEADER" + puts $::cdl_header "#endif " } - cdl_option CYGINT_FLASH_WORKSPACE_SIZE { + cdl_option CYGNUM_FLASH_WORKSPACE_SIZE { display "Extra memory required by FLASH device drivers" flavor data default_value 0x1000 @@ -74,7 +74,7 @@ cdl_package CYGPKG_IO_FLASH { display "Hardware FLASH device drivers" description " This option enables the hardware device drivers - for the current platform." + for the current platform." } cdl_interface CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM { @@ -102,4 +102,13 @@ cdl_package CYGPKG_IO_FLASH { Selecting this option will cause verification of data programmed to flash." } + cdl_option CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT { + display "Platform has flash soft DIP switch write-protect" + flavor bool + default_value 0 + description " + Selecting this option will cause the state of a hardware jumper or + dipswitch to be read by software to determine whether the flash is + write-protected or not." + } }
--- a/packages/io/flash/current/include/flash.h +++ b/packages/io/flash/current/include/flash.h @@ -23,7 +23,7 @@ // // The Initial Developer of the Original Code is Red Hat. // Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. // All Rights Reserved. // ------------------------------------------- // @@ -49,7 +49,7 @@ typedef int _printf(char* fmt, ...); -#define FLASH_MIN_WORKSPACE CYGINT_FLASH_WORKSPACE_SIZE // Space used by FLASH code +#define FLASH_MIN_WORKSPACE CYGNUM_FLASH_WORKSPACE_SIZE // Space used by FLASH code externC int flash_init(void *work_space, int work_space_length, _printf *pf); externC int flash_erase(void *base, int len, void **err_address); @@ -116,6 +116,14 @@ extern void CYGIMP_FLASH_DISABLE(void *, #define FLASH_Disable(_start_, _end_) #endif +// +// Some platforms have a DIP switch or jumper that tells the software that +// the flash is write protected. +// +#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT +externC cyg_bool plf_flash_query_soft_wp(void *addr, int len); +#endif + //--------------------------------------------------------------------------- // Execution of flash code must be done inside a // HAL_FLASH_CACHES_OFF/HAL_FLASH_CACHES_ON region - disabling the
--- a/packages/io/flash/current/src/flash.c +++ b/packages/io/flash/current/src/flash.c @@ -102,10 +102,10 @@ flash_dev_query(void* data) #ifdef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM { extern char flash_query[], flash_query_end[]; - int code_len; + CYG_ADDRESS code_len; // Query the device driver - copy 'query' code to RAM for execution - code_len = (unsigned long)&flash_query_end - (unsigned long)&flash_query; + code_len = (CYG_ADDRESS)&flash_query_end - (CYG_ADDRESS)&flash_query; _flash_query = (code_fun *)flash_info.work_space; memcpy(_flash_query, &flash_query, code_len); } @@ -127,8 +127,8 @@ flash_verify_addr(void *target) if (!flash_info.init) { return FLASH_ERR_NOT_INIT; } - if (((unsigned long)target >= (unsigned long)flash_info.start) && - ((unsigned long)target < (unsigned long)flash_info.end)) { + if (((CYG_ADDRESS)target >= (CYG_ADDRESS)flash_info.start) && + ((CYG_ADDRESS)target < (CYG_ADDRESS)flash_info.end)) { return FLASH_ERR_OK; } else { return FLASH_ERR_INVALID; @@ -170,13 +170,18 @@ flash_erase(void *addr, int len, void ** return FLASH_ERR_NOT_INIT; } +#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT + if (plf_flash_query_soft_wp(addr,len)) + return FLASH_ERR_PROTECT; +#endif + #ifdef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM { extern char flash_erase_block[], flash_erase_block_end[]; - int code_len; + CYG_ADDRESS code_len; // Copy 'erase' code to RAM for execution - code_len = (unsigned long)&flash_erase_block_end - (unsigned long)&flash_erase_block; + code_len = (CYG_ADDRESS)&flash_erase_block_end - (CYG_ADDRESS)&flash_erase_block; _flash_erase_block = (code_fun *)flash_info.work_space; memcpy(_flash_erase_block, &flash_erase_block, code_len); } @@ -187,8 +192,8 @@ flash_erase(void *addr, int len, void ** } #endif - block = (unsigned short *)((unsigned long)addr & flash_info.block_mask); - end_addr = (unsigned short *)((unsigned long)addr+len); + block = (unsigned short *)((CYG_ADDRESS)addr & flash_info.block_mask); + end_addr = (unsigned short *)((CYG_ADDRESS)addr+len); (*flash_info.pf)("... Erase from %p-%p: ", (void*)block, (void*)end_addr); @@ -216,22 +221,28 @@ flash_program(void *_addr, void *_data, { int stat = 0; int size; - typedef int code_fun(unsigned short *, unsigned short *, int, unsigned long, int); + typedef int code_fun(void *, void *, int, unsigned long, int); code_fun *_flash_program_buf; - unsigned short *addr = (unsigned short *)_addr; - unsigned short *data = (unsigned short *)_data; + unsigned char *addr = (unsigned char *)_addr; + unsigned char *data = (unsigned char *)_data; + CYG_ADDRESS tmp; int d_cache, i_cache; if (!flash_info.init) { return FLASH_ERR_NOT_INIT; } +#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT + if (plf_flash_query_soft_wp(addr,len)) + return FLASH_ERR_PROTECT; +#endif + #ifdef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM { - int code_len; + CYG_ADDRESS code_len; extern char flash_program_buf[], flash_program_buf_end[]; // Copy 'program' code to RAM for execution - code_len = (unsigned long)&flash_program_buf_end - (unsigned long)&flash_program_buf; + code_len = (CYG_ADDRESS)&flash_program_buf_end - (CYG_ADDRESS)&flash_program_buf; _flash_program_buf = (code_fun *)flash_info.work_space; memcpy(_flash_program_buf, &flash_program_buf, code_len); } @@ -243,14 +254,21 @@ flash_program(void *_addr, void *_data, #endif (*flash_info.pf)("... Program from %p-%p at %p: ", (void*)data, - (void*)(((unsigned long)data)+len), (void*)addr); + (void*)(((CYG_ADDRESS)data)+len), (void*)addr); HAL_FLASH_CACHES_OFF(d_cache, i_cache); - FLASH_Enable(addr, addr+len); + FLASH_Enable((unsigned short*)addr, (unsigned short *)(addr+len)); while (len > 0) { size = len; if (size > flash_info.block_size) size = flash_info.block_size; + tmp = (CYG_ADDRESS)addr & ~flash_info.block_mask; + if (tmp) { + tmp = flash_info.block_size - tmp; + if (size>tmp) size = tmp; + + } + stat = (*_flash_program_buf)(addr, data, size, flash_info.block_mask, flash_info.buffer_size); stat = flash_hwr_map_error(stat); @@ -270,7 +288,7 @@ flash_program(void *_addr, void *_data, addr += size/sizeof(*addr); data += size/sizeof(*data); } - FLASH_Disable(addr, addr+len); + FLASH_Disable((unsigned short*)addr, (unsigned short *)(addr+len)); HAL_FLASH_CACHES_ON(d_cache, i_cache); (*flash_info.pf)("\n"); return (stat); @@ -291,12 +309,17 @@ flash_lock(void *addr, int len, void **e return FLASH_ERR_NOT_INIT; } +#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT + if (plf_flash_query_soft_wp(addr,len)) + return FLASH_ERR_PROTECT; +#endif + #ifdef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM { extern char flash_lock_block[], flash_lock_block_end[]; - int code_len; + CYG_ADDRESS code_len; // Copy 'lock' code to RAM for execution - code_len = (unsigned long)&flash_lock_block_end - (unsigned long)&flash_lock_block; + code_len = (CYG_ADDRESS)&flash_lock_block_end - (CYG_ADDRESS)&flash_lock_block; _flash_lock_block = (code_fun *)flash_info.work_space; memcpy(_flash_lock_block, &flash_lock_block, code_len); } @@ -307,8 +330,8 @@ flash_lock(void *addr, int len, void **e } #endif - block = (unsigned short *)((unsigned long)addr & flash_info.block_mask); - end_addr = (unsigned short *)((unsigned long)addr+len); + block = (unsigned short *)((CYG_ADDRESS)addr & flash_info.block_mask); + end_addr = (unsigned short *)((CYG_ADDRESS)addr+len); (*flash_info.pf)("... Lock from %p-%p: ", block, end_addr); @@ -343,12 +366,17 @@ flash_unlock(void *addr, int len, void * return FLASH_ERR_NOT_INIT; } +#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT + if (plf_flash_query_soft_wp(addr,len)) + return FLASH_ERR_PROTECT; +#endif + #ifdef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM { extern char flash_unlock_block[], flash_unlock_block_end[]; - int code_len; + CYG_ADDRESS code_len; // Copy 'lock' code to RAM for execution - code_len = (unsigned long)&flash_unlock_block_end - (unsigned long)&flash_unlock_block; + code_len = (CYG_ADDRESS)&flash_unlock_block_end - (CYG_ADDRESS)&flash_unlock_block; _flash_unlock_block = (code_fun *)flash_info.work_space; memcpy(_flash_unlock_block, &flash_unlock_block, code_len); } @@ -359,8 +387,8 @@ flash_unlock(void *addr, int len, void * } #endif - block = (unsigned short *)((unsigned long)addr & flash_info.block_mask); - end_addr = (unsigned short *)((unsigned long)addr+len); + block = (unsigned short *)((CYG_ADDRESS)addr & flash_info.block_mask); + end_addr = (unsigned short *)((CYG_ADDRESS)addr+len); (*flash_info.pf)("... Unlock from %p-%p: ", block, end_addr);
--- a/packages/io/wallclock/current/ChangeLog +++ b/packages/io/wallclock/current/ChangeLog @@ -1,3 +1,10 @@ +2001-07-27 Jesper Skov <jskov@redhat.com> + + * include/wallclock/wallclock.inl (_simple_mktime): Added some assertions. + (_simple_mktime): Adjust assertions to correct and more sensible + values. + (_simple_mktime): A few more assertion tweaks. + 2001-06-21 Jonathan Larmour <jlarmour@redhat.com> * tests/wallclock2.cxx: No need to check for CYGINT_LIBC_STARTUP_CONTEXT
--- a/packages/io/wallclock/current/include/wallclock/wallclock.inl +++ b/packages/io/wallclock/current/include/wallclock/wallclock.inl @@ -44,6 +44,7 @@ //========================================================================== #include <cyg/infra/cyg_type.h> +#include <cyg/infra/cyg_ass.h> // assertions // ------------------------------------------------------------------------- // Some helper functions @@ -68,6 +69,13 @@ static time_t time_t secs; cyg_uint32 y, m, days; + CYG_ASSERT(year <= 3124, "Year is unreasonably large"); + CYG_ASSERT(mon <= 12, "Month is invalid"); + CYG_ASSERT(day <= 31, "Day is invalid"); + CYG_ASSERT(hour <= 23, "Hour is invalid"); + CYG_ASSERT(min <= 59, "Minutes is invalid"); + CYG_ASSERT(sec <= 62, "Seconds is invalid"); + // Number of days due to years days = 0; for (y = 1970; y < year; y++)
--- a/packages/isoinfra/current/ChangeLog +++ b/packages/isoinfra/current/ChangeLog @@ -1,3 +1,12 @@ +2001-07-26 Jonathan Larmour <jlarmour@redhat.com> + + * include/sys/types.h: Move select() related stuff into separate + sys/select header. Include it still for now. + * include/sys/select.h: New header, as per upcoming POSIX 200x standard. + + * cdl/isoinfra.cdl: Add configury for select() and poll(). + + 2001-07-20 Jonathan Larmour <jlarmour@redhat.com> * include/stdlib.h: Use correct macro names for abs and div.
--- a/packages/isoinfra/current/cdl/isoinfra.cdl +++ b/packages/isoinfra/current/cdl/isoinfra.cdl @@ -1056,6 +1056,38 @@ cdl_package CYGPKG_ISOINFRA { } # ==================================================================== + + cdl_component CYGPKG_ISO_SELECT { + display "select()/poll() functions" + flavor none + no_define + + cdl_interface CYGINT_ISO_SELECT { + display "select() implementations" + flavor booldata + requires { 1 >= CYGINT_ISO_SELECT } + } + + cdl_option CYGBLD_ISO_SELECT_HEADER { + display "select() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_POLL { + display "poll() implementations" + flavor booldata + requires { 1 >= CYGINT_ISO_POLL } + } + + cdl_option CYGBLD_ISO_POLL_HEADER { + display "poll() implementation header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== cdl_component CYGPKG_ISOINFRA_OPTIONS { display "Build options"
new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/sys/select.h @@ -0,0 +1,124 @@ +#ifndef CYGONCE_ISO_SYS_SELECT_H +#define CYGONCE_ISO_SYS_SELECT_H +/*======================================================================== +// +// sys/select.h +// +// POSIX definitions for select() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2001-07-26 +// Purpose: This file provides the macros, types and functions +// required by POSIX 1003.1. +// Description: Much of the real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include <sys/select.h> +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include <pkgconf/isoinfra.h> /* Configuration header */ + + +/* ------------------------------------------------------------------- */ + +#if !defined(_POSIX_SOURCE) + +#ifdef CYGINT_ISO_SELECT +# ifdef CYGBLD_ISO_SELECT_HEADER +# include CYGBLD_ISO_SELECT_HEADER +# else + +#define NBBY 8 /* number of bits in a byte */ + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). + * FD_SETSIZE may be defined by the user, but the default here should + * be enough for most uses. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 256 +#endif + +typedef unsigned int fd_mask; +#define __NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ + +#ifndef __howmany +#define __howmany(__x, __y) (((__x) + ((__y) - 1)) / (__y)) +#endif + +typedef struct fd_set { + fd_mask fds_bits[__howmany(FD_SETSIZE, __NFDBITS)]; +} fd_set; + +#define FD_SET(__n, __p) ((__p)->fds_bits[(__n)/__NFDBITS] |= (1 << ((__n) % __NFDBITS))) +#define FD_CLR(__n, __p) ((__p)->fds_bits[(__n)/__NFDBITS] &= ~(1 << ((__n) % __NFDBITS))) +#define FD_ISSET(__n, __p) ((__p)->fds_bits[(__n)/__NFDBITS] & (1 << ((__n) % __NFDBITS))) + +#define FD_COPY(__f, __t) \ +{ \ + unsigned int _i; \ + for( _i = 0; _i < __howmany(FD_SETSIZE, __NFDBITS) ; _i++ ) \ + (__t)->fds_bits[_i] = (__f)->fds_bits[_i]; \ +} + +#define FD_ZERO(__p) \ +{ \ + unsigned int _i; \ + for( _i = 0; _i < __howmany(FD_SETSIZE, __NFDBITS) ; _i++ ) \ + (__p)->fds_bits[_i] = 0; \ +} + +# ifdef __cplusplus +extern "C" { +# endif + +struct timeval; +extern int +select( int /* nfd */, fd_set * /* in */, fd_set * /* out */, + fd_set * /* ex */, struct timeval * /* tv */ ); + +# ifdef __cplusplus +} /* extern "C" */ +# endif +# endif +#endif + +#endif /* if !defined(_POSIX_SOURCE) */ +/* ------------------------------------------------------------------- */ +#endif /* CYGONCE_ISO_SYS_SELECT_H multiple inclusion protection */ + +/* EOF sys/select.h */
--- a/packages/isoinfra/current/include/sys/types.h +++ b/packages/isoinfra/current/include/sys/types.h @@ -87,57 +87,15 @@ typedef int pid_t; # include CYGBLD_ISO_PTHREADTYPES_HEADER #endif -#if !defined(_POSIX_SOURCE) - -#define NBBY 8 /* number of bits in a byte */ - -/* - * Select uses bit masks of file descriptors in longs. These macros - * manipulate such bit fields (the filesystem macros use chars). - * FD_SETSIZE may be defined by the user, but the default here should - * be enough for most uses. - */ -#ifndef FD_SETSIZE -#define FD_SETSIZE 256 -#endif - -typedef unsigned int fd_mask; -#define __NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ - -#ifndef __howmany -#define __howmany(x, y) (((x) + ((y) - 1)) / (y)) -#endif - -typedef struct fd_set { - fd_mask fds_bits[__howmany(FD_SETSIZE, __NFDBITS)]; -} fd_set; +/* Include <sys/select.h> for backward compatibility for now */ +#include <sys/select.h> -#define FD_SET(n, p) ((p)->fds_bits[(n)/__NFDBITS] |= (1 << ((n) % __NFDBITS))) -#define FD_CLR(n, p) ((p)->fds_bits[(n)/__NFDBITS] &= ~(1 << ((n) % __NFDBITS))) -#define FD_ISSET(n, p) ((p)->fds_bits[(n)/__NFDBITS] & (1 << ((n) % __NFDBITS))) - -#define FD_COPY(f, t) \ -{ \ - unsigned int _i; \ - for( _i = 0; _i < __howmany(FD_SETSIZE, __NFDBITS) ; _i++ ) \ - (t)->fds_bits[_i] = (f)->fds_bits[_i]; \ -} - -#define FD_ZERO(p) \ -{ \ - unsigned int _i; \ - for( _i = 0; _i < __howmany(FD_SETSIZE, __NFDBITS) ; _i++ ) \ - (p)->fds_bits[_i] = 0; \ -} - -#define CYG_FD_SET_DEFINED 1 - -#if CYGINT_ISO_BSDTYPES -# ifdef CYGBLD_ISO_BSDTYPES_HEADER -# include CYGBLD_ISO_BSDTYPES_HEADER +#if !defined(_POSIX_SOURCE) +# if CYGINT_ISO_BSDTYPES +# ifdef CYGBLD_ISO_BSDTYPES_HEADER +# include CYGBLD_ISO_BSDTYPES_HEADER +# endif # endif -#endif - #endif // !defined(_POSIX_SOURCE) #endif /* CYGONCE_ISO_SYS_TYPES_H multiple inclusion protection */
--- a/packages/kernel/current/ChangeLog +++ b/packages/kernel/current/ChangeLog @@ -1,3 +1,13 @@ +2001-07-27 Jesper Skov <jskov@redhat.com> + + * src/intr/intr.cxx (chain_isr): Return isr_ret so caller (which + may be an arbiter) can tell if the interrupt was handled. + +2001-07-26 Gary Thomas <gthomas@redhat.com> + + * src/common/clock.cxx (dsr): Fix problems mixing signed and + unsigned values. Normally only generated warnings, but... + 2001-07-09 Jonathan Larmour <jlarmour@redhat.com> * include/sched.inl (unlock_reschedule): Fix commenting.
--- a/packages/kernel/current/src/common/clock.cxx +++ b/packages/kernel/current/src/common/clock.cxx @@ -869,8 +869,8 @@ void Cyg_RealTimeClock::dsr(cyg_vector v #if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_DSR_LATENCY) if (measure_clock_latency) { - cyg_uint32 delta; - HAL_CLOCK_READ(&delta); + cyg_int32 delta; + HAL_CLOCK_READ((cyg_uint32 *)&delta); delta -= clock_dsr_start; // Note: Ignore a latency of <= 0 when finding min_clock_latency. if (delta > 0 ) {
--- a/packages/kernel/current/src/intr/intr.cxx +++ b/packages/kernel/current/src/intr/intr.cxx @@ -364,7 +364,8 @@ Cyg_Interrupt::chain_isr(cyg_vector vect HAL_DEFAULT_ISR( vector, 0 ); } #endif - return 0; + + return isr_ret & ~Cyg_Interrupt::CALL_DSR; } #endif
--- a/packages/language/c/libc/stdio/current/ChangeLog +++ b/packages/language/c/libc/stdio/current/ChangeLog @@ -1,3 +1,8 @@ +2001-07-27 Jesper Skov <jskov@redhat.com> + + * src/common/fflush.cxx (cyg_libc_stdio_flush_all_but): The check + for last operation being a read is only valid in buffered IO mode. + 2001-07-20 Jonathan Larmour <jlarmour@redhat.com> * include/stream.inl (set_position): Take read buffer into account
--- a/packages/language/c/libc/stdio/current/src/common/fflush.cxx +++ b/packages/language/c/libc/stdio/current/src/common/fflush.cxx @@ -86,8 +86,11 @@ cyg_libc_stdio_flush_all_but( Cyg_StdioS } // if else { // valid stream +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO // only buffers which we've written to need flushing - if ( !stream->flags.last_buffer_op_was_read) { + if ( !stream->flags.last_buffer_op_was_read) +#endif + { if ( stream->trylock_me() ) { err = stream->flush_output_unlocked(); stream->unlock_me();
--- a/packages/language/c/libm/current/ChangeLog +++ b/packages/language/c/libm/current/ChangeLog @@ -1,3 +1,10 @@ +2001-07-20 Jonathan Larmour <jlarmour@redhat.com> + + * src/double/portable-api/s_expm1.c: Reimport from newlib + * src/double/ieee754-core/e_pow.c: Ditto. + * src/mathincl/fdlibm.h: Define macros and types required for + newlib versions of libm files. + 2001-04-25 Bart Veer <bartv@redhat.com> * cdl/libm.cdl:
--- a/packages/language/c/libm/current/src/double/ieee754-core/e_pow.c +++ b/packages/language/c/libm/current/src/double/ieee754-core/e_pow.c @@ -23,7 +23,7 @@ // // The Initial Developer of the Original Code is Red Hat. // Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. // All Rights Reserved. // ------------------------------------------- // @@ -32,8 +32,8 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): jlarmour -// Contributors: jlarmour -// Date: 1998-02-13 +// Contributors: +// Date: 2001-07-20 // Purpose: // Description: // Usage: @@ -46,18 +46,13 @@ #include <pkgconf/libm.h> // Configuration header -// Include the Math library? -#ifdef CYGPKG_LIBM -// Derived from code with the following copyright - - -/* @(#)e_pow.c 1.3 95/01/18 */ +/* @(#)e_pow.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * - * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. @@ -66,41 +61,41 @@ /* __ieee754_pow(x,y) return x**y * - * n + * n * Method: Let x = 2 * (1+f) - * 1. Compute and return log2(x) in two pieces: - * log2(x) = w1 + w2, - * where w1 has 53-24 = 29 bit trailing zeros. - * 2. Perform y*log2(x) = n+y' by simulating muti-precision - * arithmetic, where |y'|<=0.5. - * 3. Return x**y = 2**n*exp(y'*log2) + * 1. Compute and return log2(x) in two pieces: + * log2(x) = w1 + w2, + * where w1 has 53-24 = 29 bit trailing zeros. + * 2. Perform y*log2(x) = n+y' by simulating muti-precision + * arithmetic, where |y'|<=0.5. + * 3. Return x**y = 2**n*exp(y'*log2) * * Special cases: - * 1. (anything) ** 0 is 1 - * 2. (anything) ** 1 is itself - * 3. (anything) ** NAN is NAN - * 4. NAN ** (anything except 0) is NAN - * 5. +-(|x| > 1) ** +INF is +INF - * 6. +-(|x| > 1) ** -INF is +0 - * 7. +-(|x| < 1) ** +INF is +0 - * 8. +-(|x| < 1) ** -INF is +INF - * 9. +-1 ** +-INF is NAN - * 10. +0 ** (+anything except 0, NAN) is +0 - * 11. -0 ** (+anything except 0, NAN, odd integer) is +0 - * 12. +0 ** (-anything except 0, NAN) is +INF - * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF - * 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) - * 15. +INF ** (+anything except 0,NAN) is +INF - * 16. +INF ** (-anything except 0,NAN) is +0 - * 17. -INF ** (anything) = -0 ** (-anything) - * 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) - * 19. (-anything except 0 and inf) ** (non-integer) is NAN + * 1. (anything) ** 0 is 1 + * 2. (anything) ** 1 is itself + * 3. (anything) ** NAN is NAN + * 4. NAN ** (anything except 0) is NAN + * 5. +-(|x| > 1) ** +INF is +INF + * 6. +-(|x| > 1) ** -INF is +0 + * 7. +-(|x| < 1) ** +INF is +0 + * 8. +-(|x| < 1) ** -INF is +INF + * 9. +-1 ** +-INF is NAN + * 10. +0 ** (+anything except 0, NAN) is +0 + * 11. -0 ** (+anything except 0, NAN, odd integer) is +0 + * 12. +0 ** (-anything except 0, NAN) is +INF + * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF + * 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) + * 15. +INF ** (+anything except 0,NAN) is +INF + * 16. +INF ** (-anything except 0,NAN) is +0 + * 17. -INF ** (anything) = -0 ** (-anything) + * 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) + * 19. (-anything except 0 and inf) ** (non-integer) is NAN * * Accuracy: - * pow(x,y) returns x**y nearly rounded. In particular - * pow(integer,integer) - * always returns the correct integer provided it is - * representable. + * pow(x,y) returns x**y nearly rounded. In particular + * pow(integer,integer) + * always returns the correct integer provided it is + * representable. * * Constants : * The hexadecimal values are the intended ones for the following @@ -111,17 +106,23 @@ #include "mathincl/fdlibm.h" +#ifndef _DOUBLE_IS_32BITS + +#ifdef __STDC__ static const double +#else +static double +#endif bp[] = {1.0, 1.5,}, dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ zero = 0.0, -one = 1.0, -two = 2.0, -two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ -huge = 1.0e300, +one = 1.0, +two = 2.0, +two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ +huge = 1.0e300, tiny = 1.0e-300, - /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ + /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */ L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */ L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */ @@ -138,221 +139,224 @@ lg2_h = 6.93147182464599609375e-01, /* lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */ ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */ cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ -cp_h = 9.61796700954437255859e-01,/* 0x3FEEC709, 0xE0000000 =(float)cp */ -cp_l = -7.02846165095275826516e-09,/* 0xBE3E2FE0,0x145B01F5=tail of cp_h*/ +cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */ +cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */ -ivln2_h = 1.44269502162933349609e+00, /*0x3FF71547,0x60000000=24b 1/ln2*/ -ivln2_l = 1.92596299112661746887e-08;/*0x3E54AE0B,0xF85DDF44=1/ln2 tail*/ +ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ +ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ - double __ieee754_pow(double x, double y) +#ifdef __STDC__ + double __ieee754_pow(double x, double y) +#else + double __ieee754_pow(x,y) + double x, y; +#endif { - double z,ax,z_h,z_l,p_h,p_l; - double y1,t1,t2,r,s,t,u,v,w; - int i,j,k,yisint,n; - int hx,hy,ix,iy; - unsigned lx,ly; + double z,ax,z_h,z_l,p_h,p_l; + double y1,t1,t2,r,s,t,u,v,w; + __int32_t i,j,k,yisint,n; + __int32_t hx,hy,ix,iy; + __uint32_t lx,ly; - hx = CYG_LIBM_HI(x); lx = CYG_LIBM_LO(x); - hy = CYG_LIBM_HI(y); ly = CYG_LIBM_LO(y); - ix = hx&0x7fffffff; iy = hy&0x7fffffff; + EXTRACT_WORDS(hx,lx,x); + EXTRACT_WORDS(hy,ly,y); + ix = hx&0x7fffffff; iy = hy&0x7fffffff; /* y==zero: x**0 = 1 */ - if((iy|ly)==0) return one; + if((iy|ly)==0) return one; /* +-NaN return x+y */ - if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || - iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) - return x+y; + if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || + iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) + return x+y; /* determine if y is an odd int when x < 0 - * yisint = 0 ... y is not an integer - * yisint = 1 ... y is an odd int - * yisint = 2 ... y is an even int + * yisint = 0 ... y is not an integer + * yisint = 1 ... y is an odd int + * yisint = 2 ... y is an even int */ - yisint = 0; - if(hx<0) { - if(iy>=0x43400000) yisint = 2; /* even integer y */ - else if(iy>=0x3ff00000) { - k = (iy>>20)-0x3ff; /* exponent */ - if(k>20) { - j = ly>>(52-k); - if(((unsigned)j<<(52-k))==ly) yisint = 2-(j&1); - } else if(ly==0) { - j = iy>>(20-k); - if((j<<(20-k))==iy) yisint = 2-(j&1); - } - } - } + yisint = 0; + if(hx<0) { + if(iy>=0x43400000) yisint = 2; /* even integer y */ + else if(iy>=0x3ff00000) { + k = (iy>>20)-0x3ff; /* exponent */ + if(k>20) { + j = ly>>(52-k); + if((j<<(52-k))==ly) yisint = 2-(j&1); + } else if(ly==0) { + j = iy>>(20-k); + if((j<<(20-k))==iy) yisint = 2-(j&1); + } + } + } /* special value of y */ - if(ly==0) { - if (iy==0x7ff00000) { /* y is +-inf */ - if(((ix-0x3ff00000)|lx)==0) - return y - y; /* inf**+-1 is NaN */ - else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ - return (hy>=0)? y: zero; - else /* (|x|<1)**-,+inf = inf,0 */ - return (hy<0)?-y: zero; - } - if(iy==0x3ff00000) { /* y is +-1 */ - if(hy<0) return one/x; else return x; - } - if(hy==0x40000000) return x*x; /* y is 2 */ - if(hy==0x3fe00000) { /* y is 0.5 */ - if(hx>=0) /* x >= +0 */ - return sqrt(x); - } - } + if(ly==0) { + if (iy==0x7ff00000) { /* y is +-inf */ + if(((ix-0x3ff00000)|lx)==0) + return y - y; /* inf**+-1 is NaN */ + else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ + return (hy>=0)? y: zero; + else /* (|x|<1)**-,+inf = inf,0 */ + return (hy<0)?-y: zero; + } + if(iy==0x3ff00000) { /* y is +-1 */ + if(hy<0) return one/x; else return x; + } + if(hy==0x40000000) return x*x; /* y is 2 */ + if(hy==0x3fe00000) { /* y is 0.5 */ + if(hx>=0) /* x >= +0 */ + return __ieee754_sqrt(x); + } + } - ax = fabs(x); + ax = fabs(x); /* special value of x */ - if(lx==0) { - if(ix==0x7ff00000||ix==0||ix==0x3ff00000){ - z = ax; /*x is +-0,+-inf,+-1*/ - if(hy<0) z = one/z; /* z = (1/|x|) */ - if(hx<0) { - if(((ix-0x3ff00000)|yisint)==0) { - z = (z-z)/(z-z); /* (-1)**non-int is NaN */ - } else if(yisint==1) - z = -z; /* (x<0)**odd = -(|x|**odd) */ - } - return z; - } - } + if(lx==0) { + if(ix==0x7ff00000||ix==0||ix==0x3ff00000){ + z = ax; /*x is +-0,+-inf,+-1*/ + if(hy<0) z = one/z; /* z = (1/|x|) */ + if(hx<0) { + if(((ix-0x3ff00000)|yisint)==0) { + z = (z-z)/(z-z); /* (-1)**non-int is NaN */ + } else if(yisint==1) + z = -z; /* (x<0)**odd = -(|x|**odd) */ + } + return z; + } + } /* (x<0)**(non-int) is NaN */ - /* REDHAT LOCAL: This used to be - if((((hx>>31)+1)|yisint)==0) return (x-x)/(x-x); + /* CYGNUS LOCAL: This used to be + if((((hx>>31)+1)|yisint)==0) return (x-x)/(x-x); but ANSI C says a right shift of a signed negative quantity is implementation defined. */ - - if(((((unsigned)hx>>31)-1)|yisint)==0) - return (x-x)/(x-x); + if(((((__uint32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); /* |y| is huge */ - if(iy>0x41e00000) { /* if |y| > 2**31 */ - if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */ - if(ix<=0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; - if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; - } - /* over/underflow if x is not close to one */ - if(ix<0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; - if(ix>0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; - /* now |1-x| is tiny <= 2**-20, suffice to compute - log(x) by x-x^2/2+x^3/3-x^4/4 */ - t = x-1; /* t has 20 trailing zeros */ - w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25)); - u = ivln2_h*t; /* ivln2_h has 21 sig. bits */ - v = t*ivln2_l-w*ivln2; - t1 = u+v; - CYG_LIBM_LO(t1) = 0; - t2 = v-(t1-u); - } else { - double s2,s_h,s_l,t_h,t_l; - n = 0; - /* take care subnormal number */ - if(ix<0x00100000) - {ax *= two53; n -= 53; ix = CYG_LIBM_HI(ax); } - n += ((ix)>>20)-0x3ff; - j = ix&0x000fffff; - /* determine interval */ - ix = j|0x3ff00000; /* normalize ix */ - if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */ - else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */ - else {k=0;n+=1;ix -= 0x00100000;} - CYG_LIBM_HI(ax) = ix; + if(iy>0x41e00000) { /* if |y| > 2**31 */ + if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */ + if(ix<=0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; + if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; + } + /* over/underflow if x is not close to one */ + if(ix<0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; + if(ix>0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; + /* now |1-x| is tiny <= 2**-20, suffice to compute + log(x) by x-x^2/2+x^3/3-x^4/4 */ + t = x-1; /* t has 20 trailing zeros */ + w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25)); + u = ivln2_h*t; /* ivln2_h has 21 sig. bits */ + v = t*ivln2_l-w*ivln2; + t1 = u+v; + SET_LOW_WORD(t1,0); + t2 = v-(t1-u); + } else { + double s2,s_h,s_l,t_h,t_l; + n = 0; + /* take care subnormal number */ + if(ix<0x00100000) + {ax *= two53; n -= 53; GET_HIGH_WORD(ix,ax); } + n += ((ix)>>20)-0x3ff; + j = ix&0x000fffff; + /* determine interval */ + ix = j|0x3ff00000; /* normalize ix */ + if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */ + else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */ + else {k=0;n+=1;ix -= 0x00100000;} + SET_HIGH_WORD(ax,ix); - /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ - u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ - v = one/(ax+bp[k]); - s = u*v; - s_h = s; - CYG_LIBM_LO(s_h) = 0; - /* t_h=ax+bp[k] High */ - t_h = zero; - CYG_LIBM_HI(t_h)=((ix>>1)|0x20000000)+0x00080000+(k<<18); - t_l = ax - (t_h-bp[k]); - s_l = v*((u-s_h*t_h)-s_h*t_l); - /* compute log(ax) */ - s2 = s*s; - r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); - r += s_l*(s_h+s); - s2 = s_h*s_h; - t_h = 3.0+s2+r; - CYG_LIBM_LO(t_h) = 0; - t_l = r-((t_h-3.0)-s2); - /* u+v = s*(1+...) */ - u = s_h*t_h; - v = s_l*t_h+t_l*s; - /* 2/(3log2)*(s+...) */ - p_h = u+v; - CYG_LIBM_LO(p_h) = 0; - p_l = v-(p_h-u); - z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ - z_l = cp_l*p_h+p_l*cp+dp_l[k]; - /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ - t = (double)n; - t1 = (((z_h+z_l)+dp_h[k])+t); - CYG_LIBM_LO(t1) = 0; - t2 = z_l-(((t1-t)-dp_h[k])-z_h); - } + /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ + u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ + v = one/(ax+bp[k]); + s = u*v; + s_h = s; + SET_LOW_WORD(s_h,0); + /* t_h=ax+bp[k] High */ + t_h = zero; + SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18)); + t_l = ax - (t_h-bp[k]); + s_l = v*((u-s_h*t_h)-s_h*t_l); + /* compute log(ax) */ + s2 = s*s; + r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); + r += s_l*(s_h+s); + s2 = s_h*s_h; + t_h = 3.0+s2+r; + SET_LOW_WORD(t_h,0); + t_l = r-((t_h-3.0)-s2); + /* u+v = s*(1+...) */ + u = s_h*t_h; + v = s_l*t_h+t_l*s; + /* 2/(3log2)*(s+...) */ + p_h = u+v; + SET_LOW_WORD(p_h,0); + p_l = v-(p_h-u); + z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ + z_l = cp_l*p_h+p_l*cp+dp_l[k]; + /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ + t = (double)n; + t1 = (((z_h+z_l)+dp_h[k])+t); + SET_LOW_WORD(t1,0); + t2 = z_l-(((t1-t)-dp_h[k])-z_h); + } - s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ - if((((hx>>31)+1)|(yisint-1))==0) s = -one;/* (-ve)**(odd int) */ + s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ + if(((((__uint32_t)hx>>31)-1)|(yisint-1))==0) + s = -one;/* (-ve)**(odd int) */ /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ - y1 = y; - CYG_LIBM_LO(y1) = 0; - p_l = (y-y1)*t1+y*t2; - p_h = y1*t1; - z = p_l+p_h; - j = CYG_LIBM_HI(z); - i = CYG_LIBM_LO(z); - if (j>=0x40900000) { /* z >= 1024 */ - if(((j-0x40900000)|i)!=0) /* if z > 1024 */ - return s*huge*huge; /* overflow */ - else { - if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */ - } - } else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */ - if(((j-0xc090cc00)|i)!=0) /* z < -1075 */ - return s*tiny*tiny; /* underflow */ - else { - if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */ - } - } + y1 = y; + SET_LOW_WORD(y1,0); + p_l = (y-y1)*t1+y*t2; + p_h = y1*t1; + z = p_l+p_h; + EXTRACT_WORDS(j,i,z); + if (j>=0x40900000) { /* z >= 1024 */ + if(((j-0x40900000)|i)!=0) /* if z > 1024 */ + return s*huge*huge; /* overflow */ + else { + if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */ + } + } else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */ + if(((j-0xc090cc00)|i)!=0) /* z < -1075 */ + return s*tiny*tiny; /* underflow */ + else { + if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */ + } + } /* * compute 2**(p_h+p_l) */ - i = j&0x7fffffff; - k = (i>>20)-0x3ff; - n = 0; - if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */ - n = j+(0x00100000>>(k+1)); - k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */ - t = zero; - CYG_LIBM_HI(t) = (n&~(0x000fffff>>k)); - n = ((n&0x000fffff)|0x00100000)>>(20-k); - if(j<0) n = -n; - p_h -= t; - } - t = p_l+p_h; - CYG_LIBM_LO(t) = 0; - u = t*lg2_h; - v = (p_l-(t-p_h))*lg2+t*lg2_l; - z = u+v; - w = v-(z-u); - t = z*z; - t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); - r = (z*t1)/(t1-two)-(w+z*w); - z = one-(r-z); - j = CYG_LIBM_HI(z); - j += (n<<20); - if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */ - else CYG_LIBM_HI(z) += (n<<20); - return s*z; + i = j&0x7fffffff; + k = (i>>20)-0x3ff; + n = 0; + if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */ + n = j+(0x00100000>>(k+1)); + k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */ + t = zero; + SET_HIGH_WORD(t,n&~(0x000fffff>>k)); + n = ((n&0x000fffff)|0x00100000)>>(20-k); + if(j<0) n = -n; + p_h -= t; + } + t = p_l+p_h; + SET_LOW_WORD(t,0); + u = t*lg2_h; + v = (p_l-(t-p_h))*lg2+t*lg2_l; + z = u+v; + w = v-(z-u); + t = z*z; + t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); + r = (z*t1)/(t1-two)-(w+z*w); + z = one-(r-z); + GET_HIGH_WORD(j,z); + j += (n<<20); + if((j>>20)<=0) z = scalbn(z,(int)n); /* subnormal output */ + else SET_HIGH_WORD(z,j); + return s*z; } -#endif // ifdef CYGPKG_LIBM +#endif /* defined(_DOUBLE_IS_32BITS) */ // EOF e_pow.c
--- a/packages/language/c/libm/current/src/double/portable-api/s_expm1.c +++ b/packages/language/c/libm/current/src/double/portable-api/s_expm1.c @@ -23,7 +23,7 @@ // // The Initial Developer of the Original Code is Red Hat. // Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. // All Rights Reserved. // ------------------------------------------- // @@ -31,9 +31,9 @@ //=========================================================================== //#####DESCRIPTIONBEGIN#### // -// Author(s): jlarmour -// Contributors: jlarmour -// Date: 1998-02-13 +// Author(s): jlarmour +// Contributors: +// Date: 2001-07-20 // Purpose: // Description: // Usage: @@ -46,111 +46,149 @@ #include <pkgconf/libm.h> // Configuration header -// Include the Math library? -#ifdef CYGPKG_LIBM -// Derived from code with the following copyright - - -/* @(#)s_expm1.c 1.3 95/01/18 */ +/* @(#)s_expm1.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * - * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */ +/* +FUNCTION + <<expm1>>, <<expm1f>>---exponential minus 1 +INDEX + expm1 +INDEX + expm1f + +ANSI_SYNOPSIS + #include <math.h> + double expm1(double <[x]>); + float expm1f(float <[x]>); + +TRAD_SYNOPSIS + #include <math.h> + double expm1(<[x]>); + double <[x]>; + + float expm1f(<[x]>); + float <[x]>; + +DESCRIPTION + <<expm1>> and <<expm1f>> calculate the exponential of <[x]> + and subtract 1, that is, + @ifinfo + e raised to the power <[x]> minus 1 (where e + @end ifinfo + @tex + $e^x - 1$ (where $e$ + @end tex + is the base of the natural system of logarithms, approximately + 2.71828). The result is accurate even for small values of + <[x]>, where using <<exp(<[x]>)-1>> would lose many + significant digits. + +RETURNS + e raised to the power <[x]>, minus 1. + +PORTABILITY + Neither <<expm1>> nor <<expm1f>> is required by ANSI C or by + the System V Interface Definition (Issue 2). +*/ + /* expm1(x) * Returns exp(x)-1, the exponential of x minus 1. * * Method * 1. Argument reduction: - * Given x, find r and integer k such that + * Given x, find r and integer k such that * * x = k*ln2 + r, |r| <= 0.5*ln2 ~ 0.34658 * * Here a correction term c will be computed to compensate - * the error in r when rounded to a floating-point number. + * the error in r when rounded to a floating-point number. * * 2. Approximating expm1(r) by a special rational function on - * the interval [0,0.34658]: - * Since - * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ... - * we define R1(r*r) by - * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r) - * That is, - * R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r) - * = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r)) - * = 1 - r^2/60 + r^4/2520 - r^6/100800 + ... + * the interval [0,0.34658]: + * Since + * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ... + * we define R1(r*r) by + * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r) + * That is, + * R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r) + * = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r)) + * = 1 - r^2/60 + r^4/2520 - r^6/100800 + ... * We use a special Reme algorithm on [0,0.347] to generate - * a polynomial of degree 5 in r*r to approximate R1. The - * maximum error of this polynomial approximation is bounded - * by 2**-61. In other words, - * R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5 - * where Q1 = -1.6666666666666567384E-2, - * Q2 = 3.9682539681370365873E-4, - * Q3 = -9.9206344733435987357E-6, - * Q4 = 2.5051361420808517002E-7, - * Q5 = -6.2843505682382617102E-9; - * (where z=r*r, and the values of Q1 to Q5 are listed below) - * with error bounded by - * | 5 | -61 - * | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2 - * | | - * - * expm1(r) = exp(r)-1 is then computed by the following - * specific way which minimize the accumulation rounding error: - * 2 3 - * r r [ 3 - (R1 + R1*r/2) ] - * expm1(r) = r + --- + --- * [--------------------] - * 2 2 [ 6 - r*(3 - R1*r/2) ] - * - * To compensate the error in the argument reduction, we use - * expm1(r+c) = expm1(r) + c + expm1(r)*c - * ~ expm1(r) + c + r*c - * Thus c+r*c will be added in as the correction terms for - * expm1(r+c). Now rearrange the term to avoid optimization - * screw up: - * ( 2 2 ) - * ({ ( r [ R1 - (3 - R1*r/2) ] ) } r ) - * expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- ) - * ({ ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 ) + * a polynomial of degree 5 in r*r to approximate R1. The + * maximum error of this polynomial approximation is bounded + * by 2**-61. In other words, + * R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5 + * where Q1 = -1.6666666666666567384E-2, + * Q2 = 3.9682539681370365873E-4, + * Q3 = -9.9206344733435987357E-6, + * Q4 = 2.5051361420808517002E-7, + * Q5 = -6.2843505682382617102E-9; + * (where z=r*r, and the values of Q1 to Q5 are listed below) + * with error bounded by + * | 5 | -61 + * | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2 + * | | + * + * expm1(r) = exp(r)-1 is then computed by the following + * specific way which minimize the accumulation rounding error: + * 2 3 + * r r [ 3 - (R1 + R1*r/2) ] + * expm1(r) = r + --- + --- * [--------------------] + * 2 2 [ 6 - r*(3 - R1*r/2) ] + * + * To compensate the error in the argument reduction, we use + * expm1(r+c) = expm1(r) + c + expm1(r)*c + * ~ expm1(r) + c + r*c + * Thus c+r*c will be added in as the correction terms for + * expm1(r+c). Now rearrange the term to avoid optimization + * screw up: + * ( 2 2 ) + * ({ ( r [ R1 - (3 - R1*r/2) ] ) } r ) + * expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- ) + * ({ ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 ) * ( ) - * - * = r - E + * + * = r - E * 3. Scale back to obtain expm1(x): - * From step 1, we have - * expm1(x) = either 2^k*[expm1(r)+1] - 1 - * = or 2^k*[expm1(r) + (1-2^-k)] + * From step 1, we have + * expm1(x) = either 2^k*[expm1(r)+1] - 1 + * = or 2^k*[expm1(r) + (1-2^-k)] * 4. Implementation notes: - * (A). To save one multiplication, we scale the coefficient Qi - * to Qi*2^i, and replace z by (x^2)/2. - * (B). To achieve maximum accuracy, we compute expm1(x) by - * (i) if x < -56*ln2, return -1.0, (raise inexact if x!=inf) - * (ii) if k=0, return r-E - * (iii) if k=-1, return 0.5*(r-E)-0.5 - * (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E) - * else return 1.0+2.0*(r-E); - * (v) if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1) - * (vi) if k <= 20, return 2^k((1-2^-k)-(E-r)), else - * (vii) return 2^k(1-((E+2^-k)-r)) + * (A). To save one multiplication, we scale the coefficient Qi + * to Qi*2^i, and replace z by (x^2)/2. + * (B). To achieve maximum accuracy, we compute expm1(x) by + * (i) if x < -56*ln2, return -1.0, (raise inexact if x!=inf) + * (ii) if k=0, return r-E + * (iii) if k=-1, return 0.5*(r-E)-0.5 + * (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E) + * else return 1.0+2.0*(r-E); + * (v) if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1) + * (vi) if k <= 20, return 2^k((1-2^-k)-(E-r)), else + * (vii) return 2^k(1-((E+2^-k)-r)) * * Special cases: - * expm1(INF) is INF, expm1(NaN) is NaN; - * expm1(-INF) is -1, and - * for finite argument, only expm1(0)=0 is exact. + * expm1(INF) is INF, expm1(NaN) is NaN; + * expm1(-INF) is -1, and + * for finite argument, only expm1(0)=0 is exact. * * Accuracy: - * according to an error analysis, the error is always less than - * 1 ulp (unit in the last place). + * according to an error analysis, the error is always less than + * 1 ulp (unit in the last place). * * Misc. info. - * For IEEE double - * if x > 7.09782712893383973096e+02 then expm1(x) overflow + * For IEEE double + * if x > 7.09782712893383973096e+02 then expm1(x) overflow * * Constants: * The hexadecimal values are the intended ones for the following @@ -161,106 +199,124 @@ #include "mathincl/fdlibm.h" +#ifndef _DOUBLE_IS_32BITS + +#ifdef __STDC__ static const double -one = 1.0, -huge = 1.0e+300, -tiny = 1.0e-300, -o_threshold = 7.09782712893383973096e+02,/* 0x40862E42, 0xFEFA39EF */ -ln2_hi = 6.93147180369123816490e-01,/* 0x3fe62e42, 0xfee00000 */ -ln2_lo = 1.90821492927058770002e-10,/* 0x3dea39ef, 0x35793c76 */ -invln2 = 1.44269504088896338700e+00,/* 0x3ff71547, 0x652b82fe */ - /* scaled coefficients related to expm1 */ +#else +static double +#endif +one = 1.0, +huge = 1.0e+300, +tiny = 1.0e-300, +o_threshold = 7.09782712893383973096e+02,/* 0x40862E42, 0xFEFA39EF */ +ln2_hi = 6.93147180369123816490e-01,/* 0x3fe62e42, 0xfee00000 */ +ln2_lo = 1.90821492927058770002e-10,/* 0x3dea39ef, 0x35793c76 */ +invln2 = 1.44269504088896338700e+00,/* 0x3ff71547, 0x652b82fe */ + /* scaled coefficients related to expm1 */ Q1 = -3.33333333333331316428e-02, /* BFA11111 111110F4 */ Q2 = 1.58730158725481460165e-03, /* 3F5A01A0 19FE5585 */ Q3 = -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */ Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */ Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */ - double expm1(double x) +#ifdef __STDC__ + double expm1(double x) +#else + double expm1(x) + double x; +#endif { - double y,hi,lo,c,t,e,hxs,hfx,r1; - int k,xsb; - unsigned hx; + double y,hi,lo,c,t,e,hxs,hfx,r1; + __int32_t k,xsb; + __uint32_t hx; - c=0.0; /* placate compiler */ - hx = CYG_LIBM_HI(x); /* high word of x */ - xsb = hx&0x80000000; /* sign bit of x */ - if(xsb==0) y=x; else y= -x; /* y = |x| */ - hx &= 0x7fffffff; /* high word of |x| */ + GET_HIGH_WORD(hx,x); + xsb = hx&0x80000000; /* sign bit of x */ + if(xsb==0) y=x; else y= -x; /* y = |x| */ + hx &= 0x7fffffff; /* high word of |x| */ /* filter out huge and non-finite argument */ - if(hx >= 0x4043687A) { /* if |x|>=56*ln2 */ - if(hx >= 0x40862E42) { /* if |x|>=709.78... */ + if(hx >= 0x4043687A) { /* if |x|>=56*ln2 */ + if(hx >= 0x40862E42) { /* if |x|>=709.78... */ if(hx>=0x7ff00000) { - if(((hx&0xfffff)|CYG_LIBM_LO(x))!=0) - return x+x; /* NaN */ - else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */ - } - if(x > o_threshold) return huge*huge; /* overflow */ - } - if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */ - if(x+tiny<0.0) /* raise inexact */ - return tiny-one; /* return -1 */ - } - } + __uint32_t low; + GET_LOW_WORD(low,x); + if(((hx&0xfffff)|low)!=0) + return x+x; /* NaN */ + else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */ + } + if(x > o_threshold) return huge*huge; /* overflow */ + } + if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */ + if(x+tiny<0.0) /* raise inexact */ + return tiny-one; /* return -1 */ + } + } /* argument reduction */ - if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ - if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ - if(xsb==0) - {hi = x - ln2_hi; lo = ln2_lo; k = 1;} - else - {hi = x + ln2_hi; lo = -ln2_lo; k = -1;} - } else { - k = invln2*x+((xsb==0)?0.5:-0.5); - t = k; - hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ - lo = t*ln2_lo; - } - x = hi - lo; - c = (hi-x)-lo; - } - else if(hx < 0x3c900000) { /* when |x|<2**-54, return x */ - t = huge+x; /* return x with inexact flags when x!=0 */ - return x - (t-(huge+x)); - } - else k = 0; + if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ + if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ + if(xsb==0) + {hi = x - ln2_hi; lo = ln2_lo; k = 1;} + else + {hi = x + ln2_hi; lo = -ln2_lo; k = -1;} + } else { + k = invln2*x+((xsb==0)?0.5:-0.5); + t = k; + hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ + lo = t*ln2_lo; + } + x = hi - lo; + c = (hi-x)-lo; + } + else if(hx < 0x3c900000) { /* when |x|<2**-54, return x */ + t = huge+x; /* return x with inexact flags when x!=0 */ + return x - (t-(huge+x)); + } + else k = 0; /* x is now in primary range */ - hfx = 0.5*x; - hxs = x*hfx; - r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5)))); - t = 3.0-r1*hfx; - e = hxs*((r1-t)/(6.0 - x*t)); - if(k==0) return x - (x*e-hxs); /* c is 0 */ - else { - e = (x*(e-c)-c); - e -= hxs; - if(k== -1) return 0.5*(x-e)-0.5; - if(k==1) { - if(x < -0.25) return -2.0*(e-(x+0.5)); - else return one+2.0*(x-e); - } - if (k <= -2 || k>56) { /* suffice to return exp(x)-1 */ - y = one-(e-x); - CYG_LIBM_HI(y) += (k<<20); /* add k to y's exponent */ - return y-one; - } - t = one; - if(k<20) { - CYG_LIBM_HI(t) = 0x3ff00000 - (0x200000>>k); /* t=1-2^-k */ - y = t-(e-x); - CYG_LIBM_HI(y) += (k<<20); /* add k to y's exponent */ - } else { - CYG_LIBM_HI(t) = ((0x3ff-k)<<20); /* 2^-k */ - y = x-(e+t); - y += one; - CYG_LIBM_HI(y) += (k<<20); /* add k to y's exponent */ - } - } - return y; + hfx = 0.5*x; + hxs = x*hfx; + r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5)))); + t = 3.0-r1*hfx; + e = hxs*((r1-t)/(6.0 - x*t)); + if(k==0) return x - (x*e-hxs); /* c is 0 */ + else { + e = (x*(e-c)-c); + e -= hxs; + if(k== -1) return 0.5*(x-e)-0.5; + if(k==1) { + if(x < -0.25) return -2.0*(e-(x+0.5)); + else return one+2.0*(x-e); + } + if (k <= -2 || k>56) { /* suffice to return exp(x)-1 */ + __uint32_t high; + y = one-(e-x); + GET_HIGH_WORD(high,y); + SET_HIGH_WORD(y,high+(k<<20)); /* add k to y's exponent */ + return y-one; + } + t = one; + if(k<20) { + __uint32_t high; + SET_HIGH_WORD(t,0x3ff00000 - (0x200000>>k)); /* t=1-2^-k */ + y = t-(e-x); + GET_HIGH_WORD(high,y); + SET_HIGH_WORD(y,high+(k<<20)); /* add k to y's exponent */ + } else { + __uint32_t high; + SET_HIGH_WORD(t,((0x3ff-k)<<20)); /* 2^-k */ + y = x-(e+t); + y += one; + GET_HIGH_WORD(high,y); + SET_HIGH_WORD(y,high+(k<<20)); /* add k to y's exponent */ + } + } + return y; } -#endif // ifdef CYGPKG_LIBM +#endif /* _DOUBLE_IS_32BITS */ // EOF s_expm1.c
--- a/packages/language/c/libm/current/src/mathincl/fdlibm.h +++ b/packages/language/c/libm/current/src/mathincl/fdlibm.h @@ -71,14 +71,83 @@ #endif // if DBL_MAX_EXP == 1024 +// TYPES + +typedef cyg_int32 __int32_t; +typedef cyg_uint32 __uint32_t; +typedef Cyg_libm_ieee_double_shape_type ieee_double_shape_type; + // MACRO DEFINITIONS +#ifndef __STDC__ +# define __STDC__ 1 +#endif #define CYG_LIBM_HI(__x) (((Cyg_libm_ieee_double_shape_type *)&__x)->parts.msw) #define CYG_LIBM_LO(__x) (((Cyg_libm_ieee_double_shape_type *)&__x)->parts.lsw) #define CYG_LIBM_HIp(__x) (((Cyg_libm_ieee_double_shape_type *)__x)->parts.msw) #define CYG_LIBM_LOp(__x) (((Cyg_libm_ieee_double_shape_type *)__x)->parts.lsw) + +/* Get two 32 bit ints from a double. */ + +#define EXTRACT_WORDS(ix0,ix1,d) \ +do { \ + Cyg_libm_ieee_double_shape_type ew_u; \ + ew_u.value = (d); \ + (ix0) = ew_u.parts.msw; \ + (ix1) = ew_u.parts.lsw; \ +} while (0) + +/* Get the more significant 32 bit int from a double. */ + +#define GET_HIGH_WORD(i,d) \ +do { \ + Cyg_libm_ieee_double_shape_type gh_u; \ + gh_u.value = (d); \ + (i) = gh_u.parts.msw; \ +} while (0) + +/* Get the less significant 32 bit int from a double. */ + +#define GET_LOW_WORD(i,d) \ +do { \ + Cyg_libm_ieee_double_shape_type gl_u; \ + gl_u.value = (d); \ + (i) = gl_u.parts.lsw; \ +} while (0) + +/* Set a double from two 32 bit ints. */ + +#define INSERT_WORDS(d,ix0,ix1) \ +do { \ + Cyg_libm_ieee_double_shape_type iw_u; \ + iw_u.parts.msw = (ix0); \ + iw_u.parts.lsw = (ix1); \ + (d) = iw_u.value; \ +} while (0) + +/* Set the more significant 32 bits of a double from an int. */ + +#define SET_HIGH_WORD(d,v) \ +do { \ + Cyg_libm_ieee_double_shape_type sh_u; \ + sh_u.value = (d); \ + sh_u.parts.msw = (v); \ + (d) = sh_u.value; \ +} while (0) + +/* Set the less significant 32 bits of a double from an int. */ + +#define SET_LOW_WORD(d,v) \ +do { \ + Cyg_libm_ieee_double_shape_type sl_u; \ + sl_u.value = (d); \ + sl_u.parts.lsw = (v); \ + (d) = sl_u.value; \ +} while (0) + + // REPLACEMENTS FOR STUFF FROM MATH.H DUE TO CONFIG OPTION #ifdef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION
--- a/packages/net/tcpip/current/ChangeLog +++ b/packages/net/tcpip/current/ChangeLog @@ -1,3 +1,16 @@ +2001-07-27 Jonathan Larmour <jlarmour@redhat.com> + + * include/sys/select.h: Renamed to.... + * include/sys/bsdselect.h: New file. + * include/sys/socketvar.h: Include <sys/bsdselect.h> instead of + <sys/select.h> + * src/lib/select.c: Include <sys/bsdselect.h> + +2001-07-26 Jonathan Larmour <jlarmour@redhat.com> + + * cdl/net.cdl (CYGPKG_NET_API_LOCAL): Implements select() + * include/sys/bsdtypes.h: No need for these select definitions. + 2001-06-20 Grant Edwards <grante@visi.com> 2001-06-20 Hugo Tyson <hmt@redhat.com>
--- a/packages/net/tcpip/current/cdl/net.cdl +++ b/packages/net/tcpip/current/cdl/net.cdl @@ -114,6 +114,7 @@ cdl_package CYGPKG_NET { flavor bool active_if !CYGPKG_IO_FILEIO default_value 1 + implements CYGINT_ISO_SELECT compile sys/kern/uipc_syscalls.c \ sys/kern/sys_socket.c \
new file mode 100644 --- /dev/null +++ b/packages/net/tcpip/current/include/sys/bsdselect.h @@ -0,0 +1,81 @@ +//========================================================================== +// +// include/sys/select.h +// +// Support for 'select()' system call +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//####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): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#ifndef _SYS_SELECT_H_ +#define _SYS_SELECT_H_ + +#include <pkgconf/system.h> + +#ifdef CYGPKG_IO_FILEIO + +#include <cyg/io/file.h> + +void selwakeup __P((struct selinfo *)); + +#else + +/* + * Used to maintain information about processes that wish to be + * notified when I/O becomes possible. + */ +struct selinfo { + void *unused; +}; + +void selrecord __P((void *selector, struct selinfo *)); +void selwakeup __P((struct selinfo *)); + +#endif + +#endif /* !_SYS_SELECT_H_ */
--- a/packages/net/tcpip/current/include/sys/bsdtypes.h +++ b/packages/net/tcpip/current/include/sys/bsdtypes.h @@ -200,44 +200,6 @@ typedef _BSD_TIMER_T_ timer_t; #if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) -#ifndef CYG_FD_SET_DEFINED - -#define NBBY 8 /* number of bits in a byte */ - -/* - * Select uses bit masks of file descriptors in longs. These macros - * manipulate such bit fields (the filesystem macros use chars). - * FD_SETSIZE may be defined by the user, but the default here should - * be enough for most uses. - */ -#ifndef FD_SETSIZE -#define FD_SETSIZE 256 -#endif - -typedef int32_t fd_mask; -#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ - -#ifndef howmany -#define howmany(x, y) (((x) + ((y) - 1)) / (y)) -#endif - -typedef struct fd_set { - fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; -} fd_set; - -#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) -#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) -#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) -#ifdef _KERNEL -#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) -#define FD_ZERO(p) bzero(p, sizeof(*(p))) -#else -#define FD_COPY(f, t) memcpy(t, f, sizeof(*(f))) -#define FD_ZERO(p) memset(p, 0, sizeof(*(p))) -#endif - -#endif // CYG_FD_SET_DEFINED - #if defined(__STDC__) && defined(_KERNEL) /* * Forward structure declarations for function prototypes. We include the
deleted file mode 100644 --- a/packages/net/tcpip/current/include/sys/select.h +++ /dev/null @@ -1,81 +0,0 @@ -//========================================================================== -// -// include/sys/select.h -// -// Support for 'select()' system call -// -//========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations under -// the License. -// -// The Original Code is eCos - Embedded Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//####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): gthomas -// Contributors: gthomas -// Date: 2000-01-10 -// Purpose: -// Description: -// -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#ifndef _SYS_SELECT_H_ -#define _SYS_SELECT_H_ - -#include <pkgconf/system.h> - -#ifdef CYGPKG_IO_FILEIO - -#include <cyg/io/file.h> - -void selwakeup __P((struct selinfo *)); - -#else - -/* - * Used to maintain information about processes that wish to be - * notified when I/O becomes possible. - */ -struct selinfo { - void *unused; -}; - -void selrecord __P((void *selector, struct selinfo *)); -void selwakeup __P((struct selinfo *)); - -#endif - -#endif /* !_SYS_SELECT_H_ */
--- a/packages/net/tcpip/current/include/sys/socketvar.h +++ b/packages/net/tcpip/current/include/sys/socketvar.h @@ -94,7 +94,7 @@ #ifndef _SYS_SOCKETVAR_H_ #define _SYS_SOCKETVAR_H_ -#include <sys/select.h> /* for struct selinfo */ +#include <sys/bsdselect.h> /* for struct selinfo */ /* * Kernel structure per socket.
--- a/packages/net/tcpip/current/src/lib/select.c +++ b/packages/net/tcpip/current/src/lib/select.c @@ -56,6 +56,7 @@ #include <cyg/io/file.h> #include <cyg/kernel/kapi.h> #include <sys/select.h> +#include <sys/bsdselect.h> static cyg_flag_t select_flag; static cyg_bool select_flag_init = false;
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,53 @@ +2001-07-27 Gary Thomas <gthomas@redhat.com> + + * src/load.c (load_srec_image, do_load): + * cdl/redboot.cdl: New option CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS + which can be used to disable user RAM checks in 'load' command. + + * src/load.c: Fix build problem if no IDE support. + + * src/net/tftp_client.c (tftp_stream_read): Only ACK data when it + has been processed and we're ready for the next block. This fixes + a race/timing issue which was exacerbated by the "spinner" in 'load'. + +2001-07-27 David Howells <dhowells@redhat.com> + + * src/xyzModem.c: Fixed an uninitialised variable warning. + +2001-07-27 Mark Salter <msalter@redhat.com> + + * cdl/redboot.cdl (CYGNUM_REDBOOT_MAX_PARTITIONS): New option. + Rename CYGBLD_REDBOOT_MAX_DISKS to CYGNUM_REDBOOT_MAX_DISKS. + + * include/fs/disk.h: Exported functions declared "externC". + Replace MAX_PARTITIONS with CYGNUM_REDBOOT_MAX_PARTITIONS. + + * src/fs/disk.c: Make exported functions "externC". + Rename CYGBLD_REDBOOT_MAX_DISKS to CYGNUM_REDBOOT_MAX_DISKS. + Replace MAX_PARTITIONS with CYGNUM_REDBOOT_MAX_PARTITIONS. + + * src/fs/e2fs.c: Add support for symbolic links. + * include/fs/e2fs.h: Add dir filetype support. + +2001-07-24 Mark Salter <msalter@redhat.com> + + * src/load.c: Add disk load support. + * src/fs/disk.c: New file. RedBoot disk management. + * src/fs/ide.c: New file. IDE disk I/O. + * src/fs/e2fs.c: New file. Linux ext2 filesystem support. + * cdl/redboot.cdl: Add options for disk/ide/filesystem support. + +2001-07-23 Jonathan Larmour <jlarmour@redhat.com> + + * src/main.c (set_console_baud_rate): No need to query the console + number if we don't care what it is. + (do_baud_rate): Likewise. + +2001-07-23 David Howells <dhowells@redhat.com> + + * src/flash.c: Force block-alignment for flash addresses in write + and erase functions. + 2001-07-20 Jonathan Larmour <jlarmour@redhat.com> * src/net/net_io.c (net_init): Don't overwrite static IP
--- a/packages/redboot/current/cdl/redboot.cdl +++ b/packages/redboot/current/cdl/redboot.cdl @@ -219,6 +219,18 @@ cdl_package CYGPKG_REDBOOT { five bytes are available initially so this is the minimum." } + cdl_option CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS { + display "Validate RAM addresses during load" + flavor bool + default_value 1 + description " + This option controls whether or not RedBoot will make sure that + memory being used by the \"load\" command is in fact in user RAM. + Leaving the option enabled makes for a safer environment, but this + check may not be valid on all platforms, thus the ability to + disable it. ** Disable this only with great care **" + } + cdl_component CYGPKG_REDBOOT_FLASH { display "Allow RedBoot to support FLASH programming" flavor bool @@ -409,6 +421,51 @@ cdl_package CYGPKG_REDBOOT { } } + cdl_component CYGPKG_REDBOOT_DISK { + display "Allow RedBoot to support disks" + flavor bool + default_value 1 + active_if { CYGINT_HAL_PLF_IF_IDE != 0 } + description " + If this option is enabled then RedBoot will provide commands + to load disk files." + compile -library=libextras.a fs/disk.c + + cdl_option CYGNUM_REDBOOT_MAX_DISKS { + display "Maximum number of supported disks" + flavor data + default_value 4 + description " + This option controls the number of disks supported by RedBoot." + } + + cdl_option CYGNUM_REDBOOT_MAX_PARTITIONS { + display "Maximum number of partitions per disk" + flavor data + default_value 8 + description " + This option controls the maximum number of supported partitions per disk." + } + + cdl_component CYGSEM_REDBOOT_DISK_IDE { + display "Support IDE disks." + flavor bool + default_value 1 + description " + When this option is enabled, RedBoot will support IDE disks." + compile -library=libextras.a fs/ide.c + } + + cdl_component CYGSEM_REDBOOT_DISK_EXT2FS { + display "Support Linux second extended filesystems." + flavor bool + default_value 1 + description " + When this option is enabled, RedBoot will support IDE disks." + compile -library=libextras.a fs/e2fs.c + } + } + cdl_component CYGPKG_REDBOOT_BOOT_SCRIPT { display "Boot scripting" flavor none
new file mode 100644 --- /dev/null +++ b/packages/redboot/current/include/fs/disk.h @@ -0,0 +1,164 @@ +//========================================================================== +// +// disk.h +// +// Stand-alone disk support for RedBoot +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): msalter +// Contributors: msalter +// Date: 2001-07-02 +// Purpose: +// Description: +// +// This code is part of RedBoot (tm). +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#ifndef CYGONCE_REDBOOT_DISK_H +#define CYGONCE_REDBOOT_DISK_H + +#define SECTOR_SIZE 512 + +// Convenience macros to access disk/filesystem info which may +// be stored in a fixed endian format. + +#define __SWAB16(x) \ + ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF)) + +#define __SWAB32(x) \ + ((((x) & 0xff) << 24) | \ + (((x) & 0xff00) << 8) | \ + (((x) >> 8) & 0xff) | \ + (((x) >> 24) & 0xff)) + +#if (CYG_BYTEORDER == CYG_MSBFIRST) +#define SWAB_LE16(x) __SWAB16(x) +#define SWAB_LE32(x) __SWAB32(x) +#define SWAB_BE16(x) (x) +#define SWAB_BE32(x) (x) +#else +#define SWAB_LE16(x) (x) +#define SWAB_LE32(x) (x) +#define SWAB_BE16(x) __SWAB16(x) +#define SWAB_BE32(x) __SWAB32(x) +#endif + +struct partition; + +// filesystem interface +typedef struct fs_funs { + // Load a file into memory. + void * (*open)(struct partition *p, const char *path); + int (*read)(void *fp, char *buf, cyg_uint32 nbytes); +} fs_funs_t; + +struct disk; + +typedef struct partition { + struct disk *disk; + fs_funs_t *funs; + cyg_uint32 start_sector; // first sector in partition + cyg_uint32 nr_sectors; // number of sectors in partition + cyg_uint8 systype; // FAT12, FAT16, Linux, etc. + cyg_uint8 bootflag; // not really used... +} partition_t; + +// System types +#define SYSTYPE_FAT12 0x01 +#define SYSTYPE_FAT16_32M 0x04 +#define SYSTYPE_EXTENDED 0x05 +#define SYSTYPE_FAT16 0x06 +#define SYSTYPE_LINUX_SWAP 0x82 +#define SYSTYPE_LINUX 0x83 + +typedef struct disk_funs { + int (*read)(struct disk *d, + cyg_uint32 start_sector, + cyg_uint32 *buf, + cyg_uint8 nr_sectors); +} disk_funs_t; + + +typedef struct disk { + disk_funs_t *funs; // Disk driver functions + void *private; // Whatever is needed by disk functions + cyg_uint32 nr_sectors; // Total disk size in sectors + short kind; // IDE_HD, IDE_CDROM, SCSI_HD, etc + short index; // index within specific kind + partition_t partitions[CYGNUM_REDBOOT_MAX_PARTITIONS]; +} disk_t; + +#define DISK_READ(d,s,p,n) ((d)->funs->read)((d),(s),(p),(n)) +#define PARTITION_READ(part,s,p,n) \ + DISK_READ((part)->disk, (s) + (part)->start_sector, (p), (n)) + +// Kinds of disks +#define DISK_IDE_HD 1 +#define DISK_IDE_CDROM 2 +#define DISK_FLOPPY 3 + +// DOS partition table as laid out in the MBR +// +struct mbr_partition { + cyg_uint8 boot_ind; // 0x80 == active + cyg_uint8 head; + cyg_uint8 sector; + cyg_uint8 cyl; + cyg_uint8 sys_ind; // partition type + cyg_uint8 end_head; + cyg_uint8 end_sector; + cyg_uint8 end_cyl; + cyg_uint8 start_sect[4]; // starting sector counting from 0 + cyg_uint8 nr_sects[4]; // number of sectors in partition +}; + +#define MBR_PTABLE_OFFSET 0x1be +#define MBR_MAGIC_OFFSET 0x1fe +#define MBR_MAGIC 0xaa55 + +// Add a disk to the disk table. +// Return zero if no more room in table. +// +externC int disk_register(disk_t *disk); + + +#define diskerr_badname -1 +#define diskerr_partition -2 +#define diskerr_open -3 +#define diskerr_read -4 + +externC int disk_stream_open(char *filename, int *err); +externC void disk_stream_close(int *err); +externC int disk_stream_read(char *buf, int size, int *err); +externC char *disk_error(int err); + +#endif // CYGONCE_REDBOOT_DISK_H
new file mode 100644 --- /dev/null +++ b/packages/redboot/current/include/fs/e2fs.h @@ -0,0 +1,190 @@ +//========================================================================== +// +// e2fs.h +// +// Second extended filesystem defines. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): msalter +// Contributors: msalter +// Date: 2001-06-25 +// Purpose: +// Description: +// +// This code is part of RedBoot (tm). +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#ifndef CYGONCE_REDBOOT_E2FS_H +#define CYGONCE_REDBOOT_E2FS_H + +// +// Structure of the super block +// +struct e2fs_super_block { + cyg_uint32 inodes_count; + cyg_uint32 blocks_count; + cyg_uint32 r_blocks_count; + cyg_uint32 free_blocks_count; + cyg_uint32 free_inodes_count; + cyg_uint32 first_data_block; + cyg_uint32 log_block_size; + cyg_int32 log_frag_size; + cyg_uint32 blocks_per_group; + cyg_uint32 frags_per_group; + cyg_uint32 inodes_per_group; + cyg_uint32 mtime; + cyg_uint32 wtime; + cyg_uint16 mnt_count; + cyg_int16 max_mnt_count; + cyg_uint16 magic; + cyg_uint16 state; + cyg_uint16 errors; + cyg_uint16 minor_rev_level; + cyg_uint32 lastcheck; + cyg_uint32 checkinterval; + cyg_uint32 creator_os; + cyg_uint32 rev_level; + cyg_uint16 def_resuid; + cyg_uint16 def_resgid; +}; + +#define E2FS_PRE_02B_MAGIC 0xEF51 +#define E2FS_SUPER_MAGIC 0xEF53 + +#define E2FS_PTRS_PER_BLOCK(e) ((e)->blocksize / sizeof(cyg_uint32)) + +#define E2FS_BLOCK_SIZE(s) (E2FS_MIN_BLOCK_SIZE << SWAB_LE32((s)->log_block_size)) +#define E2FS_ADDR_PER_BLOCK(s) (E2FS_BLOCK_SIZE(s) / sizeof(unsigned int)) +#define E2FS_BLOCK_SIZE_BITS(s) (SWAB_LE32((s)->log_block_size) + 10) + +#define E2FS_NR_DIR_BLOCKS 12 + +#define E2FS_IND_BLOCK E2FS_NR_DIR_BLOCKS +#define E2FS_DIND_BLOCK (E2FS_IND_BLOCK + 1) +#define E2FS_TIND_BLOCK (E2FS_DIND_BLOCK + 1) + +#define E2FS_N_BLOCKS (E2FS_TIND_BLOCK + 1) + + +// Structure of an inode on the disk +// +typedef struct e2fs_inode { + cyg_uint16 mode; + cyg_uint16 uid; + cyg_uint32 size; + cyg_uint32 atime; + cyg_uint32 ctime; + cyg_uint32 mtime; + cyg_uint32 dtime; + cyg_uint16 gid; + cyg_uint16 links_count; + cyg_uint32 blocks; + cyg_uint32 flags; + cyg_uint32 reserved1; + cyg_uint32 block[E2FS_N_BLOCKS]; + cyg_uint32 version; + cyg_uint32 file_acl; + cyg_uint32 dir_acl; + cyg_uint32 faddr; + cyg_uint8 frag; + cyg_uint8 fsize; + cyg_uint16 pad1; + cyg_uint32 reserved2[2]; +} e2fs_inode_t; + + +#define E2FS_INODES_PER_BLOCK(e) ((e)->blocksize / sizeof (struct e2fs_inode)) + +#define E2FS_MIN_BLOCK_SIZE 1024 +#define E2FS_MAX_BLOCK_SIZE 4096 + +// Special inode numbers +// +#define E2FS_BAD_INO 1 +#define E2FS_ROOT_INO 2 + +typedef struct e2fs_dir_entry { + cyg_uint32 inode; + cyg_uint16 reclen; + cyg_uint8 namelen; + cyg_uint8 filetype; + char name[2]; +} e2fs_dir_entry_t; + +#define E2FS_FTYPE_UNKNOWN 0 +#define E2FS_FTYPE_REG_FILE 1 +#define E2FS_FTYPE_DIR 2 +#define E2FS_FTYPE_CHRDEV 3 +#define E2FS_FTYPE_BLKDEV 4 +#define E2FS_FTYPE_FIFO 5 +#define E2FS_FTYPE_SOCK 6 +#define E2FS_FTYPE_SYMLINK 7 + +typedef struct e2fs_group +{ + cyg_uint32 block_bitmap; // blocks bitmap block + cyg_uint32 inode_bitmap; // inodes bitmap block + cyg_uint32 inode_table; // inodes table block + cyg_uint16 free_blocks_count; + cyg_uint16 free_inodes_count; + cyg_uint16 used_dirs_count; + cyg_uint16 pad; + cyg_uint32 reserved[3]; +} e2fs_group_t; + +#define E2FS_BLOCKS_PER_GROUP(s) (SWAB_LE32((s)->blocks_per_group)) +#define E2FS_INODES_PER_GROUP(s) (SWAB_LE32((s)->inodes_per_group)) + +#define E2FS_GDESC_PER_BLOCK(e) ((e)->blocksize / sizeof (struct e2fs_e2fs_group_desc)) +#define E2FS_GDESC_PER_SECTOR (SECTOR_SIZE/sizeof(e2fs_group_t)) +#define E2FS_GDESC_CACHE_SIZE (E2FS_GDESC_PER_SECTOR * 1) +#define E2FS_GDESC_PER_SECTOR (SECTOR_SIZE/sizeof(e2fs_group_t)) + +typedef struct e2fs_desc { + partition_t *part; // partition holding this filesystem + cyg_uint32 blocksize; // fs blocksize + cyg_uint32 ngroups; // number of groups in fs + cyg_uint32 blocks_per_group; + cyg_uint32 inodes_per_group; + cyg_uint32 gdesc_block; // block nr of group descriptors + cyg_int32 gdesc_first; // which gdesc is first in cache + e2fs_group_t gdesc_cache[E2FS_GDESC_CACHE_SIZE]; + cyg_uint32 nr_ind_blocks; + cyg_uint32 nr_dind_blocks; + cyg_uint32 nr_tind_blocks; +} e2fs_desc_t; + +#define E2FS_BLOCK_TO_SECTOR(e,b) ((b) * ((e)->blocksize / SECTOR_SIZE)) + +extern fs_funs_t redboot_e2fs_funs; + +#endif // CYGONCE_REDBOOT_E2FS_H
new file mode 100644 --- /dev/null +++ b/packages/redboot/current/include/fs/ide.h @@ -0,0 +1,85 @@ +//========================================================================== +// +// ide.h +// +// IDE Interface Driver Tables for RedBoot +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): msalter +// Contributors: msalter +// Date: 2001-07-06 +// Purpose: +// Description: +// +// This code is part of RedBoot (tm). +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#ifndef CYGONCE_REDBOOT_IDE_H +#define CYGONCE_REDBOOT_IDE_H + +// IDE Register Indices +#define IDE_REG_DATA 0 +#define IDE_REG_ERROR 1 +#define IDE_REG_FEATURES 1 +#define IDE_REG_COUNT 2 +#define IDE_REG_LBALOW 3 +#define IDE_REG_LBAMID 4 +#define IDE_REG_LBAHI 5 +#define IDE_REG_DEVICE 6 +#define IDE_REG_STATUS 7 +#define IDE_REG_COMMAND 7 + +#define IDE_STAT_BSY 0x80 +#define IDE_STAT_DRDY 0x40 +#define IDE_STAT_DRQ 0x08 +#define IDE_STAT_ERR 0x01 + +// +// Drive ID offsets of interest +// +#define IDE_DEVID_GENCONFIG 0 +#define IDE_DEVID_SERNO 20 +#define IDE_DEVID_MODEL 54 +#define IDE_DEVID_LBA_CAPACITY 120 + +struct ide_priv { + cyg_uint8 controller; + cyg_uint8 drive; + cyg_uint16 flags; +}; + +/* flag values */ +#define IDE_DEV_PRESENT 1 // Device is present +#define IDE_DEV_PACKET 2 // Supports packet interface +#define IDE_DEV_ADDR48 3 // Supports 48bit addressing + +#endif // CYGONCE_REDBOOT_IDE_H
--- a/packages/redboot/current/src/flash.c +++ b/packages/redboot/current/src/flash.c @@ -70,7 +70,7 @@ local_cmd_entry("init", #endif local_cmd_entry("list", "Display contents of FLASH Image System [FIS]", - FIS_LIST_OPTS, + FIS_LIST_OPTS, fis_list, FIS_cmds ); @@ -270,18 +270,18 @@ fis_init(int argc, char *argv[]) if (full_init) { unsigned long erase_start, erase_size; - // Erase everything except default RedBoot images, fis block, and config block. - // FIXME! This still assumes that fis and config blocks can use top of FLASH. + // Erase everything except default RedBoot images, fis block, and config block. + // FIXME! This still assumes that fis and config blocks can use top of FLASH. // first deal with the possible first part, before RedBoot images: erase_start = (unsigned long)flash_start + CYGNUM_REDBOOT_FLASH_RESERVED_BASE; erase_size = (unsigned long)flash_start + CYGBLD_REDBOOT_FLASH_BOOT_OFFSET; if ( erase_size > erase_start ) { erase_size -= erase_start; - if ((stat = flash_erase((void *)erase_start, erase_size, - (void **)&err_addr)) != 0) { - printf(" initialization failed %p: 0x%x(%s)\n", - err_addr, stat, flash_errmsg(stat)); + if ((stat = flash_erase((void *)erase_start, erase_size, + (void **)&err_addr)) != 0) { + printf(" initialization failed %p: 0x%x(%s)\n", + err_addr, stat, flash_errmsg(stat)); } } // second deal with the larger part in the main: @@ -537,6 +537,11 @@ fis_create(int argc, char *argv[]) printf(" valid range is %p-%p\n", (void *)flash_start, (void *)flash_end); return; } + if (flash_addr_set && flash_addr & (block_size-1)) { + printf("Invalid FLASH address: %p\n", (void *)flash_addr); + printf(" must be 0x%x aligned\n", block_size); + return; + } if (strlen(name) >= sizeof(img->name)) { printf("Name is too long, must be less than %d chars\n", (int)sizeof(img->name)); return; @@ -857,6 +862,11 @@ fis_write(int argc, char *argv[]) printf(" valid range is %p-%p\n", (void *)flash_start, (void *)flash_end); return; } + if (flash_addr_set && flash_addr & (block_size-1)) { + printf("Invalid FLASH address: %p\n", (void *)flash_addr); + printf(" must be 0x%x aligned\n", block_size); + return; + } if ((mem_addr < (unsigned long)ram_start) || ((mem_addr+length) >= (unsigned long)ram_end)) { printf("** WARNING: RAM address: %p may be invalid\n", (void *)mem_addr); @@ -920,6 +930,11 @@ fis_erase(int argc, char *argv[]) printf(" valid range is %p-%p\n", (void *)flash_start, (void *)flash_end); return; } + if (flash_addr_set && flash_addr & (block_size-1)) { + printf("Invalid FLASH address: %p\n", (void *)flash_addr); + printf(" must be 0x%x aligned\n", block_size); + return; + } // Safety check - make sure the address range is not within the code we're running if (flash_code_overlaps((void *)flash_addr, (void *)(flash_addr+length-1))) { printf("Can't erase this region - contains code in use!\n");
new file mode 100644 --- /dev/null +++ b/packages/redboot/current/src/fs/disk.c @@ -0,0 +1,382 @@ +//========================================================================== +// +// disk.c +// +// RedBoot disk support +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): msalter +// Contributors: msalter +// Date: 2001-07-14 +// Purpose: +// Description: +// +// This code is part of RedBoot (tm). +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <redboot.h> +#include <fs/disk.h> + +#ifdef CYGSEM_REDBOOT_DISK_EXT2FS +#include <fs/e2fs.h> +#endif + +static void do_disks(int argc, char *argv[]); + +RedBoot_cmd("disks", + "Display disks/partitions.", + "", + do_disks + ); + +static disk_t disk_table[CYGNUM_REDBOOT_MAX_DISKS]; +static int disk_count = 0; + +static int +find_dos_partitions(disk_t *d, cyg_uint8 *mbr) +{ + cyg_uint32 s, n, tmp; + struct mbr_partition *p; + int i, found = 0; + + p = (struct mbr_partition *)(mbr + MBR_PTABLE_OFFSET); + + // Look for primary partitions + for (i = 0; i < 4 && i < CYGNUM_REDBOOT_MAX_PARTITIONS; i++) { + + // Have to use memcpy because of alignment + memcpy(&tmp, p->start_sect, 4); + s = SWAB_LE32(tmp); + memcpy(&tmp, p->nr_sects, 4); + n = SWAB_LE32(tmp); + + if (s && n) { + ++found; + d->partitions[i].disk = d; + d->partitions[i].start_sector = s; + d->partitions[i].nr_sectors = n; + d->partitions[i].systype = p->sys_ind; + d->partitions[i].bootflag = p->boot_ind; + } + p++; + } + +#if CYGNUM_REDBOOT_MAX_PARTITIONS > 4 + { + cyg_uint32 buf[SECTOR_SIZE/sizeof(cyg_uint32)]; + cyg_uint16 magic; + int j, nextp; + + // Go back through and find extended partitions + for (i = 0, nextp = 4; i < 4 && nextp < CYGNUM_REDBOOT_MAX_PARTITIONS; i++) { + if (d->partitions[i].systype == SYSTYPE_EXTENDED) { + // read partition boot record (same format as mbr) + if (DISK_READ(d, d->partitions[i].start_sector, buf, 1) <= 0) + break; + + magic = *(cyg_uint16 *)((char *)buf + MBR_MAGIC_OFFSET); + if (SWAB_LE16(magic) != MBR_MAGIC) + continue; + + p = (struct mbr_partition *)(buf + MBR_PTABLE_OFFSET); + + for (j = 0; i < 4 && nextp < CYGNUM_REDBOOT_MAX_PARTITIONS; j++, nextp++) { + // Have to use memcpy because of alignment + memcpy(&tmp, p->start_sect, 4); + s = SWAB_LE32(tmp); + memcpy(&tmp, p->nr_sects, 4); + n = SWAB_LE32(tmp); + + if (s && n) { + ++found; + d->partitions[nextp].disk = d; + d->partitions[nextp].start_sector = s + d->partitions[i].start_sector; + d->partitions[nextp].nr_sectors = n; + d->partitions[nextp].systype = p->sys_ind; + d->partitions[nextp].bootflag = p->boot_ind; + } + ++p; + } + } + } + } +#endif + + return found; +} + + +// Find partitions on given disk. +// Return number of partitions found +static int +find_partitions(disk_t *d) +{ + cyg_uint32 buf[SECTOR_SIZE/sizeof(cyg_uint32)]; + cyg_uint16 magic; + partition_t *p; + int i, found = 0; + + + if (d->kind == DISK_IDE_CDROM) { + // no partition table, so fake it + p = d->partitions; + p->disk = d; + p->start_sector = 0; + p->nr_sectors = d->nr_sectors; + return 1; + } + + // read Master Boot Record + if (DISK_READ(d, 0, buf, 1) <= 0) + return 0; + + // Check for DOS MBR + magic = *(cyg_uint16 *)((char *)buf + MBR_MAGIC_OFFSET); + if (SWAB_LE16(magic) == MBR_MAGIC) { + found = find_dos_partitions(d, (cyg_uint8 *)buf); + } else { + // Might want to handle other MBR types, here... + } + +#ifdef CYGSEM_REDBOOT_DISK_ISO9660 + if (d->kind == DISK_IDE_CDROM) { + p->funs = &redboot_iso9660_funs; + return found; + } +#endif + + // Now go through all partitions and install the correct + // funcs for supported filesystems. + for (i = 0, p = d->partitions; i < CYGNUM_REDBOOT_MAX_PARTITIONS; i++, p++) { + switch (p->systype) { +#ifdef CYGSEM_REDBOOT_DISK_EXT2FS + case SYSTYPE_LINUX: + p->funs = &redboot_e2fs_funs; + break; +#endif +#ifdef CYGSEM_REDBOOT_DISK_FAT16 + case SYSTYPE_FAT16: + p->funs = &redboot_fat16_funs; + break; +#endif +#ifdef CYGSEM_REDBOOT_DISK_FAT32 + case SYSTYPE_FAT32: + p->funs = &redboot_fat32_funs; + break; +#endif + default: + break; // ignore unsupported filesystems + } + } + + return found; +} + +// Add a disk to the disk table. +// Return zero if no more room in table. +externC int +disk_register(disk_t *d) +{ + int i; + + // make sure we have room for it + if (disk_count >= CYGNUM_REDBOOT_MAX_DISKS) + return 0; + + // Set the index + d->index = 0; + for (i = 0; i < disk_count; i++) + if (disk_table[i].kind == d->kind) + d->index++; + + // put it in the table + disk_table[disk_count] = *d; + + // fill in partition info + find_partitions(&disk_table[disk_count++]); + + return 1; +} + +// Convert a filename in the form <partition_name>:<filename> into +// a partition and path. +// +static int +disk_parse_filename(const char *name, partition_t **part, const char **path) +{ + int i, kind, index, pindex; + + kind = index = pindex = 0; + + if (name[0] == 'h' && name[1] == 'd') { + // IDE hard drives + kind = DISK_IDE_HD; + if (name[2] < 'a' || name[2] > 'z') + return 0; + index = name[2] - 'a'; + if (name[3] < '1' || name[3] >= ('1' + CYGNUM_REDBOOT_MAX_PARTITIONS)) + return 0; + pindex = name[3] - '1'; + if (name[4] != ':') + return 0; + *path = &name[5]; + } + + if (kind) { + for (i = 0; i < CYGNUM_REDBOOT_MAX_DISKS; i++) { + if (disk_table[i].kind == kind && disk_table[i].index == index) { + *part = &disk_table[i].partitions[pindex]; + return 1; + } + } + } + return 0; +} + +static const struct { + int kind; + const char *str; +} systype_names[] = { + { SYSTYPE_FAT12, "FAT12" }, + { SYSTYPE_FAT16_32M, "FAT16 <32M" }, + { SYSTYPE_FAT16, "FAT16" }, + { SYSTYPE_EXTENDED, "Extended" }, + { SYSTYPE_LINUX_SWAP, "Linux Swap" }, + { SYSTYPE_LINUX, "Linux" } +}; + +static const char * +systype_name(int systype) +{ + int i; + + for (i = 0; i < sizeof(systype_names)/sizeof(systype_names[0]); i++) + if (systype_names[i].kind == systype) + return systype_names[i].str; + return "Unknown"; +} + +// List disk partitions +static void +do_disks(int argc, char *argv[]) +{ + int i, j; + disk_t *d; + partition_t *p; + char name[16]; + + for (i = 0, d = disk_table; i < disk_count; i++, d++) { + switch (d->kind) { + case DISK_IDE_HD: + for (j = 0, p = d->partitions; j < CYGNUM_REDBOOT_MAX_PARTITIONS; j++, p++) { + if (p->systype) { + sprintf(name, "hd%c%d", 'a' + d->index, j+1); + printf("%-8s %s\n", name, systype_name(p->systype)); + } + } + break; + case DISK_IDE_CDROM: + sprintf(name, "cd%d", d->index); + printf("%-8s ISO9660\n", name); + break; + } + } +} + +static void *fileptr; +static partition_t *file_part; + +externC int +disk_stream_open(char *filename, int *err) +{ + const char *filepath; + + // The filename is in <disk>:<path> format. + // Convert to a partition and path. + if (!disk_parse_filename(filename, &file_part, &filepath)) { + *err = diskerr_badname; + return -1; + } + + if (file_part->systype == 0 || file_part->funs == (fs_funs_t *)0) { + *err = diskerr_partition; + return -1; + } + + fileptr = (file_part->funs->open)(file_part, filepath); + if (fileptr == NULL) { + *err = diskerr_open; + return -1; + } + return 0; +} + +externC int +disk_stream_read(char *buf, int size, int *err) +{ + int nread; + + if ((nread = (file_part->funs->read)(fileptr, buf, size)) != size) { + *err = diskerr_read; + return -1; + } + return nread; +} + +externC void +disk_stream_close(int *err) +{ + fileptr = NULL; +} + +externC char * +disk_error(int err) +{ + switch (err) { + case diskerr_badname: + return "Bad filename"; + break; + case diskerr_partition: + return "Unsupported filesystem"; + break; + case diskerr_open: + return "Can't open file"; + break; + case diskerr_read: + return "Can't read file"; + break; + default: + return "Unknown error"; + break; + } +} +
new file mode 100644 --- /dev/null +++ b/packages/redboot/current/src/fs/e2fs.c @@ -0,0 +1,598 @@ +//========================================================================== +// +// e2fs.c +// +// RedBoot support for second extended filesystem +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): msalter +// Contributors: msalter +// Date: 2001-07-14 +// Purpose: +// Description: +// +// This code is part of RedBoot (tm). +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <redboot.h> +#include <fs/disk.h> +#include <fs/e2fs.h> + +#define DEBUG_E2FS 0 + +#if DEBUG_E2FS > 4 +static void dump_sb(struct e2fs_super_block *s); +static void dump_inode(struct e2fs_inode *i); +#endif + +static void *e2fs_open(partition_t *p, const char *path); +static int e2fs_read(void *fp, char *buf, cyg_uint32 nbytes); + +// This structure is the only thing exported by this module. +// These filesystem function pointers are attached to disk +// partitions in the generic disk handling code. +// +fs_funs_t redboot_e2fs_funs = { + e2fs_open, + e2fs_read +}; + +// A single block buffer to be shared carefully. +static cyg_uint32 blockbuf[E2FS_MAX_BLOCK_SIZE/sizeof(cyg_uint32)]; + +#define __READ_BLOCK(n) \ + PARTITION_READ(e2fs->part, E2FS_BLOCK_TO_SECTOR(e2fs, (n)), \ + blockbuf, e2fs->blocksize/SECTOR_SIZE) + +// Get a group descriptor. Returns non-zero for success. +// +static int +e2fs_get_gdesc(e2fs_desc_t *e2fs, cyg_uint32 group_nr, e2fs_group_t *gdesc) +{ + cyg_uint32 sec_nr; + + if (group_nr < e2fs->gdesc_first || + group_nr >= (e2fs->gdesc_first + E2FS_GDESC_CACHE_SIZE)) { + + // cache miss + sec_nr = E2FS_BLOCK_TO_SECTOR(e2fs, e2fs->gdesc_block); + sec_nr += (group_nr / E2FS_GDESC_PER_SECTOR); + +#if DEBUG_E2FS > 2 + printf("%s: group[%d] cache miss, sec_nr[%d]\n", + __FUNCTION__, group_nr, sec_nr); +#endif + if (!PARTITION_READ(e2fs->part, sec_nr, (cyg_uint32 *)e2fs->gdesc_cache, + sizeof(e2fs->gdesc_cache)/SECTOR_SIZE)) + return 0; + } + *gdesc = e2fs->gdesc_cache[group_nr - e2fs->gdesc_first]; + + return 1; +} + +// Read the requested inode from disk. Return non-zero if successful +// +static int +e2fs_get_inode(e2fs_desc_t *e2fs, int ino, e2fs_inode_t *ip) +{ + cyg_uint32 offset, sec_nr, buf[SECTOR_SIZE/sizeof(cyg_uint32)]; + e2fs_group_t gdesc; + + // get descriptor for group which this inode belongs to + if (!e2fs_get_gdesc(e2fs, (ino - 1) / e2fs->inodes_per_group, &gdesc)) + return 0; + if (gdesc.inode_table == 0) + return 0; + + // byte offset within group inode table + offset = ((ino - 1) % e2fs->inodes_per_group) * sizeof(struct e2fs_inode); + + // figure out which sector holds the inode + sec_nr = E2FS_BLOCK_TO_SECTOR(e2fs, SWAB_LE32(gdesc.inode_table)); + sec_nr += offset / SECTOR_SIZE; + + // and the offset within that sector. + offset %= SECTOR_SIZE; + +#if DEBUG_E2FS > 0 + printf("%s: ino[%d], sec_nr[%d] offset[%d]\n", __FUNCTION__, + ino, sec_nr, offset); +#endif + + if (!PARTITION_READ(e2fs->part, sec_nr, buf, 1)) + return 0; + + *ip = *(e2fs_inode_t *)((char *)buf + offset); + +#if DEBUG_E2FS > 0 + printf("%s: inode size[%d]\n", __FUNCTION__, SWAB_LE32(ip->size)); +#endif + + return 1; +} + +// Mount an e2fs filesystem on the given partition. +// Return 0 if successful. +// +static int +e2fs_mount(partition_t *part, e2fs_desc_t *e2fs) +{ + int sb_block = 1; + cyg_uint32 sb_buf[E2FS_MIN_BLOCK_SIZE/sizeof(cyg_uint32)]; + struct e2fs_super_block *sb = (struct e2fs_super_block *)sb_buf; + + e2fs->part = part; + + if (!PARTITION_READ(part, sb_block*(E2FS_MIN_BLOCK_SIZE/SECTOR_SIZE), + (cyg_uint32 *)sb, E2FS_MIN_BLOCK_SIZE/SECTOR_SIZE)) + return -1; + + if (SWAB_LE16(sb->magic) != E2FS_SUPER_MAGIC) { + printf("ext2_mount: bad magic 0x%x\n", SWAB_LE16(sb->magic)); + return -1; + } + + // save some stuff for easy access + e2fs->blocksize = E2FS_BLOCK_SIZE(sb); + e2fs->nr_ind_blocks = (e2fs)->blocksize / sizeof(cyg_uint32); + e2fs->nr_dind_blocks = e2fs->nr_ind_blocks * ((e2fs)->blocksize / sizeof(cyg_uint32)); + e2fs->nr_tind_blocks = e2fs->nr_dind_blocks * ((e2fs)->blocksize / sizeof(cyg_uint32)); + e2fs->blocks_per_group = SWAB_LE32(sb->blocks_per_group); + e2fs->ngroups = (SWAB_LE32(sb->blocks_count) + e2fs->blocks_per_group - 1) / + e2fs->blocks_per_group; + e2fs->inodes_per_group = SWAB_LE32(sb->inodes_per_group); + + // Find the group descriptors which follow superblock + e2fs->gdesc_block = ((sb_block * E2FS_MIN_BLOCK_SIZE) / e2fs->blocksize) + 1; + e2fs->gdesc_first = 0; // cache group 0 initially + + if (!PARTITION_READ(part, E2FS_BLOCK_TO_SECTOR(e2fs,e2fs->gdesc_block), + (cyg_uint32 *)e2fs->gdesc_cache, 1)) + return -1; + +#if DEBUG_E2FS > 1 + printf("E2FS superblock:\n"); + printf(" [%d] inodes\n", SWAB_LE32(sb->inodes_count)); + printf(" [%d] blocks\n", SWAB_LE32(sb->blocks_count)); + printf(" [%d] blocksize\n", e2fs->blocksize); + printf(" [%d] blocks per group\n", e2fs->blocks_per_group); + printf(" [%d] ngroups\n", e2fs->ngroups); +#endif + +#if DEBUG_E2FS > 4 + dump_sb(sb); +#endif + + return 0; +} + +// Convert a block index into inode data into a block_nr. +// If successful, store block number in pblknr and return non-zero. +// +// NB: This needs some block/sector caching to be speedier. But +// that takes memory and speed is not too bad now for files +// small enough to avoid double and triple indirection. +// +static int +e2fs_inode_block(e2fs_desc_t *e2fs, e2fs_inode_t *inode, + cyg_uint32 bindex, cyg_uint32 *pblknr) +{ + if (bindex < E2FS_NR_DIR_BLOCKS) { + *pblknr = SWAB_LE32(inode->block[bindex]); + return 1; + } + bindex -= E2FS_NR_DIR_BLOCKS; + + if (bindex < e2fs->nr_ind_blocks) { + // Indirect block + if (!__READ_BLOCK(SWAB_LE32(inode->block[E2FS_IND_BLOCK]))) + return 0; + *pblknr = blockbuf[bindex]; + return 1; + } + bindex -= e2fs->nr_ind_blocks; + + if (bindex < e2fs->nr_dind_blocks) { + // Double indirect block + if (!__READ_BLOCK(SWAB_LE32(inode->block[E2FS_DIND_BLOCK]))) + return 0; + if (!__READ_BLOCK(SWAB_LE32(blockbuf[bindex / e2fs->nr_ind_blocks]))) + return 0; + *pblknr = blockbuf[bindex % e2fs->nr_ind_blocks]; + return 1; + } + bindex -= e2fs->nr_dind_blocks; + + // Triple indirect block + if (!__READ_BLOCK(SWAB_LE32(inode->block[E2FS_TIND_BLOCK]))) + return 0; + if (!__READ_BLOCK(SWAB_LE32(blockbuf[bindex / e2fs->nr_dind_blocks]))) + return 0; + bindex %= e2fs->nr_dind_blocks; + if (!__READ_BLOCK(SWAB_LE32(blockbuf[bindex / e2fs->nr_ind_blocks]))) + return 0; + *pblknr = blockbuf[bindex % e2fs->nr_ind_blocks]; + return 1; +} + + +// search a single directory block in memory looking for an +// entry with the given name. Return pointer to entry if +// found, NULL if not. +// +static e2fs_dir_entry_t * +search_dir_block(e2fs_desc_t *e2fs, cyg_uint32 *blkbuf, + const char *name, int namelen) +{ + e2fs_dir_entry_t *dir; + cyg_uint16 reclen, len; + cyg_uint32 offset; + + offset = 0; + while (offset < e2fs->blocksize) { + dir = (e2fs_dir_entry_t *)((char *)blkbuf + offset); + reclen = SWAB_LE16(dir->reclen); + offset += reclen; + len = dir->namelen; + + // terminate on anything which doesn't make sense + if (reclen < 8 || (len + 8) > reclen || offset > (e2fs->blocksize + 1)) + return NULL; + + if (dir->inode && len == namelen && !strncmp(dir->name, name, len)) + return dir; + } + return NULL; +} + + +// Look in the given directory for an entry with the given name. +// If found, return a pointer to that entry. Return NULL if not +// found. +// +static e2fs_dir_entry_t * +e2fs_dir_lookup(e2fs_desc_t *e2fs, cyg_uint32 dir_ino, + const char *name, int namelen) +{ + e2fs_inode_t inode; + e2fs_dir_entry_t *dir; + cyg_uint32 nblocks, last_block_size, i, block_nr, nbytes; + +#if DEBUG_E2FS > 0 + printf("%s: looking for %s [%d] in ino[%d]\n", + __FUNCTION__, name, namelen, dir_ino); +#endif + + if (!e2fs_get_inode(e2fs, dir_ino, &inode)) { +#if DEBUG_E2FS > 0 + printf("%s: e2fs_get_inode [%d] failed\n", __FUNCTION__, dir_ino); +#endif + return NULL; + } + + nbytes = SWAB_LE32(inode.size); + nblocks = (nbytes + e2fs->blocksize - 1) / e2fs->blocksize; + + last_block_size = nbytes % e2fs->blocksize; + if (last_block_size == 0) + last_block_size = e2fs->blocksize; + + for (i = 0; i < nblocks; i++) { + if (!e2fs_inode_block(e2fs, &inode, i, &block_nr)) + return NULL; + + if (block_nr) { + if (!__READ_BLOCK(block_nr)) + return NULL; + } else + memset(blockbuf, 0, e2fs->blocksize); + + dir = search_dir_block(e2fs, blockbuf, name, namelen); + + if (dir != NULL) + return dir; + } + return NULL; +} + +typedef struct ino_info { + cyg_uint32 ino; + cyg_uint32 parent_ino; + cyg_uint8 filetype; +} ino_info_t; + +static int e2fs_inode_lookup(e2fs_desc_t *e2fs, cyg_uint32 dir_ino, + const char *pathname, ino_info_t *info); + +// Starting from the given directory, find the inode number, filetype, and +// parent inode for the file pointed to by the given symbolic link inode. +// If successful, fills out ino_info_t and return true. +// +static int +e2fs_follow_symlink(e2fs_desc_t *e2fs, cyg_uint32 dir_ino, cyg_uint32 sym_ino, ino_info_t *info) +{ +#define MAX_SYMLINK_NAME 255 + char symlink[MAX_SYMLINK_NAME+1]; + int pathlen; + cyg_uint32 block_nr; + e2fs_inode_t inode; + + if (!e2fs_get_inode(e2fs, sym_ino, &inode)) { +#if DEBUG_E2FS > 0 + printf("%s: e2fs_get_inode [%d] failed\n", __FUNCTION__, *ino); +#endif + return 0; + } + + pathlen = SWAB_LE32(inode.size); + if (pathlen > MAX_SYMLINK_NAME) + return 0; + + if (inode.blocks) { + if (!e2fs_inode_block(e2fs, &inode, 0, &block_nr)) + return 0; + if (block_nr) { + if (!PARTITION_READ(e2fs->part, E2FS_BLOCK_TO_SECTOR(e2fs, block_nr), + blockbuf, e2fs->blocksize/SECTOR_SIZE)) + return 0; + memcpy(symlink, blockbuf, pathlen); + } else + return 0; + } else { + // small enough path to fit in inode struct + memcpy(symlink, (char *)&inode.block[0], pathlen); + } + symlink[pathlen] = 0; + + return e2fs_inode_lookup(e2fs, dir_ino, symlink, info); +} + + +// Starting from the given directory, find the inode number, filetype, and +// parent inode for the given file pathname. +// If successful, fills out ino_info_t and return true. +// +static int +e2fs_inode_lookup(e2fs_desc_t *e2fs, cyg_uint32 dir_ino, const char *pathname, ino_info_t *info) +{ + int len, pathlen; + const char *p; + e2fs_dir_entry_t *dir = NULL; + + if (!pathname || (pathlen = strlen(pathname)) == 0) + return 0; + + if (*pathname == '/') { + if (--pathlen == 0) { + info->ino = info->parent_ino = E2FS_ROOT_INO; + info->filetype = E2FS_FTYPE_DIR; + return 1; + } + ++pathname; + dir_ino = E2FS_ROOT_INO; + } + + while (pathlen) { + // find next delimiter in path. + for (p = pathname, len = 0; len < pathlen; len++, p++) { + // skip delimiter if found. + if (*p == '/') { + ++p; + --pathlen; + break; + } + } + dir = e2fs_dir_lookup(e2fs, dir_ino, pathname, len); + if (dir == NULL) + return 0; + + pathlen -= len; + pathname = p; + + switch (dir->filetype) { + case E2FS_FTYPE_SYMLINK: + // follow the symbolic link (this will cause recursion) + if (!e2fs_follow_symlink(e2fs, dir_ino, SWAB_LE32(dir->inode), info)) + return 0; + if (pathlen == 0) + return 1; + // must be a dir if we want to continue + if (info->filetype != E2FS_FTYPE_DIR) + return 0; + dir_ino = info->ino; + break; + + case E2FS_FTYPE_DIR: + if (pathlen) + dir_ino = SWAB_LE32(dir->inode); + break; + + case E2FS_FTYPE_REG_FILE: + if (pathlen) + return 0; // regular file embedded in middle of path + break; + + case E2FS_FTYPE_UNKNOWN: + case E2FS_FTYPE_CHRDEV: + case E2FS_FTYPE_BLKDEV: + case E2FS_FTYPE_FIFO: + case E2FS_FTYPE_SOCK: + default: + return 0; + } + } + info->ino = SWAB_LE32(dir->inode); + info->parent_ino = dir_ino; + info->filetype = dir->filetype; + return 1; +} + +struct read_info { + e2fs_desc_t e2fs_desc; + e2fs_inode_t inode; + cyg_uint32 fsize; + cyg_uint32 fpos; +}; + +static void * +e2fs_open(partition_t *p, const char *filepath) +{ + static struct read_info rinfo; + ino_info_t ino_info; + + // mount partition + if (e2fs_mount(p, &rinfo.e2fs_desc) != 0) { + printf("mount failed.\n"); + return NULL; + } + + // find file inode + if (!e2fs_inode_lookup(&rinfo.e2fs_desc, E2FS_ROOT_INO, filepath, &ino_info)) { + printf("%s: e2fs_inode_lookup failed\n", __FUNCTION__); + return NULL; + } + + // read inode + if (!e2fs_get_inode(&rinfo.e2fs_desc, ino_info.ino, &rinfo.inode)) { + printf("%s: e2fs_get_inode failed for ino[%d]\n", __FUNCTION__, ino_info.ino); + return NULL; + } + + rinfo.fsize = SWAB_LE32(rinfo.inode.size); + rinfo.fpos = 0; + + return &rinfo; +} + +static int +e2fs_read(void *fp, char *buf, cyg_uint32 nbytes) +{ + struct read_info *info = fp; + e2fs_desc_t *e2fs; + cyg_uint32 nread = 0, rem, block_nr, bindex, to_read; + + if ((info->fpos + nbytes) > info->fsize) + nbytes = info->fsize - info->fpos; + + e2fs = &info->e2fs_desc; + + // see if we need to copy leftover data from last read call + rem = e2fs->blocksize - (info->fpos % e2fs->blocksize); + if (rem != e2fs->blocksize) { + char *p = (char *)blockbuf + e2fs->blocksize - rem; + + if (rem > nbytes) + rem = nbytes; + + memcpy(buf, p, rem); + + nread += rem; + buf += rem; + info->fpos += rem; + } + + // now loop through blocks if we're not done + bindex = info->fpos / e2fs->blocksize; + while (nread < nbytes) { + if (!e2fs_inode_block(e2fs, &info->inode, bindex, &block_nr)) + return -1; + + if (block_nr) { + if (!PARTITION_READ(e2fs->part, E2FS_BLOCK_TO_SECTOR(e2fs, block_nr), + blockbuf, e2fs->blocksize/SECTOR_SIZE)) + return 0; + } else + memset(blockbuf, 0, e2fs->blocksize); + + to_read = nbytes - nread; + if (to_read > e2fs->blocksize) + to_read = e2fs->blocksize; + + memcpy(buf, blockbuf, to_read); + + nread += to_read; + buf += to_read; + info->fpos += to_read; + ++bindex; + } + + return nread; +} + +#if DEBUG_E2FS > 4 +static void dump_sb(struct e2fs_super_block *s) +{ + printf("inode_count: %d\n", SWAB_LE32(s->inodes_count)); + printf("blocks_count: %d\n", SWAB_LE32(s->blocks_count)); + printf("r_blocks_count: %d\n", SWAB_LE32(s->r_blocks_count)); + printf("free_blocks_count: %d\n", SWAB_LE32(s->free_blocks_count)); + printf("free_inodes_count: %d\n", SWAB_LE32(s->free_inodes_count)); + printf("first_data_block: %d\n", SWAB_LE32(s->first_data_block)); + printf("log_block_size: %d\n", SWAB_LE32(s->log_block_size)); + printf("log_frag_size: %d\n", SWAB_LE32(s->log_frag_size)); + printf("blocks_per_group: %d\n", SWAB_LE32(s->blocks_per_group)); + printf("frags_per_group: %d\n", SWAB_LE32(s->frags_per_group)); + printf("inodes_per_group: %d\n", SWAB_LE32(s->inodes_per_group)); + printf("mnt_count: %d\n", SWAB_LE16(s->mnt_count)); + printf("max_mnt_count: %d\n", SWAB_LE16(s->max_mnt_count)); + printf("magic: %d\n", SWAB_LE16(s->magic)); + printf("state: %d\n", SWAB_LE16(s->state)); + printf("errors: %d\n", SWAB_LE16(s->errors)); + printf("minor_rev_level: %d\n", SWAB_LE16(s->minor_rev_level)); + printf("lastcheck: %d\n", SWAB_LE32(s->lastcheck)); + printf("checkinterval: %d\n", SWAB_LE32(s->checkinterval)); + printf("creator_os: %d\n", SWAB_LE32(s->creator_os)); + printf("rev_level: %d\n", SWAB_LE32(s->rev_level)); +} + +static void dump_inode(struct e2fs_inode *i) +{ + int j, n; + + printf("mode: %o\n", SWAB_LE16(i->mode)); + printf("uid: %o\n", SWAB_LE16(i->uid)); + printf("size: %d\n", SWAB_LE32(i->size)); + printf("gid: %o\n", SWAB_LE16(i->gid)); + printf("links: %d\n", SWAB_LE16(i->links_count)); + printf("blocks: %d\n", SWAB_LE32(i->blocks)); + + n = i->blocks; + if (n > E2FS_N_BLOCKS) + n = E2FS_N_BLOCKS; + + for (j = 0; j < n; j++) + printf(" block: %d\n", SWAB_LE32(i->block[j])); +} +#endif + +
new file mode 100644 --- /dev/null +++ b/packages/redboot/current/src/fs/ide.c @@ -0,0 +1,236 @@ +//========================================================================== +// +// ide.c +// +// RedBoot IDE support +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): msalter +// Contributors: msalter +// Date: 2001-07-14 +// Purpose: +// Description: +// +// This code is part of RedBoot (tm). +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <redboot.h> +#include <cyg/hal/hal_io.h> +#include <fs/disk.h> +#include <fs/ide.h> + +static int ide_read(struct disk *d, + cyg_uint32 start_sector, + cyg_uint32 *buf, + cyg_uint8 nr_sectors); + +static disk_funs_t ide_funs = { ide_read }; + +static struct ide_priv ide_privs[HAL_IDE_NUM_CONTROLLERS * 2]; + +static inline void +__wait_for_ready(int ctlr) +{ + cyg_uint8 status; + do { + HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status); + } while (status & (IDE_STAT_BSY | IDE_STAT_DRQ)); +} + +static inline int +__wait_for_drq(int ctlr) +{ + cyg_uint8 status; + + CYGACC_CALL_IF_DELAY_US(10); + do { + HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status); + if (status & IDE_STAT_DRQ) + return 1; + } while (status & IDE_STAT_BSY); + + return 0; +} + +static void +ide_reset(int ctlr) +{ + HAL_IDE_WRITE_CONTROL(ctlr, 6); // polled mode, reset asserted + CYGACC_CALL_IF_DELAY_US(5000); + HAL_IDE_WRITE_CONTROL(ctlr, 2); // polled mode, reset cleared + CYGACC_CALL_IF_DELAY_US((cyg_uint32)50000); + __wait_for_ready(ctlr); +} + +static int +ide_ident(int ctlr, int dev, int is_packet_dev, cyg_uint16 *buf) +{ + int i; + + HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_DEVICE, dev << 4); + HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COMMAND, is_packet_dev ? 0xA1 : 0xEC); + + if (!__wait_for_drq(ctlr)) { + cyg_uint8 status; + + HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status); + + printf("%s: NO DRQ for ide%d, device %d. status[%02x]\n", + __FUNCTION__, ctlr, dev, status); + return 0; + } + + for (i = 0; i < (SECTOR_SIZE / sizeof(cyg_uint16)); i++, buf++) + HAL_IDE_READ_UINT16(ctlr, IDE_REG_DATA, *buf); + + return 1; +} + +static int +ide_read_sectors(int ctlr, int dev, cyg_uint32 start, cyg_uint8 count, cyg_uint16 *buf) +{ + int i, j; + cyg_uint16 *p; + + HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COUNT, count); + HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBALOW, start & 0xff); + HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBAMID, (start >> 8) & 0xff); + HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBAHI, (start >> 16) & 0xff); + HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_DEVICE, + ((start >> 24) & 0xf) | (dev << 4) | 0x40); + HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COMMAND, 0x20); + + for(p = buf, i = 0; i < count; i++) { + + if (!__wait_for_drq(ctlr)) { + printf("%s: NO DRQ for ide%d, device %d.\n", + __FUNCTION__, ctlr, dev); + return 0; + } + + for (j = 0; j < (SECTOR_SIZE / sizeof(cyg_uint16)); j++, p++) + HAL_IDE_READ_UINT16(ctlr, IDE_REG_DATA, *p); + } + return 1; +} + +static int +ide_read(struct disk *d, + cyg_uint32 start_sec, cyg_uint32 *buf, cyg_uint8 nr_secs) +{ + struct ide_priv *p = (struct ide_priv *)(d->private); + + return ide_read_sectors(p->controller, p->drive, + start_sec, nr_secs, (cyg_uint16 *)buf); +} + + +static void +ide_init(void) +{ + cyg_uint32 buf[SECTOR_SIZE/sizeof(cyg_uint32)]; + cyg_uint32 u32; + cyg_uint16 u16; + cyg_uint8 sig[2][4]; + int i, j; + disk_t disk; + struct ide_priv *priv; + + HAL_IDE_INIT(); + + CYGACC_CALL_IF_DELAY_US(5); + + priv = ide_privs; + for (i = 0; i < HAL_IDE_NUM_CONTROLLERS; i++) { + + // soft reset the devices on this controller + ide_reset(i); + + // save off signature values for later + HAL_IDE_WRITE_UINT8(i, IDE_REG_DEVICE, (0 << 4)); + HAL_IDE_READ_UINT8(i, IDE_REG_COUNT, sig[0][0]); + HAL_IDE_READ_UINT8(i, IDE_REG_LBALOW, sig[0][1]); + HAL_IDE_READ_UINT8(i, IDE_REG_LBAMID, sig[0][2]); + HAL_IDE_READ_UINT8(i, IDE_REG_LBAHI, sig[0][3]); + HAL_IDE_WRITE_UINT8(i, IDE_REG_DEVICE, (1 << 4)); + HAL_IDE_READ_UINT8(i, IDE_REG_COUNT, sig[1][0]); + HAL_IDE_READ_UINT8(i, IDE_REG_LBALOW, sig[1][1]); + HAL_IDE_READ_UINT8(i, IDE_REG_LBAMID, sig[1][2]); + HAL_IDE_READ_UINT8(i, IDE_REG_LBAHI, sig[1][3]); + + // 2 devices per controller + for (j = 0; j < 2; j++, priv++) { + + priv->controller = i; + priv->drive = j; + priv->flags = 0; + + if (sig[j][0] != 0x01 || sig[j][1] != 0x01) + continue; + + if (!(sig[j][2] == 0x00 && sig[j][3] == 0x00) && + !(sig[j][2] == 0x14 && sig[j][3] == 0xeb)) + continue; + + // device present + + priv->flags = IDE_DEV_PRESENT; + + if (sig[j][2] == 0x14 && sig[j][3] == 0xeb) + priv->flags |= IDE_DEV_PACKET; + + if (ide_ident(i, j, priv->flags & IDE_DEV_PACKET, (cyg_uint16 *)buf) <= 0) + continue; + + memset(&disk, 0, sizeof(disk)); + disk.funs = &ide_funs; + disk.private = priv; + + disk.kind = DISK_IDE_HD; // until proven otherwise + + if (priv->flags & IDE_DEV_PACKET) { + u16 = *(cyg_uint16 *)((char *)buf + IDE_DEVID_GENCONFIG); + if (((u16 >> 8) & 0x1f) == 5) + disk.kind = DISK_IDE_CDROM; + } else { + u32 = *(cyg_uint32 *)((char *)buf + IDE_DEVID_LBA_CAPACITY); + disk.nr_sectors = u32; + } + + if (!disk_register(&disk)) + return; + } + } +} + +RedBoot_init(ide_init, RedBoot_INIT_FIRST); +
--- a/packages/redboot/current/src/load.c +++ b/packages/redboot/current/src/load.c @@ -45,6 +45,9 @@ #include <redboot.h> #include <xyzModem.h> +#ifdef CYGPKG_REDBOOT_DISK +#include <fs/disk.h> +#endif // Buffer used by redboot_getc getc_info_t getc_info; @@ -53,8 +56,11 @@ static char usage[] = "[-r] [-v] " #ifdef CYGPKG_COMPRESS_ZLIB "[-d] " #endif - "[-h <host>] [-m {TFTP | xyzMODEM}]\n" - " [-b <base_address>] <file_name>"; + "[-h <host>] [-m {TFTP | xyzMODEM" +#ifdef CYGPKG_REDBOOT_DISK + " | disk" +#endif + "}]\n [-b <base_address>] <file_name>"; // Exported CLI function RedBoot_cmd("load", @@ -158,11 +164,13 @@ load_srec_image(int (*getc)(void), unsig if ((unsigned long)(addr-addr_offset) < lowest_address) { lowest_address = (unsigned long)(addr - addr_offset); } +#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS if ((addr < user_ram_start) || (addr > user_ram_end)) { if (!verify_action("Attempt to load S-record data to address: %p\n" "RedBoot does not believe this is in RAM", (void*)addr)) return 0; } +#endif count -= ((type-'1'+2)+1); offset += count; while (count-- > 0) { @@ -251,9 +259,10 @@ redboot_getc_rewind(void) } #define MODE_TFTP 0 -#define MODE_XMODEM xyzModem_xmodem -#define MODE_YMODEM xyzModem_ymodem -#define MODE_ZMODEM xyzModem_zmodem +#define MODE_XMODEM xyzModem_xmodem // 1 +#define MODE_YMODEM xyzModem_ymodem // 2 +#define MODE_ZMODEM xyzModem_zmodem // 3 +#define MODE_DISK 4 void do_load(int argc, char *argv[]) @@ -297,7 +306,7 @@ do_load(int argc, char *argv[]) init_opts(&opts[2], 'b', true, OPTION_ARG_TYPE_NUM, (void **)&base, (bool *)&base_addr_set, "load address"); init_opts(&opts[3], 'm', true, OPTION_ARG_TYPE_STR, - (void **)&mode_str, (bool *)&mode_str_set, "download mode (TFTP or xyzMODEM)"); + (void **)&mode_str, (bool *)&mode_str_set, "download mode (TFTP, xyzMODEM, or disk)"); num_options = 4; #ifdef CYGPKG_REDBOOT_NETWORKING init_opts(&opts[4], 'h', true, OPTION_ARG_TYPE_STR, @@ -341,6 +350,10 @@ do_load(int argc, char *argv[]) // When using a serial download type, override verbose // setting: spinner interferes with the protocol. verbose = false; +#ifdef CYGPKG_REDBOOT_DISK + } else if (strcmpci(mode_str, "disk") == 0) { + mode = MODE_DISK; +#endif #ifdef CYGPKG_REDBOOT_NETWORKING } else if (strcmpci(mode_str, "tftp") == 0) { mode = MODE_TFTP; @@ -354,19 +367,21 @@ do_load(int argc, char *argv[]) return; } } -#ifdef CYGPKG_REDBOOT_NETWORKING - if ((mode == MODE_TFTP) && !filename) { +#if defined(CYGPKG_REDBOOT_NETWORKING) || defined(CYGPKG_REDBOOT_DISK) + if ((mode == MODE_TFTP || mode == MODE_DISK) && !filename) { printf("File name missing\n"); printf("usage: load %s\n", usage); return; } #endif +#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS if (base_addr_set && ((base < (unsigned long)user_ram_start) || (base > (unsigned long)user_ram_end))) { if (!verify_action("Specified address (%p) is not believed to be in RAM", (void*)base)) return; } +#endif if (raw && !base_addr_set) { printf("Raw load requires a memory address\n"); return; @@ -381,8 +396,18 @@ do_load(int argc, char *argv[]) redboot_getc_init(tftp_stream_read, verbose); } #endif +#ifdef CYGPKG_REDBOOT_DISK + else if (mode == MODE_DISK) { + res = disk_stream_open(filename, &err); + if (res < 0) { + printf("Can't load '%s': %s\n", filename, disk_error(err)); + return; + } + redboot_getc_init(disk_stream_read, verbose); + } +#endif else { - res = xyzModem_stream_open(filename, mode, &err); + res = xyzModem_stream_open(filename, mode, &err); if (res < 0) { printf("Can't load '%s': %s\n", filename, xyzModem_error(err)); return; @@ -458,13 +483,21 @@ do_load(int argc, char *argv[]) } } } + + switch (mode) { +#ifdef CYGPKG_REDBOOT_DISK + case MODE_DISK: + disk_stream_close(&err); + break; +#endif #ifdef CYGPKG_REDBOOT_NETWORKING - if (mode == MODE_TFTP) { + case MODE_TFTP: tftp_stream_close(&err); - } + break; #endif - if (mode != MODE_TFTP) { + default: xyzModem_stream_close(&err); + break; } return; }
--- a/packages/redboot/current/src/main.c +++ b/packages/redboot/current/src/main.c @@ -523,7 +523,6 @@ set_console_baud_rate(int rate) static int current_rate = CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD; if (rate != current_rate) { - CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT); __chan = CYGACC_CALL_IF_CONSOLE_PROCS(); ret = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_SETBAUD, rate); if (ret <= 0) { @@ -549,7 +548,6 @@ do_baud_rate(int argc, char *argv[]) if (!scan_opts(argc, argv, 1, opts, 1, 0, 0, "")) { return; } - CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT); __chan = CYGACC_CALL_IF_CONSOLE_PROCS(); if (new_rate_set) { #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
--- a/packages/redboot/current/src/net/net_io.c +++ b/packages/redboot/current/src/net/net_io.c @@ -543,6 +543,7 @@ net_init(void) flash_get_config("net_debug", &net_debug, CONFIG_BOOL); flash_get_config("gdb_port", &gdb_port, CONFIG_INT); flash_get_config("bootp", &use_bootp, CONFIG_BOOL); + if (!use_bootp) { ip_addr_t bootp_my_ip; char i; @@ -553,8 +554,9 @@ net_init(void) for (i=0; i<4; i++) __local_ip_addr[i] = bootp_my_ip[i]; } + flash_get_config("bootp_server_ip", &my_bootp_info.bp_siaddr, + CONFIG_IP); } - flash_get_config("bootp_server_ip", &my_bootp_info.bp_siaddr, CONFIG_IP); #endif have_net = false; // Make sure the recv buffers are set up
--- a/packages/redboot/current/src/net/tftp_client.c +++ b/packages/redboot/current/src/net/tftp_client.c @@ -287,6 +287,17 @@ tftp_stream_read(char *buf, tftp_stream.avail -= size; total_bytes += size; } else { + if (tftp_stream.last_good_block != 0) { + // Send out the ACK + hdr->th_opcode = htons(ACK); + hdr->th_block = htons(tftp_stream.last_good_block); + if (__udp_sendto(tftp_stream.data, 4 /* FIXME */, + &tftp_stream.from_addr, &tftp_stream.local_addr) < 0) { + // Problem sending ACK + *err = TFTP_NETERR; + return -1; + } + } if ((tftp_stream.actual_len >= 0) && (tftp_stream.actual_len < SEGSIZE)) { // Out of data break; @@ -303,15 +314,6 @@ tftp_stream_read(char *buf, *err = TFTP_TIMEOUT; return -1; } - // Try resending last ACK - hdr->th_opcode = htons(ACK); - hdr->th_block = htons(tftp_stream.last_good_block); - if (__udp_sendto(tftp_stream.data, 4 /* FIXME */, - &tftp_stream.from_addr, &tftp_stream.local_addr) < 0) { - // Problem sending request - *err = TFTP_NETERR; - return -1; - } } else { if (ntohs(hdr->th_opcode) == DATA) { if (ntohs(hdr->th_block) == (tftp_stream.last_good_block+1)) { @@ -321,15 +323,6 @@ tftp_stream_read(char *buf, tftp_stream.bufp = hdr->th_data; tftp_stream.last_good_block++; } - // Send out the ACK - hdr->th_opcode = htons(ACK); - hdr->th_block = htons(tftp_stream.last_good_block); - if (__udp_sendto(tftp_stream.data, 4 /* FIXME */, - &tftp_stream.from_addr, &tftp_stream.local_addr) < 0) { - // Problem sending ACK - *err = TFTP_NETERR; - return -1; - } } else { if (ntohs(hdr->th_opcode) == ERROR) { *err = ntohs(hdr->th_code);
--- a/packages/redboot/current/src/xyzModem.c +++ b/packages/redboot/current/src/xyzModem.c @@ -355,6 +355,7 @@ xyzModem_stream_read(char *buf, int size int retries; total = 0; + stat = xyzModem_cancel; // Try and get 'size' bytes into the buffer while (!xyz.at_eof && (size > 0)) { if (xyz.len == 0) {
