Mercurial > flash_v2
changeset 132:0ae0bc38e387 ecos-sw-2000-10-31
Merge from eCos master repository on 2000-10-31-00:30:36-GMT
line wrap: on
line diff
--- a/packages/NEWS +++ b/packages/NEWS @@ -1,3 +1,6 @@ +* FLASH driver added for PowerPC/MBX +* sigsetjmp() and siglongjmp() added +* A choice of getcwd() implementations have been added * SH serial driver cleanup. SCIF driver added. SCI and SCIF drivers are now separate packages. SCIF driver uses full FIFO and can utilize DMA for transmit operations.
--- a/packages/compat/posix/current/ChangeLog +++ b/packages/compat/posix/current/ChangeLog @@ -1,3 +1,7 @@ +2000-10-27 Jesper Skov <jskov@redhat.com> + + * tests/signal2.c (cause_illegal_access): Don't loop forever. + 2000-10-16 Jonathan Larmour <jlarmour@redhat.com> * include/sigsetjmp.h (sigsetjmp): Various fixes to make portable
--- a/packages/compat/posix/current/tests/signal2.c +++ b/packages/compat/posix/current/tests/signal2.c @@ -99,7 +99,7 @@ cause_illegal_access(void) { x = *(volatile int *)(p); p += (CYG_ADDRESS)0x100000; - } while( p != 0 ); + } while( p != &jbuf ); } // cause_unaligned_access()
--- a/packages/devs/eth/powerpc/quicc/current/ChangeLog +++ b/packages/devs/eth/powerpc/quicc/current/ChangeLog @@ -1,3 +1,7 @@ +2000-10-20 Gary Thomas <gthomas@redhat.com> + + * src/if_quicc.c: Changes to compile in stand-alone mode. + 2000-09-01 Hugo Tyson <hmt@cygnus.co.uk> * src/if_quicc.c (quicc_eth_init): Work with new fast net
--- a/packages/devs/eth/powerpc/quicc/current/src/if_quicc.c +++ b/packages/devs/eth/powerpc/quicc/current/src/if_quicc.c @@ -54,14 +54,20 @@ // Ethernet device driver for MPC8xx QUICC +#include <pkgconf/system.h> +#include <pkgconf/devs_eth_powerpc_quicc.h> + +#ifdef CYGPKG_NET #include <pkgconf/net.h> -#include <pkgconf/devs_eth_powerpc_quicc.h> +#endif #include <cyg/infra/cyg_type.h> +#include <cyg/infra/diag.h> + #include <cyg/hal/hal_arch.h> -#include <cyg/infra/diag.h> +#include <cyg/hal/hal_cache.h> +#include <cyg/hal/hal_intr.h> #include <cyg/hal/drv_api.h> -#include <cyg/hal/hal_cache.h> #include <netdev.h> #include <eth_drv.h> @@ -94,12 +100,12 @@ NETDEVTAB_ENTRY(quicc_netdev, quicc_eth_init, &quicc_eth0_sc); +extern int _mbx_fetch_VPD(int, void *, int); + static cyg_interrupt quicc_eth_interrupt; static cyg_handle_t quicc_eth_interrupt_handle; static void quicc_eth_int(struct eth_drv_sc *data); -extern int _mbx_fetch_VPD(int, void *, int); - // This ISR is called when the ethernet interrupt occurs static int quicc_eth_isr(cyg_vector_t vector, cyg_addrword_t data, HAL_SavedRegisters *regs) @@ -164,7 +170,7 @@ quicc_eth_init(struct cyg_netdevtab_entr // Shut down ethernet, in case it is already running scc->scc_gsmr_l &= ~(QUICC_SCC_GSML_ENR | QUICC_SCC_GSML_ENT); - bzero((void *)enet_pram, sizeof(*enet_pram)); + memset((void *)enet_pram, 0, sizeof(*enet_pram)); TxBD = 0x2C00; // FIXME RxBD = TxBD + CYGNUM_DEVS_ETH_POWERPC_QUICC_TxNUM * sizeof(struct cp_bufdesc); @@ -395,7 +401,11 @@ quicc_eth_send(struct eth_drv_sc *sc, st txbd++; } if (txbd == txfirst) { +#ifdef CYGPKG_NET panic ("No free xmit buffers"); +#else + printf("QUICC Ethernet: No free xmit buffers\n"); +#endif } } // Remember the next buffer to try @@ -410,7 +420,7 @@ quicc_eth_send(struct eth_drv_sc *sc, st txbd->length = total_len; bp = txbd->buffer; for (i = 0; i < sg_len; i++) { - bcopy((void *)sg_list[i].buf, (void *)bp, sg_list[i].len); + memcpy((void *)bp, (void *)sg_list[i].buf, sg_list[i].len); bp += sg_list[i].len; } // Note: the MBX860 does not seem to snoop/invalidate the data cache properly! @@ -471,7 +481,7 @@ quicc_eth_recv(struct eth_drv_sc *sc, st } for (i = 0; i < sg_len; i++) { if (sg_list[i].buf != 0) { - bcopy(bp, (void *)sg_list[i].buf, sg_list[i].len); + memcpy((void *)sg_list[i].buf, bp, sg_list[i].len); bp += sg_list[i].len; } }
--- a/packages/devs/flash/arm/assabet/current/ChangeLog +++ b/packages/devs/flash/arm/assabet/current/ChangeLog @@ -1,3 +1,10 @@ +2000-10-24 Gary Thomas <gthomas@redhat.com> + + * src/flash_unlock_block.c (flash_unlock_block): + * src/flash_lock_block.c (flash_lock_block): + * src/flash_program_buf.c (flash_program_buf): + * src/flash_erase_block.c (flash_erase_block): Support up to 32M FLASH. + 2000-09-10 Gary Thomas <gthomas@redhat.com> * src/flash_unlock_block.c:
--- a/packages/devs/flash/arm/assabet/current/src/flash_erase_block.c +++ b/packages/devs/flash/arm/assabet/current/src/flash_erase_block.c @@ -66,7 +66,7 @@ int flash_erase_block(volatile unsigned HAL_DCACHE_DISABLE(); } - ROM = (volatile unsigned long *)((unsigned long)block & 0xFF800000); + ROM = (volatile unsigned long *)((unsigned long)block & 0xFE000000); // Clear any error conditions ROM[0] = FLASH_Clear_Status;
--- a/packages/devs/flash/arm/assabet/current/src/flash_lock_block.c +++ b/packages/devs/flash/arm/assabet/current/src/flash_lock_block.c @@ -58,7 +58,7 @@ flash_lock_block(volatile unsigned long int timeout = 5000000; int cache_on; - ROM = (volatile unsigned long *)((unsigned long)block & 0xFF800000); + ROM = (volatile unsigned long *)((unsigned long)block & 0xFE000000); HAL_DCACHE_IS_ENABLED(cache_on); if (cache_on) {
--- a/packages/devs/flash/arm/assabet/current/src/flash_program_buf.c +++ b/packages/devs/flash/arm/assabet/current/src/flash_program_buf.c @@ -66,7 +66,7 @@ flash_program_buf(volatile unsigned long HAL_DCACHE_DISABLE(); } - ROM = (volatile unsigned long *)((unsigned long)addr & 0xFF800000); + ROM = (volatile unsigned long *)((unsigned long)addr & 0xFE000000); // Clear any error conditions ROM[0] = FLASH_Clear_Status;
--- a/packages/devs/flash/arm/assabet/current/src/flash_unlock_block.c +++ b/packages/devs/flash/arm/assabet/current/src/flash_unlock_block.c @@ -75,7 +75,7 @@ flash_unlock_block(volatile unsigned lon HAL_DCACHE_DISABLE(); } - ROM = (volatile unsigned long *)((unsigned long)block & 0xFF800000); + ROM = (volatile unsigned long *)((unsigned long)block & 0xFE000000); // Clear any error conditions ROM[0] = FLASH_Clear_Status;
--- a/packages/devs/serial/mips/vrc4373/current/src/vrc4373_serial.c +++ b/packages/devs/serial/mips/vrc4373/current/src/vrc4373_serial.c @@ -473,7 +473,7 @@ vrc4373_serial_DSR(cyg_vector_t vector, chan = vrc4373_chans[0]; // Hardware channel A vrc4373_int(chan, stat>>3); // Handle interrupt } else if (stat & (RR3_BExt | RR3_BTxIP | RR3_BRxIP)) { - chan = vrc4373_chans[1]; // Hardware channel A + chan = vrc4373_chans[1]; // Hardware channel B vrc4373_int(chan, stat); // Handle interrupt } else { // No more interrupts, all done
--- a/packages/devs/serial/powerpc/quicc/current/ChangeLog +++ b/packages/devs/serial/powerpc/quicc/current/ChangeLog @@ -1,3 +1,8 @@ +2000-10-24 Jonathan Larmour <jlarmour@redhat.com> + + * src/quicc_smc_serial.c (quicc_smc_serial_ISR): Return with + CYG_ISR_HANDLED (reported by Daniel Lind) + 2000-08-01 Jonathan Larmour <jlarmour@redhat.co.uk> * src/quicc_smc_serial.c (quicc_smc_serial_set_config): Now use keys
--- a/packages/devs/serial/powerpc/quicc/current/src/quicc_smc_serial.c +++ b/packages/devs/serial/powerpc/quicc/current/src/quicc_smc_serial.c @@ -613,7 +613,7 @@ quicc_smc_serial_ISR(cyg_vector_t vector serial_channel *chan = (serial_channel *)data; quicc_smc_serial_info *smc_chan = (quicc_smc_serial_info *)chan->dev_priv; cyg_drv_interrupt_mask(smc_chan->int_num); - return CYG_ISR_CALL_DSR; // Cause DSR to be run + return (CYG_ISR_HANDLED|CYG_ISR_CALL_DSR); // Cause DSR to be run } // Serial I/O - high level interrupt handler (DSR)
--- a/packages/ecos.db +++ b/packages/ecos.db @@ -144,6 +144,7 @@ package CYGPKG_DEVS_FLASH_ASSABET { on the Intel StrongARM SA-1110 Assabet platform." } + package CYGPKG_DEVS_FLASH_MBX { alias { "FLASH memory support for Motorola PowerPC/860 MBX" flash_mbx } directory devs/flash/powerpc/mbx @@ -163,6 +164,7 @@ package CYGPKG_IO_SERIAL_ARM_EBSA285 { description "Intel StrongARM/EBSA285 serial device drivers" } + package CYGPKG_IO_SERIAL_ARM_SA11X0 { alias { "Intel StrongARM SA11x0 serial driver" devs_serial_arm_sa11x0 sa11x0_serial_driver } @@ -766,7 +768,6 @@ package CYGPKG_HAL_ARM_SA11X0_BRUTUS { The BRUTUS HAL package provides the support needed to run eCos on a Intel StrongARM SA1110 evaulation board (brutus)." } - package CYGPKG_HAL_ARM_EDB7XXX { alias { "Cirrus Logic development board" hal_arm_edb7xxx arm_edb7xxx_hal } directory hal/arm/edb7xxx @@ -786,6 +787,7 @@ The cma230 HAL package provides the supp CMA230 (ARM7TDMI) or CMA222 (ARM710T) eval board." } + # -------------------------------------------------------------------------- # SH packages package CYGPKG_HAL_SH {
--- a/packages/hal/arm/arch/current/ChangeLog +++ b/packages/hal/arm/arch/current/ChangeLog @@ -1,3 +1,20 @@ +2000-10-27 Mark Salter <msalter@redhat.com> + + * src/arm_stub.c: Removed uneccesary include. + + * src/vectors.S (start): Fix use of registers which may have + been destroyed by an LED macro. + +2000-10-26 Mark Salter <msalter@redhat.com> + + * src/arm_stub.c (__computeSignal): Add hook for platforms to + check for hw watchpoint/breakpoint events. + (__install_breakpoints): Support HAL breakpoint list. + (__clear_breakpoints): Ditto. + + * include/hal_arch.h (HAL_BREAKINST_TYPE): Define. Needed by + hw watchpoint/breakpoint support in stub. + 2000-10-20 Jesper Skov <jskov@redhat.com> * src/hal_misc.c: Update __mem_fault_handler declaration.
--- a/packages/hal/arm/arch/current/include/hal_arch.h +++ b/packages/hal/arm/arch/current/include/hal_arch.h @@ -193,6 +193,7 @@ asm volatile (" .code 16;" # define HAL_BREAKINST HAL_BREAKINST_THUMB # define HAL_BREAKINST_SIZE HAL_BREAKINST_THUMB_SIZE +# define HAL_BREAKINST_TYPE cyg_uint16 #else // __thumb__ #define HAL_BREAKPOINT(_label_) \ @@ -204,6 +205,7 @@ asm volatile (" .globl " #_label_ ";" //#define HAL_BREAKINST {0xFE, 0xDE, 0xFF, 0xE7} #define HAL_BREAKINST HAL_BREAKINST_ARM #define HAL_BREAKINST_SIZE HAL_BREAKINST_ARM_SIZE +#define HAL_BREAKINST_TYPE cyg_uint32 #endif // __thumb__ //--------------------------------------------------------------------------
--- a/packages/hal/arm/arch/current/src/arm_stub.c +++ b/packages/hal/arm/arch/current/src/arm_stub.c @@ -77,6 +77,11 @@ int __computeSignal (unsigned int trap_number) { + // Check to see if we stopped because of a hw watchpoint/breakpoint. +#ifdef HAL_STUB_IS_STOPPED_BY_HARDWARE + if (HAL_STUB_IS_STOPPED_BY_HARDWARE(trap_number)) + return SIGTRAP; +#endif // should also catch CYGNUM_HAL_VECTOR_UNDEF_INSTRUCTION here but we // can't tell the different between a real one and a breakpoint :-( switch (trap_number) { @@ -494,12 +499,17 @@ void __clear_single_step (void) void __install_breakpoints (void) { -// FIXME(); +#if defined(CYGNUM_HAL_BREAKPOINT_LIST_SIZE) && (CYGNUM_HAL_BREAKPOINT_LIST_SIZE > 0) + /* Install the breakpoints in the breakpoint list */ + __install_breakpoint_list(); +#endif } void __clear_breakpoints (void) { -// FIXME(); +#if defined(CYGNUM_HAL_BREAKPOINT_LIST_SIZE) && (CYGNUM_HAL_BREAKPOINT_LIST_SIZE > 0) + __clear_breakpoint_list(); +#endif } /* If the breakpoint we hit is in the breakpoint() instruction, return a
--- a/packages/hal/arm/arch/current/src/vectors.S +++ b/packages/hal/arm/arch/current/src/vectors.S @@ -309,6 +309,8 @@ 10: #if defined(CYG_HAL_STARTUP_ROM) // Set up reset vector + mov r0,#0 + ldr r1,.__exception_handlers ldr r2,[r1,#0x00] // reset vector intstruction str r2,[r0,#0x00] ldr r2,=warm_reset
--- a/packages/hal/arm/edb7xxx/current/ChangeLog +++ b/packages/hal/arm/edb7xxx/current/ChangeLog @@ -1,3 +1,9 @@ +2000-10-26 Jonathan Larmour <jlarmour@redhat.com> + + * misc/edb7211_redboot_ROM.cfg: Ensure CYGSEM_HAL_ROM_MONITOR is + enabled + * misc/edb7212_redboot_ROM.cfg: Ditto + 2000-10-20 Jonathan Larmour <jlarmour@redhat.com> * include/pkgconf/mlt_arm_cl7111_ram.mlt:
--- a/packages/hal/arm/edb7xxx/current/misc/edb7211_redboot_ROM.cfg +++ b/packages/hal/arm/edb7xxx/current/misc/edb7211_redboot_ROM.cfg @@ -15,12 +15,12 @@ cdl_configuration eCos { package -hardware CYGPKG_HAL_ARM_EDB7XXX current ; package -hardware CYGPKG_DEVS_ETH_ARM_EDB7XXX current ; package -hardware CYGPKG_IO_SERIAL_ARM_EDB7XXX current ; + package -hardware CYGPKG_DEVS_FLASH_EDB7XXX current ; package -template CYGPKG_HAL current ; package -template CYGPKG_INFRA current ; package -template CYGPKG_REDBOOT current ; package CYGPKG_IO_ETH_DRIVERS current ; package CYGPKG_IO_FLASH current ; - package CYGPKG_DEVS_FLASH_EDB7XXX current ; }; cdl_option CYGBLD_BUILD_GDB_STUBS { @@ -31,14 +31,26 @@ cdl_option CYGDBG_HAL_COMMON_INTERRUPTS_ 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 }; @@ -55,7 +67,7 @@ cdl_option CYGHWR_HAL_ARM_EDB7XXX_PROCES user_value 73728 }; -cdl_option CYGBLD_BUILD_REDBOOT { +cdl_component CYGBLD_BUILD_REDBOOT { user_value 1 };
--- a/packages/hal/arm/edb7xxx/current/misc/edb7212_redboot_ROM.cfg +++ b/packages/hal/arm/edb7xxx/current/misc/edb7212_redboot_ROM.cfg @@ -15,12 +15,12 @@ cdl_configuration eCos { package -hardware CYGPKG_HAL_ARM_EDB7XXX current ; package -hardware CYGPKG_DEVS_ETH_ARM_EDB7XXX current ; package -hardware CYGPKG_IO_SERIAL_ARM_EDB7XXX current ; + package -hardware CYGPKG_DEVS_FLASH_EDB7XXX current ; package -template CYGPKG_HAL current ; package -template CYGPKG_INFRA current ; package -template CYGPKG_REDBOOT current ; package CYGPKG_IO_ETH_DRIVERS current ; package CYGPKG_IO_FLASH current ; - package CYGPKG_DEVS_FLASH_EDB7XXX current ; }; cdl_option CYGBLD_BUILD_GDB_STUBS { @@ -31,14 +31,26 @@ cdl_option CYGDBG_HAL_COMMON_INTERRUPTS_ 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 }; @@ -55,7 +67,7 @@ cdl_option CYGHWR_HAL_ARM_EDB7XXX_PROCES user_value 73728 }; -cdl_option CYGBLD_BUILD_REDBOOT { +cdl_component CYGBLD_BUILD_REDBOOT { user_value 1 };
--- a/packages/hal/arm/sa11x0/var/current/ChangeLog +++ b/packages/hal/arm/sa11x0/var/current/ChangeLog @@ -1,3 +1,9 @@ +2000-10-25 Drew Moseley <dmoseley@redhat.com> + + * src/hal_diag.c: Added UART1 support for SA1100 targets. + + * include/hal_sa11x0.h: Added GPIO bit definitions. + 2000-07-14 Gary Thomas <gthomas@redhat.com> * include/hal_diag.h (HAL_DELAY_US): Define.
--- a/packages/hal/arm/sa11x0/var/current/include/hal_sa11x0.h +++ b/packages/hal/arm/sa11x0/var/current/include/hal_sa11x0.h @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 2000-04-04 // Purpose: Platform register definitions // Description: @@ -664,34 +664,34 @@ /* * SA-1100 GPIO Register Definitions */ -#define SA11X0_GPIO_PIN_0 BIT0 -#define SA11X0_GPIO_PIN_1 BIT1 -#define SA11X0_GPIO_PIN_2 BIT2 -#define SA11X0_GPIO_PIN_3 BIT3 -#define SA11X0_GPIO_PIN_4 BIT4 -#define SA11X0_GPIO_PIN_5 BIT5 -#define SA11X0_GPIO_PIN_6 BIT6 -#define SA11X0_GPIO_PIN_7 BIT7 -#define SA11X0_GPIO_PIN_8 BIT8 -#define SA11X0_GPIO_PIN_9 BIT9 -#define SA11X0_GPIO_PIN_10 BIT10 -#define SA11X0_GPIO_PIN_11 BIT11 -#define SA11X0_GPIO_PIN_12 BIT12 -#define SA11X0_GPIO_PIN_13 BIT13 -#define SA11X0_GPIO_PIN_14 BIT14 -#define SA11X0_GPIO_PIN_15 BIT15 -#define SA11X0_GPIO_PIN_16 BIT16 -#define SA11X0_GPIO_PIN_17 BIT17 -#define SA11X0_GPIO_PIN_18 BIT18 -#define SA11X0_GPIO_PIN_19 BIT19 -#define SA11X0_GPIO_PIN_20 BIT20 -#define SA11X0_GPIO_PIN_21 BIT21 -#define SA11X0_GPIO_PIN_22 BIT22 -#define SA11X0_GPIO_PIN_23 BIT23 -#define SA11X0_GPIO_PIN_24 BIT24 -#define SA11X0_GPIO_PIN_25 BIT25 -#define SA11X0_GPIO_PIN_26 BIT26 -#define SA11X0_GPIO_PIN_27 BIT27 +#define SA11X0_GPIO_PIN_0 (1 << 0) +#define SA11X0_GPIO_PIN_1 (1 << 1) +#define SA11X0_GPIO_PIN_2 (1 << 2) +#define SA11X0_GPIO_PIN_3 (1 << 3) +#define SA11X0_GPIO_PIN_4 (1 << 4) +#define SA11X0_GPIO_PIN_5 (1 << 5) +#define SA11X0_GPIO_PIN_6 (1 << 6) +#define SA11X0_GPIO_PIN_7 (1 << 7) +#define SA11X0_GPIO_PIN_8 (1 << 8) +#define SA11X0_GPIO_PIN_9 (1 << 9) +#define SA11X0_GPIO_PIN_10 (1 << 10) +#define SA11X0_GPIO_PIN_11 (1 << 11) +#define SA11X0_GPIO_PIN_12 (1 << 12) +#define SA11X0_GPIO_PIN_13 (1 << 13) +#define SA11X0_GPIO_PIN_14 (1 << 14) +#define SA11X0_GPIO_PIN_15 (1 << 15) +#define SA11X0_GPIO_PIN_16 (1 << 16) +#define SA11X0_GPIO_PIN_17 (1 << 17) +#define SA11X0_GPIO_PIN_18 (1 << 18) +#define SA11X0_GPIO_PIN_19 (1 << 19) +#define SA11X0_GPIO_PIN_20 (1 << 20) +#define SA11X0_GPIO_PIN_21 (1 << 21) +#define SA11X0_GPIO_PIN_22 (1 << 22) +#define SA11X0_GPIO_PIN_23 (1 << 23) +#define SA11X0_GPIO_PIN_24 (1 << 24) +#define SA11X0_GPIO_PIN_25 (1 << 25) +#define SA11X0_GPIO_PIN_26 (1 << 26) +#define SA11X0_GPIO_PIN_27 (1 << 27) #define SA11X0_GPIO_PIN_LEVEL SA11X0_REGISTER(0x10040000) #define SA11X0_GPIO_PIN_DIRECTION SA11X0_REGISTER(0x10040004)
--- a/packages/hal/arm/sa11x0/var/current/src/hal_diag.c +++ b/packages/hal/arm/sa11x0/var/current/src/hal_diag.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors:nickg, gthomas +// Contributors:nickg, gthomas, dmoseley // Travis C. Furrer <furrer@mit.edu> // Date: 2000-05-08 // Purpose: HAL diagnostic output @@ -94,19 +94,22 @@ init_channel(channel_data_t* __ch_data) base->utsr0 = SA11X0_UART_RX_IDLE | SA11X0_UART_RX_BEGIN_OF_BREAK | SA11X0_UART_RX_END_OF_BREAK; -#if 0 // later - if (SA11X0_UART1_BASE == __ch_data) { + if (SA11X0_UART1_BASE == (volatile unsigned long *)base) { + cyg_uint32 pdr, afr, par; + + HAL_READ_UINT32(SA11X0_GPIO_PIN_DIRECTION, pdr); + HAL_READ_UINT32(SA11X0_GPIO_ALTERNATE_FUNCTION, afr); + HAL_READ_UINT32(SA11X0_PPC_PIN_ASSIGNMENT, par); //Set pin 14 as an output (Tx) and pin 15 as in input (Rx). - base->gpdr = (*SA11X0_REG_GPDR | SA11X0_GPIO_14) & ~SA11X0_GPIO_15; + HAL_WRITE_UINT32(SA11X0_GPIO_PIN_DIRECTION, ((pdr | SA11X0_GPIO_PIN_14) & ~SA11X0_GPIO_PIN_15)); // Use GPIO 14 & 15 pins for serial port 1. - base->gafr |= SA11X0_GPIO_14 | SA11X0_GPIO_15; + HAL_WRITE_UINT32(SA11X0_GPIO_ALTERNATE_FUNCTION, afr | SA11X0_GPIO_PIN_14 | SA11X0_GPIO_PIN_15); // Pin reassignment for serial port 1. - base->ppar |= SA11X0_UART_PIN_REASSIGNMENT_MASK; + HAL_WRITE_UINT32(SA11X0_PPC_PIN_ASSIGNMENT, par | SA11X0_PPC_UART_PIN_REASSIGNMENT_MASK); } -#endif // Set UART to 8N1 (8 data bits, no partity, 1 stop bit) base->utcr0 = SA11X0_UART_PARITY_DISABLED | SA11X0_UART_STOP_BITS_1 |
--- a/packages/hal/common/current/ChangeLog +++ b/packages/hal/common/current/ChangeLog @@ -1,3 +1,24 @@ +2000-10-27 Mark Salter <msalter@redhat.com> + + * src/generic-stub.c: Fixed preprocessor warning. + +2000-10-27 Gary Thomas <gthomas@redhat.com> + + * src/generic-stub.c (__process_packet): Remove warnings when + hardware breakpoint support (Z packet) not enabled. + +2000-10-26 Mark Salter <msalter@redhat.com> + + * src/generic-stub.c (__process_packet): Add Z packet support. + + * src/bplist-dynamic.c: Include <pkgconf/hal.h> to pick up + CYGNUM_HAL_BREAKPOINT_LIST_SIZE. + +2000-10-24 Jesper Skov <jskov@redhat.com> + + * src/generic-stub.c (__process_packet): Disable buffer size + z-packet. + 2000-10-23 Jesper Skov <jskov@redhat.com> * src/hal_stub.c: Made __mem_fault_handler pointer volatile.
--- a/packages/hal/common/current/src/bplist-dynamic.c +++ b/packages/hal/common/current/src/bplist-dynamic.c @@ -44,7 +44,7 @@ //========================================================================= #include <pkgconf/system.h> -#include CYGBLD_HAL_PLATFORM_H +#include <pkgconf/hal.h> #if defined(CYGNUM_HAL_BREAKPOINT_LIST_SIZE) && (CYGNUM_HAL_BREAKPOINT_LIST_SIZE > 0) && defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
--- a/packages/hal/common/current/src/generic-stub.c +++ b/packages/hal/common/current/src/generic-stub.c @@ -992,8 +992,11 @@ int __process_packet (char *packet) { int is_binary = 0; +#if defined(CYGNUM_HAL_BREAKPOINT_LIST_SIZE) + int is_Z = 0; +#endif + remcomOutBuffer[0] = 0; - switch (packet[0]) { case '?': @@ -1008,6 +1011,7 @@ int #ifdef __ECOS__ #if !defined(CYG_HAL_STARTUP_RAM) // Only for ROM based stubs +#if 0 // Disable to avoid conflict with stub-breakpoint z/Z-packets case 'z': /* report IO buffer sizes so download can achieve optimal download speed */ @@ -1017,6 +1021,7 @@ int remcomOutBuffer[i] = 0; break; } +#endif case 'd': /* toggle debug flag */ strcpy(remcomOutBuffer, "eCos GDB stubs" @@ -1304,6 +1309,79 @@ int __set_baud_rate (baudrate); break; } + +#if defined(CYGNUM_HAL_BREAKPOINT_LIST_SIZE) && (CYGNUM_HAL_BREAKPOINT_LIST_SIZE > 0) + case 'Z': + is_Z = 1; + case 'z': + { + char *ptr = &packet[1]; + target_register_t ztype, addr, length; + int err; + + if (__hexToInt (&ptr, &ztype) && *(ptr++) == ',') + { + if (__hexToInt (&ptr, &addr)) + { + if (*(ptr++) == ',') + { + /* When there is a comma, there must be a length */ + if (!__hexToInt (&ptr, &length)) + { + strcpy (remcomOutBuffer, "E02"); + break; + } + } + else + length = 0; + + switch (ztype) + { + case 0: + /* sw breakpoint */ + if (is_Z) + err = __set_breakpoint(addr); + else + err = __remove_breakpoint(addr); + if (!err) + strcpy (remcomOutBuffer, "OK"); + else + strcpy (remcomOutBuffer, "E02"); + break; +#ifdef HAL_STUB_HW_BREAKPOINT + case 1: + /* hw breakpoint */ + if (!HAL_STUB_HW_BREAKPOINT(is_Z, (void *)addr, length)) + strcpy (remcomOutBuffer, "OK"); + else + strcpy (remcomOutBuffer, "E02"); + break; +#endif +#ifdef HAL_STUB_HW_WATCHPOINT + case 2: + case 3: + case 4: + { + /* hw watchpoint */ + if (!HAL_STUB_HW_WATCHPOINT(is_Z, (void *)addr, length, ztype)) + strcpy (remcomOutBuffer, "OK"); + else + strcpy (remcomOutBuffer, "E02"); + } + break; + + // FIXME !!Test only!! + case 5: + addr = (target_register_t)HAL_STUB_HW_STOPPED_DATA_ADDRESS(); + __mem2hex ((char *)&addr, remcomOutBuffer, sizeof(target_register_t), 0); + break; +#endif + } + } + } + break; + } +#endif // Z packet support default: __process_target_packet (packet, remcomOutBuffer, 300); break;
--- a/packages/hal/powerpc/arch/current/ChangeLog +++ b/packages/hal/powerpc/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2000-10-24 Jonathan Larmour <jlarmour@redhat.com> + + * src/powerpc.ld: Match multiple sections where relevant (.bss*, + .sbss*, .sdata*, etc.) + 2000-10-20 Jesper Skov <jskov@redhat.com> * src/hal_misc.c: Update __mem_fault_handler declaration.
--- a/packages/hal/powerpc/arch/current/src/powerpc.ld +++ b/packages/hal/powerpc/arch/current/src/powerpc.ld @@ -73,7 +73,7 @@ GROUP(libtarget.a libgcc.a) #define SECTION_rodata1(_region_, _vma_, _lma_) \ .rodata1 _vma_ : _lma_ \ - { FORCE_OUTPUT; *(.rodata1) } \ + { FORCE_OUTPUT; *(.rodata1*) } \ > _region_ #define SECTION_rodata(_region_, _vma_, _lma_) \ @@ -111,8 +111,8 @@ GROUP(libtarget.a libgcc.a) /* We want the small data sections together, so single-instruction */ \ /* offsets can access them all, and initialized data all before */ \ /* uninitialized, so we can shorten the on-disk segment size. */ \ - __SDATA_START__ = ABSOLUTE(.); *(.sdata) \ - __SDATA2_START__ = ABSOLUTE(.); *(.sdata2) } \ + __SDATA_START__ = ABSOLUTE(.); *(.sdata*) \ + __SDATA2_START__ = ABSOLUTE(.); *(.sdata2*) } \ > _region_ \ __rom_data_start = LOADADDR(.data); \ __ram_data_end = .; PROVIDE(__ram_data_end = .); \ @@ -121,16 +121,16 @@ GROUP(libtarget.a libgcc.a) #define SECTION_sbss(_region_, _vma_, _lma_) \ .sbss _vma_ : _lma_ \ { __sbss_start = ABSOLUTE (.); \ - __SBSS_START__ = ABSOLUTE(.); *(.sbss) __SBSS_END__ = ABSOLUTE(.); \ - __SBSS2_START__ = ABSOLUTE(.); *(.sbss2) __SBSS2_END__ = ABSOLUTE(.); \ - *(.scommon) \ + __SBSS_START__ = ABSOLUTE(.); *(.sbss*) __SBSS_END__ = ABSOLUTE(.); \ + __SBSS2_START__ = ABSOLUTE(.); *(.sbss2*) __SBSS2_END__ = ABSOLUTE(.);\ + *(.scommon*) \ __sbss_end = ABSOLUTE (.); } \ > _region_ #define SECTION_bss(_region_, _vma_, _lma_) \ .bss _vma_ : _lma_ \ { __bss_start = ABSOLUTE (.); \ - FORCE_OUTPUT; *(.dynbss) *(.bss) *(COMMON) \ + FORCE_OUTPUT; *(.dynbss*) *(.bss*) *(COMMON) \ __bss_end = ABSOLUTE (.); } \ > _region_
--- a/packages/hal/sh/arch/current/ChangeLog +++ b/packages/hal/sh/arch/current/ChangeLog @@ -1,3 +1,7 @@ +2000-10-24 Jesper Skov <jskov@redhat.com> + + * src/vectors.S (hal_hw_init): Added errata comment. + 2000-10-23 Jesper Skov <jskov@redhat.com> * src/hal_misc.c: Always include hal_intr.h
--- a/packages/hal/sh/arch/current/src/vectors.S +++ b/packages/hal/sh/arch/current/src/vectors.S @@ -782,6 +782,9 @@ hal_hw_init: # Call platform specific hardware initialization # This may include memory controller initialization. It is not # safe to access RAM until after this point. + # Note that caches must not be enabled until after this point, + # since we may be fiddling the FRQCR which cannot be safely done + # by code in burst/cachable memory (errata SH7-184e). hal_hardware_init # Now copy necessary bits to RAM and jump to the VMA base
--- a/packages/io/eth/current/ChangeLog +++ b/packages/io/eth/current/ChangeLog @@ -1,3 +1,7 @@ +2000-10-30 Gary Thomas <gthomas@redhat.com> + + * include/eth_drv.h: Fix compile error in stand-alone mode. + 2000-10-17 Hugo Tyson <hmt@redhat.com> 2000-10-10 Andrew Lunn <Andrew.Lunn@ascom.ch> * cdl/eth_drivers.cdl: Add configury to disable the warnings about
--- a/packages/io/eth/current/include/eth_drv.h +++ b/packages/io/eth/current/include/eth_drv.h @@ -77,6 +77,9 @@ #include <net/bpf.h> #include <net/bpfdesc.h> #endif + +#else // !CYGPKG_NET +#include <cyg/hal/drv_api.h> #endif struct eth_drv_sg {
--- a/packages/kernel/current/ChangeLog +++ b/packages/kernel/current/ChangeLog @@ -1,3 +1,27 @@ +2000-10-30 Jesper Skov <jskov@redhat.com> + + * cdl/synch.cdl: Replaced CYGINT_KERNEL_SCHEDULER_CAN_YIELD with + CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES. + * cdl/scheduler.cdl: + CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL requires + CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES. + + * tests/thread2.cxx: Use new option. + * tests/klock.c: Same. + * src/common/thread.cxx: Same. + * src/common/clock.cxx: Same. + + * include/bitmap.hxx: Leave unique priority setting to CDL. + * include/mlqueue.hxx: Same. + * include/sched.hxx: Let CDL do sanity check of config. + +2000-10-27 Jesper Skov <jskov@redhat.com> + + * cdl/scheduler.cdl: Added CYGINT_KERNEL_SCHEDULER_CAN_YIELD + + * tests/klock.c: Avoid use of disabled features. Require scheduler + that can yield. + 2000-10-20 Jonathan Larmour <jlarmour@redhat.com> * tests/bin_sem0.cxx:
--- a/packages/kernel/current/cdl/scheduler.cdl +++ b/packages/kernel/current/cdl/scheduler.cdl @@ -46,6 +46,14 @@ cdl_interface CYGINT_KERNEL_SCHEDULER { requires 1 == CYGINT_KERNEL_SCHEDULER } +cdl_interface CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES { + display "Non-zero if the active schedule only has unique priorities" + description " + Not all schedulers allow mutiple threads to use the same + priority. That property is signalled via this option, allowing + scheduler and tests to behave accordingly." +} + # FIXME: The two below options must be mutually exclusive cdl_option CYGSEM_KERNEL_SCHED_MLQUEUE { display "Multi-level queue scheduler" @@ -63,6 +71,7 @@ cdl_option CYGSEM_KERNEL_SCHED_BITMAP { display "Bitmap scheduler" default_value 0 implements CYGINT_KERNEL_SCHEDULER + implements CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES description " The bitmap scheduler supports multiple priority levels but only one thread can exist at each priority level. This means
--- a/packages/kernel/current/cdl/synch.cdl +++ b/packages/kernel/current/cdl/synch.cdl @@ -47,6 +47,7 @@ cdl_component CYGSEM_KERNEL_SYNCH_MUTEX_ legal_values { "SIMPLE" } default_value { "SIMPLE" } active_if { CYGSEM_KERNEL_SCHED_MLQUEUE } + requires { CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES == 0 } description " This component controls the protocols used to protect mutexes against priority inversion. If this option is enabled it defines which
--- a/packages/kernel/current/include/bitmap.hxx +++ b/packages/kernel/current/include/bitmap.hxx @@ -73,7 +73,6 @@ typedef cyg_ucount32 cyg_sched_bitmap; // Customize the scheduler #define CYGIMP_THREAD_PRIORITY 1 -#define CYG_SCHED_UNIQUE_PRIORITIES 1 #define CYG_THREAD_MIN_PRIORITY (CYGNUM_KERNEL_SCHED_BITMAP_SIZE-1) #define CYG_THREAD_MAX_PRIORITY 0
--- a/packages/kernel/current/include/mlqueue.hxx +++ b/packages/kernel/current/include/mlqueue.hxx @@ -82,7 +82,6 @@ typedef cyg_ucount32 cyg_sched_bitmap; // Customize the scheduler #define CYGIMP_THREAD_PRIORITY 1 // Threads have changable priorities -#define CYG_SCHED_UNIQUE_PRIORITIES 0 // Threads don't have unique priorities #define CYG_THREAD_MIN_PRIORITY (CYGNUM_KERNEL_SCHED_PRIORITIES-1) #define CYG_THREAD_MAX_PRIORITY 0
--- a/packages/kernel/current/include/sched.hxx +++ b/packages/kernel/current/include/sched.hxx @@ -95,9 +95,6 @@ protected: # ifndef CYGIMP_THREAD_PRIORITY # error Priority inversion protocols will not work without priorities!!! # endif -# if CYG_SCHED_UNIQUE_PRIORITIES -# error Priority inversion protocols need non-unique priorities!!! -# endif #endif // -------------------------------------------------------------------------
--- a/packages/kernel/current/src/common/clock.cxx +++ b/packages/kernel/current/src/common/clock.cxx @@ -923,7 +923,7 @@ void Cyg_RealTimeClock::dsr(cyg_vector v rtc->tick( count ); #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE -#if 0 == CYG_SCHED_UNIQUE_PRIORITIES +#if 0 == CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES // If timeslicing is enabled, call the scheduler to // handle it. But not if we have unique priorities.
--- a/packages/kernel/current/src/common/thread.cxx +++ b/packages/kernel/current/src/common/thread.cxx @@ -841,7 +841,7 @@ Cyg_Thread::set_priority( cyg_priority n Cyg_Scheduler::scheduler.deregister_thread(this); -#if CYG_SCHED_UNIQUE_PRIORITIES +#if CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES // Check that there are no other threads at this priority. // If so, leave is as it is. @@ -851,7 +851,7 @@ Cyg_Thread::set_priority( cyg_priority n if( Cyg_Scheduler::scheduler.unique(new_priority) ) priority = new_priority; -#else // !CYG_SCHED_UNIQUE_PRIORITIES +#else // !CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE @@ -874,7 +874,7 @@ Cyg_Thread::set_priority( cyg_priority n #endif -#endif // CYG_SCHED_UNIQUE_PRIORITIES +#endif // CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES Cyg_Scheduler::scheduler.register_thread(this);
--- a/packages/kernel/current/tests/klock.c +++ b/packages/kernel/current/tests/klock.c @@ -1,8 +1,8 @@ /*================================================================= // -// kthread1.c +// klock.c // -// Kernel C API Thread test 1 +// Kernel lock test // //========================================================================== //####COPYRIGHTBEGIN#### @@ -47,6 +47,8 @@ #ifdef CYGFUN_KERNEL_API_C +#if (CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES == 0) + //========================================================================== #include "testaux.h" @@ -83,8 +85,6 @@ volatile static int thread1_state = 0; static void entry0( cyg_addrword_t data ) { - void *mbret; - CHECK( 222 == (int)data ); // Do everything with the scheduler locked. @@ -100,6 +100,7 @@ static void entry0( cyg_addrword_t data cyg_thread_resume(pt1); thread0_state = 2; +#ifdef CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT cyg_cond_wait( &cv ); thread0_state = 3; @@ -107,10 +108,12 @@ static void entry0( cyg_addrword_t data cyg_cond_broadcast( &cv ); thread0_state = 4; +#endif cyg_mutex_unlock( &mx ); thread0_state = 5; + // -------------------------------------------------- // Semaphore test @@ -134,13 +137,18 @@ static void entry0( cyg_addrword_t data // -------------------------------------------------- // Message box test - mbret = cyg_mbox_get( mbh ); - CYG_TEST_CHECK( mbret == (void *)0xAAAAAAAA , "bad result from cyg_mbox_timed_get()"); - thread0_state = 10; +#ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT + { + void *mbret; - cyg_mbox_put( mbh, (void *)0xBBBBBBBB ); - thread0_state = 11; - + mbret = cyg_mbox_get( mbh ); + CYG_TEST_CHECK( mbret == (void *)0xAAAAAAAA , "bad result from cyg_mbox_timed_get()"); + thread0_state = 10; + + cyg_mbox_put( mbh, (void *)0xBBBBBBBB ); + thread0_state = 11; + } +#endif // -------------------------------------------------- thread0_state = 999; @@ -151,7 +159,7 @@ static void entry0( cyg_addrword_t data CYG_TEST_CHECK( thread0_state == 999, "thread 0 not in exit state"); CYG_TEST_CHECK( thread1_state == 999, "thread 1 not in exit state"); - CYG_TEST_PASS_FINISH("Kernel C API Thread 1 OK"); + CYG_TEST_PASS_FINISH("Kernel lock test OK"); } //========================================================================== @@ -159,7 +167,6 @@ static void entry0( cyg_addrword_t data static void entry1( cyg_addrword_t data ) { cyg_bool res; - void *mbret; CHECK( 333 == (int)data ); @@ -168,7 +175,7 @@ static void entry1( cyg_addrword_t data // -------------------------------------------------- // Mutex test - +#ifdef CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT cyg_mutex_lock( &mx ); thread1_state = 1; @@ -183,6 +190,7 @@ static void entry1( cyg_addrword_t data cyg_mutex_unlock( &mx ); thread1_state = 4; +#endif // -------------------------------------------------- // Semaphore test @@ -211,14 +219,17 @@ static void entry1( cyg_addrword_t data // -------------------------------------------------- // Message box test - - cyg_mbox_timed_put( mbh, (void *)0xAAAAAAAA, cyg_current_time()+10 ); - thread1_state = 10; +#ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT + { + void *mbret; + cyg_mbox_timed_put( mbh, (void *)0xAAAAAAAA, cyg_current_time()+10 ); + thread1_state = 10; - mbret = cyg_mbox_timed_get( mbh, cyg_current_time()+10); - CYG_TEST_CHECK( mbret == (void *)0xBBBBBBBB , "bad result from cyg_mbox_timed_get()"); - thread1_state = 9; - + mbret = cyg_mbox_timed_get( mbh, cyg_current_time()+10); + CYG_TEST_CHECK( mbret == (void *)0xBBBBBBBB , "bad result from cyg_mbox_timed_get()"); + thread1_state = 9; + } +#endif // -------------------------------------------------- thread1_state = 999; @@ -261,20 +272,22 @@ cyg_start( void ) //========================================================================== -#else /* def CYGFUN_KERNEL_API_C */ +#else /* CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES == 0 */ +# define NA_MSG "Schedule has unique priorities" +#endif -//========================================================================== +#else /* def CYGFUN_KERNEL_API_C */ +# define NA_MSG "Kernel C API layer disabled" +#endif +#ifdef NA_MSG externC void cyg_start( void ) { CYG_TEST_INIT(); - CYG_TEST_NA("Kernel C API layer disabled"); + CYG_TEST_NA(NA_MSG); } +#endif //========================================================================== - -#endif /* def CYGFUN_KERNEL_API_C */ - -//========================================================================== -/* EOF kthread1.c */ +/* EOF klock.c */
--- a/packages/kernel/current/tests/thread2.cxx +++ b/packages/kernel/current/tests/thread2.cxx @@ -40,7 +40,7 @@ // + check highest priority running thread is always running // + check next highest runs when highest suspended // + check several threads of equal priority share time -// (only !CYG_SCHED_UNIQUE_PRIORITIES) +// (only !CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES) // + check other threads are starved // + check setting priority dynamically causes a thread to // become/stay current/non-current @@ -48,7 +48,7 @@ // check yield // check can set threads with min and max priority // Options: -// CYG_SCHED_UNIQUE_PRIORITIES +// CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES // CYGIMP_THREAD_PRIORITY // CYGNUM_KERNEL_SCHED_PRIORITIES // CYGSEM_KERNEL_SCHED_BITMAP @@ -108,7 +108,8 @@ static void entry1( CYG_ADDRWORD data ) CHECK( 6 == thread1->get_priority() ); CHECK( 7 == thread2->get_priority() ); q = 100; -#if !(CYG_SCHED_UNIQUE_PRIORITIES) && defined(CYGSEM_KERNEL_SCHED_TIMESLICE) +#if !(CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES) \ + && defined(CYGSEM_KERNEL_SCHED_TIMESLICE) thread2->set_priority(6); CHECK( 6 == thread1->get_priority() ); CHECK( 6 == thread2->get_priority() ); @@ -136,7 +137,8 @@ static void entry2( CYG_ADDRWORD data ) CHECK( 11 == q++ ); thread2->set_priority(7); -#if !(CYG_SCHED_UNIQUE_PRIORITIES) && defined(CYGSEM_KERNEL_SCHED_TIMESLICE) +#if !(CYGINT_KERNEL_SCHEDULER_UNIQUE_PRIORITIES) \ + && defined(CYGSEM_KERNEL_SCHED_TIMESLICE) CHECK( 6 == thread1->get_priority() ); CHECK( 6 == thread2->get_priority() );
--- a/packages/language/c/libc/stdio/current/ChangeLog +++ b/packages/language/c/libc/stdio/current/ChangeLog @@ -1,3 +1,8 @@ +2000-10-23 Jesper Skov <jskov@redhat.com> + + * include/streambuf.inl: Adjust assertions to cope with buffers + generated by sprintf and similar non-bound-buffer calls. + 2000-08-09 Jonathan Larmour <jlarmour@redhat.co.uk> * include/io.inl: No need to include string.h
--- a/packages/language/c/libc/stdio/current/include/streambuf.inl +++ b/packages/language/c/libc/stdio/current/include/streambuf.inl @@ -61,6 +61,7 @@ #include <stdio.h> // fpos_t and iobuf defines #include <stdlib.h> // free() #include <cyg/libc/stdio/streambuf.hxx> // header for this file, just in case +#include <limits.h> // INT_MAX // FUNCTIONS @@ -129,7 +130,9 @@ Cyg_StdioStreamBuffer::set_bytes_read( c current_buffer_position += bytes; - CYG_ASSERT( (current_buffer_position <= buffer_top), + // INT_MAX is used by some callers to mean infinite. + CYG_ASSERT( (current_buffer_position <= buffer_top) + || (get_buffer_size() == INT_MAX), "read too many bytes from buffer" ); if (current_buffer_position == buffer_max) @@ -154,7 +157,9 @@ Cyg_StdioStreamBuffer::set_bytes_written { buffer_top += bytes; - CYG_ASSERT( (buffer_top <= &buffer_bottom[ get_buffer_size() ]), + // INT_MAX is used by some callers to mean infinite. + CYG_ASSERT( (buffer_top <= &buffer_bottom[ get_buffer_size() ]) + || (get_buffer_size() == INT_MAX), "wrote too many bytes into buffer" ); } // set_bytes_written()
--- a/packages/language/c/libc/time/current/ChangeLog +++ b/packages/language/c/libc/time/current/ChangeLog @@ -1,3 +1,22 @@ +2000-10-30 Jonathan Larmour <jlarmour@redhat.com> + + * include/time.inl: Ensure POSIX *_r functions can be accessed by + non-POSIX implementation even when CYGFUN_LIBC_TIME_POSIX is off. + + * src/asctime_r.cxx: No need to make conditional on posix CDL option - + we may want to define an internal-only function. + * src/ctime_r.cxx: Ditto + * src/gmtime_r.cxx: Ditto + * src/localtime_r.cxx: Ditto + + * cdl/time.cdl: abs() is also a requirement + + * src/clock.cxx (clock): Always use unsigned long longs for temp + variables (and make sure it's used), rather than making + assumptions about clock_t. + + * tests/clock.c: Rewrite + 2000-07-26 Jonathan Larmour <jlarmour@redhat.co.uk> * cdl/time.cdl: Add CYGINT_ISO_DIV dependency
--- a/packages/language/c/libc/time/current/cdl/time.cdl +++ b/packages/language/c/libc/time/current/cdl/time.cdl @@ -54,6 +54,7 @@ cdl_package CYGPKG_LIBC_TIME { "<cyg/libc/time/time.h>" } requires CYGPKG_ISOINFRA requires CYGINT_ISO_DIV + requires CYGINT_ISO_ABS compile asctime.cxx asctime_r.cxx clock.cxx \ ctime.cxx ctime_r.cxx difftime.cxx \
--- a/packages/language/c/libc/time/current/include/time.inl +++ b/packages/language/c/libc/time/current/include/time.inl @@ -238,15 +238,22 @@ cyg_libc_time_setdst( Cyg_libc_time_dst // the string to return into __buf // +#ifdef CYGFUN_LIBC_TIME_POSIX +# define __asctime_r asctime_r +#else +// prototype internal function +__externC char * +__asctime_r( const struct tm *__timeptr, char *__buf ); +#endif + #ifdef CYGIMP_LIBC_TIME_ASCTIME_R_INLINE -#include <stdio.h> // for sprintf() #include <cyg/libc/time/timeutil.h> // for cyg_libc_time_{day,month}_name // and cyg_libc_time_itoa() #include <string.h> // for memcpy() CYGPRI_LIBC_TIME_ASCTIME_R_INLINE char * -asctime_r( const struct tm *__timeptr, char *__buf ) +__asctime_r( const struct tm *__timeptr, char *__buf ) { cyg_uint8 __i; @@ -335,12 +342,20 @@ asctime_r( const struct tm *__timeptr, c // the result in the space occupied by __result // +#ifdef CYGFUN_LIBC_TIME_POSIX +# define __gmtime_r gmtime_r +#else +// prototype internal function +__externC struct tm * +__gmtime_r( const time_t *__timer, struct tm *__result ); +#endif + #ifdef CYGIMP_LIBC_TIME_GMTIME_R_INLINE #include <cyg/libc/time/timeutil.h> // for cyg_libc_time_month_lengths CYGPRI_LIBC_TIME_GMTIME_R_INLINE struct tm * -gmtime_r( const time_t *__timer, struct tm *__result ) +__gmtime_r( const time_t *__timer, struct tm *__result ) { time_t _tim; const cyg_uint8 *_months_p; @@ -452,12 +467,20 @@ gmtime_r( const time_t *__timer, struct // stores the result in the space occupied by __result // +#ifdef CYGFUN_LIBC_TIME_POSIX +# define __localtime_r localtime_r +#else +// prototype internal function +__externC struct tm * +__localtime_r( const time_t *__timer, struct tm *__result ); +#endif + #ifdef CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE #include <cyg/libc/time/timeutil.h> // for cyg_libc_time_normalize_structtm() CYGPRI_LIBC_TIME_LOCALTIME_R_INLINE struct tm * -localtime_r( const time_t *__timer, struct tm *__result ) +__localtime_r( const time_t *__timer, struct tm *__result ) { time_t __stdoffset, __dstoffset; CYG_REPORT_FUNCNAMETYPE("localtime_r", "returning %08x"); @@ -466,7 +489,7 @@ localtime_r( const time_t *__timer, stru CYG_REPORT_FUNCARG2("*__timer=%d, __result is at %08x", *__timer, __result); - gmtime_r(__timer, __result); + __gmtime_r(__timer, __result); // Adjust for STD/DST __result->tm_isdst = cyg_libc_time_getzoneoffsets(&__stdoffset, @@ -498,10 +521,18 @@ localtime_r( const time_t *__timer, stru // to store the returned string // +#ifdef CYGFUN_LIBC_TIME_POSIX +# define __ctime_r ctime_r +#else +// prototype internal function +__externC char * +__ctime_r( const time_t *__timer, char *__buf ); +#endif + #ifdef CYGIMP_LIBC_TIME_CTIME_R_INLINE CYGPRI_LIBC_TIME_CTIME_R_INLINE char * -ctime_r( const time_t *__timer, char *__buf ) +__ctime_r( const time_t *__timer, char *__buf ) { struct tm _mytm; @@ -512,9 +543,9 @@ ctime_r( const time_t *__timer, char *__ CYG_REPORT_FUNCARG2("*__timer = %d, __buf=%08x", *__timer, __buf); - localtime_r( __timer, &_mytm ); + __localtime_r( __timer, &_mytm ); - asctime_r(&_mytm, __buf); + __asctime_r(&_mytm, __buf); CYG_REPORT_RETVAL(__buf); @@ -677,7 +708,7 @@ asctime( const struct tm *__timeptr ) // paranoia CYG_CHECK_DATA_PTR(__timeptr, "__timeptr is not a valid pointer!"); - (void)asctime_r( __timeptr, cyg_libc_time_asctime_buf ); + (void)__asctime_r( __timeptr, cyg_libc_time_asctime_buf ); CYG_REPORT_RETVAL(cyg_libc_time_asctime_buf); @@ -705,7 +736,7 @@ gmtime( const time_t *__timer ) CYG_CHECK_DATA_PTR(__timer, "__timer is not a valid pointer!"); CYG_REPORT_FUNCARG1("*__timer=%d", *__timer); - gmtime_r(__timer, &cyg_libc_time_gmtime_buf); + __gmtime_r(__timer, &cyg_libc_time_gmtime_buf); CYG_REPORT_RETVAL(&cyg_libc_time_gmtime_buf); @@ -733,7 +764,7 @@ localtime( const time_t *__timer ) CYG_CHECK_DATA_PTR(__timer, "__timer is not a valid pointer!"); CYG_REPORT_FUNCARG1("*__timer=%d", *__timer); - localtime_r(__timer, &cyg_libc_time_localtime_buf); + __localtime_r(__timer, &cyg_libc_time_localtime_buf); CYG_REPORT_RETVAL(&cyg_libc_time_localtime_buf);
--- a/packages/language/c/libc/time/current/src/asctime_r.cxx +++ b/packages/language/c/libc/time/current/src/asctime_r.cxx @@ -46,8 +46,6 @@ #include <pkgconf/libc_time.h> // C library configuration -#ifdef CYGFUN_LIBC_TIME_POSIX - // INCLUDES #include <cyg/infra/cyg_type.h> // Common type definitions and support @@ -61,6 +59,4 @@ #include <time.h> // Main date and time definitions -#endif // ifdef CYGFUN_LIBC_TIME_POSIX - // EOF asctime_r.cxx
--- a/packages/language/c/libc/time/current/src/clock.cxx +++ b/packages/language/c/libc/time/current/src/clock.cxx @@ -89,6 +89,7 @@ clock( void ) cyg_tick_count curr_clock; // kernel clock value Cyg_Clock::cyg_resolution resolution; // kernel clock resolution clock_t clocks; + unsigned long long temp; CYG_TRACE0( TL1, "getting clock resolution" ); @@ -103,11 +104,14 @@ clock( void ) CYG_TRACE1( TL1, "got clock value %d", curr_clock ); - // scale the value so that clock()/CLOCKS_PER_SEC works - clock_t - // should be big enough to cope - clocks = ((clock_t)curr_clock * resolution.dividend) / - (resolution.divisor * (1000000000 / CLOCKS_PER_SEC)); - + // scale the value so that clock()/CLOCKS_PER_SEC works + // We use an unsigned long long to avoid overflow as the dividend + // and divisors tend to be huge + temp = (1000000000 / CLOCKS_PER_SEC); + temp *= resolution.divisor; + temp = (unsigned long long)curr_clock * resolution.dividend / temp; + clocks = (clock_t)temp; + CYG_REPORT_RETVAL( clocks ); return clocks;
--- a/packages/language/c/libc/time/current/src/ctime_r.cxx +++ b/packages/language/c/libc/time/current/src/ctime_r.cxx @@ -46,8 +46,6 @@ #include <pkgconf/libc_time.h> // C library configuration -#ifdef CYGFUN_LIBC_TIME_POSIX - // The following lines allow ctime_r() to be included non-inline which // actually defines it as a function here #define CYGPRI_LIBC_TIME_CTIME_R_INLINE @@ -57,6 +55,4 @@ #include <time.h> // Main date and time definitions -#endif // ifdef CYGFUN_LIBC_TIME_POSIX - // EOF ctime_r.cxx
--- a/packages/language/c/libc/time/current/src/gmtime_r.cxx +++ b/packages/language/c/libc/time/current/src/gmtime_r.cxx @@ -46,8 +46,6 @@ #include <pkgconf/libc_time.h> // C library configuration -#ifdef CYGFUN_LIBC_TIME_POSIX - // The following lines allow gmtime_r() to be included non-inline which // actually defines it as a function here #define CYGPRI_LIBC_TIME_GMTIME_R_INLINE @@ -57,6 +55,4 @@ #include <time.h> // Main date and time definitions -#endif // ifdef CYGFUN_LIBC_TIME_POSIX - // EOF gmtime_r.cxx
--- a/packages/language/c/libc/time/current/src/localtime_r.cxx +++ b/packages/language/c/libc/time/current/src/localtime_r.cxx @@ -47,8 +47,6 @@ #include <pkgconf/libc_time.h> // C library configuration -#ifdef CYGFUN_LIBC_TIME_POSIX - // The following lines allow localtime_r() to be included non-inline which // actually defines it as a function here #define CYGPRI_LIBC_TIME_LOCALTIME_R_INLINE @@ -58,6 +56,4 @@ #include <time.h> // Main date and time definitions -#endif // ifdef CYGFUN_LIBC_TIME_POSIX - // EOF localtime_r.cxx
--- a/packages/language/c/libc/time/current/tests/clock.c +++ b/packages/language/c/libc/time/current/tests/clock.c @@ -42,37 +42,37 @@ // CONFIGURATION #include <pkgconf/libc_time.h> // Configuration header +#include <pkgconf/system.h> +#include <pkgconf/isoinfra.h> + +#include <cyg/infra/testcase.h> + +// This test is bound to fail on Linux -- we don't have exclusive access +// to the CPU. + +#if defined(CYGPKG_HAL_I386_LINUX) +# define NA_MSG "Cannot run on synthetic target" +#elif !defined(CYGINT_ISO_MAIN_STARTUP) +# define NA_MSG "Requires main() startup" +#endif + +#ifdef NA_MSG +void +cyg_start(void) +{ + CYG_TEST_NA( NA_MSG ); +} + +#else + // INCLUDES #include <time.h> -#include <cyg/infra/testcase.h> - -#define RUN_TEST 1 - -// This test is bound to fail on Linux -- we don't have exclusive access -// to the CPU. -#if defined(CYGPKG_HAL_I386_LINUX) -#undef RUN_TEST -#define RUN_TEST 0 -#endif - - -// HOW TO START TESTS - -#if RUN_TEST - +#include <cyg/infra/diag.h> #include <cyg/hal/hal_cache.h> #include <cyg/hal/hal_intr.h> -# define START_TEST( test ) test(0) - -#else - -# define START_TEST( test ) CYG_EMPTY_STATEMENT - -#endif - // CONSTANTS @@ -81,13 +81,14 @@ #define MAX_TIMEOUT 1000000 // Percentage error before we declare fail: range 0 - 100 -#define TOLERANCE 40 +#define TOLERANCE 25 + +// Number of samples to take +#define SAMPLES 30 // FUNCTIONS -#if RUN_TEST - static int my_abs(int i) { @@ -95,12 +96,49 @@ my_abs(int i) } // my_abs() -static void -test( CYG_ADDRWORD data ) +// Clock measurement is done in a separate function so that alignment +// constraints are deterministic - some processors may perform better +// in loops that are better aligned, so by making it always the same +// function, this is prevented. +// FIXME: how do we guarantee the compiler won't inline this on -O3? +static unsigned long +clock_loop( const int timeout, clock_t prevclock, clock_t *newclock ) { - unsigned long ctr, ctr2, err; - clock_t clock_init; - clock_t clock_first=0, clock_second=0, clock_third=0; + clock_t c=0; + long i; + + for (i=0; i<timeout; i++) { + c = clock(); + if ( c != prevclock ) + break; // Hit the next clock pulse + } + + if (i==timeout) + CYG_TEST_FAIL_FINISH("No change in clock state!"); + + // it should not overflow in the lifetime of this test + if (c < prevclock) + CYG_TEST_FAIL_FINISH("Clock decremented!"); + + *newclock = c; + + return i; +} // clock_loop() + +// both of these get zeroed out +static unsigned long ctrs[SAMPLES]; +static clock_t clocks[SAMPLES]; + +int +main(int argc, char *argv[]) +{ + unsigned long mean=0, sum=0; + int i; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "clock() function"); // First disable the caches - they may affect the timing loops // below - especially if tracing or assertions are enabled, causing @@ -123,78 +161,59 @@ test( CYG_ADDRWORD data ) // the clock period. Repeat this, and make sure that it the // two timed periods are acceptably close. - err = 101; - clock_init = clock(); + clocks[0] = clock(); - if (clock_init == (clock_t)-1) // unimplemented is just as valid - { - CYG_TEST_PASS_FINISH( "clock() returns -1, meaning unimplemented"); - } // if - - for (ctr = 0; ctr<MAX_TIMEOUT; ctr++) - { - if ((clock_first=clock()) > clock_init) - break; // Hit the next clock pulse - } - if (ctr < MAX_TIMEOUT) + if (clocks[0] == (clock_t)-1) // unimplemented is potentially valid. { - // We hit a clock pulse, rather than a timeout - // Now we are at the beginning of a pulse, so time until the - // next one in order to get a measure of the length. - for (ctr = 0; ctr<MAX_TIMEOUT; ctr++) - { - if ((clock_second=clock()) > clock_first) - break; // Hit the next clock pulse - } // for - if (ctr < MAX_TIMEOUT) - { - // We hit a clock pulse, rather than a timeout. ctr contains - // the number of loops/tick. Measure this again, and see if - // the two results are acceptably close. - for (ctr2 = 0; ctr2<MAX_TIMEOUT; ctr2++) - { - if ((clock_third=clock()) > clock_second) - break; // Hit the next clock pulse - } // for - if (ctr2 < MAX_TIMEOUT) - { - err = (100 * my_abs(ctr-ctr2)) / ctr; - } // if (ctr < MAX_TIMEOUT) - else - { - CYG_TEST_FAIL_FINISH("No change in clock state!"); - } // else (ctr < MAX_TIMEOUT) - } // if (ctr < MAX_TIMEOUT) - else - { - CYG_TEST_FAIL_FINISH("No change in clock state!"); - } // else (ctr < MAX_TIMEOUT) +#ifdef CYGSEM_LIBC_TIME_CLOCK_WORKING + CYG_TEST_FAIL_FINISH( "clock() returns -1, meaning unimplemented"); +#else + CYG_TEST_PASS_FINISH( "clock() returns -1, meaning unimplemented"); +#endif + } // if + + // record clocks in a tight consistent loop to avoid random variations + for (i=1; i<SAMPLES; i++) { + ctrs[i] = clock_loop( MAX_TIMEOUT, clocks[i-1], &clocks[i] ); + } + + for (i=0;i<SAMPLES;i++) { + // output what we got - useful for diagnostics of occasional + // test failures + diag_printf("clocks[%d] = %d, ctrs[%d] = %d\n", i, clocks[i], + i, ctrs[i]); - } // if (ctr < MAX_TIMEOUT) - else - { - CYG_TEST_FAIL_FINISH("No change in clock state!"); - } // else (ctr < MAX_TIMEOUT) - - CYG_TEST_PASS_FAIL(err < TOLERANCE, "clock() stability"); + // Now we work out the error etc. + // We ignore ctrs[0] because it's always 0 + // We ignore ctrs[1] because it will always be odd since it was + // the first measurement taken at the start of the looping, and + // the initial clock measurement (in clocks[0]) was not treated as + // part of the loop and therefore can't be considered to take the same + // time. + if (i>=2) { + sum += ctrs[i]; + } + } - CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " - "clock() function"); -} // test() -#endif + // deduce out the average + mean = sum / (SAMPLES-2); + + // now go through valid results and compare against average + for (i=2;i<SAMPLES;i++) { + unsigned long err; -int -main(int argc, char *argv[]) -{ - CYG_TEST_INIT(); + err = (100 * my_abs(ctrs[i]-mean)) / mean; + if (err > TOLERANCE) { + diag_printf("mean=%d, ctrs[%d]=%d, err=%d\n", mean, i, ctrs[i], + err); + CYG_TEST_FAIL_FINISH("clock() within tolerance"); + } + } - CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " - "clock() function"); - - START_TEST( test ); - - CYG_TEST_NA("Testing is not applicable to this configuration"); + CYG_TEST_PASS_FINISH("clock() stable"); } // main() +#endif // ifndef NA_MSG + // EOF clock.c
--- a/packages/net/tcpip/current/ChangeLog +++ b/packages/net/tcpip/current/ChangeLog @@ -1,3 +1,8 @@ +2000-10-24 Hugo Tyson <hmt@redhat.com> + + * src/lib/tftp_server.c (tftpd_server): Cut down the chatter to + nothing (unless there's an error) if running automated testing. + 2000-10-17 Hugo Tyson <hmt@redhat.com> 2000-10-10 Andrew Lunn <Andrew.Lunn@ascom.ch>
--- a/packages/net/tcpip/current/src/lib/tftp_server.c +++ b/packages/net/tcpip/current/src/lib/tftp_server.c @@ -423,8 +423,10 @@ tftpd_server(cyg_addrword_t p) struct tftphdr *hdr = (struct tftphdr *)data; #ifndef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS +#ifndef CYGPKG_NET_AUTOTEST // cut the chatter if automated testing // Otherwise routine printfs fail the test - interrupts disabled too long. diag_printf("TFTPD [%x]: port %d\n", p, server->port); +#endif // !CYGPKG_NET_AUTOTEST #endif // Set up port @@ -456,7 +458,9 @@ tftpd_server(cyg_addrword_t p) close(s); #ifdef CYGSEM_TFTP_SERVER_MULTITHREADED #ifndef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS +#ifndef CYGPKG_NET_AUTOTEST // cut the chatter if automated testing diag_printf("TFTPD [%x]: waiting to bind to service port\n", p); +#endif // !CYGPKG_NET_AUTOTEST #endif // Wait until the socket is free... cyg_semaphore_wait( &tftp_server_sem ); @@ -481,9 +485,11 @@ tftpd_server(cyg_addrword_t p) diag_printf("TFTPD [%x]: can't read request\n", p); } else { #ifndef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS +#ifndef CYGPKG_NET_AUTOTEST // cut the chatter if automated testing diag_printf("TFTPD [%x]: received %x from %s:%d\n", p, ntohs(hdr->th_opcode), inet_ntoa(from_addr.sin_addr), from_addr.sin_port); +#endif // !CYGPKG_NET_AUTOTEST #endif switch (ntohs(hdr->th_opcode)) { case WRQ:
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,5 +1,58 @@ +2000-10-30 Gary Thomas <gthomas@redhat.com> + + * src/net/udp.c: + * src/net/pktbuf.c: + * src/net/net_io.c: + * src/net/enet.c: + * include/net/net.h: Minor cleanups to remove warnings. + + * cdl/redboot.cdl: Support threads in all but RAM mode. Note: + this should allow thread support in ROM and FLOPPY startup mode. + +2000-10-27 Gary Thomas <gthomas@redhat.com> + + * src/xyzModem.c (xyzModem_stream_open): Add extra delay during + startup - to give the sender time to get started. + + * src/flash.c (fis_load): Add "-c" option to show checksum of + image after loading. + (fis_list): Add "-c" to display stored checksums. + +2000-10-26 Mark Salter <msalter@redhat.com> + + * src/load.c (do_load): Move some local variable declarations + needed by xyzmodem support so they can be used when redboot + networking not enabled. + +2000-10-26 Gary Thomas <gthomas@redhat.com> + + * cdl/redboot.cdl: Improve CDL so CYGSEM_HAL_ROM_MONITOR can + be correctly infered (when building ROM versions). + + * cdl/redboot.cdl: + * src/load.c: Add support for xyzModem serial download. + + * src/xyzModem.h: + * src/xyzModem.c: New file(s). + +2000-10-24 Gary Thomas <gthomas@redhat.com> + + * src/flash.c: + * cdl/redboot.cdl: Add new option which supports keeping all + important RedBoot data "locked" in FLASH. + 2000-10-23 Gary Thomas <gthomas@redhat.com> + * src/flash.c (fis_lookup): New exported function. + (fis_load): Add memory load option. Also checksum data after copy. + + * include/fis.h: Add 'data_length' member. + Prototype for 'fis_lookup()'. + + * src/main.c (bist): New [weak] function. Provide hook for + platform specific "builtin tests". This will be overridden by + platform based functions. + * cdl/redboot.cdl: * src/main.c (cyg_start): * src/flash.c: Script timeout now has a configurable resolution.
--- a/packages/redboot/current/cdl/redboot.cdl +++ b/packages/redboot/current/cdl/redboot.cdl @@ -60,14 +60,11 @@ cdl_package CYGPKG_REDBOOT { requires CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT requires ! CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT requires ! CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT - - requires ! CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT - requires ! CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT requires ! CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM cdl_option CYGBLD_BUILD_REDBOOT_WITH_THREADS { no_define - active_if { CYG_HAL_STARTUP == "ROM" } + active_if { CYG_HAL_STARTUP != "RAM" } requires CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT } @@ -77,7 +74,7 @@ cdl_package CYGPKG_REDBOOT { stripping before being converted to a binary image. This is handled by a rule in the target CDL." - compile printf.c misc_funs.c io.c parse.c ticks.c + compile printf.c misc_funs.c io.c parse.c ticks.c xyzModem.c compile -library=libextras.a load.c make -priority 320 { @@ -161,6 +158,17 @@ cdl_package CYGPKG_REDBOOT { include such items as the node IP address or startup scripts." } + cdl_option CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL { + display "Keep all RedBoot FLASH data blocks locked." + flavor bool + default_value 1 + active_if { CYGHWR_IO_FLASH_BLOCK_LOCKING != 0 } + description " + When this option is enabled, RedBoot will keep configuration + data and the FIS directory blocks implicitly locked. While + this is somewhat safer, it does add overhead during updates." + } + cdl_option CYGNUM_REDBOOT_FLASH_SCRIPT_TIMEOUT_RESOLUTION { display "Resolution (in ms) for script timeout value." flavor data @@ -182,5 +190,13 @@ cdl_package CYGPKG_REDBOOT { scripts, when they are enabled." } } + + cdl_option CYGPRI_REDBOOT_ROM_MONITOR { + active_if { CYG_HAL_STARTUP == "ROM" } + requires CYGSEM_HAL_ROM_MONITOR + calculated 1 + no_define + } + }
--- a/packages/redboot/current/doc/redboot.ebsa285 +++ b/packages/redboot/current/doc/redboot.ebsa285 @@ -144,7 +144,10 @@ 2. Execute RedBoot from RAM, and initial The IP and server info comes from BOOTP, which is how this RedBoot will start up if the flash does not contain good config info. - % minicom -o ttyS0 + % minicom -o + + Be sure to check that minicom is set to use the correct serial port and + with the correct port settings (normally 38400-N-1, no flow control) $c#63 RedBoot(tm) debug environment - built 07:45:57, Aug 7 2000
--- a/packages/redboot/current/include/fis.h +++ b/packages/redboot/current/include/fis.h @@ -1,3 +1,5 @@ +#ifndef _FIS_H_ +#define _FIS_H_ //========================================================================== // // fis.h @@ -49,7 +51,12 @@ struct fis_image_desc { unsigned long mem_base; // Address in memory where it executes unsigned long size; // Length of image unsigned long entry_point; // Execution entry point - unsigned char _pad[256-40]; + unsigned long data_length; // Length of actual data + unsigned char _pad[256-(16+7*sizeof(unsigned long))]; unsigned long desc_cksum; // Checksum over image descriptor unsigned long file_cksum; // Checksum over image data }; + +struct fis_image_desc *fis_lookup(char *name); + +#endif // _FIS_H_
--- a/packages/redboot/current/include/net/net.h +++ b/packages/redboot/current/include/net/net.h @@ -369,6 +369,11 @@ extern pktbuf_t *__pktbuf_alloc(int nbyt */ extern void __pktbuf_free(pktbuf_t *pkt); +/* + * Dump packet structures (debug, in case of running out) + */ +extern void __pktbuf_dump(void); + /* * Install handlers for ethernet packets. @@ -407,6 +412,12 @@ extern void __arp_handler(pktbuf_t *pkt) */ extern int __arp_request(ip_addr_t *ip_addr, enet_addr_t *eth_addr); +/* + * Lookup an address from the local ARP cache. If not found, + * then call 'arp_request' to find it. [Basically just a cached + * version of 'arp_request'] + */ +extern int __arp_lookup(ip_addr_t *host, ip_route_t *rt); /* * Do a one's complement checksum.
--- a/packages/redboot/current/src/flash.c +++ b/packages/redboot/current/src/flash.c @@ -70,7 +70,7 @@ local_cmd_entry("init", ); local_cmd_entry("list", "Display contents of FLASH Image System [FIS]", - "", + "[-c]", fis_list, FIS_cmds ); @@ -108,7 +108,7 @@ local_cmd_entry("delete", ); local_cmd_entry("load", "Load image from FLASH Image System [FIS] into RAM", - "name", + "[-b <memory_load_address>] [-c] name", fis_load, FIS_cmds ); @@ -130,6 +130,38 @@ static void *flash_start, *flash_end; static int block_size, blocks; static void *fis_work_block; +// Simple XOR style checksum +static unsigned long +_cksum(unsigned long *buf, int len) +{ + unsigned long cksum = 0; + + // Round 'len' up to multiple of longwords + len = (len + (sizeof(unsigned long)-1)) / sizeof(unsigned long); + while (len-- > 0) { + cksum ^= *buf++; + } + return cksum; +} + +struct fis_image_desc * +fis_lookup(char *name) +{ + int i; + void *fis_addr; + struct fis_image_desc *img; + + fis_addr = (void *)((unsigned long)flash_end - block_size); + memcpy(fis_work_block, fis_addr, block_size); + img = (struct fis_image_desc *)fis_work_block; + for (i = 0; i < block_size/sizeof(*img); i++, img++) { + if ((img->name[0] != (unsigned char)0xFF) && (strcmp(name, img->name) == 0)) { + return img; + } + } + return (struct fis_image_desc *)0; +} + static void fis_usage(char *why) { @@ -205,6 +237,10 @@ fis_init(int argc, char *argv[]) img->mem_base = (unsigned long)fis_base; img->size = block_size; img++; img_count++; +#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL + // Insure [quietly] that the directory is unlocked before trying to update + flash_unlock((void *)fis_base, block_size, (void **)&err_addr); +#endif if ((stat = flash_erase(fis_base, block_size, (void **)&err_addr)) != 0) { printf(" initialization failed %p: %x(%s)\n", err_addr, stat, flash_errmsg(stat)); } else { @@ -214,6 +250,10 @@ fis_init(int argc, char *argv[]) err_addr, stat, flash_errmsg(stat)); } } +#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL + // Insure [quietly] that the directory is locked after the update + flash_lock((void *)fis_base, block_size, (void **)&err_addr); +#endif } static void @@ -221,13 +261,25 @@ fis_list(int argc, char *argv[]) { struct fis_image_desc *img; int i; + bool show_cksums = false; + struct option_info opts[1]; + + init_opts(&opts[0], 'c', false, OPTION_ARG_TYPE_FLG, + (void **)&show_cksums, (bool *)0, "display checksums"); + if (!scan_opts(argc, argv, 2, opts, 1, 0, 0, "")) + { + return; + } img = (struct fis_image_desc *)((unsigned long)flash_end - block_size); - printf("Name FLASH addr Mem addr Length Entry point\n"); + printf("Name FLASH addr %s Length Entry point\n", + show_cksums ? "Checksum" : "Mem addr"); for (i = 0; i < block_size/sizeof(*img); i++, img++) { if (img->name[0] != (unsigned char)0xFF) { - printf("%-16s 0x%08lX 0x%08lX 0x%06lX 0x%08lX\n", img->name, - img->flash_base, img->mem_base, img->size, img->entry_point); + printf("%-16s 0x%08lX 0x%08lX 0x%08lX 0x%08lX\n", img->name, + img->flash_base, + show_cksums ? img->file_cksum : img->mem_base, + img->size, img->entry_point); } } } @@ -440,6 +492,12 @@ fis_create(int argc, char *argv[]) img->mem_base = exec_addr_set ? exec_addr : (flash_addr_set ? flash_addr : mem_addr); img->entry_point = entry_addr_set ? entry_addr : (unsigned long)entry_address; // Hope it's been set img->size = length; + img->data_length = img_size; + img->file_cksum = _cksum((unsigned long *)mem_addr, img_size); +#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL + // Insure [quietly] that the directory is unlocked before trying to update + flash_unlock((void *)fis_addr, block_size, (void **)&err_addr); +#endif if ((stat = flash_erase((void *)fis_addr, block_size, (void **)&err_addr)) != 0) { printf("Error erasing at %p: %x(%s)\n", err_addr, stat, flash_errmsg(stat)); // Don't try to program if the erase failed @@ -449,6 +507,10 @@ fis_create(int argc, char *argv[]) printf("Error programming at %p: %x(%s)\n", err_addr, stat, flash_errmsg(stat)); } } +#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL + // Insure [quietly] that the directory is locked after the update + flash_lock((void *)fis_addr, block_size, (void **)&err_addr); +#endif } static void @@ -605,6 +667,10 @@ fis_delete(int argc, char *argv[]) if ((stat = flash_erase((void *)img->flash_base, img->size, (void **)&err_addr)) != 0) { printf("Error erasing at %p: %x(%s)\n", err_addr, stat, flash_errmsg(stat)); } +#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL + // Insure [quietly] that the directory is unlocked before trying to update + flash_unlock((void *)fis_addr, block_size, (void **)&err_addr); +#endif // Update directory memset(img, 0xFF, sizeof(*img)); if ((stat = flash_erase((void *)fis_addr, block_size, (void **)&err_addr)) != 0) { @@ -616,45 +682,56 @@ fis_delete(int argc, char *argv[]) printf("Error programming at %p: %x(%s)\n", err_addr, stat, flash_errmsg(stat)); } } +#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL + // Insure [quietly] that the directory is locked after the update + flash_lock((void *)fis_addr, block_size, (void **)&err_addr); +#endif } static void fis_load(int argc, char *argv[]) { char *name; - int i; - void *fis_addr; struct fis_image_desc *img; - bool slot_found; + unsigned long mem_addr; + bool mem_addr_set = false; + bool show_cksum = false; + struct option_info opts[2]; - if (!scan_opts(argc, argv, 2, 0, 0, (void **)&name, OPTION_ARG_TYPE_STR, "image name")) + init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, + (void **)&mem_addr, (bool *)&mem_addr_set, "memory [load] base address"); + init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG, + (void **)&show_cksum, (bool *)0, "display checksum"); + if (!scan_opts(argc, argv, 2, opts, 2, (void **)&name, OPTION_ARG_TYPE_STR, "image name")) { fis_usage("invalid arguments"); return; } - - slot_found = false; - fis_addr = (void *)((unsigned long)flash_end - block_size); - memcpy(fis_work_block, fis_addr, block_size); - img = (struct fis_image_desc *)fis_work_block; - for (i = 0; i < block_size/sizeof(*img); i++, img++) { - if ((img->name[0] != (unsigned char)0xFF) && (strcmp(name, img->name) == 0)) { - slot_found = true; - break; - } - } - if (!slot_found) { + if ((img = fis_lookup(name)) == (struct fis_image_desc *)0) { printf("No image '%s' found\n", name); return; } + if (!mem_addr_set) { + mem_addr = img->mem_base; + } // Load image from FLASH into RAM - if ((img->mem_base < (unsigned long)ram_start) || - ((img->mem_base+img->size) >= (unsigned long)ram_end)) { + if ((mem_addr < (unsigned long)ram_start) || + ((mem_addr+img->size) >= (unsigned long)ram_end)) { printf("Not a loadable image\n"); return; } - memcpy((void *)img->mem_base, (void *)img->flash_base, img->size); + memcpy((void *)mem_addr, (void *)img->flash_base, img->size); entry_address = (unsigned long *)img->entry_point; + if (img->file_cksum) { + unsigned long cksum = _cksum((unsigned long *)mem_addr, img->data_length); + if (cksum != img->file_cksum) { + printf("** Warning - checksum failure. stored: %08lx, computed: %08lx\n", + img->file_cksum, cksum); + } + if (show_cksum) { + printf("Checksum: %08lx\n", cksum); + } + } } static bool @@ -672,7 +749,7 @@ do_flash_init(void) } flash_get_limits((void *)0, (void **)&flash_start, (void **)&flash_end); flash_get_block_info(&block_size, &blocks); - printf("FLASH: %p - %p, %d blocks of %p bytes ea.\n", + printf("FLASH: %p - %p, %d blocks of %p bytes each.\n", flash_start, flash_end, blocks, (void *)block_size); fis_work_block = (unsigned char *)(ram_end-FLASH_MIN_WORKSPACE-block_size); } @@ -904,7 +981,7 @@ get_config(struct config_option *opt, in // over time. static unsigned long -_cksum(unsigned long *buf, int len) +_fconfig_cksum(unsigned long *buf, int len) { unsigned long cksum = 0; int shift = 0; @@ -993,9 +1070,13 @@ do_flash_config(int argc, char *argv[]) done: if (!need_update) return; config.key1 = CONFIG_KEY1; config.key2 = CONFIG_KEY2; - config.cksum = _cksum((unsigned long *)&config, sizeof(config)-sizeof(config.cksum)); + config.cksum = _fconfig_cksum((unsigned long *)&config, sizeof(config)-sizeof(config.cksum)); cfg_base = (void *)((unsigned long)flash_end - (2*block_size)); if (verify_action("Update RedBoot non-volatile configuration")) { +#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL + // Insure [quietly] that the config page is unlocked before trying to update + flash_unlock((void *)cfg_base, block_size, (void **)&err_addr); +#endif if ((stat = flash_erase(cfg_base, block_size, (void **)&err_addr)) != 0) { printf(" initialization failed %p: %x(%s)\n", err_addr, stat, flash_errmsg(stat)); } else { @@ -1005,6 +1086,10 @@ do_flash_config(int argc, char *argv[]) err_addr, stat, flash_errmsg(stat)); } } +#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL + // Insure [quietly] that the config data is locked after the update + flash_lock((void *)cfg_base, block_size, (void **)&err_addr); +#endif } } @@ -1072,7 +1157,7 @@ load_flash_config(void) if (!do_flash_init()) return; cfg_base = (void *)((unsigned long)flash_end - (2*block_size)); memcpy(&config, cfg_base, sizeof(config)); - if ((_cksum((unsigned long *)&config, sizeof(config)-sizeof(config.cksum)) != config.cksum) || + if ((_fconfig_cksum((unsigned long *)&config, sizeof(config)-sizeof(config.cksum)) != config.cksum) || (config.key1 != CONFIG_KEY1)|| (config.key2 != CONFIG_KEY2)) { printf("FLASH configuration checksum error or invalid key\n"); memset(&config, 0, sizeof(config));
--- a/packages/redboot/current/src/load.c +++ b/packages/redboot/current/src/load.c @@ -44,15 +44,17 @@ //========================================================================== #include <redboot.h> +#include <xyzModem.h> // Buffer used by redboot_getc getc_info_t getc_info; +static char usage[] = "[-r] [-v] [-h <host>] [-m {TFTP | xyzMODEM}] [-b <base_address>] <file_name>"; // Exported CLI function RedBoot_cmd("load", "Load a file", - "[-v] [-r] [-b <mem_addr>] <file_name>", + usage, do_load ); @@ -240,18 +242,19 @@ redboot_getc_rewind(void) } #define MODE_TFTP 0 -#define MODE_ZMODEM 1 +#define MODE_XMODEM xyzModem_xmodem +#define MODE_YMODEM xyzModem_ymodem +#define MODE_ZMODEM xyzModem_zmodem void do_load(int argc, char *argv[]) { int res, num_options; - int mode; + int i, err, mode; bool verbose, raw; bool base_addr_set, mode_str_set; char *mode_str; #ifdef CYGPKG_REDBOOT_NETWORKING - int i, err; struct sockaddr_in host; bool hostname_set; char *hostname; @@ -259,7 +262,6 @@ do_load(int argc, char *argv[]) unsigned long base = 0; char type[4]; char *filename = 0; - char *usage = "usage: load <file_name> [-r] [-v] [-h <host>] [-m {TFTP | ZMODEM}] [-b <base_address>]\n"; struct option_info opts[5]; #ifdef CYGPKG_REDBOOT_NETWORKING @@ -272,7 +274,7 @@ do_load(int argc, char *argv[]) #ifdef CYGPKG_REDBOOT_NETWORKING mode = MODE_TFTP; #else - mode = MODE_ZMODEM; + mode = MODE_YMODEM; #endif init_opts(&opts[0], 'v', false, OPTION_ARG_TYPE_FLG, @@ -282,7 +284,7 @@ do_load(int argc, char *argv[]) init_opts(&opts[2], 'b', true, OPTION_ARG_TYPE_NUM, (void **)&base, (bool *)&base_addr_set, "load address"); init_opts(&opts[3], 'm', true, OPTION_ARG_TYPE_STR, - (void **)&mode_str, (bool *)&mode_str_set, "download mode (TFTP or ZMODEM)"); + (void **)&mode_str, (bool *)&mode_str_set, "download mode (TFTP or xyzMODEM)"); num_options = 4; #ifdef CYGPKG_REDBOOT_NETWORKING init_opts(&opts[4], 'h', true, OPTION_ARG_TYPE_STR, @@ -302,8 +304,21 @@ do_load(int argc, char *argv[]) } #endif if (mode_str_set) { - if (strcmpci(mode_str, "zmodem") == 0) { - mode = MODE_ZMODEM; + if (strncmpci(&mode_str[1], "modem", strlen(&mode_str[1])) == 0) { + switch (tolower(mode_str[0])) { + case 'x': + mode = MODE_XMODEM; + break; + case 'y': + mode = MODE_YMODEM; + break; + case 'z': + mode = MODE_ZMODEM; + break; + default: + printf("Invalid 'mode': %s\n", mode_str); + return; + } #ifdef CYGPKG_REDBOOT_NETWORKING } else if (strcmpci(mode_str, "tftp") == 0) { mode = MODE_TFTP; @@ -319,7 +334,7 @@ do_load(int argc, char *argv[]) } if ((mode == MODE_TFTP) && !filename) { printf("File name missing\n"); - printf(usage); + printf("usage: load %s\n", usage); return; } #ifdef CYGPKG_REDBOOT_NETWORKING @@ -330,44 +345,46 @@ do_load(int argc, char *argv[]) return; } redboot_getc_init(tftp_stream_read, verbose); - for (i = 0; i < sizeof(type); i++) { - if ((res = redboot_getc()) < 0) { - err = getc_info.err; - break; - } - type[i] = res; - } - if (res < 0) { - printf("Error reading header via TFTP: %s\n", tftp_error(err)); - tftp_stream_close(&err); - return; - } } #endif - if (mode == MODE_ZMODEM) { - printf("Sorry, zmodem download not yet available\n"); - return; + else { + res = xyzModem_stream_open(filename, mode, &err); + if (res < 0) { + printf("Can't load '%s': %s\n", filename, xyzModem_error(err)); + return; + } + redboot_getc_init(xyzModem_stream_read, verbose); } - redboot_getc_rewind(); // Restore header to stream - if (raw) { - if (!base_addr_set) { - printf("Raw load requires a memory address\n"); + // Read initial header - to determine file [image] type + for (i = 0; i < sizeof(type); i++) { + if ((res = redboot_getc()) < 0) { + err = getc_info.err; + break; + } + type[i] = res; + } + if (res >= 0) { + redboot_getc_rewind(); // Restore header to stream + if (raw) { + if (!base_addr_set) { + printf("Raw load requires a memory address\n"); + } else { + unsigned char *mp = (unsigned char *)base; + while ((res = redboot_getc()) >= 0) { + *mp++ = res; + } + printf("Raw file loaded %p-%p\n", (void *)base, (void *)mp); + } } else { - unsigned char *mp = (unsigned char *)base; - while ((res = redboot_getc()) >= 0) { - *mp++ = res; + // Treat data as some sort of executable image + if (strncmp(&type[1], "ELF", 3) == 0) { + load_elf_image(redboot_getc); + } else if ((type[0] == 'S') && + ((type[1] >= '0') && (type[1] <= '9'))) { + load_srec_image(redboot_getc, base); + } else { + printf("Unrecognized image type: %lx\n", *(unsigned long *)type); } - printf("Raw file loaded %p-%p\n", (void *)base, (void *)mp); - } - } else { - // Treat data as some sort of executable image - if (strncmp(&type[1], "ELF", 3) == 0) { - load_elf_image(redboot_getc); - } else if ((type[0] == 'S') && - ((type[1] >= '0') && (type[1] <= '9'))) { - load_srec_image(redboot_getc, base); - } else { - printf("Unrecognized image type: %lx\n", *(unsigned long *)type); } } #ifdef CYGPKG_REDBOOT_NETWORKING
--- a/packages/redboot/current/src/main.c +++ b/packages/redboot/current/src/main.c @@ -52,6 +52,9 @@ #include <cyg/hal/hal_tables.h> +// Builtin Self Test (BIST) +externC void bist(void); + // GDB interfaces extern void breakpoint(void); @@ -108,6 +111,8 @@ cyg_start(void) ram_start = (unsigned char *)CYGMEM_REGION_ram; ram_end = (unsigned char *)(CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE); + bist(); + printf("\nRedBoot(tm) debug environment - built %s, %s\n", __TIME__, __DATE__); #ifdef HAL_PLATFORM_CPU printf("Platform: %s (%s) %s\n", HAL_PLATFORM_BOARD, HAL_PLATFORM_CPU, HAL_PLATFORM_EXTRA); @@ -274,3 +279,13 @@ do_go(int argc, char *argv[]) HAL_DCACHE_INVALIDATE_ALL(); (*fun)(); } + +// +// [Null] Builtin [Power On] Self Test +// +void bist(void) CYGBLD_ATTRIB_WEAK; + +void +bist(void) +{ +}
--- a/packages/redboot/current/src/net/enet.c +++ b/packages/redboot/current/src/net/enet.c @@ -43,7 +43,9 @@ // //========================================================================== +#include <redboot.h> #include <net/net.h> +#include <eth_drv.h> // Logical driver interfaces #define ENET_STATS 1 @@ -79,7 +81,7 @@ void return; } - if ((pkt->pkt_bytes = eth_drv_read(ð_hdr, (char *)pkt->buf, + if ((pkt->pkt_bytes = eth_drv_read((char *)ð_hdr, (char *)pkt->buf, ETH_MAX_PKTLEN)) > 0) { #if ENET_STATS ++num_received; @@ -138,7 +140,7 @@ void memcpy(ð_hdr.source, __local_enet_addr, sizeof(enet_addr_t)); eth_hdr.type = htons(eth_type); - eth_drv_write(ð_hdr, (const char *)pkt->buf, pkt->pkt_bytes); + eth_drv_write((char *)ð_hdr, (char *)pkt->buf, pkt->pkt_bytes); #if ENET_STATS ++num_transmitted; #endif
--- a/packages/redboot/current/src/net/net_io.c +++ b/packages/redboot/current/src/net/net_io.c @@ -44,6 +44,7 @@ //========================================================================== #include <redboot.h> +#include <eth_drv.h> // Logical driver interfaces #include <net/net.h> #include <cyg/hal/hal_misc.h> // Helper functions #include <cyg/hal/hal_if.h> // HAL I/O interfaces
--- a/packages/redboot/current/src/net/pktbuf.c +++ b/packages/redboot/current/src/net/pktbuf.c @@ -43,6 +43,7 @@ // //========================================================================== +#include <redboot.h> #include <net/net.h> #define MAX_PKTBUF CYGNUM_REDBOOT_NETWORKING_MAX_PKTBUF
--- a/packages/redboot/current/src/net/udp.c +++ b/packages/redboot/current/src/net/udp.c @@ -43,7 +43,7 @@ // //========================================================================== - +#include <redboot.h> #include <net/net.h> #ifdef UDP_STATS @@ -192,7 +192,7 @@ int { ip_route_t rt; - if (__arp_lookup(&server->sin_addr, &rt) < 0) { + if (__arp_lookup((ip_addr_t *)&server->sin_addr, &rt) < 0) { printf("%s: Can't find address of server\n", __FUNCTION__); return -1; } else {
new file mode 100644 --- /dev/null +++ b/packages/redboot/current/src/xyzModem.c @@ -0,0 +1,358 @@ +//========================================================================== +// +// xyzModem.c +// +// RedBoot stream handler for xyzModem protocol +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-14 +// Purpose: +// Description: +// +// This code is part of RedBoot (tm). +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <redboot.h> +#include <xyzModem.h> + +// Assumption - run xyzModem protocol over the console port + +// Values magic to the protocol +#define SOH 0x01 +#define STX 0x02 +#define EOT 0x04 +#define ACK 0x06 +#define NAK 0x15 +#define CAN 0x18 + +// Data & state local to the protocol +static struct { + hal_virtual_comm_table_t* __chan; + unsigned char pkt[1024], *bufp; + unsigned char blk,cblk,crc1,crc2; + unsigned char next_blk; // Expected block + int len; + bool crc_mode, at_eof; +} xyz; + +#define xyzModem_CHAR_TIMEOUT 1000 // 1 second +#define xyzModem_MAX_RETRIES 20 + +// Table of CRC constants - implements x^16+x^12+x^5+1 +static unsigned short crc16[] = { + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, + 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, + 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, + 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, + 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, + 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, + 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, + 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, + 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, + 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, + 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, + 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, + 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, + 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, + 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, + 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, + 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, + 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, + 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, + 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, + 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, + 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, + 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0, +}; + +void +zm_dprintf(char *fmt, ...) +{ + int cur_console; + va_list args; + + va_start(args, fmt); + cur_console = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT); + CYGACC_CALL_IF_SET_CONSOLE_COMM(1); + vprintf(fmt, args); + CYGACC_CALL_IF_SET_CONSOLE_COMM(cur_console); +} + +void +zm_dump_buf(void *buf, int len) +{ + int cur_console; + + cur_console = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT); + CYGACC_CALL_IF_SET_CONSOLE_COMM(1); + dump_buf(buf, len); + CYGACC_CALL_IF_SET_CONSOLE_COMM(cur_console); +} + +// Wait for the line to go idle +static void +xyzModem_flush(void) +{ + int res; + char c; + while (true) { + res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c); + if (!res) return; + } +} + +static int +xyzModem_get_hdr(void) +{ + char c; + int res; + bool hdr_found = false; + int i; + unsigned short cksum; + + // Find the start of a header + while (!hdr_found) { + res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c); + if (res) { + switch (c) { + case SOH: + case STX: + hdr_found = true; + break; + case CAN: + return xyzModem_cancel; + case EOT: + return xyzModem_eof; + default: + // Ignore, waiting for start of header + } + } else { + // Data stream timed out + return xyzModem_timeout; + } + } + + // Header found, now read the data + res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &xyz.blk); + if (!res) { + return xyzModem_timeout; + } + res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &xyz.cblk); + if (!res) { + return xyzModem_timeout; + } + xyz.len = (c == SOH) ? 128 : 1024; + xyz.bufp = xyz.pkt; + for (i = 0; i < xyz.len; i++) { + res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c); + if (res) { + xyz.pkt[i] = c; + } else { + return xyzModem_timeout; + } + } + res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &xyz.crc1); + if (!res) { + return xyzModem_timeout; + } + if (xyz.crc_mode) { + res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &xyz.crc2); + if (!res) { + return xyzModem_timeout; + } + } + // Validate the message + if ((xyz.blk ^ xyz.cblk) != (unsigned char)0xFF) { + zm_dprintf("Framing error - blk: %x/%x/%x\n", xyz.blk, xyz.cblk, (xyz.blk ^ xyz.cblk)); + zm_dump_buf(xyz.pkt, xyz.len); + xyzModem_flush(); + return xyzModem_frame; + } + // Verify checksum/CRC + if (xyz.crc_mode) { + cksum = 0; + for (i = 0; i < xyz.len; i++) { + cksum = crc16[((cksum>>8) ^ xyz.pkt[i]) & 0xFF] ^ (cksum << 8); + } + if (cksum != ((xyz.crc1 << 8) | xyz.crc2)) { + zm_dprintf("CRC error - recvd: %02x%02x, computed: %x\n", + xyz.crc1, xyz.crc2, cksum & 0xFFFF); + return xyzModem_cksum; + } + } else { + cksum = 0; + for (i = 0; i < xyz.len; i++) { + cksum += xyz.pkt[i]; + } + if (xyz.crc1 != (cksum & 0xFF)) { + zm_dprintf("Checksum error - recvd: %x, computed: %x\n", xyz.crc1, cksum & 0xFF); + return xyzModem_cksum; + } + } + // If we get here, the message passes [structural] muster + return 0; +} + +int +xyzModem_stream_open(char *filename, int mode, int *err) +{ + int console_chan, stat; + int retries = xyzModem_MAX_RETRIES; + + if (mode == xyzModem_zmodem) { + *err = xyzModem_noZmodem; + return -1; + } + + // Set up the I/O channel. Note: this allows for using a different port in the future + console_chan = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT); + CYGACC_CALL_IF_SET_CONSOLE_COMM(console_chan); + xyz.__chan = CYGACC_CALL_IF_CONSOLE_PROCS(); + CYGACC_CALL_IF_SET_CONSOLE_COMM(console_chan); + CYGACC_COMM_IF_CONTROL(*xyz.__chan, __COMMCTL_SET_TIMEOUT, xyzModem_CHAR_TIMEOUT); + xyz.len = 0; + xyz.crc_mode = true; + xyz.at_eof = false; + + while (retries-- > 0) { + stat = xyzModem_get_hdr(); + if (stat == 0) { + CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK); + // Note: yModem file name data blocks quietly discarded + xyz.next_blk = 1; + xyz.len = 0; + return 0; + } else + if (stat == xyzModem_timeout) { + CYGACC_CALL_IF_DELAY_US(5*100000); // Extra delay for startup + CYGACC_COMM_IF_PUTC(*xyz.__chan, 'C'); + } + } + *err = stat; + return -1; +} + +int +xyzModem_stream_read(char *buf, int size, int *err) +{ + int stat, total, len; + int retries; + + total = 0; + // Try and get 'size' bytes into the buffer + while (!xyz.at_eof && (size > 0)) { + if (xyz.len == 0) { + retries = xyzModem_MAX_RETRIES; + while (retries-- > 0) { + stat = xyzModem_get_hdr(); + if (stat == 0) { + if (xyz.blk == xyz.next_blk) { + CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK); + xyz.next_blk = (xyz.next_blk + 1) & 0xFF; + break; + } else if (xyz.blk == ((xyz.next_blk - 1) & 0xFF)) { + // Just re-ACK this so sender will get on with it + CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK); + continue; // Need new header + } else { + stat = xyzModem_sequence; + } + } + if (stat == xyzModem_eof) { + CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK); + xyz.at_eof = true; + break; + } + CYGACC_COMM_IF_PUTC(*xyz.__chan, 'C'); + } + if (stat < 0) { + *err = stat; + xyz.len = -1; + return total; + } + } + len = xyz.len; + if (size < len) len = size; + memcpy(buf, xyz.bufp, len); + size -= len; + buf += len; + total += len; + xyz.len -= len; + xyz.bufp += len; + } + return total; +} + +char * +xyzModem_error(int err) +{ + switch (err) { + case xyzModem_access: + return "Can't access file"; + break; + case xyzModem_noZmodem: + return "Sorry, zModem not available yet"; + break; + case xyzModem_timeout: + return "Timed out"; + break; + case xyzModem_eof: + return "End of file"; + break; + case xyzModem_cancel: + return "Cancelled"; + break; + case xyzModem_frame: + return "Invalid framing"; + break; + case xyzModem_cksum: + return "CRC/checksum error"; + break; + case xyzModem_sequence: + return "Block sequence error"; + break; + default: + return "Unknown error"; + break; + } +}
new file mode 100644 --- /dev/null +++ b/packages/redboot/current/src/xyzModem.h @@ -0,0 +1,66 @@ +//========================================================================== +// +// xyzModem.h +// +// RedBoot stream handler for xyzModem protocol +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-14 +// Purpose: +// Description: +// +// This code is part of RedBoot (tm). +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#ifndef _XYZMODEM_H_ +#define _XYZMODEM_H_ + +#define xyzModem_xmodem 1 +#define xyzModem_ymodem 2 +#define xyzModem_zmodem 3 + +#define xyzModem_access -1 +#define xyzModem_noZmodem -2 +#define xyzModem_timeout -3 +#define xyzModem_eof -4 +#define xyzModem_cancel -5 +#define xyzModem_frame -6 +#define xyzModem_cksum -7 +#define xyzModem_sequence -8 + +int xyzModem_stream_open(char *filename, int mode, int *err); +int xyzModem_stream_read(char *buf, int size, int *err); +char *xyzModem_error(int err); + +#endif // _XYZMODEM_H_
--- a/packages/services/memalloc/common/current/ChangeLog +++ b/packages/services/memalloc/common/current/ChangeLog @@ -1,3 +1,8 @@ +2000-10-31 Jonathan Larmour <jlarmour@redhat.com> + + * tests/testaux.hxx: Prototype cyg_hal_invoke_constructors() + [ Forgot to check this in at the same time as below ] + 2000-10-20 Jonathan Larmour <jlarmour@redhat.com> * tests/dlmalloc1.cxx:
--- a/packages/services/memalloc/common/current/tests/testaux.hxx +++ b/packages/services/memalloc/common/current/tests/testaux.hxx @@ -1,5 +1,5 @@ -#ifndef CYGONCE_KERNEL_TESTS_TESTAUX_HXX -#define CYGONCE_KERNEL_TESTS_TESTAUX_HXX +#ifndef CYGONCE_MEMALLOC_TESTS_TESTAUX_HXX +#define CYGONCE_MEMALLOC_TESTS_TESTAUX_HXX //========================================================================== // @@ -49,6 +49,13 @@ static inline void *operator new(size_t size, void *ptr) { return ptr; }; +#include <pkgconf/hal.h> + +#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG +externC void +cyg_hal_invoke_constructors(); +#endif + #ifdef NTHREADS #ifndef STACKSIZE
--- a/packages/templates/elix/ChangeLog +++ b/packages/templates/elix/ChangeLog @@ -1,3 +1,8 @@ +2000-10-11 Jonathan Larmour <jlarmour@redhat.com> + + * current.ect: CYGPKG_NET_ETH_DRIVERS has been renamed to + CYGPKG_IO_ETH_DRIVERS + 2000-07-24 Jonathan Larmour <jlarmour@redhat.co.uk> * current.ect: Include net package
--- a/packages/templates/elix/current.ect +++ b/packages/templates/elix/current.ect @@ -31,7 +31,7 @@ This is the configuration to build eCos package CYGPKG_IO_WALLCLOCK current ; package CYGPKG_ERROR current ; package CYGPKG_NET current ; - package CYGPKG_NET_ETH_DRIVERS current ; + package CYGPKG_IO_ETH_DRIVERS current ; }; cdl_option CYGIMP_KERNEL_SCHED_SORTED_QUEUES {
