Mercurial > ecos
changeset 196:9b55e9c69693
Merge from eCos master repository on 2001-11-23-15:32:03-GMT
line wrap: on
line diff
--- a/host/tools/configtool/standalone/wxwin/CHANGES.txt +++ b/host/tools/configtool/standalone/wxwin/CHANGES.txt @@ -1,13 +1,17 @@ Release History for eCos Configuration Tool 2 ============================================= -*** Version 2.08, September 25th 2001 +*** Version 2.08, October 25th 2001 - Looks in PATH for gcc locations on UNIX. - Uses current directory for initial save directory, instead of configtool directory. +- Mounts /ecos-x paths (where x is a drive letter) for repository, build + and install paths, so that the compiler is always using text-mounted + files. + *** Version 2.07, September 5th 2001
--- a/host/tools/configtool/standalone/wxwin/TODO.txt +++ b/host/tools/configtool/standalone/wxwin/TODO.txt @@ -15,10 +15,6 @@ To-Do List for Configuration Tool 2.x - Switching to Rich Edit control for Output Window causes scroll problems on Windows 98. -- Added menu option Build | Generate Build Tree to simply recreate the - build tree, since otherwise one sometimes has to alter a value to convince the - tool to save and create the tree. - - Resolve target makefile problems. A user:- "It looks like the Configuration Tool 2.0 builds the library by replacing
--- a/host/tools/configtool/standalone/wxwin/setup/configtool.iss +++ b/host/tools/configtool/standalone/wxwin/setup/configtool.iss @@ -29,7 +29,7 @@ AlwaysCreateUninstallIcon=1 Uninstallable=1 DefaultDirName=c:\Program Files\Red Hat\eCos Configuration Tool - DefaultGroupName=eCos Configuration Tool + DefaultGroupName=Red Hat eCos Configuration Tool 2.08 LicenseFile=v:\deliver\configtool\license.txt InfoBeforeFile=v:\deliver\configtool\readme.txt MessagesFile=compiler:default.isl
--- a/host/tools/configtool/standalone/wxwin/setup/innotop.txt +++ b/host/tools/configtool/standalone/wxwin/setup/innotop.txt @@ -29,7 +29,7 @@ AlwaysCreateUninstallIcon=1 Uninstallable=1 DefaultDirName=c:\Program Files\Red Hat\eCos Configuration Tool - DefaultGroupName=Red Hat eCos Configuration Tool + DefaultGroupName=Red Hat eCos Configuration Tool %VERSION% LicenseFile=v:\deliver\configtool\license.txt InfoBeforeFile=v:\deliver\configtool\readme.txt MessagesFile=compiler:default.isl
--- a/host/tools/ecostest/common/eCosTest.cpp +++ b/host/tools/ecostest/common/eCosTest.cpp @@ -1243,7 +1243,7 @@ bool CeCosTest::InteractiveInferior(LPCT // any output so far // (if target ready) host:port if(GetTargetReady(strHostPort)){ - Log(_T("Use %s\n"),(LPCTSTR)strHostPort); + Log(_T("Use target remote %s\n"),(LPCTSTR)strHostPort); String strInferior(m_ep.Platform()->Prefix()); strInferior+=_T("-gdb"); #ifdef _WIN32
--- a/packages/ChangeLog +++ b/packages/ChangeLog @@ -1,3 +1,22 @@ +2001-11-22 Jesper Skov <jskov@redhat.com> + + * pkgconf/rules.mak: Added HOST_CC definition. This really belongs + in the top-level makefile, but requires tool changes. + +2001-11-21 Andrew Lunn <andrew.lunn@ascom.ch> + + * pkgconf/rules.mak (tests.stamp): Be explicit about substitution + to avoid potential problems with trailing spaces. + [Bug #56239] + +2001-11-14 Jesper Skov <jskov@redhat.com> + + * ecos.db: edb7xxx target now uses generic CS8900A driver. + +2001-11-02 Jesper Skov <jskov@redhat.com> + + * ecos.db: Added CS8900A package. + 2001-10-30 Jonathan Larmour <jlarmour@redhat.com> * ecos.db: Added ARM Integrator target including HAL, serial driver, @@ -254,7 +273,6 @@ 2000-11-25 Jonathan Larmour <jlarmour@ 2000-11-21 Bart Veer <bartv@redhat.com> * ecos.db: - * customers: Added USB support 2000-11-16 Jesper Skov <jskov@redhat.com>
--- a/packages/NEWS +++ b/packages/NEWS @@ -1,3 +1,6 @@ +* EDB7xxx ethernet driver rewritten to be a generic Cirrus Logic CS8900A + package. +* Incorporated FTP client code (library and test) from Andrew Lunn. * Incorporated ARM Development board aka INTEGRATOR port from Philippe Robin at ARM. Includes FLASH, ethernet and serial drivers, along with RedBoot support.
--- a/packages/compat/posix/current/ChangeLog +++ b/packages/compat/posix/current/ChangeLog @@ -1,3 +1,8 @@ +2001-11-06 Gary Thomas <gthomas@redhat.com> + + * include/muttypes.h: Need <pkgconf/kernel.h> configuration info, + otherwise structures defined here could have the wrong size. + 2001-10-25 I-Jui Sung <ijsung@csie.nctu.edu.tw> * src/mqueue.cxx (do_mq_unlink): Nullify table entries' mq as this
--- a/packages/compat/posix/current/include/muttypes.h +++ b/packages/compat/posix/current/include/muttypes.h @@ -48,6 +48,7 @@ //============================================================================= #include <pkgconf/posix.h> +#include <pkgconf/kernel.h> #include <cyg/infra/cyg_type.h>
--- a/packages/devs/eth/arm/ebsa285/current/ChangeLog +++ b/packages/devs/eth/arm/ebsa285/current/ChangeLog @@ -1,3 +1,15 @@ +2001-11-19 Hugo Tyson <hmt@redhat.com> +2001-11-19 Anssi Pulkkinen <Anssi.Pulkkinen@ascom.ch> + + * src/if_ebsa285.c (TxMachine): The test to see if there is a new + tx to start must also say "go" if the tx queue is full. Normally, + if the txqueue is full, a tx will be occurring at all times - so + one will complete soon, so the tx queue full flag will soon be + cleared, and this condition will recover. I suspect a subtle race + which effectively means a new tx is queued and fills the queue in + between two tx's, so no TxDone() follows, causes the hang which we + get without this extra test under high load. [CASE 106686] + 2001-08-31 Hugo Tyson <hmt@redhat.com> 2001-08-31 Sanjay Bisen <sanjay.bisen@ascom.ch>
--- a/packages/devs/eth/arm/ebsa285/current/src/if_ebsa285.c +++ b/packages/devs/eth/arm/ebsa285/current/src/if_ebsa285.c @@ -1446,7 +1446,8 @@ static void TxMachine(struct i82559* p_i // is the CU idle, and there a next tx to set going? if ( ( ! p_i82559->tx_in_progress ) - && p_i82559->tx_descriptor_add != tx_descriptor_active ) { + && (( p_i82559->tx_descriptor_add != tx_descriptor_active ) + || p_i82559->tx_queue_full ) ) { TxCB *p_txcb; p_txcb = p_i82559->tx_ring[tx_descriptor_active]; CYG_ASSERT( (cyg_uint8 *)p_txcb >= i82559_heap_base, "txcb under" );
--- a/packages/devs/eth/arm/edb7xxx/current/ChangeLog +++ b/packages/devs/eth/arm/edb7xxx/current/ChangeLog @@ -1,3 +1,15 @@ +2001-11-20 Jesper Skov <jskov@redhat.com> + From hmt: + * include/devs_eth_arm_edb7xxx.inl (_edb7xxx_provide_eth0_esa): + Use VV calls to get this even from an application; config changed + accordingly to include this function even in an application. + +2001-11-14 Jesper Skov <jskov@redhat.com> + + * cdl/edb7xxx_eth_drivers.cdl: Make use of the new generic Cirrus + Logic CS8900A driver. + * include/devs_eth_arm_edb7xxx.inl: Added. + 2001-10-18 Jonathan Larmour <jlarmour@redhat.com> * src/if_edb7xxx.c (cs8900_TxEvent): Use cyg_io_eth_net_debug now,
--- a/packages/devs/eth/arm/edb7xxx/current/cdl/edb7xxx_eth_drivers.cdl +++ b/packages/devs/eth/arm/edb7xxx/current/cdl/edb7xxx_eth_drivers.cdl @@ -24,7 +24,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. # ------------------------------------------- # @@ -33,8 +33,7 @@ ######DESCRIPTIONBEGIN#### # # Author(s): gthomas -# Original data: gthomas -# Contributors: +# Contributors: gthomas, jskov # Date: 2000-01-25 # #####DESCRIPTIONEND#### @@ -48,47 +47,60 @@ cdl_package CYGPKG_DEVS_ETH_ARM_EDB7XXX active_if CYGPKG_IO_ETH_DRIVERS active_if CYGPKG_HAL_ARM_EDB7XXX - implements CYGHWR_NET_DRIVERS - implements CYGHWR_NET_DRIVER_ETH0 - include_dir . - include_files ; # none _exported_ whatsoever + include_dir cyg/io + description "Ethernet driver for Cirrus Logic EP7xxx based development boards." - compile -library=libextras.a if_edb7xxx.c + + # FIXME: This really belongs in the CL CS8900A package + cdl_interface CYGINT_DEVS_ETH_CL_CS8900A_REQUIRED { + display "Cirrus Logic CS8900A ethernet driver required" + } - cdl_component CYGSEM_ARM_EDB7XXX_SET_ESA { - display "Set the ethernet station address" + define_proc { + puts $::cdl_system_header "/***** ethernet driver proc output start *****/" + puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_CL_CS8900A_INL <cyg/io/devs_eth_arm_edb7xxx.inl>" + puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_CL_CS8900A_CFG <pkgconf/devs_eth_arm_edb7xxx.h>" + puts $::cdl_system_header "/***** ethernet driver proc output end *****/" + } + + cdl_component CYGPKG_DEVS_ETH_ARM_EDB7XXX_ETH0 { + display "EDB7XXX ethernet port driver" flavor bool - default_value 0 - description "Enabling this option will allow the ethernet - station address to be forced to the value set by the - configuration. This may be required if the hardware does - not include a serial EEPROM for the ESA." + default_value 1 + description " + This option includes the ethernet device driver for the + EDB7XXX port." + + implements CYGHWR_NET_DRIVERS + implements CYGHWR_NET_DRIVER_ETH0 + implements CYGINT_DEVS_ETH_CL_CS8900A_REQUIRED - cdl_option CYGDAT_ARM_EDB7XXX_ESA { - display "The ethernet station address" - flavor data - default_value {"{0x08, 0x88, 0x12, 0x34, 0x56, 0x78}"} - description "The ethernet station address" + cdl_option CYGDAT_DEVS_ETH_ARM_EDB7XXX_ETH0_NAME { + display "Device name for the ETH0 ethernet driver" + flavor data + default_value {"\"eth0\""} + description " + This option sets the name of the ethernet device." + } + + cdl_component CYGSEM_DEVS_ETH_ARM_EDB7XXX_ETH0_SET_ESA { + display "Set the ethernet station address" + flavor bool + calculated 0 + description "Enabling this option will allow the ethernet + station address to be forced to the value set by the + configuration. This may be required if the hardware does + not include a serial EEPROM for the ESA." + + cdl_option CYGDAT_DEVS_ETH_ARM_EDB7XXX_ETH0_ESA { + display "The ethernet station address" + flavor data + default_value {"{0x08, 0x88, 0x12, 0x34, 0x56, 0x78}"} + description "The ethernet station address" + } } } - cdl_component CYGPKG_DEVS_ETH_ARM_EDB7XXX_OPTIONS { - display "Cirrus Logic ethernet driver build options" - flavor none - no_define - - cdl_option CYGPKG_DEVS_ETH_ARM_EDB7XXX_CFLAGS_ADD { - display "Additional compiler flags" - flavor data - no_define - default_value { "-D_KERNEL -D__ECOS" } - description " - This option modifies the set of compiler flags for - building the Cirrus Logic ethernet driver package. - These flags are used in addition - to the set of global flags." - } - } }
new file mode 100644 --- /dev/null +++ b/packages/devs/eth/arm/edb7xxx/current/include/devs_eth_arm_edb7xxx.inl @@ -0,0 +1,145 @@ +//========================================================================== +// +// devs_eth_arm_edb7xxx.inl +// +// EDB7XXX 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): jskov +// Contributors:jskov +// Date: 2001-11-14 +// Purpose: EDB7XXX ethernet defintions +// +//####DESCRIPTIONEND#### +//========================================================================== + +#include <cyg/hal/hal_intr.h> // CYGNUM_HAL_INTERRUPT_EINT3 +#include <cyg/hal/hal_if.h> + +#ifdef CYGPKG_REDBOOT +# include <pkgconf/redboot.h> +# ifdef CYGSEM_REDBOOT_FLASH_CONFIG +# include <redboot.h> +# include <flash_config.h> +# endif +#endif + +#ifdef __WANT_CONFIG + +# define CS8900A_step 4 + +#endif + +#ifdef __WANT_DEVS + +#ifdef CYGPKG_DEVS_ETH_ARM_EDB7XXX_ETH0 + +#ifndef CYGSEM_DEVS_ETH_ARM_EDB7XXX_ETH0_SET_ESA +# if defined(CYGPKG_REDBOOT) && defined(CYGSEM_REDBOOT_FLASH_CONFIG) +RedBoot_config_option("Set " CYGDAT_DEVS_ETH_ARM_EDB7XXX_ETH0_NAME " network hardware address [MAC]", + eth0_esa, + ALWAYS_ENABLED, true, + CONFIG_BOOL, false + ); +RedBoot_config_option(CYGDAT_DEVS_ETH_ARM_EDB7XXX_ETH0_NAME " network hardware address [MAC]", + eth0_esa_data, + "eth0_esa", true, + CONFIG_ESA, 0 + ); +# endif // CYGPKG_REDBOOT && CYGSEM_REDBOOT_FLASH_CONFIG + +# ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT +// Note that this section *is* active in an application, outside RedBoot, +// where the above section is not included. + +# include <cyg/hal/hal_if.h> + +# ifndef CONFIG_ESA +# define CONFIG_ESA (6) +# endif +# ifndef CONFIG_BOOL +# define CONFIG_BOOL (1) +# endif + +cyg_bool +_edb7xxx_provide_eth0_esa(struct cs8900a_priv_data* cpd) +{ + cyg_bool set_esa; + int ok; + ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET, + "eth0_esa", &set_esa, CONFIG_BOOL); + if (ok && set_esa) { + ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET, + "eth0_esa_data", cpd->esa, CONFIG_ESA); + } + return ok && set_esa; +} + +# endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT +#endif // ! CYGSEM_DEVS_ETH_ARM_EDB7XXX_ETH0_SET_ESA + +static cs8900a_priv_data_t cs8900a_eth0_priv_data = { + base : (cyg_addrword_t) 0x20000000, + interrupt: CYGNUM_HAL_INTERRUPT_EINT3, +#ifdef CYGSEM_DEVS_ETH_ARM_EDB7XXX_ETH0_SET_ESA + esa : CYGDAT_DEVS_ETH_ARM_EDB7XXX_ETH0_ESA, + hardwired_esa : true, +#else + hardwired_esa : false, +# ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT + provide_esa : &_edb7xxx_provide_eth0_esa, +# else + provide_esa : NULL, +# endif +#endif +}; + +ETH_DRV_SC(cs8900a_sc, + &cs8900a_eth0_priv_data, // Driver specific data + CYGDAT_DEVS_ETH_ARM_EDB7XXX_ETH0_NAME, + cs8900a_start, + cs8900a_stop, + cs8900a_control, + cs8900a_can_send, + cs8900a_send, + cs8900a_recv, + cs8900a_deliver, // "pseudoDSR" called from fast net thread + cs8900a_poll, // poll function, encapsulates ISR and DSR + cs8900a_int_vector); + +NETDEVTAB_ENTRY(cs8900a_netdev, + "cs8900a_" CYGDAT_DEVS_ETH_ARM_EDB7XXX_ETH0_NAME, + cs8900a_init, + &cs8900a_sc); + +#endif // CYGPKG_DEVS_ETH_ARM_EDB7XXX_ETH0 + +#endif // __WANT_DEVS + +// EOF devs_eth_arm_edb7xxx.inl
deleted file mode 100644 --- a/packages/devs/eth/arm/edb7xxx/current/src/cs8900.h +++ /dev/null @@ -1,210 +0,0 @@ -//========================================================================== -// -// dev/cs8900.h -// -// Cirrus Logic CS8900 Ethernet chip -// -//========================================================================== -//####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#### -// -//========================================================================== - -// Cirrus Logic CS8900A Ethernet - -// Assumption - all registers are 16 bits - -// Directly visible registers -#define CS8900_RTDATA *(volatile unsigned short *)(CS8900_BASE+0x00) -#define CS8900_TxCMD *(volatile unsigned short *)(CS8900_BASE+0x08) -#define CS8900_TxLEN *(volatile unsigned short *)(CS8900_BASE+0x0C) -#define CS8900_ISQ *(volatile unsigned short *)(CS8900_BASE+0x10) -#define CS8900_PPTR *(volatile unsigned short *)(CS8900_BASE+0x14) -#define CS8900_PDATA *(volatile unsigned short *)(CS8900_BASE+0x18) -#define ISQ_RxEvent 0x04 -#define ISQ_TxEvent 0x08 -#define ISQ_BufEvent 0x0C -#define ISQ_RxMissEvent 0x10 -#define ISQ_TxColEvent 0x12 -#define ISQ_EventMask 0x3F - -// Registers available via "page pointer" (indirect access) -#define PP_ChipID 0x0000 // Chip identifier - must be 0x630E -#define PP_ChipRev 0x0002 // Chip revision, model codes - -#define PP_IntReg 0x0022 // Interrupt configuration -#define PP_IntReg_IRQ0 0x0000 // Use INTR0 pin -#define PP_IntReg_IRQ1 0x0001 // Use INTR1 pin -#define PP_IntReg_IRQ2 0x0002 // Use INTR2 pin -#define PP_IntReg_IRQ3 0x0003 // Use INTR3 pin - -#define PP_RxCFG 0x0102 // Receiver configuration -#define PP_RxCFG_Skip1 0x0040 // Skip (i.e. discard) current frame -#define PP_RxCFG_Stream 0x0080 // Enable streaming mode -#define PP_RxCFG_RxOK 0x0100 // RxOK interrupt enable -#define PP_RxCFG_RxDMAonly 0x0200 // Use RxDMA for all frames -#define PP_RxCFG_AutoRxDMA 0x0400 // Select RxDMA automatically -#define PP_RxCFG_BufferCRC 0x0800 // Include CRC characters in frame -#define PP_RxCFG_CRC 0x1000 // Enable interrupt on CRC error -#define PP_RxCFG_RUNT 0x2000 // Enable interrupt on RUNT frames -#define PP_RxCFG_EXTRA 0x4000 // Enable interrupt on frames with extra data - -#define PP_RxCTL 0x0104 // Receiver control -#define PP_RxCTL_IAHash 0x0040 // Accept frames that match hash -#define PP_RxCTL_Promiscuous 0x0080 // Accept any frame -#define PP_RxCTL_RxOK 0x0100 // Accept well formed frames -#define PP_RxCTL_Multicast 0x0200 // Accept multicast frames -#define PP_RxCTL_IA 0x0400 // Accept frame that matches IA -#define PP_RxCTL_Broadcast 0x0800 // Accept broadcast frames -#define PP_RxCTL_CRC 0x1000 // Accept frames with bad CRC -#define PP_RxCTL_RUNT 0x2000 // Accept runt frames -#define PP_RxCTL_EXTRA 0x4000 // Accept frames that are too long - -#define PP_TxCFG 0x0106 // Transmit configuration -#define PP_TxCFG_CRS 0x0040 // Enable interrupt on loss of carrier -#define PP_TxCFG_SQE 0x0080 // Enable interrupt on Signal Quality Error -#define PP_TxCFG_TxOK 0x0100 // Enable interrupt on successful xmits -#define PP_TxCFG_Late 0x0200 // Enable interrupt on "out of window" -#define PP_TxCFG_Jabber 0x0400 // Enable interrupt on jabber detect -#define PP_TxCFG_Collision 0x0800 // Enable interrupt if collision -#define PP_TxCFG_16Collisions 0x8000 // Enable interrupt if > 16 collisions - -#define PP_TxCmd 0x0108 // Transmit command status -#define PP_TxCmd_TxStart_5 0x0000 // Start after 5 bytes in buffer -#define PP_TxCmd_TxStart_381 0x0040 // Start after 381 bytes in buffer -#define PP_TxCmd_TxStart_1021 0x0080 // Start after 1021 bytes in buffer -#define PP_TxCmd_TxStart_Full 0x00C0 // Start after all bytes loaded -#define PP_TxCmd_Force 0x0100 // Discard any pending packets -#define PP_TxCmd_OneCollision 0x0200 // Abort after a single collision -#define PP_TxCmd_NoCRC 0x1000 // Do not add CRC -#define PP_TxCmd_NoPad 0x2000 // Do not pad short packets - -#define PP_BufCFG 0x010A // Buffer configuration -#define PP_BufCFG_SWI 0x0040 // Force interrupt via software -#define PP_BufCFG_RxDMA 0x0080 // Enable interrupt on Rx DMA -#define PP_BufCFG_TxRDY 0x0100 // Enable interrupt when ready for Tx -#define PP_BufCFG_TxUE 0x0200 // Enable interrupt in Tx underrun -#define PP_BufCFG_RxMiss 0x0400 // Enable interrupt on missed Rx packets -#define PP_BufCFG_Rx128 0x0800 // Enable Rx interrupt after 128 bytes -#define PP_BufCFG_TxCol 0x1000 // Enable int on Tx collision ctr overflow -#define PP_BufCFG_Miss 0x2000 // Enable int on Rx miss ctr overflow -#define PP_BufCFG_RxDest 0x8000 // Enable int on Rx dest addr match - -#define PP_LineCTL 0x0112 // Line control -#define PP_LineCTL_Rx 0x0040 // Enable receiver -#define PP_LineCTL_Tx 0x0080 // Enable transmitter - -#define PP_RER 0x0124 // Receive event -#define PP_RER_IAHash 0x0040 // Frame hash match -#define PP_RER_Dribble 0x0080 // Frame had 1-7 extra bits after last byte -#define PP_RER_RxOK 0x0100 // Frame received with no errors -#define PP_RER_Hashed 0x0200 // Frame address hashed OK -#define PP_RER_IA 0x0400 // Frame address matched IA -#define PP_RER_Broadcast 0x0800 // Broadcast frame -#define PP_RER_CRC 0x1000 // Frame had CRC error -#define PP_RER_RUNT 0x2000 // Runt frame -#define PP_RER_EXTRA 0x4000 // Frame was too long - -#define PP_TER 0x0128 // Transmit event -#define PP_TER_CRS 0x0040 // Carrier lost -#define PP_TER_SQE 0x0080 // Signal Quality Error -#define PP_TER_TxOK 0x0100 // Packet sent without error -#define PP_TER_Late 0x0200 // Out of window -#define PP_TER_Jabber 0x0400 // Stuck transmit? -#define PP_TER_NumCollisions 0x7800 // Number of collisions -#define PP_TER_16Collisions 0x8000 // > 16 collisions - -#define PP_SelfCtl 0x0114 // Chip control -#define PP_SelfCtl_Reset 0x0040 // Self-clearing reset - -#define PP_BusCtl 0x0116 // Bus control -#define PP_BusCtl_ResetRxDMA 0x0040 // Reset receiver DMA engine -#define PP_BusCtl_DMAextend 0x0100 -#define PP_BusCtl_UseSA 0x0200 -#define PP_BusCtl_MemoryE 0x0400 // Enable "memory mode" -#define PP_BusCtl_DMAburst 0x0800 -#define PP_BusCtl_IOCH_RDYE 0x1000 -#define PP_BusCtl_RxDMAsize 0x2000 -#define PP_BusCtl_EnableIRQ 0x8000 // Enable interrupts - -#define PP_LineStat 0x0134 // Line status -#define PP_LineStat_LinkOK 0x0080 // Line is connected and working -#define PP_LineStat_AUI 0x0100 // Connected via AUI -#define PP_LineStat_10BT 0x0200 // Connected via twisted pair -#define PP_LineStat_Polarity 0x1000 // Line polarity OK (10BT only) -#define PP_LineStat_CRS 0x4000 // Frame being received - -#define PP_SelfStat 0x0136 // Chip status -#define PP_SelfStat_InitD 0x0080 // Chip initialization complete -#define PP_SelfStat_SIBSY 0x0100 // EEPROM is busy -#define PP_SelfStat_EEPROM 0x0200 // EEPROM present -#define PP_SelfStat_EEPROM_OK 0x0400 // EEPROM checks out -#define PP_SelfStat_ELPresent 0x0800 // External address latch logic available -#define PP_SelfStat_EEsize 0x1000 // Size of EEPROM - -#define PP_BusStat 0x0138 // Bus status -#define PP_BusStat_TxBid 0x0080 // Tx error -#define PP_BusStat_TxRDY 0x0100 // Ready for Tx data - -#define PP_LAF 0x0150 // Logical address filter (6 bytes) -#define PP_IA 0x0158 // Individual address (MAC) - -// "page pointer" access functions - -static __inline__ unsigned short -get_reg(int regno) -{ - unsigned short val; - CS8900_PPTR = regno; - val = CS8900_PDATA; - return val; -} - -static __inline__ void -put_reg(int regno, unsigned short val) -{ - CS8900_PPTR = regno; - CS8900_PDATA = val; -}
deleted file mode 100644 --- a/packages/devs/eth/arm/edb7xxx/current/src/if_edb7xxx.c +++ /dev/null @@ -1,528 +0,0 @@ -//========================================================================== -// -// dev/if_edb7xxx.c -// -// Ethernet device driver for Cirrus Logic EDB7xxx using CS8900 -// -//========================================================================== -//####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): gthomas -// Contributors: gthomas -// Date: 2000-01-10 -// Purpose: -// Description: hardware driver for CS8900 ethernet -// -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -// Ethernet device driver for Cirrus Logic EDB7xxx -// Based on CS8900A - -#include <pkgconf/system.h> -#include <pkgconf/devs_eth_arm_edb7xxx.h> -#ifdef CYGPKG_NET -#include <pkgconf/net.h> -#include <cyg/kernel/kapi.h> -#endif -#include <pkgconf/io_eth_drivers.h> -#include <cyg/infra/cyg_type.h> -#include <cyg/hal/hal_arch.h> -#include <cyg/hal/hal_intr.h> -#include <cyg/infra/diag.h> -#include <cyg/hal/drv_api.h> -#include <netdev.h> -#include <eth_drv.h> - -#ifndef CYGSEM_ARM_EDB7XXX_SET_ESA -#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]", - edb7xxx_esa, - ALWAYS_ENABLED, true, - CONFIG_ESA, 0 - ); -#endif -#endif -#endif - -#define INTS_DONT_WORK -#undef INTS_DONT_WORK - -#ifdef INTS_DONT_WORK -#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_MINIMUM -static char cs8900_fake_int_stack[STACK_SIZE]; -static cyg_thread cs8900_fake_int_thread_data; -static cyg_handle_t cs8900_fake_int_thread_handle; -static void cs8900_fake_int(cyg_addrword_t); -#endif - -#define CS8900_BASE 0x20000000 -#include "cs8900.h" -#define ETHER_ADDR_LEN 6 - -#ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG -extern int cyg_io_eth_net_debug; -#endif - -struct cs8900_priv_data { - int txbusy; // A packet has been sent - unsigned long txkey; // Used to ack when packet sent -#ifdef CYGPKG_NET - cyg_tick_count_t txstart; -#endif -} _cs8900_priv_data; - -ETH_DRV_SC(edb7xxx_sc, - &_cs8900_priv_data, // Driver specific data - "eth0", // Name for this interface - cs8900_start, - cs8900_stop, - cs8900_control, - cs8900_can_send, - cs8900_send, - cs8900_recv, - cs8900_deliver, // "pseudoDSR" called from fast net thread - cs8900_int, // poll function, encapsulates ISR and DSR - cs8900_int_vector); - -NETDEVTAB_ENTRY(edb7xxx_netdev, - "edb7xxx", - edb7xxx_cs8900_init, - &edb7xxx_sc); - -#ifdef CYGSEM_ARM_EDB7XXX_SET_ESA -static unsigned char enaddr[] = CYGDAT_ARM_EDB7XXX_ESA; -#else -static unsigned char enaddr[ETHER_ADDR_LEN]; -#endif - -static void cs8900_int(struct eth_drv_sc *sc); -static cyg_interrupt cs8900_interrupt; -static cyg_handle_t cs8900_interrupt_handle; - -// This ISR is called when the ethernet interrupt occurs -static int -cs8900_isr(cyg_vector_t vector, cyg_addrword_t data, HAL_SavedRegisters *regs) -{ - cyg_drv_interrupt_mask(CYGNUM_HAL_INTERRUPT_EINT3); - return (CYG_ISR_HANDLED|CYG_ISR_CALL_DSR); // Run the DSR -} - -// The deliver function (ex-DSR) handles the ethernet [logical] processing -static void -cs8900_deliver(struct eth_drv_sc *sc) -{ - cs8900_int(sc); - // Allow interrupts to happen again - cyg_drv_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_EINT3); - cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_EINT3); -} - -static int -cs8900_int_vector(struct eth_drv_sc *sc) -{ - return (CYGNUM_HAL_INTERRUPT_EINT3); -} - -static bool -edb7xxx_cs8900_init(struct cyg_netdevtab_entry *tab) -{ - struct eth_drv_sc *sc = (struct eth_drv_sc *)tab->device_instance; - unsigned short chip_type, chip_rev, chip_status; - int i; - long timeout = 500000; - - // Initialize environment, setup interrupt handler - cyg_drv_interrupt_create(CYGNUM_HAL_INTERRUPT_EINT3, - 99, // Priority - what goes here? - (cyg_addrword_t)sc, // Data item passed to interrupt handler - (cyg_ISR_t *)cs8900_isr, - (cyg_DSR_t *)eth_drv_dsr, // The logical driver DSR - &cs8900_interrupt_handle, - &cs8900_interrupt); - cyg_drv_interrupt_attach(cs8900_interrupt_handle); - cyg_drv_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_EINT3); - cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_EINT3); - -#ifdef INTS_DONT_WORK - cyg_thread_create(1, // Priority - cs8900_fake_int, // entry - 0, // entry parameter - "CS8900 int", // Name - &cs8900_fake_int_stack[0], // Stack - STACK_SIZE, // Size - &cs8900_fake_int_thread_handle, // Handle - &cs8900_fake_int_thread_data // Thread data structure - ); - cyg_thread_resume(cs8900_fake_int_thread_handle); // Start it -#endif - - chip_type = get_reg(PP_ChipID); - chip_rev = get_reg(PP_ChipRev); - -#if 0 - diag_printf("CS8900 - type: %x, rev: %x\n", chip_type, chip_rev); -#endif - if (chip_type != 0x630e) { - diag_printf("CS8900 - invalid device: %x, must be 0x630E\n", chip_type); - return false; - } - - // Fetch hardware address -#if defined(CYGPKG_REDBOOT) && \ - defined(CYGSEM_REDBOOT_FLASH_CONFIG) && \ - !defined(CYGSEM_ARM_EDB7XXX_SET_ESA) - flash_get_config("edb7xxx_esa", enaddr, CONFIG_ESA); -#elif !defined(CYGSEM_ARM_EDB7XXX_SET_ESA) - for (i = 0; i < ETHER_ADDR_LEN; i += 2) { - unsigned short esa_reg = get_reg(PP_IA+i); - enaddr[i] = esa_reg & 0xFF; - enaddr[i+1] = esa_reg >> 8; - } -#endif - - put_reg(PP_SelfCtl, PP_SelfCtl_Reset); // Reset chip - while ((get_reg(PP_SelfStat) & PP_SelfStat_InitD) == 0) { - if (--timeout <= 0) { - diag_printf("CS8900 didn't reset - abort!\n"); - return false; - } - } - - chip_status = get_reg(PP_SelfStat); -#if 0 - diag_printf("CS8900 - status: %x (%sEEPROM present)\n", chip_status, - chip_status&PP_SelfStat_EEPROM ? "" : "no "); -#endif - - // Set up hardware address - for (i = 0; i < ETHER_ADDR_LEN; i += 2) { - put_reg(PP_LAF+i, 0xFFFF); - put_reg(PP_IA+i, enaddr[i] | (enaddr[i+1] << 8)); - } - - // Initialize upper level driver - (sc->funs->eth_drv->init)(sc, enaddr); - - return true; -} - -static void -cs8900_stop(struct eth_drv_sc *sc) -{ - put_reg(PP_SelfCtl, PP_SelfCtl_Reset); // Reset chip - while ((get_reg(PP_SelfStat) & PP_SelfStat_InitD) == 0) ; -} - -// -// This function is called to "start up" the interface. It may be called -// multiple times, even when the hardware is already running. It will be -// called whenever something "hardware oriented" changes and should leave -// the hardware ready to send/receive packets. -// -static void -cs8900_start(struct eth_drv_sc *sc, unsigned char *enaddr, int flags) -{ - unsigned short stat; - struct cs8900_priv_data *cpd = (struct cs8900_priv_data *)sc->driver_private; - - put_reg(PP_BusCtl, PP_BusCtl_MemoryE); // Disable interrupts, memory mode - put_reg(PP_IntReg, PP_IntReg_IRQ0); // Only possibility - put_reg(PP_RxCFG, PP_RxCFG_RxOK | PP_RxCFG_CRC | - PP_RxCFG_RUNT | PP_RxCFG_EXTRA); - put_reg(PP_RxCTL, PP_RxCTL_RxOK | PP_RxCTL_Broadcast | - PP_RxCTL_IA); - put_reg(PP_TxCFG, PP_TxCFG_TxOK | PP_TxCFG_Collision | - PP_TxCFG_CRS | PP_TxCFG_SQE | PP_TxCFG_Late | - PP_TxCFG_Jabber | PP_TxCFG_16Collisions); - put_reg(PP_BufCFG, PP_BufCFG_TxRDY | PP_BufCFG_TxUE | PP_BufCFG_RxMiss | - PP_BufCFG_TxCol | PP_BufCFG_Miss | PP_BufCFG_SWI); - put_reg(PP_IntReg, PP_IntReg_IRQ0); // Only possibility - put_reg(PP_LineCTL, PP_LineCTL_Rx | PP_LineCTL_Tx); - // Clear Interrupt Status Queue before enabling interrupts - while ((stat = CS8900_ISQ) != 0) ; - cpd->txbusy = 0; - put_reg(PP_BusCtl, PP_BusCtl_EnableIRQ); -} - -// -// This routine is called to perform special "control" opertions -// -static int -cs8900_control(struct eth_drv_sc *sc, unsigned long key, - void *data, int data_length) -{ - switch (key) { - case ETH_DRV_SET_MAC_ADDRESS: - return 0; - break; - default: - return 1; - break; - } -} - -// -// This routine is called to see if it is possible to send another packet. -// It will return non-zero if a transmit is possible, zero otherwise. -// -static int -cs8900_can_send(struct eth_drv_sc *sc) -{ - struct cs8900_priv_data *cpd = (struct cs8900_priv_data *)sc->driver_private; - unsigned short stat; - - stat = get_reg(PP_LineStat); - if ((stat & PP_LineStat_LinkOK) == 0) { - return false; // Link not connected - } -#ifdef CYGPKG_NET - // Horrible hack! - if (cpd->txbusy > 0) { - cyg_tick_count_t now = cyg_current_time(); - if ((now - cpd->txstart) > 25) { - // 250ms is more than enough to transmit one frame - diag_printf("CS8900: Tx interrupt lost\n"); - cpd->txbusy = 0; - // Free up the buffer (with error indication) - (sc->funs->eth_drv->tx_done)(sc, cpd->txkey, 1); - } - } -#endif - return (cpd->txbusy == 0); -} - -// -// This routine is called to send data to the hardware. -static void -cs8900_send(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len, - int total_len, unsigned long key) -{ - struct cs8900_priv_data *cpd = (struct cs8900_priv_data *)sc->driver_private; - int i; - int len; - unsigned char *data; - unsigned short saved_data = 0, *sdata; - unsigned short stat; - bool odd_byte = false; - - // Mark xmitter busy - cpd->txbusy = 1; - cpd->txkey = key; -#ifdef CYGPKG_NET - cpd->txstart = cyg_current_time(); -#endif - // Start the xmit sequence - - // The hardware indicates that there are options as to when the actual - // packet transmission will start wrt moving of data into the transmit - // buffer. However, impirical results seem to indicate that if the - // packet is large and transmission is allowed to start before the - // entire packet has been pushed into the buffer, the hardware gets - // confused and the packet is lost, along with a "lost" Tx interrupt. - // This may be a case of the copy loop below being interrupted, e.g. - // a system timer interrupt, and the hardware getting unhappy that - // not all of the data was provided before the transmission should - // have completed (i.e. buffer underrun). - // For now, the solution is to not allow this overlap. -// CS8900_TxCMD = PP_TxCmd_TxStart_5; // Start more-or-less immediately - CS8900_TxCMD = PP_TxCmd_TxStart_Full; // Start only when all data sent to chip - - CS8900_TxLEN = total_len; - stat = get_reg(PP_BusStat); // This actually starts the xmit - - // Put data into buffer - for (i = 0; i < sg_len; i++) { - data = (unsigned char *)sg_list[i].buf; - len = sg_list[i].len; - if (len > 0) { - /* Finish the last word. */ - if (odd_byte) { - saved_data |= (*data++ << 8); - CS8900_RTDATA = saved_data; - len--; - odd_byte = false; - } - /* Output contiguous words. */ - sdata = (unsigned short *)data; - while (len > 1) { - CS8900_RTDATA = *sdata++; - len -= sizeof(unsigned short); - } - /* Save last byte, if necessary. */ - if (len == 1) { - data = (unsigned char *)sdata; - saved_data = *data; - odd_byte = true; - } - } - } - if (odd_byte) { - CS8900_RTDATA = saved_data; - } -} - -// -// This function is called when a packet has been received. It's job is -// to prepare to unload the packet from the hardware. Once the length of -// the packet is known, the upper layer of the driver can be told. When -// the upper layer is ready to unload the packet, the internal function -// 'cs8900_recv' will be called to actually fetch it from the hardware. -// -static void -cs8900_RxEvent(struct eth_drv_sc *sc) -{ - unsigned short stat, len; - - stat = CS8900_RTDATA; - len = CS8900_RTDATA; -#ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG - if (cyg_io_eth_net_debug) { - diag_printf("RxEvent - stat: %x, len: %d\n", stat, len); - } -#endif - (sc->funs->eth_drv->recv)(sc, len); -} - -// -// This function is called as a result of the "eth_drv_recv()" call above. -// It's job is to actually fetch data for a packet from the hardware once -// memory buffers have been allocated for the packet. Note that the buffers -// may come in pieces, using a scatter-gather list. This allows for more -// efficient processing in the upper layers of the stack. -// -static void -cs8900_recv(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len) -{ - int i, mlen; - unsigned short *data, val; - unsigned char *cp, cval; - - for (i = 0; i < sg_len; i++) { - data = (unsigned short *)sg_list[i].buf; - mlen = sg_list[i].len; - while (mlen >= sizeof(*data)) { - val = CS8900_RTDATA; - if (data) { - *data++ = val; - } - mlen -= sizeof(*data); - } - if (mlen) { - // Fetch last odd byte - cval = CS8900_RTDATA & 0xFF; - if ((cp = (unsigned char *)data) != 0) { - *cp = cval; - } - } - } -} - -static void -cs8900_TxEvent(struct eth_drv_sc *sc, int stat) -{ - struct cs8900_priv_data *cpd = (struct cs8900_priv_data *)sc->driver_private; - - stat = get_reg(PP_TER); -#ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG - if (cyg_io_eth_net_debug) { - diag_printf("Tx event: %x\n", stat); - } -#endif - cpd->txbusy = 0; - (sc->funs->eth_drv->tx_done)(sc, cpd->txkey, 0); -} - -static void -cs8900_BufEvent(struct eth_drv_sc *sc, int stat) -{ - if (stat & PP_BufCFG_RxMiss) { - } - if (stat & PP_BufCFG_TxUE) { - } -} - -static void -cs8900_int(struct eth_drv_sc *sc) -{ - unsigned short event; - - while ((event = CS8900_ISQ) != 0) { - switch (event & ISQ_EventMask) { - case ISQ_RxEvent: - cs8900_RxEvent(sc); - break; - case ISQ_TxEvent: - cs8900_TxEvent(sc, event); - break; - case ISQ_BufEvent: - cs8900_BufEvent(sc, event); - break; - case ISQ_RxMissEvent: - // Receive miss counter has overflowed - break; - case ISQ_TxColEvent: - // Transmit collision counter has overflowed - break; - default: - diag_printf("%s: Unknown event: %x\n", __FUNCTION__, event); - break; - } - } -} - -#ifdef INTS_DONT_WORK -void -cs8900_fake_int(cyg_addrword_t param) -{ - int s; - - while (true) { - cyg_thread_delay(5); - s = splnet(); - cs8900_int(&edb7xxx_sc); - splx(s); - } -} -#endif -
new file mode 100644 --- /dev/null +++ b/packages/devs/eth/cl/cs8900a/current/ChangeLog @@ -0,0 +1,85 @@ +2001-11-20 Jesper Skov <jskov@redhat.com> + + * src/if_cs8900a.c: Added some more debug output. Set all 4 LAF + registers. Don't reset device to stop it - just disable TX & RX. + +2001-11-16 Jesper Skov <jskov@redhat.com> + + * src/if_cs8900a.c (cs8900a_send): Wait for controller ready + signal before starting transmission. + +2001-11-14 Jesper Skov <jskov@redhat.com> + + * src/if_cs8900a.c: Use platform init, reset and int_clear + macros. + * include/cs8900.h: Tidy up those (default) macros. + +2001-11-09 Jesper Skov <jskov@redhat.com> + + * src/if_cs8900a.c (cs8900a_init): Rewrote ESA setup to be more + consistent. + + * include/cs8900.h: Added provide_esa field to driver structure. + +2001-11-08 Jesper Skov <jskov@redhat.com> + + * src/if_cs8900a.c: Made it build with faked interrupts. + + * include/cs8900.h: Added debug output for put/get functions. + + * src/if_cs8900a.c: Made it build when NET package enabled. + + * include/cs8900.h: Added tab field. + + * src/if_cs8900a.c: Renamed broken ints option, more diag_printf + #ifdefing and removed RedBoot ESA option code. + +2001-11-07 Jesper Skov <jskov@redhat.com> + + * src/if_cs8900a.c: Interrupt stuff cleaned up. Fix device + probing. Make driver fail when no ESA available and none has been + configured. Compiler warning fixes and some printout cleanups. + + * src/if_cs8900a.c: Platform driver provides device + information. Renamed functions and definitions. Init code changed + some. + + * include/cs8900.h: Renaming some definitions. + + * cdl/cl_cs8900a_eth_drivers.cdl: Platform driver provides + options. + +2001-11-06 Jesper Skov <jskov@redhat.com> + + * src/if_cs8900a.c: Assorted hacking. + * include/cs8900.h: Same. + +2001-11-02 Jesper Skov <jskov@redhat.com> + + * Cloned from edb7xxx driver. + +//=========================================================================== +//####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/cl/cs8900a/current/cdl/cl_cs8900a_eth_drivers.cdl @@ -0,0 +1,79 @@ +# ==================================================================== +# +# cl_cs8900a_eth_drivers.cdl +# +# Ethernet driver for Cirrus Logic CS8900A controller +# +# ==================================================================== +#####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 +# Contributors: gthomas, jskov +# Date: 2001-11-02 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVS_ETH_CL_CS8900A { + display "Driver for Cirrus Logic CS8900A ethernet controller." + + parent CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_IO_ETH_DRIVERS + + implements CYGHWR_NET_DRIVERS + + active_if CYGINT_DEVS_ETH_CL_CS8900A_REQUIRED + + include_dir cyg/io + description "Driver for Cirrus Logic CS8900A ethernet controller." + compile -library=libextras.a if_cs8900a.c + + define_proc { + puts $::cdl_header "#include <pkgconf/system.h>"; + puts $::cdl_header "#include CYGDAT_DEVS_ETH_CL_CS8900A_CFG"; + } + + cdl_component CYGPKG_DEVS_ETH_CL_CS8900A_OPTIONS { + display "Cirrus Logic ethernet driver build options" + flavor none + no_define + + cdl_option CYGPKG_DEVS_ETH_CL_CS8900A_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "-D_KERNEL -D__ECOS" } + description " + This option modifies the set of compiler flags for + building the Cirrus Logic ethernet driver package. + These flags are used in addition + to the set of global flags." + } + } +} +
new file mode 100644 --- /dev/null +++ b/packages/devs/eth/cl/cs8900a/current/include/cs8900.h @@ -0,0 +1,305 @@ +//========================================================================== +// +// dev/cs8900.h +// +// Cirrus Logic CS8900 Ethernet chip +// +//========================================================================== +//####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): gthomas +// Contributors: gthomas, jskov +// Date: 2001-11-07 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <cyg/infra/cyg_type.h> + +#include <cyg/hal/hal_io.h> +#include <pkgconf/devs_eth_cl_cs8900a.h> + +#define __WANT_CONFIG +#include CYGDAT_DEVS_ETH_CL_CS8900A_INL +#undef __WANT_CONFIG + +// ------------------------------------------------------------------------ +// Debugging details + +// Set to perms of: +// 0 disables all debug output +// 1 for process debug output +// 2 for added data IO output: get_reg, put_reg +// 4 for packet allocation/free output +// 8 for only startup status, so we can tell we're installed OK +#define DEBUG 0x0 + +#if DEBUG & 1 +#define DEBUG_FUNCTION() do { diag_printf("%s\n", __FUNCTION__); } while (0) +#define DEBUG_LINE() do { diag_printf("%d\n", __LINE__); } while (0) +#else +#define DEBUG_FUNCTION() do {} while(0) +#define DEBUG_LINE() do {} while(0) +#endif + +// ------------------------------------------------------------------------ +// Macros for keeping track of statistics +#if defined(ETH_DRV_GET_IF_STATS) || defined (ETH_DRV_GET_IF_STATS_UD) +#define KEEP_STATISTICS +#endif + +#ifdef KEEP_STATISTICS +#define INCR_STAT( _x_ ) (cpd->stats. _x_ ++) +#else +#define INCR_STAT( _x_ ) CYG_EMPTY_STATEMENT +#endif + +// ------------------------------------------------------------------------ +// Private driver structure +struct cs8900a_priv_data; +typedef cyg_bool (*provide_esa_t)(struct cs8900a_priv_data* cpd); + +typedef struct cs8900a_priv_data { + bool txbusy, hardwired_esa; + cyg_uint8 esa[6]; + provide_esa_t provide_esa; + cyg_vector_t interrupt; // Interrupt vector used by controller + cyg_handle_t interrupt_handle; + cyg_interrupt interrupt_object; + cyg_addrword_t base; + cyg_uint32 txkey; // Used to ack when packet sent + struct cyg_netdevtab_entry *tab; +#ifdef CYGPKG_NET + cyg_tick_count_t txstart; +#endif +} cs8900a_priv_data_t; + +// ------------------------------------------------------------------------ +// Macros for accessing CS registers +// These can be overridden by the platform header + +#ifndef CS_IN +# define CS_IN(_b_, _o_, _d_) HAL_READ_UINT16 ((cyg_addrword_t)(_b_)+(_o_), (_d_)) +# define CS_OUT(_b_, _o_, _d_) HAL_WRITE_UINT16((cyg_addrword_t)(_b_)+(_o_), (_d_)) +#endif + +// ------------------------------------------------------------------------ +// Macros allowing platform to customize some of the driver details + +#ifndef CYGHWR_CL_CS8900A_PLF_RESET +# define CYGHWR_CL_CS8900A_PLF_RESET(_b_) do { } while (0) +#endif + +#ifndef CYGHWR_CL_CS8900A_PLF_INT_CLEAR +# define CYGHWR_CL_CS8900A_PLF_INT_CLEAR(_cdp_) +#endif + +#ifndef CYGHWR_CL_CS8900A_PLF_INIT +#define CYGHWR_CL_CS8900A_PLF_INIT(_cdp_) do { } while (0) +#endif + + +// ------------------------------------------------------------------------ +// Directly visible registers. +// Platform can override stepping or layout if necessary. +#ifndef CS8900A_step +# define CS8900A_step 2 +#endif +#ifndef CS8900A_RTDATA +# define CS8900A_RTDATA (0*CS8900A_step) +# define CS8900A_TxCMD (2*CS8900A_step) +# define CS8900A_TxLEN (3*CS8900A_step) +# define CS8900A_ISQ (4*CS8900A_step) +# define CS8900A_PPTR (5*CS8900A_step) +# define CS8900A_PDATA (6*CS8900A_step) +#endif + +#define ISQ_RxEvent 0x04 +#define ISQ_TxEvent 0x08 +#define ISQ_BufEvent 0x0C +#define ISQ_RxMissEvent 0x10 +#define ISQ_TxColEvent 0x12 +#define ISQ_EventMask 0x3F + +// ------------------------------------------------------------------------ +// Registers available via "page pointer" (indirect access) +#define PP_ChipID 0x0000 // Chip identifier - must be 0x630E +#define PP_ChipRev 0x0002 // Chip revision, model codes + +#define PP_IntReg 0x0022 // Interrupt configuration +#define PP_IntReg_IRQ0 0x0000 // Use INTR0 pin +#define PP_IntReg_IRQ1 0x0001 // Use INTR1 pin +#define PP_IntReg_IRQ2 0x0002 // Use INTR2 pin +#define PP_IntReg_IRQ3 0x0003 // Use INTR3 pin + +#define PP_RxCFG 0x0102 // Receiver configuration +#define PP_RxCFG_Skip1 0x0040 // Skip (i.e. discard) current frame +#define PP_RxCFG_Stream 0x0080 // Enable streaming mode +#define PP_RxCFG_RxOK 0x0100 // RxOK interrupt enable +#define PP_RxCFG_RxDMAonly 0x0200 // Use RxDMA for all frames +#define PP_RxCFG_AutoRxDMA 0x0400 // Select RxDMA automatically +#define PP_RxCFG_BufferCRC 0x0800 // Include CRC characters in frame +#define PP_RxCFG_CRC 0x1000 // Enable interrupt on CRC error +#define PP_RxCFG_RUNT 0x2000 // Enable interrupt on RUNT frames +#define PP_RxCFG_EXTRA 0x4000 // Enable interrupt on frames with extra data + +#define PP_RxCTL 0x0104 // Receiver control +#define PP_RxCTL_IAHash 0x0040 // Accept frames that match hash +#define PP_RxCTL_Promiscuous 0x0080 // Accept any frame +#define PP_RxCTL_RxOK 0x0100 // Accept well formed frames +#define PP_RxCTL_Multicast 0x0200 // Accept multicast frames +#define PP_RxCTL_IA 0x0400 // Accept frame that matches IA +#define PP_RxCTL_Broadcast 0x0800 // Accept broadcast frames +#define PP_RxCTL_CRC 0x1000 // Accept frames with bad CRC +#define PP_RxCTL_RUNT 0x2000 // Accept runt frames +#define PP_RxCTL_EXTRA 0x4000 // Accept frames that are too long + +#define PP_TxCFG 0x0106 // Transmit configuration +#define PP_TxCFG_CRS 0x0040 // Enable interrupt on loss of carrier +#define PP_TxCFG_SQE 0x0080 // Enable interrupt on Signal Quality Error +#define PP_TxCFG_TxOK 0x0100 // Enable interrupt on successful xmits +#define PP_TxCFG_Late 0x0200 // Enable interrupt on "out of window" +#define PP_TxCFG_Jabber 0x0400 // Enable interrupt on jabber detect +#define PP_TxCFG_Collision 0x0800 // Enable interrupt if collision +#define PP_TxCFG_16Collisions 0x8000 // Enable interrupt if > 16 collisions + +#define PP_TxCmd 0x0108 // Transmit command status +#define PP_TxCmd_TxStart_5 0x0000 // Start after 5 bytes in buffer +#define PP_TxCmd_TxStart_381 0x0040 // Start after 381 bytes in buffer +#define PP_TxCmd_TxStart_1021 0x0080 // Start after 1021 bytes in buffer +#define PP_TxCmd_TxStart_Full 0x00C0 // Start after all bytes loaded +#define PP_TxCmd_Force 0x0100 // Discard any pending packets +#define PP_TxCmd_OneCollision 0x0200 // Abort after a single collision +#define PP_TxCmd_NoCRC 0x1000 // Do not add CRC +#define PP_TxCmd_NoPad 0x2000 // Do not pad short packets + +#define PP_BufCFG 0x010A // Buffer configuration +#define PP_BufCFG_SWI 0x0040 // Force interrupt via software +#define PP_BufCFG_RxDMA 0x0080 // Enable interrupt on Rx DMA +#define PP_BufCFG_TxRDY 0x0100 // Enable interrupt when ready for Tx +#define PP_BufCFG_TxUE 0x0200 // Enable interrupt in Tx underrun +#define PP_BufCFG_RxMiss 0x0400 // Enable interrupt on missed Rx packets +#define PP_BufCFG_Rx128 0x0800 // Enable Rx interrupt after 128 bytes +#define PP_BufCFG_TxCol 0x1000 // Enable int on Tx collision ctr overflow +#define PP_BufCFG_Miss 0x2000 // Enable int on Rx miss ctr overflow +#define PP_BufCFG_RxDest 0x8000 // Enable int on Rx dest addr match + +#define PP_LineCTL 0x0112 // Line control +#define PP_LineCTL_Rx 0x0040 // Enable receiver +#define PP_LineCTL_Tx 0x0080 // Enable transmitter + +#define PP_RER 0x0124 // Receive event +#define PP_RER_IAHash 0x0040 // Frame hash match +#define PP_RER_Dribble 0x0080 // Frame had 1-7 extra bits after last byte +#define PP_RER_RxOK 0x0100 // Frame received with no errors +#define PP_RER_Hashed 0x0200 // Frame address hashed OK +#define PP_RER_IA 0x0400 // Frame address matched IA +#define PP_RER_Broadcast 0x0800 // Broadcast frame +#define PP_RER_CRC 0x1000 // Frame had CRC error +#define PP_RER_RUNT 0x2000 // Runt frame +#define PP_RER_EXTRA 0x4000 // Frame was too long + +#define PP_TER 0x0128 // Transmit event +#define PP_TER_CRS 0x0040 // Carrier lost +#define PP_TER_SQE 0x0080 // Signal Quality Error +#define PP_TER_TxOK 0x0100 // Packet sent without error +#define PP_TER_Late 0x0200 // Out of window +#define PP_TER_Jabber 0x0400 // Stuck transmit? +#define PP_TER_NumCollisions 0x7800 // Number of collisions +#define PP_TER_16Collisions 0x8000 // > 16 collisions + +#define PP_SelfCtl 0x0114 // Chip control +#define PP_SelfCtl_Reset 0x0040 // Self-clearing reset + +#define PP_BusCtl 0x0116 // Bus control +#define PP_BusCtl_ResetRxDMA 0x0040 // Reset receiver DMA engine +#define PP_BusCtl_DMAextend 0x0100 +#define PP_BusCtl_UseSA 0x0200 +#define PP_BusCtl_MemoryE 0x0400 // Enable "memory mode" +#define PP_BusCtl_DMAburst 0x0800 +#define PP_BusCtl_IOCH_RDYE 0x1000 +#define PP_BusCtl_RxDMAsize 0x2000 +#define PP_BusCtl_EnableIRQ 0x8000 // Enable interrupts + +#define PP_LineStat 0x0134 // Line status +#define PP_LineStat_LinkOK 0x0080 // Line is connected and working +#define PP_LineStat_AUI 0x0100 // Connected via AUI +#define PP_LineStat_10BT 0x0200 // Connected via twisted pair +#define PP_LineStat_Polarity 0x1000 // Line polarity OK (10BT only) +#define PP_LineStat_CRS 0x4000 // Frame being received + +#define PP_SelfStat 0x0136 // Chip status +#define PP_SelfStat_InitD 0x0080 // Chip initialization complete +#define PP_SelfStat_SIBSY 0x0100 // EEPROM is busy +#define PP_SelfStat_EEPROM 0x0200 // EEPROM present +#define PP_SelfStat_EEPROM_OK 0x0400 // EEPROM checks out +#define PP_SelfStat_ELPresent 0x0800 // External address latch logic available +#define PP_SelfStat_EEsize 0x1000 // Size of EEPROM + +#define PP_BusStat 0x0138 // Bus status +#define PP_BusStat_TxBid 0x0080 // Tx error +#define PP_BusStat_TxRDY 0x0100 // Ready for Tx data + +#define PP_LAF 0x0150 // Logical address filter (6 bytes) +#define PP_IA 0x0158 // Individual address (MAC) + +// ------------------------------------------------------------------------ +// "page pointer" access functions +static __inline__ cyg_uint16 +get_reg(cyg_addrword_t base, int regno) +{ + cyg_uint16 val; + HAL_WRITE_UINT16(base+CS8900A_PPTR, regno); + HAL_READ_UINT16(base+CS8900A_PDATA, val); +#if DEBUG & 2 + diag_printf("get_reg(%p, %d) => 0x%04x\n", base, regno, val); +#endif + return val; +} + +static __inline__ void +put_reg(cyg_addrword_t base, int regno, cyg_uint16 val) +{ +#if DEBUG & 2 + diag_printf("put_reg(%p, %d, 0x%04x)\n", base, regno, val); +#endif + HAL_WRITE_UINT16(base+CS8900A_PPTR, regno); + HAL_WRITE_UINT16(base+CS8900A_PDATA, val); +}
new file mode 100644 --- /dev/null +++ b/packages/devs/eth/cl/cs8900a/current/src/if_cs8900a.c @@ -0,0 +1,578 @@ +//========================================================================== +// +// dev/if_cs8900a.c +// +// Device driver for Cirrus Logic CS8900A ethernet controller +// +//========================================================================== +//####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): gthomas +// Contributors: gthomas, jskov +// Date: 2001-11-02 +// Purpose: +// Description: Driver for CS8900 ethernet controller +// +// Note: Platform can define CYGSEM_DEVS_ETH_CL_CS8900A_NOINTS +// to get a timer thread polling instead of interupt based +// operation. +// +// Note: Driver will need some changes to support multiple instances +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <pkgconf/system.h> +#ifdef CYGPKG_NET +#include <pkgconf/net.h> +#include <cyg/kernel/kapi.h> +#endif +#include <pkgconf/io_eth_drivers.h> +#include <cyg/infra/cyg_type.h> +#include <cyg/hal/hal_arch.h> +#include <cyg/hal/hal_intr.h> +#include <cyg/infra/diag.h> +#include <cyg/hal/drv_api.h> +#undef __ECOS +#define __ECOS +#include <eth_drv.h> +#include <netdev.h> + +#include <cyg/io/cs8900.h> + +#define __WANT_DEVS +#include CYGDAT_DEVS_ETH_CL_CS8900A_INL +#undef __WANT_DEVS + +// NOINTS operation only relevant when the NET package is loaded +#ifndef CYGPKG_NET +# undef CYGSEM_DEVS_ETH_CL_CS8900A_NOINTS +#endif + +#ifdef CYGSEM_DEVS_ETH_CL_CS8900A_NOINTS +#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_MINIMUM +static char cs8900a_fake_int_stack[STACK_SIZE]; +static cyg_thread cs8900a_fake_int_thread_data; +static cyg_handle_t cs8900a_fake_int_thread_handle; +static void cs8900a_fake_int(cyg_addrword_t); +#endif + +#ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG +extern int cyg_io_eth_net_debug; +#endif + +static void cs8900a_poll(struct eth_drv_sc *sc); +#ifdef CYGPKG_NET +// This ISR is called when the ethernet interrupt occurs +static int +cs8900a_isr(cyg_vector_t vector, cyg_addrword_t data, HAL_SavedRegisters *regs) +{ + cs8900a_priv_data_t* cpd = (cs8900a_priv_data_t *)data; + cyg_drv_interrupt_mask(cpd->interrupt); + return (CYG_ISR_HANDLED|CYG_ISR_CALL_DSR); // Run the DSR +} + +static void +cs8900a_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data) +{ + // This conditioning out is necessary because of explicit calls to this + // DSR - which would not ever be called in the case of a polled mode + // usage ie. in RedBoot. +#ifdef CYGPKG_IO_ETH_DRIVERS_NET + cs8900a_priv_data_t* cpd = (cs8900a_priv_data_t *)data; + struct cyg_netdevtab_entry *ndp = (struct cyg_netdevtab_entry *)(cpd->tab); + struct eth_drv_sc *sc = (struct eth_drv_sc *)(ndp->device_instance); + + DEBUG_FUNCTION(); + + // but here, it must be a *sc: + eth_drv_dsr( vector, count, (cyg_addrword_t)sc ); +#else +# ifndef CYGPKG_REDBOOT +# error Empty CS8900A ethernet DSR is compiled. Is this what you want? +# endif +#endif +} +#endif + +// The deliver function (ex-DSR) handles the ethernet [logical] processing +static void +cs8900a_deliver(struct eth_drv_sc *sc) +{ + cs8900a_poll(sc); +#ifdef CYGPKG_NET + { + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + // Allow interrupts to happen again + cyg_drv_interrupt_acknowledge(cpd->interrupt); + cyg_drv_interrupt_unmask(cpd->interrupt); + } +#endif +} + +static int +cs8900a_int_vector(struct eth_drv_sc *sc) +{ + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + return (cpd->interrupt) ? 1 : 0; +} + +static bool +cs8900a_init(struct cyg_netdevtab_entry *tab) +{ + struct eth_drv_sc *sc = (struct eth_drv_sc *)tab->device_instance; + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + cyg_addrword_t base = cpd->base; + cyg_uint16 chip_type, chip_rev, chip_status; + int i; + long timeout = 500000; + + cpd->tab = tab; + + CYGHWR_CL_CS8900A_PLF_INIT(cpd); + +#ifdef CYGPKG_NET + // Initialize environment, setup interrupt handler + cyg_drv_interrupt_create(cpd->interrupt, + 0, // Priority - what goes here? + (cyg_addrword_t)cpd, // Data item passed to interrupt handler + (cyg_ISR_t *)cs8900a_isr, + (cyg_DSR_t *)cs8900a_dsr, + &cpd->interrupt_handle, + &cpd->interrupt_object); + cyg_drv_interrupt_attach(cpd->interrupt_handle); + cyg_drv_interrupt_acknowledge(cpd->interrupt); + cyg_drv_interrupt_unmask(cpd->interrupt); + +#ifdef CYGSEM_DEVS_ETH_CL_CS8900A_NOINTS + cyg_thread_create(1, // Priority + cs8900a_fake_int, // entry + (cyg_addrword_t)sc, // entry parameter + "CS8900 int", // Name + &cs8900a_fake_int_stack[0], // Stack + STACK_SIZE, // Size + &cs8900a_fake_int_thread_handle, // Handle + &cs8900a_fake_int_thread_data // Thread data structure + ); + cyg_thread_resume(cs8900a_fake_int_thread_handle); // Start it +#endif +#endif + + // Read controller ID - the first is a dummy read, since (on some + // platforms) the first access to the controller seems to skip the + // MSB 8 bits. + get_reg(base, PP_ChipID); + chip_type = get_reg(base, PP_ChipID); + chip_rev = get_reg(base, PP_ChipRev); +#if DEBUG & 8 + diag_printf("CS8900A[%p] - type: 0x%04x, rev: 0x%04x\n", base, chip_type, chip_rev); +#endif + if (chip_type != 0x630e) { +#if DEBUG & 8 + diag_printf("CS8900 - invalid type (0x%04x), must be 0x630e\n", chip_type); +#endif + return false; + } + + CYGHWR_CL_CS8900A_PLF_RESET(base); + put_reg(base, PP_SelfCtl, PP_SelfCtl_Reset); // Reset chip + while ((get_reg(base, PP_SelfStat) & PP_SelfStat_InitD) == 0) { + if (--timeout <= 0) { +#if DEBUG & 8 + diag_printf("CS8900 didn't reset - abort!\n"); +#endif + return false; + } + } + + chip_status = get_reg(base, PP_SelfStat); +#if DEBUG & 8 + diag_printf("CS8900 - status: 0x%04x (%sEEPROM present)\n", chip_status, + chip_status & PP_SelfStat_EEPROM ? "" : "no "); +#endif + + + // Disable reception whilst finding the ESA + put_reg(base, PP_LineCTL, 0 ); + // Find ESA + if (!cpd->hardwired_esa) { + cyg_bool esa_configured = false; + if (NULL != cpd->provide_esa) { + esa_configured = cpd->provide_esa(cpd); +# if DEBUG & 8 + if (esa_configured) + diag_printf("Got ESA from RedBoot option\n"); +# endif + } + if (!esa_configured && (chip_status & PP_SelfStat_EEPROM)) { + // Get ESA from EEPROM - via the PP_IA registers + cyg_uint16 esa_word; + for (i = 0; i < sizeof(cpd->esa); i += 2) { + esa_word = get_reg(base, PP_IA+i); + cpd->esa[i] = (esa_word & 0xFF); + cpd->esa[i+1] = (esa_word >> 8) & 0xFF; + } + esa_configured = true; + } + if (!esa_configured) { +# if DEBUG & 8 + diag_printf("CS8900 - no EEPROM, static ESA or RedBoot config option.\n"); +# endif + return false; + } + } + // Tell the chip what ESA to use + for (i = 0; i < sizeof(cpd->esa); i += 2) { + put_reg(base, PP_IA+i, cpd->esa[i] | (cpd->esa[i+1] << 8)); + } + // Set logical address mask + for (i = 0; i < 8; i += 2) { + put_reg(base, PP_LAF+i, 0xFFFF); + } +# if DEBUG & 8 + diag_printf("ESA %02x:%02x:%02x:%02x:%02x:%02x\n", + cpd->esa[0], cpd->esa[1], cpd->esa[2], + cpd->esa[3], cpd->esa[4], cpd->esa[5]); +# endif + + // Initialize upper level driver + (sc->funs->eth_drv->init)(sc, cpd->esa); + + return true; +} + +static void +cs8900a_stop(struct eth_drv_sc *sc) +{ + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + cyg_addrword_t base = cpd->base; + + put_reg(base, PP_LineCTL, 0); +} + +// This function is called to "start up" the interface. It may be called +// multiple times, even when the hardware is already running. It will be +// called whenever something "hardware oriented" changes and should leave +// the hardware ready to send/receive packets. +static void +cs8900a_start(struct eth_drv_sc *sc, cyg_uint8 *esa, int flags) +{ + cyg_uint16 stat; + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + cyg_addrword_t base = cpd->base; + + put_reg(base, PP_BusCtl, PP_BusCtl_MemoryE); // Disable interrupts, memory mode + put_reg(base, PP_IntReg, PP_IntReg_IRQ0); // Only possibility + put_reg(base, PP_RxCFG, PP_RxCFG_RxOK | PP_RxCFG_CRC | + PP_RxCFG_RUNT | PP_RxCFG_EXTRA); + put_reg(base, PP_RxCTL, PP_RxCTL_RxOK | PP_RxCTL_Broadcast | + PP_RxCTL_IA); + put_reg(base, PP_TxCFG, PP_TxCFG_TxOK | PP_TxCFG_Collision | + PP_TxCFG_CRS | PP_TxCFG_SQE | PP_TxCFG_Late | + PP_TxCFG_Jabber | PP_TxCFG_16Collisions); + put_reg(base, PP_BufCFG, PP_BufCFG_TxRDY | PP_BufCFG_TxUE | PP_BufCFG_RxMiss | + PP_BufCFG_TxCol | PP_BufCFG_Miss | PP_BufCFG_SWI); + put_reg(base, PP_IntReg, PP_IntReg_IRQ0); // Only possibility + put_reg(base, PP_LineCTL, PP_LineCTL_Rx | PP_LineCTL_Tx); + // Clear Interrupt Status Queue before enabling interrupts + do { + HAL_READ_UINT16(cpd->base+CS8900A_ISQ, stat); + } while (stat != 0) ; + cpd->txbusy = false; + put_reg(base, PP_BusCtl, PP_BusCtl_EnableIRQ); +} + +// This routine is called to perform special "control" opertions +static int +cs8900a_control(struct eth_drv_sc *sc, unsigned long key, void *data, int data_length) +{ + switch (key) { + case ETH_DRV_SET_MAC_ADDRESS: + return 0; + break; + default: + return 1; + break; + } +} + +// This routine is called to see if it is possible to send another packet. +// It will return non-zero if a transmit is possible, zero otherwise. +static int +cs8900a_can_send(struct eth_drv_sc *sc) +{ + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + cyg_addrword_t base = cpd->base; + cyg_uint16 stat; + + stat = get_reg(base, PP_LineStat); + if ((stat & PP_LineStat_LinkOK) == 0) { + return false; // Link not connected + } +#ifdef CYGPKG_NET + // Horrible hack! + if (cpd->txbusy) { + cyg_tick_count_t now = cyg_current_time(); + if ((now - cpd->txstart) > 25) { + // 250ms is more than enough to transmit one frame +#if DEBUG & 1 + diag_printf("CS8900: Tx interrupt lost\n"); +#endif + cpd->txbusy = false; + // Free up the buffer (with error indication) + (sc->funs->eth_drv->tx_done)(sc, cpd->txkey, 1); + } + } +#endif + return (cpd->txbusy == false); +} + +// This routine is called to send data to the hardware. +static void +cs8900a_send(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len, + int total_len, unsigned long key) +{ + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + cyg_addrword_t base = cpd->base; + int i; + int len; + cyg_uint8 *data; + cyg_uint16 saved_data = 0, *sdata; + cyg_uint16 stat; + bool odd_byte = false; + + // Mark xmitter busy + cpd->txbusy = true; + cpd->txkey = key; +#ifdef CYGPKG_NET + cpd->txstart = cyg_current_time(); +#endif + // Start the xmit sequence + + // The hardware indicates that there are options as to when the actual + // packet transmission will start wrt moving of data into the transmit + // buffer. However, impirical results seem to indicate that if the + // packet is large and transmission is allowed to start before the + // entire packet has been pushed into the buffer, the hardware gets + // confused and the packet is lost, along with a "lost" Tx interrupt. + // This may be a case of the copy loop below being interrupted, e.g. + // a system timer interrupt, and the hardware getting unhappy that + // not all of the data was provided before the transmission should + // have completed (i.e. buffer underrun). + // For now, the solution is to not allow this overlap. + //HAL_WRITE_UINT16(cpd->base+CS8900A_TxCMD, PP_TxCmd_TxStart_5) + + // Start only when all data sent to chip + HAL_WRITE_UINT16(cpd->base+CS8900A_TxCMD, PP_TxCmd_TxStart_Full); + + HAL_WRITE_UINT16(cpd->base+CS8900A_TxLEN, total_len); + // Wait for controller ready signal + do { + stat = get_reg(base, PP_BusStat); + } while (!(stat & PP_BusStat_TxRDY)); + + // Put data into buffer + for (i = 0; i < sg_len; i++) { + data = (cyg_uint8 *)sg_list[i].buf; + len = sg_list[i].len; + + if (len > 0) { + /* Finish the last word. */ + if (odd_byte) { + saved_data |= ((cyg_uint16)*data++) << 8; + HAL_WRITE_UINT16(cpd->base+CS8900A_RTDATA, saved_data); + len--; + odd_byte = false; + } + /* Output contiguous words. */ + sdata = (cyg_uint16 *)data; + while (len > 1) { + HAL_WRITE_UINT16(cpd->base+CS8900A_RTDATA, *sdata++); + len -= sizeof(cyg_uint16); + } + /* Save last byte, if necessary. */ + if (len == 1) { + data = (cyg_uint8 *)sdata; + saved_data = (cyg_uint16)*data; + odd_byte = true; + } + } + } + if (odd_byte) { + HAL_WRITE_UINT16(cpd->base+CS8900A_RTDATA, saved_data); + } +} + +// This function is called when a packet has been received. It's job is +// to prepare to unload the packet from the hardware. Once the length of +// the packet is known, the upper layer of the driver can be told. When +// the upper layer is ready to unload the packet, the internal function +// 'cs8900a_recv' will be called to actually fetch it from the hardware. +static void +cs8900a_RxEvent(struct eth_drv_sc *sc) +{ + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + cyg_addrword_t base = cpd->base; + cyg_uint16 stat, len; + + HAL_READ_UINT16(base+CS8900A_RTDATA, stat); + HAL_READ_UINT16(base+CS8900A_RTDATA, len); +#ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG + if (cyg_io_eth_net_debug) { + diag_printf("RxEvent - stat: %x, len: %d\n", stat, len); + } +#endif + (sc->funs->eth_drv->recv)(sc, len); +} + +// This function is called as a result of the "eth_drv_recv()" call above. +// It's job is to actually fetch data for a packet from the hardware once +// memory buffers have been allocated for the packet. Note that the buffers +// may come in pieces, using a scatter-gather list. This allows for more +// efficient processing in the upper layers of the stack. +static void +cs8900a_recv(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len) +{ + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + cyg_addrword_t base = cpd->base; + int i, mlen; + cyg_uint16 *data, val; + cyg_uint8 *cp, cval; + + for (i = 0; i < sg_len; i++) { + data = (cyg_uint16 *)sg_list[i].buf; + mlen = sg_list[i].len; + while (mlen >= sizeof(*data)) { + HAL_READ_UINT16(base+CS8900A_RTDATA, val); + if (data) { + *data++ = val; + } + mlen -= sizeof(*data); + } + if (mlen) { + // Fetch last odd byte + HAL_READ_UINT16(base+CS8900A_RTDATA, cval); + cval &= 0xFF; + if ((cp = (cyg_uint8 *)data) != 0) { + *cp = cval; + } + } + } +} + +static void +cs8900a_TxEvent(struct eth_drv_sc *sc, int stat) +{ + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + cyg_addrword_t base = cpd->base; + + stat = get_reg(base, PP_TER); +#ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG + if (cyg_io_eth_net_debug) { + diag_printf("Tx event: %x\n", stat); + } +#endif + cpd->txbusy = false; + (sc->funs->eth_drv->tx_done)(sc, cpd->txkey, 0); +} + +static void +cs8900a_BufEvent(struct eth_drv_sc *sc, int stat) +{ + if (stat & PP_BufCFG_RxMiss) { + } + if (stat & PP_BufCFG_TxUE) { + } +} + +static void +cs8900a_poll(struct eth_drv_sc *sc) +{ + cyg_uint16 event; + cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; + cyg_addrword_t base = cpd->base; + + HAL_READ_UINT16(base+CS8900A_ISQ, event); + while (event != 0) { + switch (event & ISQ_EventMask) { + case ISQ_RxEvent: + cs8900a_RxEvent(sc); + break; + case ISQ_TxEvent: + cs8900a_TxEvent(sc, event); + break; + case ISQ_BufEvent: + cs8900a_BufEvent(sc, event); + break; + case ISQ_RxMissEvent: + // Receive miss counter has overflowed + break; + case ISQ_TxColEvent: + // Transmit collision counter has overflowed + break; + default: +#if DEBUG & 1 + diag_printf("%s: Unknown event: %x\n", __FUNCTION__, event); +#endif + break; + } + HAL_READ_UINT16(base+CS8900A_ISQ, event); + } + + CYGHWR_CL_CS8900A_PLF_INT_CLEAR(cpd); +} + +#ifdef CYGSEM_DEVS_ETH_CL_CS8900A_NOINTS +void +cs8900a_fake_int(cyg_addrword_t param) +{ + struct eth_drv_sc *sc = (struct eth_drv_sc *) param; + int s; + +#if DEBUG & 1 + diag_printf("cs8900a_fake_int()\n"); +#endif + + while (true) { + cyg_thread_delay(5); + s = splnet(); + cs8900a_poll(sc); + splx(s); + } +} +#endif
--- a/packages/devs/eth/intel/i82559/current/ChangeLog +++ b/packages/devs/eth/intel/i82559/current/ChangeLog @@ -1,3 +1,15 @@ +2001-11-19 Hugo Tyson <hmt@redhat.com> +2001-11-19 Anssi Pulkkinen <Anssi.Pulkkinen@ascom.ch> + + * src/if_i82559.c (TxMachine): The test to see if there is a new + tx to start must also say "go" if the tx queue is full. Normally, + if the txqueue is full, a tx will be occurring at all times - so + one will complete soon, so the tx queue full flag will soon be + cleared, and this condition will recover. I suspect a subtle race + which effectively means a new tx is queued and fills the queue in + between two tx's, so no TxDone() follows, causes the hang which we + get without this extra test under high load. [CASE 106686] + 2001-09-20 Gary Thomas <gthomas@redhat.com> * src/if_i82559.c: Add declaration of 'i82559_stop' to quiet warning.
--- a/packages/devs/eth/intel/i82559/current/src/if_i82559.c +++ b/packages/devs/eth/intel/i82559/current/src/if_i82559.c @@ -2035,7 +2035,8 @@ TxMachine(struct i82559* p_i82559) // is the CU idle, and there a next tx to set going? if ( ( ! p_i82559->tx_in_progress ) - && p_i82559->tx_descriptor_add != tx_descriptor_active ) { + && (( p_i82559->tx_descriptor_add != tx_descriptor_active ) + || p_i82559->tx_queue_full ) ) { TxCB *p_txcb = p_i82559->tx_ring[tx_descriptor_active]; cyg_uint16 status;
--- a/packages/ecos.db +++ b/packages/ecos.db @@ -684,6 +684,13 @@ package CYGPKG_NET { description "Generic networking support, including TCP/IP." } +package CYGPKG_NET_FTPCLIENT { + alias { "FTP Client" ftpclient } + directory net/ftpclient + script ftpclient.cdl + description "FTP client support for get and put of files." +} + package CYGPKG_SNMPLIB { alias { "SNMP library" snmplib } directory net/snmp/lib @@ -812,6 +819,15 @@ package CYGPKG_DEVS_ETH_NS_DP83902A { description "Ethernet driver for NS DP83902A controller." } +package CYGPKG_DEVS_ETH_CL_CS8900A { + alias { "Cirrus Logic CS8900A ethernet driver" cs8900a_eth_driver } + hardware + directory devs/eth/cl/cs8900a + script cl_cs8900a_eth_drivers.cdl + description "Ethernet driver for Cirrus Logic CS8900A controller." +} + + # Not sure whether this should be "hardware"; if so, it should be mentioned # in all targets that can use it. package CYGPKG_DEVS_ETH_CF { @@ -2137,6 +2153,7 @@ target edb7xxx { packages { CYGPKG_HAL_ARM CYGPKG_HAL_ARM_EDB7XXX CYGPKG_DEVS_ETH_ARM_EDB7XXX + CYGPKG_DEVS_ETH_CL_CS8900A CYGPKG_IO_SERIAL_ARM_EDB7XXX CYGPKG_DEVS_FLASH_EDB7XXX }
--- a/packages/fs/rom/current/ChangeLog +++ b/packages/fs/rom/current/ChangeLog @@ -1,3 +1,12 @@ +2001-11-23 Jonathan Larmour <jlarmour@redhat.com> + + * cdl/romfs.cdl (CYGTST_ROMFS_BUILD_TESTS): Try gcc and cc if $HOST_CC + doesn't exist or has a problem. + +2001-11-22 Jesper Skov <jskov@redhat.com> + + * cdl/romfs.cdl: Use HOST_CC instead of 'cc'. + 2001-10-17 Drew Moseley <dmoseley@redhat.com> 2001-10-17 Jonathan Larmour <jlarmour@redhat.com>
--- a/packages/fs/rom/current/cdl/romfs.cdl +++ b/packages/fs/rom/current/cdl/romfs.cdl @@ -71,7 +71,7 @@ cdl_package CYGPKG_FS_ROM { make -priority 100 { <PREFIX>/bin/mk_romfs: <PACKAGE>/support/mk_romfs.c @mkdir -p "$(dir $@)" - @cc -g -O2 -o $@ $< + @$(HOST_CC) -g -O2 -o $@ $< || cc -g -O2 -o $@ $< || gcc -g -O2 -o $@ $< } make -priority 100 {
--- a/packages/hal/arm/arch/current/ChangeLog +++ b/packages/hal/arm/arch/current/ChangeLog @@ -1,3 +1,10 @@ +2001-11-02 Hugo Tyson <hmt@redhat.com> + + * include/arm_stub.h (CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION): Nasty + bodge to fix a tools issue where an "unused" label is migrated to + where some real code is, ie. the wrong place in this case. + Problem applies to arm9e-elf tools and other arm variants also. + 2001-10-29 Hugo Tyson <hmt@redhat.com> * src/arm.ld (SECTION_rom_vectors): Define symbols used for ROMRAM
--- a/packages/hal/arm/arch/current/include/arm_stub.h +++ b/packages/hal/arm/arch/current/include/arm_stub.h @@ -138,6 +138,19 @@ do { } while ( 0 ) #endif // __thumb_ + +// Also define ..LEAVE.. with a trick to *use* the label - sometimes the +// tools want to move the label, which is bad. +#define CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION( _old_ ) \ +do { \ + cyg_hal_gdb_remove_break( (target_register_t)&&cyg_hal_gdb_break_place ); \ + HAL_RESTORE_INTERRUPTS(_old_); \ + _old_ = 1; /* actually use the label as a label... */ \ +cyg_hal_gdb_break_place: \ + if ( (_old_)-- > 0 ) /* ...or the compiler might move it! */ \ + goto cyg_hal_gdb_break_place; \ +} while ( 0 ) + #endif // CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
--- a/packages/hal/arm/arm9/var/current/ChangeLog +++ b/packages/hal/arm/arm9/var/current/ChangeLog @@ -1,3 +1,17 @@ +2001-11-16 Jesper Skov <jskov@redhat.com> + + * src/arm9_misc.c (hal_hardware_init): Don't invalidate caches on + RAM startup. + +2001-11-07 Jesper Skov <jskov@redhat.com> + + * src/arm9_misc.c (cyg_hal_arm9_soft_reset): Also put CPU in SVC + mode (as after a reset). Still broken though. + +2001-11-06 Gary Thomas <gthomas@redhat.com> + + * include/hal_cache.h: Add virtual->physical translation setup. + 2001-11-01 Jesper Skov <jskov@redhat.com> * src/arm9_misc.c (cyg_hal_arm9_soft_reset): Attempt at soft
--- a/packages/hal/arm/arm9/var/current/include/hal_cache.h +++ b/packages/hal/arm/arm9/var/current/include/hal_cache.h @@ -443,5 +443,12 @@ CYG_MACRO_END CYG_MACRO_END //----------------------------------------------------------------------------- +// Virtual<->Physical translations + +extern cyg_uint32 hal_virt_to_phys_address(cyg_uint32 phys); +#define HAL_VIRT_TO_PHYS_ADDRESS(_va, _pa) \ + _pa = hal_virt_to_phys_address(_va) + +//----------------------------------------------------------------------------- #endif // ifndef CYGONCE_HAL_CACHE_H // End of hal_cache.h
--- a/packages/hal/arm/arm9/var/current/src/arm9_misc.c +++ b/packages/hal/arm/arm9/var/current/src/arm9_misc.c @@ -64,9 +64,12 @@ void hal_hardware_init(void) // Set up eCos/ROM interfaces hal_if_init(); - // Enable caches +#ifndef CYG_HAL_STARTUP_RAM + // Invalidate caches HAL_DCACHE_INVALIDATE_ALL(); HAL_ICACHE_INVALIDATE_ALL(); +#endif + // Enable caches #ifdef CYGSEM_HAL_ENABLE_DCACHE_ON_STARTUP HAL_DCACHE_ENABLE(); #endif @@ -82,7 +85,12 @@ cyg_hal_arm9_soft_reset(CYG_ADDRESS entr /* It would probably make more sense to have the clear/drain/invalidate after disabling the cache and MMU, but then we'd have to know the (unmapped) address of this code. */ - asm volatile ("mov r1, #0;" + asm volatile ("mrs r1,cpsr;" + "bic r1,r1,#0x1F;" /* Put processor in SVC mode */ + "orr r1,r1,#0x13;" + "msr cpsr,r1;" + + "mov r1, #0;" "mcr p15,0,r1,c7,c7,0;" /* clear I+DCache */ "mcr p15,0,r1,c7,c10,4;" /* Drain Write Buffer */ "mcr p15,0,r1,c8,c7,0;" /* Invalidate TLBs */
--- a/packages/hal/arm/ebsa285/current/ChangeLog +++ b/packages/hal/arm/ebsa285/current/ChangeLog @@ -1,3 +1,19 @@ +2001-11-02 Andrew Lunn <Andrew.Lunn@ascom.ch> +2001-11-02 Jonathan Larmour <jlarmour@redhat.com> + + * cdl/hal_arm_ebsa285.cdl: Add ROMRAM startup type and MLT file config. + + * include/hal_platform_setup.h: Support relocation of ROMRAM image. + + * include/pkgconf/mlt_arm_ebsa285_romram.h: New MLT files for romram. + * include/pkgconf/mlt_arm_ebsa285_romram.ldi: Ditto. + * include/pkgconf/mlt_arm_ebsa285_romram.mlt: Ditto. + * include/pkgconf/mlt_arm_ebsa285_ram.mlt: Move app base to 0x30000 to + allow for romram space. + * include/pkgconf/mlt_arm_ebsa285_ram.ldi: Regenerate. + + * misc/redboot_ROMRAM.ecm: New file. + 2001-08-22 Gary Thomas <gthomas@redhat.com> * src/redboot_cmds.c:
--- a/packages/hal/arm/ebsa285/current/cdl/hal_arm_ebsa285.cdl +++ b/packages/hal/arm/ebsa285/current/cdl/hal_arm_ebsa285.cdl @@ -71,7 +71,7 @@ cdl_package CYGPKG_HAL_ARM_EBSA285 { display "Startup type" flavor data default_value {"RAM"} - legal_values {"RAM" "ROM"} + legal_values {"RAM" "ROM" "ROMRAM"} no_define define -file system.h CYG_HAL_STARTUP description " @@ -80,8 +80,9 @@ cdl_package CYGPKG_HAL_ARM_EBSA285 { 'ram' when building programs to load into RAM using onboard debug software such as Angel or eCos GDB stubs. Select 'rom' when building a stand-alone application which will be put - into ROM." - } + into ROM. Using ROMRAM will allow the program to exist in + ROM, but be copied to RAM during startup." + } cdl_option CYGHWR_HAL_ARM_EBSA285_PCI_MEM_MAP_BASE { display "Base of memory accessible via PCI space" @@ -296,16 +297,18 @@ cdl_package CYGPKG_HAL_ARM_EBSA285 { display "Memory layout" flavor data no_define - calculated { CYG_HAL_STARTUP == "RAM" ? "arm_ebsa285_ram" : \ - "arm_ebsa285_rom" } + calculated { (CYG_HAL_STARTUP == "RAM") ? "arm_ebsa285_ram" : + (CYG_HAL_STARTUP == "ROMRAM") ? "arm_ebsa285_romram" : + "arm_ebsa285_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_ebsa285_ram.ldi>" : \ - "<pkgconf/mlt_arm_ebsa285_rom.ldi>" } + calculated { (CYG_HAL_STARTUP == "RAM") ? "<pkgconf/mlt_arm_ebsa285_ram.ldi>" : + (CYG_HAL_STARTUP == "ROMRAM") ? "<pkgconf/mlt_arm_ebsa285_romram.ldi>" : + "<pkgconf/mlt_arm_ebsa285_rom.ldi>" } } cdl_option CYGHWR_MEMORY_LAYOUT_H { @@ -313,8 +316,9 @@ cdl_package CYGPKG_HAL_ARM_EBSA285 { flavor data no_define define -file system.h CYGHWR_MEMORY_LAYOUT_H - calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_arm_ebsa285_ram.h>" : \ - "<pkgconf/mlt_arm_ebsa285_rom.h>" } + calculated { (CYG_HAL_STARTUP == "RAM") ? "<pkgconf/mlt_arm_ebsa285_ram.h>" : + (CYG_HAL_STARTUP == "ROMRAM") ? "<pkgconf/mlt_arm_ebsa285_romram.h>" : + "<pkgconf/mlt_arm_ebsa285_rom.h>" } } } @@ -323,7 +327,7 @@ cdl_package CYGPKG_HAL_ARM_EBSA285 { flavor bool default_value 0 parent CYGPKG_HAL_ROM_MONITOR - requires { CYG_HAL_STARTUP == "ROM" } + requires { CYG_HAL_STARTUP == "ROM" || CYG_HAL_STARTUP == "ROMRAM" } 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
--- a/packages/hal/arm/ebsa285/current/include/hal_platform_setup.h +++ b/packages/hal/arm/ebsa285/current/include/hal_platform_setup.h @@ -47,14 +47,20 @@ #include <pkgconf/system.h> // System-wide configuration info #include CYGBLD_HAL_PLATFORM_H // Platform specific configuration +#include CYGHWR_MEMORY_LAYOUT_H // Location of the ROM #include <cyg/hal/hal_ebsa285.h> // Platform specific hardware definitions #include <cyg/hal/hal_mmu.h> // MMU definitions // Note that we do NOT define CYGHWR_HAL_ARM_HAS_MMU so that at reset we // jump straight into the ROM; this makes it unnecessary to take any // special steps to switch from executing in the ROM alias at low -// addresses. Make no difference for RAM start. +// addresses. Make no difference for RAM start. For ROMRAM startup the +// application is linked with RAM addresses, but we have to jump to +// the ROM address at startup. Diddle the UNMAPPED macro to do this +#if defined (CYG_HAL_STARTUP_ROMRAM) +#define UNMAPPED(x) (x + CYGMEM_REGION_rom) +#endif // Define macro used to diddle the LEDs during early initialization. // Can use r0+r1. Argument in \x. @@ -73,7 +79,7 @@ 667: // divided into further macros to make it easier to manage what's enabled // when. -#if defined(CYG_HAL_STARTUP_ROM) || \ +#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) || \ defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) || \ !defined(CYGSEM_HAL_USE_ROM_MONITOR) @@ -96,6 +102,7 @@ 667: INIT_XBUS_ACCESS \ ALLOW_CLOCK_SWITCHING \ CALL_MEMINIT_CODE \ + ROMRAM_COPY \ BASIC_PCI_SETUP #else #define PLATFORM_SETUP1 @@ -157,6 +164,30 @@ 778: str r0, [ r1 ] /* store the top of memory address */ ;\ mov lr, r10 /* in hal_dram_size for future use */ ;\ +// If we are doing a ROMRAM startup copy all sections up to the start of +// the data section to RAM. +#if defined(CYG_HAL_STARTUP_ROMRAM) +#define ROMRAM_COPY \ + ldr r0,=(CYGMEM_REGION_rom) ;\ + ldr r1,=0 ;\ + ldr r2,=0x40 ;\ +810: ldr r3,[r0],#4 ;\ + str r3,[r1],#4 ;\ + cmp r1,r2 ;\ + bne 810b ;\ + ldr r0,=(CYGMEM_REGION_rom+reset_vector) ;\ + ldr r1,=(reset_vector) ;\ + ldr r2,=(CYGMEM_REGION_rom_SIZE) ;\ +820: ldr r3,[r0],#4 ;\ + str r3,[r1],#4 ;\ + cmp r1,r2 ;\ + bne 820b ;\ + ldr r0,=830f ;\ + mov pc,r0 ;\ +830: +#else +#define ROMRAM_COPY +#endif #define BASIC_PCI_SETUP \ /**************************************************************** \
--- a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.ldi +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.ldi @@ -13,7 +13,7 @@ SECTIONS { SECTIONS_BEGIN SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA) - SECTION_rom_vectors (ram, 0x20000, LMA_EQ_VMA) + SECTION_rom_vectors (ram, 0x30000, 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)
--- a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.mlt +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.mlt @@ -1,7 +1,7 @@ version 0 region ram 0 1000000 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 rom_vectors 0 1 0 1 1 1 1 1 30000 30000 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 !
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_romram.h @@ -0,0 +1,25 @@ +// eCos memory layout - Tue Sep 05 16:58:21 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 (0x1000000) +#define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) +#define CYGMEM_REGION_rom (0x41000000) +#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 (0xf00000 - (size_t) CYG_LABEL_NAME (__heap1)) +#ifndef __ASSEMBLER__ +extern char CYG_LABEL_NAME (__pci_window) []; +#endif +#define CYGMEM_SECTION_pci_window (CYG_LABEL_NAME (__pci_window)) +#define CYGMEM_SECTION_pci_window_SIZE (0x100000)
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_romram.ldi @@ -0,0 +1,28 @@ +// eCos memory layout - Tue Sep 05 16:58:21 2000 + +// This is a generated file - do not edit + +#include <cyg/infra/cyg_type.inc> + +MEMORY +{ + ram : ORIGIN = 0, LENGTH = 0x1000000 +} + +SECTIONS +{ + SECTIONS_BEGIN + SECTION_rom_vectors (ram, 0x0, LMA_EQ_VMA) + SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA) + SECTION_text (ram, 0x8000, 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); + CYG_LABEL_DEFN(__pci_window) = 0xf00000; . = CYG_LABEL_DEFN(__pci_window) + 0x100000; + SECTIONS_END +}
new file mode 100644 --- /dev/null +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_romram.mlt @@ -0,0 +1,15 @@ +version 0 +region ram 0 1000000 0 ! +region rom 41000000 400000 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 pci_window 100000 1 0 0 1 0 1 0 f00000 f00000 !This is the memory area that is dual-ported to devices onthe PCI bus. Such devices can read and write this memory areaas their own. Examples include the EBSA-285 Ethernet driver, which receives and transmits packets via this memory area. It must be 1Mb aligned, so that the MMU initialization can arrange for it to be uncacheable. +section rom_vectors 0 1 0 1 1 1 1 1 41000000 41000000 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/ebsa285/current/misc/redboot_ROMRAM.ecm @@ -0,0 +1,79 @@ +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 ebsa285 ; + template redboot ; + package -hardware CYGPKG_HAL_ARM v1_5_2 ; + package -hardware CYGPKG_HAL_ARM_EBSA285 v1_5_2 ; + package -hardware CYGPKG_IO_PCI v1_5_2 ; + package -hardware CYGPKG_DEVS_ETH_ARM_EBSA285 v1_5_2 ; + package -hardware CYGPKG_IO_SERIAL_ARM_EBSA285 v1_5_2 ; + package -hardware CYGPKG_DEVICES_WATCHDOG_ARM_EBSA285 v1_5_2 ; + package -hardware CYGPKG_DEVS_FLASH_EBSA285 v1_5_2 ; + package -template CYGPKG_HAL v1_5_2 ; + package -template CYGPKG_INFRA v1_5_2 ; + package -template CYGPKG_REDBOOT v1_5_2 ; + package CYGPKG_IO_FLASH v1_5_2 ; + package CYGPKG_IO_ETH_DRIVERS v1_5_2 ; +}; + +cdl_option CYGBLD_BUILD_GDB_STUBS { + user_value 0 +}; + +cdl_option CYGDBG_DEVS_ETH_ARM_EBSA285_CHATTER { + user_value 0 +}; + +cdl_option CYGNUM_DEVS_ETH_ARM_EBSA285_DEV_COUNT { + user_value 1 +}; + +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 ROMRAM +}; + +cdl_component CYGBLD_BUILD_REDBOOT { + user_value 1 +}; + +cdl_option CYGSEM_REDBOOT_BSP_SYSCALLS { + inferred_value 1 +}; +
--- a/packages/hal/common/current/ChangeLog +++ b/packages/hal/common/current/ChangeLog @@ -1,3 +1,14 @@ +2001-11-23 Nick Garnett <nickg@redhat.com> + + * src/generic-stub.c (__process_packet): Fixed bogosity in + handling of 'r' packet. It tried to send two replies, messing up + the protocol and confusing GDB. + +2001-11-02 Hugo Tyson <hmt@redhat.com> + + * include/hal_stub.h (CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION): + Permit this too to be defined externally ie. in a platform HAL. + 2001-10-25 Gary Thomas <gthomas@redhat.com> * cdl/hal.cdl:
--- a/packages/hal/common/current/include/hal_stub.h +++ b/packages/hal/common/current/include/hal_stub.h @@ -230,12 +230,15 @@ do { } while ( 0 ) #endif +// This macro may already have been defined by the architecture HAL +#ifndef CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION #define CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION( _old_ ) \ do { \ cyg_hal_gdb_remove_break( (target_register_t)&&cyg_hal_gdb_break_place ); \ HAL_RESTORE_INTERRUPTS(_old_); \ cyg_hal_gdb_break_place:; \ } while ( 0 ) +#endif #else // use __builtin_return_address instead.
--- a/packages/hal/common/current/src/generic-stub.c +++ b/packages/hal/common/current/src/generic-stub.c @@ -1435,10 +1435,6 @@ int return -1; case 'r': /* Reset */ -#ifdef __ECOS__ - __putpacket (remcomOutBuffer); - hal_flush_output(); -#endif /* With the next 'k' packet, reset the board */ __process_exit_vec = &__reset; break;
--- a/packages/hal/i386/arch/current/ChangeLog +++ b/packages/hal/i386/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2001-11-21 Mark Salter <msalter@redhat.com> + + * src/i386_stub.c (__do_read_msr): Add mem_fault handling. + (__do_write_msr): Ditto. + 2001-10-19 Ian Campbell <icampbell@arcom.co.uk> * include/hal_cache.h: Provide HAL_DCACHE_IS_ENABLED and
--- a/packages/hal/i386/arch/current/src/i386_stub.c +++ b/packages/hal/i386/arch/current/src/i386_stub.c @@ -263,10 +263,22 @@ put_register (regnames_t which, target_r // Handle the Model Specific Registers static target_register_t _msrval[2]; static int _which_msr = 0; +static int _dummy_flag = 0; + +extern void * volatile __mem_fault_handler; static void __do_read_msr (void) { + // _dummy_flag is always false but the goto is necessary to keep + // some compilers from reordering stuff across the 'err' label. + if (_dummy_flag) + goto err; + + __mem_fault = 1; // Defaults to 'fail'. Is cleared + // when the wrmsr completes. + __mem_fault_handler = &&err; + asm volatile ("movl %2,%%ecx\n" "rdmsr\n" "movl %%edx,%1\n" @@ -274,11 +286,25 @@ static void : "=m" (_msrval[0]), "=m" (_msrval[1]) : "m" (_which_msr) : "ecx", "ebx", "edx", "eax", "memory"); + + __mem_fault = 0; + + err: + __mem_fault_handler = (void *)0; } static void __do_write_msr (void) { + // _dummy_flag is always false but the goto is necessary to keep + // some compilers from reordering stuff across the 'err' label. + if (_dummy_flag) + goto err; + + __mem_fault = 1; // Defaults to 'fail'. Is cleared + // when the wrmsr completes. + __mem_fault_handler = &&err; + asm volatile ("movl %1,%%edx\n" "movl %0,%%eax\n" "movl %2,%%ecx\n" @@ -286,6 +312,11 @@ static void : /* no outputs */ : "m" (_msrval[0]), "m" (_msrval[1]), "m" (_which_msr) : "ecx", "ebx", "edx", "eax", "memory"); + + __mem_fault = 0; + + err: + __mem_fault_handler = (void *)0; } static int
--- a/packages/hal/i386/pcmb/current/ChangeLog +++ b/packages/hal/i386/pcmb/current/ChangeLog @@ -1,3 +1,8 @@ +2001-11-23 Nick Garnett <nickg@redhat.com> + + * include/pcmb_io.h (PC_WRITE_SCREEN): Wrap positions beyond end + of screen back to start. + 2001-11-01 Jonathan Larmour <jlarmour@redhat.com> * src/pcmb_misc.c (hal_pcmb_init): Fix typo:
--- a/packages/hal/i386/pcmb/current/include/pcmb_io.h +++ b/packages/hal/i386/pcmb/current/include/pcmb_io.h @@ -174,7 +174,8 @@ CYG_MACRO_END // Debug macros // Some simple macros for writing useful info to a PC ASCII display -#define PC_WRITE_SCREEN( __pos, __ch ) (*((short *)(0xB8000)+(__pos)) = (0x0700+(__ch))) +#define PC_WRITE_SCREEN( __pos, __ch ) \ + (*((short *)(0xB8000)+((__pos)%(80*25))) = (0x0700+(__ch))) #define PC_SCREEN_LINE( __line ) ((__line)*80)
--- a/packages/hal/mips/arch/current/ChangeLog +++ b/packages/hal/mips/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2001-11-16 Nick Garnett <nickg@redhat.com> + + * src/hal_misc.c (hal_msbit_index): Fixed this function so that it + actually works! + 2001-10-24 Nick Garnett <nickg@redhat.com> * src/vectors.S:
--- a/packages/hal/mips/arch/current/src/hal_misc.c +++ b/packages/hal/mips/arch/current/src/hal_misc.c @@ -327,7 +327,7 @@ cyg_uint32 hal_msbit_index(cyg_uint32 ma w = (w & 0x33333333) + ((w >> 2) & 0x33333333); w = w + (w >> 4); w = (w & 0x000F000F) + ((w >> 8) & 0x000F000F); - return (cyg_uint32)((w + (w >> 16)) & 0xFF); + return (cyg_uint32)((w + (w >> 16)) & 0xFF) - 1; }
--- a/packages/hal/mips/mips64/current/ChangeLog +++ b/packages/hal/mips/mips64/current/ChangeLog @@ -1,3 +1,7 @@ +2001-11-06 Mark Salter <msalter@redhat.com> + + * src/mips_mips64.ld: Add .2ram section. + 2001-02-23 Jesper Skov <jskov@redhat.com> * include/var_cache.h: Removed HAL_FLASH_CACHES_WANT_OPTIMAL. It
--- a/packages/hal/mips/mips64/current/src/mips_mips64.ld +++ b/packages/hal/mips/mips64/current/src/mips_mips64.ld @@ -193,6 +193,7 @@ GROUP(libtarget.a libgcc.a) { \ __ram_data_start = ABSOLUTE (.); _fdata = . ; \ *(.data) *(.data.*) *(.gnu.linkonce.d*) \ + *( .2ram.*) \ . = ALIGN (8); \ SORT(CONSTRUCTORS) \ } > _region_ \
--- a/packages/hal/mn10300/arch/current/ChangeLog +++ b/packages/hal/mn10300/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2001-11-16 Nick Garnett <nickg@redhat.com> + + * src/hal_misc.c (hal_msbit_index): Fixed this function so that it + actually works! + 2001-10-16 David Howells <dhowells@redhat.com> * src/hal_syscall.c: mustn't increment the return address by 4.
--- a/packages/hal/mn10300/arch/current/src/hal_misc.c +++ b/packages/hal/mn10300/arch/current/src/hal_misc.c @@ -145,8 +145,7 @@ hal_msbit_index(cyg_uint32 mask) w = (w & 0x33333333) + ((w >> 2) & 0x33333333); w = w + (w >> 4); w = (w & 0x000F000F) + ((w >> 8) & 0x000F000F); - return (cyg_uint32)((w + (w >> 16)) & 0xFF); - + return (cyg_uint32)((w + (w >> 16)) & 0xFF) - 1; } /*------------------------------------------------------------------------*/
--- a/packages/hal/powerpc/arch/current/ChangeLog +++ b/packages/hal/powerpc/arch/current/ChangeLog @@ -1,3 +1,13 @@ +2001-11-16 Nick Garnett <nickg@redhat.com> + + * include/hal_arch.h (HAL_MSBIT_INDEX): Fixed this macro so that + it actually works! + +2001-11-15 Jesper Skov <jskov@redhat.com> + + * src/hal_misc.c (hal_arch_default_isr): Added return + statement (found by Christoph Csebits). + 2001-02-23 Jesper Skov <jskov@redhat.com> * src/powerpc.ld: Added .2ram section matching to .data section.
--- a/packages/hal/powerpc/arch/current/include/hal_arch.h +++ b/packages/hal/powerpc/arch/current/include/hal_arch.h @@ -106,8 +106,12 @@ externC void cyg_hal_deliver_exception( : "r11" \ ); -#define HAL_MSBIT_INDEX(index, mask) \ - asm ( "cntlzw %1,%0" : "=r" (mask) : "r" (index) ); +#define HAL_MSBIT_INDEX(index, mask) \ + asm ( "cntlzw %0,%1\n" \ + "subfic %0,%0,31;" \ + : "=r" (index) \ + : "r" (mask) \ + ); //----------------------------------------------------------------------------- // eABI
--- a/packages/hal/powerpc/arch/current/src/hal_misc.c +++ b/packages/hal/powerpc/arch/current/src/hal_misc.c @@ -216,6 +216,7 @@ hal_default_isr(CYG_ADDRWORD vector, CYG externC cyg_uint32 hal_arch_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data) { + return 0; } #endif
--- a/packages/hal/sh/arch/current/ChangeLog +++ b/packages/hal/sh/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2001-11-16 Nick Garnett <nickg@redhat.com> + + * src/hal_misc.c (hal_msbit_index): Fixed this function so that it + actually works! + 2001-10-15 David Howells <dhowells@redhat.com> * cdl/hal_sh.cdl: improved the description on the RTC constants
--- a/packages/hal/sh/arch/current/src/hal_misc.c +++ b/packages/hal/sh/arch/current/src/hal_misc.c @@ -182,7 +182,7 @@ hal_msbit_index(cyg_uint32 mask) w = (w & 0x33333333) + ((w >> 2) & 0x33333333); w = w + (w >> 4); w = (w & 0x000F000F) + ((w >> 8) & 0x000F000F); - return (cyg_uint32)((w + (w >> 16)) & 0xFF); + return (cyg_uint32)((w + (w >> 16)) & 0xFF) - 1; }
--- a/packages/hal/sh/cq7750/current/ChangeLog +++ b/packages/hal/sh/cq7750/current/ChangeLog @@ -1,3 +1,8 @@ +2001-11-19 Jesper Skov <jskov@redhat.com> + + * cdl/hal_sh_sh7750_cq7750.cdl: Added CYGHWR_HAL_SH_OOC_DIVIDER_1 + (found by Koichi Nagashima) + 2001-09-11 Jonathan Larmour <jlarmour@redhat.com> * cdl/hal_sh_sh7750_cq7750.cdl: Default to big endian.
--- a/packages/hal/sh/cq7750/current/cdl/hal_sh_sh7750_cq7750.cdl +++ b/packages/hal/sh/cq7750/current/cdl/hal_sh_sh7750_cq7750.cdl @@ -152,6 +152,17 @@ cdl_package CYGPKG_HAL_SH_SH7750_CQ7750 be set to zero." } + cdl_option CYGHWR_HAL_SH_OOC_DIVIDER_1 { + display "SH clock first clock divider" + flavor data + legal_values { 1 2 } + default_value 1 + no_define + description " + First stage clock divider according to the mode (MD0..2). + Set 2 for mode 2 and 4, otherwise set 1." + } + cdl_option CYGHWR_HAL_SH_OOC_DIVIDER_IFC { display "SH CPU clock divider" flavor data
--- a/packages/hal/sh/dreamcast/current/ChangeLog +++ b/packages/hal/sh/dreamcast/current/ChangeLog @@ -1,3 +1,8 @@ +2001-11-21 Jesper Skov <jskov@redhat.com> + + * cdl/hal_sh_sh7750_dreamcast.cdl: Added + CYGHWR_HAL_SH_OOC_DIVIDER_1 option. + 2001-08-06 Jesper Skov <jskov@redhat.com> * cdl/hal_sh_sh7750_dreamcast.cdl: Set linux boot parameters.
--- a/packages/hal/sh/dreamcast/current/cdl/hal_sh_sh7750_dreamcast.cdl +++ b/packages/hal/sh/dreamcast/current/cdl/hal_sh_sh7750_dreamcast.cdl @@ -162,6 +162,17 @@ cdl_package CYGPKG_HAL_SH_SH7750_DREAMCA This selects whether PLL2 is enabled." } + cdl_option CYGHWR_HAL_SH_OOC_DIVIDER_1 { + display "SH clock first clock divider" + flavor data + legal_values { 1 2 } + default_value 1 + no_define + description " + First stage clock divider according to the mode (MD0..2). + Set 2 for mode 2 and 4, otherwise set 1." + } + cdl_option CYGHWR_HAL_SH_OOC_DIVIDER_IFC { display "SH clock divider, core" flavor data
--- a/packages/hal/sh/sh4/current/ChangeLog +++ b/packages/hal/sh/sh4/current/ChangeLog @@ -1,3 +1,7 @@ +2001-11-07 Jesper Skov <jskov@redhat.com> + + * src/var_mk_defs.c (main): Fix warning. + 2001-10-17 Jesper Skov <jskov@redhat.com> * include/mod_regs_ubc.h (CYGARC_REG_BRCR_ONE_STEP): Added.
--- a/packages/hal/sh/sh4/current/src/var_mk_defs.c +++ b/packages/hal/sh/sh4/current/src/var_mk_defs.c @@ -85,6 +85,8 @@ main(void) DEFINE(CYGARC_REG_DCACHE_ADDRESS_TOP,CYGARC_REG_DCACHE_ADDRESS_TOP); DEFINE(CYGARC_REG_DCACHE_ADDRESS_STEP,CYGARC_REG_DCACHE_ADDRESS_STEP); DEFINE(CYGARC_REG_DCACHE_ADDRESS_FLUSH, CYGARC_REG_DCACHE_ADDRESS_FLUSH); + + return 0; } //--------------------------------------------------------------------------
--- a/packages/io/fileio/current/ChangeLog +++ b/packages/io/fileio/current/ChangeLog @@ -1,3 +1,9 @@ +2001-11-02 Felix Wong <felixwong@i-technologies.cc> +2001-11-02 Jonathan Larmour <jlarmour@redhat.com> + + * src/devfs.cxx (dev_fo_read): Support block devices. + (dev_fo_write): Ditto. + 2001-10-09 Jonathan Larmour <jlarmour@redhat.com> * src/fio.h: Make cancellation point dependand on
--- a/packages/io/fileio/current/src/devfs.cxx +++ b/packages/io/fileio/current/src/devfs.cxx @@ -332,10 +332,16 @@ static int dev_fo_read (struct CYG_ { cyg_iovec *iov = &uio->uio_iov[i]; cyg_uint32 len = iov->iov_len; - - err = cyg_io_read( (cyg_io_handle_t)fp->f_data, - iov->iov_base, - &len); + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)fp->f_data; + + if (t->status & CYG_DEVTAB_STATUS_BLOCK) + err = cyg_io_bread( (cyg_io_handle_t)t, + iov->iov_base, + &len, fp->f_offset); + else + err = cyg_io_read( (cyg_io_handle_t)t, + iov->iov_base, + &len); if( EAGAIN == err ) // must be in non-blocking mode { @@ -363,10 +369,16 @@ static int dev_fo_write (struct CYG_ { cyg_iovec *iov = &uio->uio_iov[i]; cyg_uint32 len = iov->iov_len; - - err = cyg_io_write( (cyg_io_handle_t)fp->f_data, - iov->iov_base, - &len); + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)fp->f_data; + + if (t->status & CYG_DEVTAB_STATUS_BLOCK) + err = cyg_io_bwrite( (cyg_io_handle_t)t, + iov->iov_base, + &len, fp->f_offset); + else + err = cyg_io_write( (cyg_io_handle_t)t, + iov->iov_base, + &len); if( EAGAIN == err ) // must be in non-blocking mode {
--- a/packages/language/c/libc/stdio/current/ChangeLog +++ b/packages/language/c/libc/stdio/current/ChangeLog @@ -1,3 +1,8 @@ +2001-11-23 Jonathan Larmour <jlarmour@redhat.com> + + * cdl/stdio.cdl: Add dependency on stdlib string conversion functions + for *scanf. + 2001-08-10 Robin Farine <robin.farine@terminus.org> * src/output/vfnprintf.cxx (cvt): Handles the cases of finite,
--- a/packages/language/c/libc/stdio/current/cdl/stdio.cdl +++ b/packages/language/c/libc/stdio/current/cdl/stdio.cdl @@ -78,6 +78,9 @@ cdl_package CYGPKG_LIBC_STDIO { requires CYGINT_ISO_STRERROR requires CYGINT_ISO_STRING_STRFUNCS requires CYGINT_ISO_STRING_MEMFUNCS + # The following is for scanf only. We could express this better, + # particularly since scanf is also dependent on the optional ungetc. + requires CYGINT_ISO_STDLIB_STRCONV compile common/fclose.cxx common/feof.cxx \ common/fflush.cxx common/fopen.cxx \
new file mode 100644 --- /dev/null +++ b/packages/net/ftpclient/current/ChangeLog @@ -0,0 +1,31 @@ +2001-11-4 Andrew Lunn <andrew.lunn@ascom.ch> + + * First version. Implements an FTP client which can get and put + files on a server. + +//=========================================================================== +//####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/net/ftpclient/current/cdl/ftpclient.cdl @@ -0,0 +1,99 @@ +#==================================================================== +# +# ftpclient.cdl +# +# SNMP library 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 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): andrew.lunn@ascom.ch +# Original data: andrew.lunn@ascom.ch +# Contributors: +# Date: 2001-11-04 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_NET_FTPCLIENT { + display "FTP client" + parent CYGPKG_NET + requires CYGPKG_IO + requires { 0 != CYGINT_ISO_STRING_STRFUNCS } + requires { 0 != CYGINT_ISO_STRING_MEMFUNCS } + requires { 0 != CYGINT_ISO_STDLIB_STRCONV } + requires { 0 != CYGINT_ISO_STDIO_FORMATTED_IO } + requires { 0 != CYGINT_ISO_STRING_STRFUNCS } + requires { 0 != CYGINT_ISO_ERRNO } + requires { 0 != CYGINT_ISO_ERRNO_CODES } + requires { 0 != CYGINT_ISO_CTYPE } + requires CYGPKG_NET + description " + FTP client support. Provides ftp_put and ftp_get to put a file + onto a remote FTP server and get a file from a remote server. + Only binary more is supported." + + compile ftpclient.c + + cdl_component CYGPKG_NET_FTPCLIENT_OPTIONS { + display "FTP client build options" + flavor none + no_define + + cdl_option CYGPKG_NET_FTPCLIENT_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "-D_KERNEL -D__ECOS" } + description " + This option modifies the set of compiler flags for + building the FTP client package. These flags are used + in addition to the set of global flags." + } + + cdl_option CYGPKG_NET_FTPCLIENT_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the FTP client package. These flags are removed from + the set of global flags if present." + } + } + cdl_option CYGPKG_NET_FTPCLIENT_TESTS { + display "FTP Client tests" + flavor data + no_define + calculated { "tests/ftpclient1.c"} + description " + This option specifies the set of tests for the ftpclient package." + } +} +
new file mode 100644 --- /dev/null +++ b/packages/net/ftpclient/current/include/ftpclient.h @@ -0,0 +1,97 @@ +#ifndef CYGONCE_NET_FTPCLIENT_FTPCLIENT_H +#define CYGONCE_NET_FTPCLIENT_FTPCLIENT_H + +//========================================================================== +// +// ftpclient.h +// +// A simple FTP client +// +//========================================================================== +//####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): andrew.lunn@ascom.ch +// Contributors: andrew.lunn@ascom.ch +// Date: 2001-11-4 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +typedef void (*ftp_printf_t)(unsigned error, const char *, ...); + +/* Use the FTP protocol to retrieve a file from a server. Only binary + mode is supported. The filename can include a directory name. Only + use unix style / not M$'s \. The file is placed into buf. buf has + maximum size buf_size. If the file is bigger than this, the + transfer fails and FTP_TOOBIG is returned. Other error codes as + listed below can also be returned. If the transfer is succseful the + number of bytes received is returned. */ + +int ftp_get(char * hostname, + char * username, + char * passwd, + char * filename, + char * buf, + unsigned buf_size, + ftp_printf_t ftp_printf); + +/*Use the FTP protocol to send a file from a server. Only binary mode + is supported. The filename can include a directory name. Only use + unix style / not M$'s \. The contents of buf is placed into the file + on the server. If an error occurs one of the codes as listed below + will be returned. If the transfer is succseful zero is returned.*/ + +int ftp_put(char * hostname, + char * username, + char * passwd, + char * filename, + char * buf, + unsigned buf_size, + ftp_printf_t ftp_printf); + +/*ftp_get() and ftp_put take the name of a function to call to print + out diagnostic and error messages. This is a sample implementation + which can be used if you don't want to implement the function + yourself. error will be true when the message to print is an error + message. Otherwise the message is diagnostic, eg the commands sent + and received from the server.*/ + +void ftpclient_printf(unsigned error, const char *fmt, ...); + +/* Error codes */ + +#define FTP_BAD -2 /* Catch all, socket errors etc. */ +#define FTP_NOSUCHHOST -3 /* The server does not exist. */ +#define FTP_BADUSER -4 /* Username/Password failed */ +#define FTP_TOOBIG -5 /* Out of buffer space or disk space */ +#define FTP_BADFILENAME -6 /* The file does not exist */ + +#endif CYGONCE_NET_FTPCLIENT_FTPCLIENT +
new file mode 100644 --- /dev/null +++ b/packages/net/ftpclient/current/src/ftpclient.c @@ -0,0 +1,679 @@ +//========================================================================== +// +// ftpclient.c +// +// A simple FTP client +// +//========================================================================== +//####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): andrew.lunn@ascom.ch +// Contributors: andrew.lunn@ascom.ch +// Date: 2001-11-4 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <network.h> +#include <stdio.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <ctype.h> +#include "ftpclient.h" + +/* Build one command to send to the FTP server */ +static int +build_cmd(char *buf, + unsigned bufsize, + char *cmd, + char *arg1) +{ + int cnt; + + if (arg1) { + cnt = snprintf(buf,bufsize,"%s %s\r\n",cmd,arg1); + } else { + cnt = snprintf(buf,bufsize,"%s\r\n",cmd); + } + + if (cnt < bufsize) + return 1; + + return 0; +} + + +/* Read one line from the server, being careful not to overrun the + buffer. If we do reach the end of the buffer, discard the rest of + the line. */ +static int +get_line(int s, char *buf, unsigned buf_size,ftp_printf_t ftp_printf) { + + int eol = 0; + int cnt = 0; + int ret; + char c; + + while(!eol) { + ret = read(s,&c,1); + + if (ret != 1) { + ftp_printf(1,"read %s\n",strerror(errno)); + return FTP_BAD; + } + + if (c == '\n') { + eol = 1; + continue; + } + + if (cnt < buf_size) { + buf[cnt++] = c; + } + } + if (cnt < buf_size) { + buf[cnt++] = '\0'; + } else { + buf[buf_size -1] = '\0'; + } + return 0; +} + +/* Read the reply from the server and return the MSB from the return + code. This gives us a basic idea if the command failed/worked. The + reply can be spread over multiple lines. When this happens the line + will start with a - to indicate there is more*/ +static int +get_reply(int s,ftp_printf_t ftp_printf) { + + char buf[BUFSIZ]; + int more = 0; + int ret; + + do { + + if ((ret=get_line(s,buf,sizeof(buf),ftp_printf)) < 0) { + return(ret); + } + + ftp_printf(0,"FTP: %s\n",buf); + + more = (buf[3] == '-'); + } while (more); + + return (buf[0] - '0'); +} + +/* Send a command to the server */ +static int +send_cmd(int s,char * msgbuf,ftp_printf_t ftp_printf) { + + int len; + int slen = strlen(msgbuf); + + if ((len = write(s,msgbuf,slen)) != slen) { + if (slen < 0) { + ftp_printf(1,"write %s\n",strerror(errno)); + return FTP_BAD; + } else { + ftp_printf(1,"write truncasted!\n"); + return FTP_BAD; + } + } + return 1; +} + +/* Send a complete command to the server and receive the reply. Return the + MSB of the reply code. */ +static int +command(char * cmd, + char * arg, + int s, + char *msgbuf, + int msgbuflen, + ftp_printf_t ftp_printf) { + + int err; + + if (!build_cmd(msgbuf,msgbuflen,cmd,arg)) { + ftp_printf(1,"FTP: %s command to long\n",cmd); + return FTP_BAD; + } + + ftp_printf(0,"FTP: Sending %s command\n",cmd); + + if ((err=send_cmd(s,msgbuf,ftp_printf)) < 0) { + return(err); + } + + return (get_reply(s,ftp_printf)); +} + +/* Open a socket and connect it to the server. Also print out the + address of the server for debug purposes.*/ + +static int +connect_to_server(char *hostname, + struct sockaddr_in * local, + ftp_printf_t ftp_printf) +{ + struct sockaddr_in host; + struct servent *sent; + struct hostent *hp; + int s, len; + + s = socket(AF_INET, SOCK_STREAM, 0); + if (s < 0) { + ftp_printf(1,"socket: %s\n",strerror(errno)); + return FTP_BAD; + } + + sent = getservbyname("ftp", "tcp"); + if (sent == (struct servent *)0) { + ftp_printf(1,"FTP: unknown serivice\n"); + close(s); + return FTP_BAD; + } + + hp = gethostbyname(hostname); + + if (hp) { /* try name first */ + host.sin_family = hp->h_addrtype; + bcopy(hp->h_addr, &host.sin_addr, hp->h_length); + } else { /* maybe it's a numeric address ?*/ + host.sin_family = AF_INET; + + if (inet_aton(hostname,&host.sin_addr) == 0) { + ftp_printf(1,"host not found: %s\n", hostname); + close (s); + return FTP_NOSUCHHOST; + } + } + + host.sin_port = sent->s_port; + + if (connect(s, (struct sockaddr *)&host, sizeof(host)) < 0) { + ftp_printf(1,"FTP Connect failed: %s\n",strerror(errno)); + close (s); + return FTP_NOSUCHHOST; + } + + len = sizeof(struct sockaddr_in); + if (getsockname(s, (struct sockaddr *)local, &len) < 0) { + ftp_printf(1,"getsockname failed %s\n",strerror(errno)); + close(s); + return FTP_BAD; + } + ftp_printf(0,"FTP: Connected to %s.%d\n", + inet_ntoa(host.sin_addr), ntohs(host.sin_port)); + + return (s); +} + +/* Perform a login to the server. Pass the username and password and + put the connection into binary mode. This assumes a passwd is + always needed. Is this true? */ + +static int +login(char * username, + char *passwd, + int s, + char *msgbuf, + unsigned msgbuflen, + ftp_printf_t ftp_printf) { + + int ret; + + ret = command("USER",username,s,msgbuf,msgbuflen,ftp_printf); + if (ret != 3) { + ftp_printf(1,"FTP: User %s not accepted\n",username); + return (FTP_BADUSER); + } + + ret = command("PASS",passwd,s,msgbuf,msgbuflen,ftp_printf); + if (ret < 0) { + return (ret); + } + if (ret != 2) { + ftp_printf(1,"FTP: Login failed for User %s\n",username); + return (FTP_BADUSER); + } + + ftp_printf(0,"FTP: Login sucessfull\n"); + + ret = command("TYPE","I",s,msgbuf,msgbuflen,ftp_printf); + if (ret < 0) { + return (ret); + } + if (ret != 2) { + ftp_printf(1,"FTP: TYPE failed!\n"); + return (FTP_BAD); + } + return (ret); +} + + +/* Open a data socket. This is a client socket, i.e. its listening +waiting for the FTP server to connect to it. Once the socket has been +opened send the port command to the server so the server knows which +port we are listening on.*/ +static int +opendatasock(int ctrl_s, + struct sockaddr_in ctrl, + char *msgbuf, + unsigned msgbuflen, + ftp_printf_t ftp_printf) { + + struct sockaddr_in local; + socklen_t len; + int on = 1; + char buf[4*6+1]; + char *a, *p; + int ret; + int s; + + s = socket(AF_INET, SOCK_STREAM, 0); + if (s < 0) { + ftp_printf(1,"socket: %s\n",strerror(errno)); + return FTP_BAD; + } + + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof (on)) < 0) { + ftp_printf(1,"setsockopt: %s\n",strerror(errno)); + close(s); + return FTP_BAD; + } + + local = ctrl; + local.sin_family = AF_INET; + local.sin_port = 0; + if (bind(s,(struct sockaddr *)&local,sizeof(local)) < 0) { + ftp_printf(1,"bind: %s\n",strerror(errno)); + close(s); + return FTP_BAD; + } + + len = sizeof(local); + if (getsockname(s,(struct sockaddr *)&local,&len) < 0) { + ftp_printf(1,"getsockname: %s\n",strerror(errno)); + close(s); + return FTP_BAD; + } + + if (listen(s, 1) < 0) { + ftp_printf(1,"listen: %s\n",strerror(errno)); + close(s); + return FTP_BAD; + } + +#define BtoI(b) (((int)b)&0xff) + a = (char *)&local.sin_addr; + p = (char *)&local.sin_port; + sprintf(buf,"%d,%d,%d,%d,%d,%d", + BtoI(a[0]),BtoI(a[1]),BtoI(a[2]),BtoI(a[3]), + BtoI(p[0]),BtoI(p[1])); + + ret = command("PORT",buf,ctrl_s,msgbuf,msgbuflen,ftp_printf); + if (ret < 0) { + close(s); + return (ret); + } + + if (ret != 2) { + ftp_printf(1,"FTP: PORT failed!\n"); + close(s); + return (FTP_BAD); + } + return (s); +} + +/* Receive the file into the buffer and close the data socket + afterwards */ +static int +receive_file(int data_s, char *buf, int buf_size,ftp_printf_t ftp_printf) +{ + int remaining = buf_size; + int finished = 0; + int total_size=0; + char *bufp = buf; + int len; + int s; + + s = accept(data_s,NULL,0); + if (s<0) { + ftp_printf(1,"listen: %s\n",strerror(errno)); + return FTP_BAD; + } + + do { + len = read(s,bufp,remaining); + if (len < 0) { + ftp_printf(1,"read: %s\n",strerror(errno)); + close(s); + return FTP_BAD; + } + + if (len == 0) { + finished = 1; + } else { + total_size += len; + remaining -= len; + bufp += len; + + if (total_size == buf_size) { + ftp_printf(1,"FTP: File too big!\n"); + close(s); + return FTP_TOOBIG; + } + } + } while (!finished); + + close(s); + return total_size; +} + +/* Receive the file into the buffer and close the socket afterwards*/ +static int +send_file(int data_s, char *buf, int buf_size,ftp_printf_t ftp_printf) +{ + int remaining=buf_size; + int finished = 0; + char * bufp = buf; + int len; + int s; + + s = accept(data_s,NULL,0); + if (s<0) { + ftp_printf(1,"listen: %s\n",strerror(errno)); + return FTP_BAD; + } + + do { + len = write(s,bufp,remaining); + if (len < 0) { + ftp_printf(1,"write: %s\n",strerror(errno)); + close(s); + return FTP_BAD; + } + + if (len == remaining) { + finished = 1; + } else { + remaining -= len; + bufp += len; + } + } while (!finished); + + close(s); + return 0; +} + +/* All done, say bye, bye */ +static int quit(int s, + char *msgbuf, + unsigned msgbuflen, + ftp_printf_t ftp_printf) { + + int ret; + + ret = command("QUIT","",s,msgbuf,msgbuflen,ftp_printf); + if (ret < 0) { + return (ret); + } + if (ret != 2) { + ftp_printf(1,"FTP: Quit failed!\n"); + return (FTP_BAD); + } + + ftp_printf(0,"FTP: Connection closed\n"); + return (0); +} + +/* Get a file from an FTP server. Hostname is the name/IP address of + the server. username is the username used to connect to the server + with. Passwd is the password used to authentificate the + username. filename is the name of the file to receive. It should be + the full pathname of the file. buf is a pointer to a buffer the + contents of the file should be placed in and buf_size is the size + of the buffer. If the file is bigger than the buffer, buf_size + bytes will be retrieved and an error code returned. ftp_printf is a + function to be called to perform printing. On success the number of + bytes received is returned. On error a negative value is returned + indicating the type of error. */ + +int ftp_get(char * hostname, + char * username, + char * passwd, + char * filename, + char * buf, + unsigned buf_size, + ftp_printf_t ftp_printf) +{ + + struct sockaddr_in local; + char msgbuf[256]; + int s,data_s; + int bytes; + int ret; + + s = connect_to_server(hostname,&local,ftp_printf); + if (s < 0) { + return (s); + } + + /* Read the welcome message from the server */ + if (get_reply(s,ftp_printf) != 2) { + ftp_printf(0,"FTP: Server refused connection\n"); + close(s); + return FTP_BAD; + } + + ret = login(username,passwd,s,msgbuf,sizeof(msgbuf),ftp_printf); + if (ret < 0) { + close(s); + return (ret); + } + + /* We are now logged in and ready to transfer the file. Open the + data socket ready to receive the file. It also build the PORT + command ready to send */ + data_s = opendatasock(s,local,msgbuf,sizeof(msgbuf),ftp_printf); + if (data_s < 0) { + close (s); + return (data_s); + } + + /* Ask for the file */ + ret = command("RETR",filename,s,msgbuf,sizeof(msgbuf),ftp_printf); + if (ret < 0) { + close(s); + close(data_s); + return (ret); + } + + if (ret != 1) { + ftp_printf(0,"FTP: RETR failed!\n"); + close (data_s); + close(s); + return (FTP_BADFILENAME); + } + + if ((bytes=receive_file(data_s,buf,buf_size,ftp_printf)) < 0) { + ftp_printf(0,"FTP: Receiving file failed\n"); + close (data_s); + close(s); + return (bytes); + } + + if (get_reply(s,ftp_printf) != 2) { + ftp_printf(0,"FTP: Transfer failed!\n"); + close (data_s); + close(s); + return (FTP_BAD); + } + + ret = quit(s,msgbuf,sizeof(msgbuf),ftp_printf); + if (ret < 0) { + close(s); + close(data_s); + return (ret); + } + + close (data_s); + close(s); + return bytes; +} + +/* Put a file on an FTP server. Hostname is the name/IP address of the + server. username is the username used to connect to the server + with. Passwd is the password used to authentificate the + username. filename is the name of the file to receive. It should be + the full pathname of the file. buf is a pointer to a buffer the + contents of the file should be placed in and buf_size is the size + of the buffer. ftp_printf is a function to be called to perform + printing. On success 0 is returned. On error a negative value is + returned indicating the type of error. */ + +int ftp_put(char * hostname, + char * username, + char * passwd, + char * filename, + char * buf, + unsigned buf_size, + ftp_printf_t ftp_printf) +{ + + struct sockaddr_in local; + char msgbuf[256]; + int s,data_s; + int ret; + + s = connect_to_server(hostname,&local,ftp_printf); + if (s < 0) { + return (s); + } + + /* Read the welcome message from the server */ + if (get_reply(s,ftp_printf) != 2) { + ftp_printf(1,"FTP: Server refused connection\n"); + close(s); + return FTP_BAD; + } + + ret = login(username,passwd,s,msgbuf,sizeof(msgbuf),ftp_printf); + if (ret < 0) { + close(s); + return (ret); + } + + /* We are now logged in and ready to transfer the file. Open the + data socket ready to receive the file. It also build the PORT + command ready to send */ + data_s = opendatasock(s,local,msgbuf,sizeof(msgbuf),ftp_printf); + if (data_s < 0) { + close (s); + return (data_s); + } + + /* Ask for the file */ + ret = command("STOR",filename,s,msgbuf,sizeof(msgbuf),ftp_printf); + if (ret < 0) { + close(s); + close(data_s); + return (ret); + } + + if (ret != 1) { + ftp_printf(1,"FTP: STOR failed!\n"); + close (data_s); + close(s); + return (FTP_BADFILENAME); + } + + if ((ret = send_file(data_s,buf,buf_size,ftp_printf)) < 0) { + ftp_printf(1,"FTP: Sending file failed\n"); + close (data_s); + close(s); + return (ret); + } + + if (get_reply(s,ftp_printf) != 2) { + ftp_printf(1,"FTP: Transfer failed!\n"); + close (data_s); + close(s); + return (FTP_BAD); + } + + ret = quit(s,msgbuf,sizeof(msgbuf),ftp_printf); + if (ret < 0) { + close(s); + close(data_s); + return (ret); + } + + close (data_s); + close(s); + return 0; +} + +/* An example ftp_printf function. This uses the standard eCos diag +output device for outputting error and diagnostic messages. The +function take one addition parameter to the normal printf function. The +first parameter indicates when the message is an error message when +true. This can be used to filter errors from diagnostic output. In +this example the error parameter is ignored and everything printed. + +The diag_vprintf() function does not use varargs, so we have to do the +hard work ourselves of unpacking the stack and passing an array of +pointers*/ + +externC void diag_vprintf( const char *fmt, CYG_ADDRWORD *args); + +void ftpclient_printf(unsigned error, const char *fmt, ...) +{ + va_list ap; + CYG_ADDRWORD args[8]; + + va_start(ap, fmt); + + args[0] = va_arg(ap,CYG_ADDRWORD); + args[1] = va_arg(ap,CYG_ADDRWORD); + args[2] = va_arg(ap,CYG_ADDRWORD); + args[3] = va_arg(ap,CYG_ADDRWORD); + args[4] = va_arg(ap,CYG_ADDRWORD); + args[5] = va_arg(ap,CYG_ADDRWORD); + args[6] = va_arg(ap,CYG_ADDRWORD); + args[7] = va_arg(ap,CYG_ADDRWORD); + + diag_vprintf( fmt, args); + + va_end(ap); +}
new file mode 100644 --- /dev/null +++ b/packages/net/ftpclient/current/tests/ftpclient1.c @@ -0,0 +1,155 @@ +//========================================================================== +// +// tests/dns1.c +// +// Simple test of DNS client 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): andrew.lunn +// Contributors: andrew.lunn, jskov +// Date: 2001-09-18 +// Purpose: +// Description: Test FTPClient functions. Note that the _XXX defines below +// control what addresses the test uses. These must be +// changed to match the particular testing network in which +// the test is to be run. +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <network.h> +#include <ftpclient.h> +#include <cyg/infra/testcase.h> + +#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) +static char stack[STACK_SIZE]; +static cyg_thread thread_data; +static cyg_handle_t thread_handle; + +#define __string(_x) #_x +#define __xstring(_x) __string(_x) + +#define _FTP_SRV __xstring(172.16.19.254) // farmnet dns0 address + +#define FTPBUFSIZE (1024 * 64) +char ftpbuf[FTPBUFSIZE]; +char ftpbuf1[FTPBUFSIZE]; + +void +ftp_test(cyg_addrword_t p) +{ + int ret; + + CYG_TEST_INIT(); + + init_all_network_interfaces(); + + CYG_TEST_INFO("Getting /etc/passwd from %s\n" _FTP_SRV); + ret = ftp_get(_FTP_SRV,"anonymous","ftpclient1", + "/etc/passwd",ftpbuf,FTPBUFSIZE, + ftpclient_printf); + + if (ret > 0) { + diag_printf("PASS:< %s bytes received>\n",ret); + } else { + diag_printf("FAIL:< ftp_get returned %d>\n",ret); + } + + CYG_TEST_INFO("Putting passwd file back in /incoming/passwd\n"); + ret = ftp_put(_FTP_SRV,"anonymous","ftpclient1", + "/incoming/passwd",ftpbuf,ret, + ftpclient_printf); + + if (ret > 0) { + diag_printf("PASS:\n"); + } else { + diag_printf("FAIL:< ftp_get returned %d>\n",ret); + } + + CYG_TEST_INFO("Reading back /incoming/passwd\n"); + ret = ftp_get(_FTP_SRV,"anonymous","ftpclient1", + "/incoming/passwd",ftpbuf1,FTPBUFSIZE, + ftpclient_printf); + + if (ret > 0) { + diag_printf("PASS:< %s bytes received>\n",ret); + } else { + diag_printf("FAIL:< ftp_get returned %d>\n",ret); + } + + CYG_TEST_PASS_FAIL(!memcmp(ftpbuf,ftpbuf1,ret),"Transfer integrity"); + + CYG_TEST_INFO("ftp_Get'ing with a bad username\n"); + ret = ftp_get(_FTP_SRV,"nosuchuser","ftpclient1", + "/incoming/passwd",ftpbuf1,FTPBUFSIZE, + ftpclient_printf); + CYG_TEST_PASS_FAIL(ret==FTP_BADUSER,"Bad Username"); + + CYG_TEST_INFO("ftp_get'ting with a bad passwd\n"); + ret = ftp_get(_FTP_SRV,"nobody","ftpclient1", + "/incoming/passwd",ftpbuf1,FTPBUFSIZE, + ftpclient_printf); + CYG_TEST_PASS_FAIL(ret==FTP_BADUSER,"Bad passwd"); + + CYG_TEST_INFO("ftp_get'ing from a with a bad passwd\n"); + ret = ftp_get(_FTP_SRV,"nobody","ftpclient1", + "/incoming/passwd",ftpbuf1,FTPBUFSIZE, + ftpclient_printf); + CYG_TEST_PASS_FAIL(ret==FTP_BADUSER,"Bad passwd"); + + CYG_TEST_INFO("ftp_get'ing from a bad server\n"); + ret = ftp_get("127.0.0.1","nobody","ftpclient1", + "/incoming/passwd",ftpbuf1,FTPBUFSIZE, + ftpclient_printf); + CYG_TEST_PASS_FAIL(ret==FTP_NOSUCHHOST,"Bad server"); + + CYG_TEST_INFO("ftp_get'ing a file which is too big"); + ret = ftp_get(_FTP_SRV,"nobody","ftpclient1", + "/incoming/passwd",ftpbuf,2, + ftpclient_printf); + CYG_TEST_PASS_FAIL(ret==FTP_TOOBIG,"File too big"); +} + +void +cyg_start(void) +{ + /* Create a main thread, so we can run the scheduler and have time 'pass' */ + cyg_thread_create(10, // Priority - just a number + ftp_test, // entry + 0, // entry parameter + "FTP test", // Name + &stack[0], // Stack + STACK_SIZE, // Size + &thread_handle, // Handle + &thread_data // Thread data structure + ); + cyg_thread_resume(thread_handle); /* Start it */ + cyg_scheduler_start(); +}
--- a/packages/net/tcpip/current/ChangeLog +++ b/packages/net/tcpip/current/ChangeLog @@ -1,3 +1,23 @@ +2001-11-19 Hugo Tyson <hmt@redhat.com> + + * include/bootp.h (BP_STD_TX_MINPKTSZ): New symbol defining the + minimal DHCP packet size which we should send. + + * src/lib/dhcp_prot.c (scan_dhcp_size): New routine to scan up to + the end of the packet, for length determination and padding. + (dhcp_size): Now uses scan_dhcp_size(). + (dhcp_size_for_send): New, uses scan_dhcp_size() and pads with + zero up to the min packet size that we should send. + (do_dhcp): In every sendto() call, use dhcp_size_for_send(xmit) in + order to send padded, full size packets as needed. 5 instances. + + Credit to "Anssi Pulkkinen" <Anssi.Pulkkinen@ascom.ch> for the + original version of this patch. + +2001-11-08 Jesper Skov <jskov@redhat.com> + + * tests/server_test.c (net_test): Fix compile error. + 2001-11-02 Gary Thomas <gthomas@redhat.com> * src/ecos/support.c:
--- a/packages/net/tcpip/current/include/bootp.h +++ b/packages/net/tcpip/current/include/bootp.h @@ -99,6 +99,9 @@ SOFTWARE. #define BP_SNAME_LEN 64 #define BP_FILE_LEN 128 +/* std min packet size to transmit for DHCP relays to work */ +#define BP_STD_TX_MINPKTSZ (300) + #ifdef CYGPKG_NET_DHCP // The standard requires only 312 bytes here #define BP_VEND_LEN (312 + 32)
--- a/packages/net/tcpip/current/src/lib/dhcp_prot.c +++ b/packages/net/tcpip/current/src/lib/dhcp_prot.c @@ -56,10 +56,12 @@ #include <cyg/infra/cyg_ass.h> // ------------------------------------------------------------------------ -// Get the actual packet size of an initialized buffer +// Returns a pointer to the end of dhcp message (or NULL if invalid) +// meaning the address of the byte *after* the TAG_END token in the vendor +// data. -static int -dhcp_size( struct bootp *ppkt ) +static unsigned char * +scan_dhcp_size( struct bootp *ppkt ) { unsigned char *op; @@ -70,17 +72,53 @@ dhcp_size( struct bootp *ppkt ) op[2] != 83 || op[3] != 99 ) { CYG_FAIL( "Bad DHCP cookie" ); - return 0; + return NULL; } op += 4; while (*op != TAG_END) { op += *(op+1)+2; if ( op > &ppkt->bp_vend[BP_VEND_LEN-1] ) { CYG_FAIL( "Oversize DHCP packet in dhcp_size" ); - return 0; + return NULL; } } - return (op - (unsigned char *)ppkt) + 1; + // Check op has not gone wild + CYG_ASSERT( op > (unsigned char *)(&ppkt[0]), "op pointer underflow!" ); + // Compare op with non-existent "next" struct bootp in the array. + CYG_ASSERT( op < (unsigned char *)(&ppkt[1]), "op pointer overflow!" ); + return op + 1; // Address of first invalid byte +} + +// ------------------------------------------------------------------------ +// Get the actual packet size of an initialized buffer + +static int +dhcp_size( struct bootp *ppkt ) +{ + unsigned char *op; + + op = scan_dhcp_size( ppkt ); + if ( !op ) return 0; + return (op - (unsigned char *)ppkt); +} + + +// ------------------------------------------------------------------------ +// Get the actual packet size of an initialized buffer +// This will also pad the packet with 0 if length is less +// than BP_STD_TX_MINPKTSZ. + +static int +dhcp_size_for_send( struct bootp *ppkt ) +{ + unsigned char *op; + + op = scan_dhcp_size( ppkt ); + if ( !op ) return 0; // Better not scribble! + // Zero extra bytes until the packet is large enough. + for ( ; op < (((unsigned char *)ppkt) + BP_STD_TX_MINPKTSZ); op++ ) + *op = 0; + return (op - (unsigned char *)ppkt); } // ------------------------------------------------------------------------ @@ -528,7 +566,7 @@ do_dhcp(const char *intf, struct bootp * diag_printf( "---------DHCPSTATE_INIT sending:\n" ); show_bootp( intf, xmit ); #endif - if(sendto(s, xmit, dhcp_size(xmit), 0, + if(sendto(s, xmit, dhcp_size_for_send(xmit), 0, (struct sockaddr *)&broadcast_addr, sizeof(broadcast_addr)) < 0) { *pstate = DHCPSTATE_FAILED; break; @@ -621,7 +659,7 @@ do_dhcp(const char *intf, struct bootp * diag_printf( "---------DHCPSTATE_REQUESTING sending:\n" ); show_bootp( intf, xmit ); #endif - if(sendto(s, xmit, dhcp_size(xmit), 0, + if(sendto(s, xmit, dhcp_size_for_send(xmit), 0, (struct sockaddr *)&broadcast_addr, sizeof(broadcast_addr)) < 0) { *pstate = DHCPSTATE_FAILED; break; @@ -746,7 +784,7 @@ do_dhcp(const char *intf, struct bootp * show_bootp( intf, xmit ); #endif - if(sendto(s, xmit, dhcp_size(xmit), 0, + if(sendto(s, xmit, dhcp_size_for_send(xmit), 0, // UNICAST address of the server: (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { @@ -837,7 +875,7 @@ do_dhcp(const char *intf, struct bootp * diag_printf( "---------DHCPSTATE_REBINDING sending:\n" ); show_bootp( intf, xmit ); #endif - if(sendto(s, xmit, dhcp_size(xmit), 0, + if(sendto(s, xmit, dhcp_size_for_send(xmit), 0, (struct sockaddr *)&broadcast_addr, sizeof(broadcast_addr)) < 0) { *pstate = DHCPSTATE_FAILED; break; @@ -972,7 +1010,7 @@ do_dhcp(const char *intf, struct bootp * server_addr.sin_port ); show_bootp( intf, xmit ); #endif - if(sendto(s, xmit, dhcp_size(xmit), 0, + if(sendto(s, xmit, dhcp_size_for_send(xmit), 0, // UNICAST address of the server: (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
--- a/packages/net/tcpip/current/tests/server_test.c +++ b/packages/net/tcpip/current/tests/server_test.c @@ -147,9 +147,11 @@ net_test(cyg_addrword_t param) { diag_printf("Start SERVER test\n"); init_all_network_interfaces(); +#ifdef CYGHWR_NET_DRIVER_ETH0 if (eth0_up) { server_test(ð0_bootp_data); } +#endif cyg_test_exit(); }
--- a/packages/pkgconf/rules.mak +++ b/packages/pkgconf/rules.mak @@ -40,6 +40,9 @@ #####DESCRIPTIONEND#### #============================================================================= +# FIXME: This definition belongs in the top-level makefile. +export HOST_CC := gcc + .PHONY: default build clean tests headers mlt_headers # include any dependency rules generated previously @@ -137,7 +140,7 @@ TESTS := $(TESTS:.c=) TESTS := $(TESTS:.S=) tests.stamp: $(foreach target,$(TESTS),$(target).d $(PREFIX)/tests/$(PACKAGE)/$(target)$(EXEEXT)) ifneq ($(strip $(TESTS)),) - @cat $(TESTS:=.d) > $(@:.stamp=.deps) + @cat $(TESTS:%=%.d) > $(@:.stamp=.deps) endif @touch $@
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,27 @@ +2001-11-15 Jesper Skov <jskov@redhat.com> + + * include/redboot.h: Added load_address and load_address_end + variables to hold bounds of a loaded image. + * src/load.c: Fill load_address and load_address_end after srec + and binary loads. + * src/flash.c: Same. + * src/main.c (do_go): removed unneeded cast. + +2001-11-14 Gary Thomas <gthomas@redhat.com> + + * src/io.c (_rb_gets_preloaded): More correct timeout handling. + n.b. in practice, this changes nothing, but it is more "correct". + +2001-11-05 Gary Thomas <gthomas@redhat.com> + + * src/load.c: Minor typo in help string. + + * src/io.c (_rb_gets_preloaded): Clear buffer if ^C. + +2001-11-02 Jesper Skov <jskov@redhat.com> + + * src/flash.c (fis_init): Fix warning. + 2001-11-01 Jesper Skov <jskov@redhat.com> * src/flash.c (fis_init): tweaks to the SIB protection code.
--- a/packages/redboot/current/include/redboot.h +++ b/packages/redboot/current/include/redboot.h @@ -75,7 +75,12 @@ EXTERN unsigned char *ram_start, *ram_en EXTERN unsigned char *user_ram_start, *user_ram_end; EXTERN unsigned char *workspace_start, *workspace_end; EXTERN unsigned long workspace_size; -EXTERN unsigned long *entry_address; + +// Data squirreled away after a load operation +EXTERN unsigned long entry_address; +EXTERN unsigned long load_address; +EXTERN unsigned long load_address_end; + #ifdef CYGPKG_REDBOOT_ANY_CONSOLE EXTERN bool console_selected;
--- a/packages/redboot/current/src/flash.c +++ b/packages/redboot/current/src/flash.c @@ -296,7 +296,7 @@ fis_init(int argc, char *argv[]) footer_p->blockBase = (char*)_ADDR_REDBOOT_TO_ARM(flash_start); footer_p->blockBase += CYGNUM_REDBOOT_FLASH_RESERVED_BASE + redboot_image_size; #else - footer_p->blockBase = _ADDR_REDBOOT_TO_ARM(fis_work_block); + footer_p->blockBase = (char*)_ADDR_REDBOOT_TO_ARM(fis_work_block); #endif footer_p->infoBase = NULL; footer_p->signature = FLASH_FOOTER_SIGNATURE; @@ -890,12 +890,20 @@ fis_load(int argc, char *argv[]) diag_printf("Image loaded from %p-%p\n", (unsigned char *)mem_addr, p->out_buf); } + // Set load address/top + load_address = mem_addr; + load_address_end = (unsigned long)p->out_buf; } else // dangling block #endif { memcpy((void *)mem_addr, (void *)img->flash_base, img->data_length); + + // Set load address/top + load_address = mem_addr; + load_address_end = mem_addr + img->data_length; } - entry_address = (unsigned long *)img->entry_point; + entry_address = (unsigned long)img->entry_point; + #ifdef CYGPKG_REDBOOT_FIS_CRC_CHECK cksum = crc32((unsigned char *)mem_addr, img->data_length); if (show_cksum) {
--- a/packages/redboot/current/src/io.c +++ b/packages/redboot/current/src/io.c @@ -290,6 +290,7 @@ int char c; bool res = false; static char last_ch = '\0'; + int _timeout; #if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0 // // Command line history support @@ -322,7 +323,8 @@ int #endif if ((timeout > 0) && (eol == buf)) { #define MIN_TIMEOUT 50 - mon_set_read_char_timeout(timeout > MIN_TIMEOUT ? MIN_TIMEOUT : timeout); + _timeout = timeout > MIN_TIMEOUT ? MIN_TIMEOUT : timeout; + mon_set_read_char_timeout(_timeout); while (timeout > 0) { res = mon_read_char_with_timeout(&c); if (res) { @@ -330,7 +332,7 @@ int do_idle(false); break; } - timeout -= MIN_TIMEOUT; + timeout -= _timeout; } if (res == false) { do_idle(true); @@ -449,6 +451,7 @@ int case CTRL('C'): // ^C // Abort current input diag_printf("^C\n"); + *buf = '\0'; // Nothing useful in buffer return _GETS_CTRLC; case '\n': case '\r':
--- a/packages/redboot/current/src/load.c +++ b/packages/redboot/current/src/load.c @@ -62,7 +62,7 @@ static char usage[] = "[-r] [-v] " " | disk" #endif #if CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS > 1 - "-c <channel_number>" + " -c <channel_number>" #endif "}]\n [-b <base_address>] <file_name>"; @@ -208,11 +208,16 @@ load_srec_image(int (*getc)(void), void case '9': addr = (unsigned char *)_hex2(getc, ('9'-type+2), &sum); offset += ('9'-type+2); - entry_address = (unsigned long *)addr; + entry_address = (unsigned long)addr; if (terminate) (*terminate)(xyzModem_close, getc); if (addr_offset) diag_printf("Address offset = %p\n", (void *)addr_offset); diag_printf("Entry point: %p, address range: %p-%p\n", (void*)entry_address, (void *)lowest_address, (void *)highest_address); + + // Save load base/top + load_address = lowest_address; + load_address_end = highest_address; + return highest_address; default: if (terminate) (*terminate)(xyzModem_abort, getc); @@ -502,6 +507,11 @@ do_load(int argc, char *argv[]) err = 0; end = (unsigned long) mp; } + + // Save load base/top + load_address = base; + load_address_end = end; + if (0 == err) diag_printf("Raw file loaded %p-%p\n", (void *)base, (void *)end); } else {
--- a/packages/redboot/current/src/main.c +++ b/packages/redboot/current/src/main.c @@ -514,7 +514,7 @@ do_go(int argc, char *argv[]) struct option_info opts[1]; char line[8]; - entry = (unsigned long)entry_address; // Default from last 'load' operation + entry = 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"); if (!scan_opts(argc, argv, 1, opts, 1, (void *)&entry, OPTION_ARG_TYPE_NUM, "starting address"))
