--- hercules-3.13.orig/.pc/.quilt_patches +++ hercules-3.13/.pc/.quilt_patches @@ -0,0 +1 @@ +debian/patches --- hercules-3.13.orig/.pc/.quilt_series +++ hercules-3.13/.pc/.quilt_series @@ -0,0 +1 @@ +series --- hercules-3.13.orig/.pc/.version +++ hercules-3.13/.pc/.version @@ -0,0 +1 @@ +2 --- hercules-3.13.orig/.pc/always-strict-alignment.patch/machdep.h +++ hercules-3.13/.pc/always-strict-alignment.patch/machdep.h @@ -0,0 +1,808 @@ +/* MACHDEP.H (c) Copyright Greg Smith, 2001-2010 */ +/* Hercules machine specific code */ + +/*-------------------------------------------------------------------*/ +/* */ +/* This header file contains the following functions, defined as */ +/* either normal unoptimzed C code, or else as hand-tuned optimized */ +/* assembler-assisted functions for the given machine architecture: */ +/* */ +/* */ +/* Atomic COMPARE-AND-EXCHANGE functions: */ +/* */ +/* cmpxchg1, cmpxchg4, cmpxchg8, cmpxchg16 */ +/* */ +/* */ +/* Atomic word/double-word FETCH/STORE functions: */ +/* */ +/* fetch_hw, fetch_hw_noswap, store_hw, store_hw_noswap */ +/* fetch_fw, fetch_fw_noswap, store_fw, store_fw_noswap */ +/* fetch_dw, fetch_dw_noswap, store_dw, store_dw_noswap */ +/* */ +/* 64 bit architectures would normally not need to specify */ +/* any of the fetch_ or store_ macros. */ +/* */ +/* 32 bit architectures should specify one of the `fetch_dw' */ +/* and `store_dw' macros. Little-endian machines should specify */ +/* the `noswap' macros. Big-endian machines can specify either, */ +/* both being the same. */ +/* */ +/*-------------------------------------------------------------------*/ + +#ifndef _HERCULES_MACHDEP_H +#define _HERCULES_MACHDEP_H 1 + +#include "opcode.h" // (need CSWAP32, et.al macros, etc) +#include "htypes.h" // (need Hercules fixed-size data types) + +/*------------------------------------------------------------------- + * Microsoft Visual C/C++... + *-------------------------------------------------------------------*/ +#if defined( _MSVC_ ) + + // PROGRAMMING NOTE: Optimizations normally only apply for release + // builds, but we support optionally enabling them for debug too, + // as well as purposely DISABLING them for troubleshooting... + + #define OPTION_ENABLE_MSVC_OPTIMIZATIONS_FOR_DEBUG_BUILDS_TOO + // #define OPTION_DISABLE_MSVC_OPTIMIZATIONS + + #undef GEN_MSC_ASSISTS + + #if defined( DEBUG) || defined( _DEBUG ) + #if defined(OPTION_ENABLE_MSVC_OPTIMIZATIONS_FOR_DEBUG_BUILDS_TOO) && \ + !defined(OPTION_DISABLE_MSVC_OPTIMIZATIONS) + #define GEN_MSC_ASSISTS + #endif + #else // (presumed RELEASE build) + #if !defined(OPTION_DISABLE_MSVC_OPTIMIZATIONS) + #define GEN_MSC_ASSISTS + #endif + #endif // (debug or release) + + #undef MSC_X86_32BIT // any 32-bit X86 (Pentium Pro, Pentium II, Pentium III or better) + #undef MSC_X86_64BIT // any 64-bit X86 (AMD64 or Intel Itanium) + #undef MSC_X86_AMD64 // AMD64 only + #undef MSC_X86_IA64 // Intel Itanium only + + #if defined( _M_IX86 ) && ( _M_IX86 >= 600 ) + #define MSC_X86_32BIT + #endif + #if defined( _M_AMD64 ) + #define MSC_X86_AMD64 + #define MSC_X86_64BIT + #endif + #if defined( _M_IA64 ) + #define MSC_X86_IA64 + #define MSC_X86_64BIT + #endif + + #if defined(GEN_MSC_ASSISTS) && (defined(MSC_X86_32BIT) || defined(MSC_X86_64BIT)) + + // Any X86 at all (both 32/64-bit) + + #pragma intrinsic ( _InterlockedCompareExchange ) + + #define cmpxchg1( x, y, z ) cmpxchg1_x86( x, y, z ) + #define cmpxchg4( x, y, z ) cmpxchg4_x86( x, y, z ) + #define cmpxchg8( x, y, z ) cmpxchg8_x86( x, y, z ) + + #if ( _MSC_VER < 1400 ) + + // PROGRAMMING NOTE: compiler versions earlier than VS8 2005 + // do not have the _InterlockedCompareExchange64 intrinsic so + // we use our own hand-coded inline assembler routine instead. + // Also note that we can't use __fastcall here since doing so + // would interfere with our register usage. + + static __inline BYTE cmpxchg8_x86 ( U64 *pOldVal, U64 u64NewVal, volatile void *pTarget ) + { + // returns 0 == success, 1 otherwise + BYTE rc; + U32 u32NewValHigh = u64NewVal >> 32; + U32 u32NewValLow = u64NewVal & 0xffffffff; + __asm + { + mov esi, [pOldVal] + mov eax, [esi + 0] + mov edx, [esi + 4] + mov ebx, [u32NewValLow] + mov ecx, [u32NewValHigh] + mov esi, [pTarget] + #ifdef OPTION_SMP + lock cmpxchg8b qword ptr [esi] + #else + cmpxchg8b qword ptr [esi] + #endif + setne rc + jz success + mov esi, [pOldVal] + mov [esi + 0], eax + mov [esi + 4], edx + }; + success: + return rc; + } + + #else // ( _MSC_VER >= 1400 ) + + #pragma intrinsic ( _InterlockedCompareExchange64 ) + + static __inline BYTE __fastcall cmpxchg8_x86 ( U64 *old, U64 new, volatile void *ptr ) + { + // returns 0 == success, 1 otherwise + U64 tmp = *old; + *old = _InterlockedCompareExchange64( ptr, new, *old ); + return ((tmp == *old) ? 0 : 1); + } + + #endif // ( _MSC_VER >= 1400 ) + + static __inline BYTE __fastcall cmpxchg4_x86 ( U32 *old, U32 new, volatile void *ptr ) + { + // returns 0 == success, 1 otherwise + U32 tmp = *old; + *old = _InterlockedCompareExchange( ptr, new, *old ); + return ((tmp == *old) ? 0 : 1); + } + + // (must follow cmpxchg4 since it uses it) + static __inline BYTE __fastcall cmpxchg1_x86 ( BYTE *old, BYTE new, volatile void *ptr ) + { + // returns 0 == success, 1 otherwise + + LONG_PTR off, shift; + BYTE cc; + U32 *ptr4, val4, old4, new4; + + off = (LONG_PTR)ptr & 3; + shift = (3 - off) * 8; + ptr4 = (U32*)(((BYTE*)ptr) - off); + val4 = CSWAP32(*ptr4); + + old4 = CSWAP32((val4 & ~(0xff << shift)) | (*old << shift)); + new4 = CSWAP32((val4 & ~(0xff << shift)) | ( new << shift)); + + cc = cmpxchg4( &old4, new4, ptr4 ); + + *old = (CSWAP32(old4) >> shift) & 0xff; + + return cc; + } + + #if defined(MSC_X86_32BIT) + + #define fetch_dw_noswap(_p) fetch_dw_x86_noswap((_p)) + // (must follow cmpxchg8 since it uses it) + static __inline U64 __fastcall fetch_dw_x86_noswap ( volatile void *ptr ) + { + U64 value = *(U64*)ptr; + cmpxchg8( &value, value, (U64*)ptr ); + return value; + } + + #define store_dw_noswap(_p, _v) store_dw_x86_noswap( (_p), (_v)) + // (must follow cmpxchg8 since it uses it) + static __inline void __fastcall store_dw_x86_noswap ( volatile void *ptr, U64 value ) + { + U64 orig = *(U64*)ptr; + while ( cmpxchg8( &orig, value, (U64*)ptr ) ); + } + #endif /* defined(MSC_X86_32BIT) */ + + #endif // defined(GEN_MSC_ASSISTS) && (defined(MSC_X86_32BIT) || defined(MSC_X86_64BIT)) + + // ------------------------------------------------------------------ + + #if defined(GEN_MSC_ASSISTS) && defined(MSC_X86_IA64) + + // (64-bit Itanium assists only) + + // ZZ FIXME: we should probably use the 'cmpxchg16b' instruction here + // instead if the processor supports it (CPUID instruction w/EAX function + // code 1 == Feature Information --> ECX bit 13 = CMPXCHG16B available) + + #pragma intrinsic ( _AcquireSpinLock ) + #pragma intrinsic ( _ReleaseSpinLock ) + #pragma intrinsic ( _ReadWriteBarrier ) + + #define cmpxchg16( x1, x2, y1, y2, z ) \ + cmpxchg16_x86( x1, x2, y1, y2, z ) + + static __inline int __fastcall cmpxchg16_x86 ( U64 *old1, U64 *old2, + U64 new1, U64 new2, + volatile void *ptr ) + { + // returns 0 == success, 1 otherwise + + static unsigned __int64 lock = 0; + int code; + + _AcquireSpinLock( &lock ); + + _ReadWriteBarrier(); + + if (*old1 == *(U64*)ptr && *old2 == *((U64*)ptr + 1)) + { + *(U64*)ptr = new1; + *((U64*)ptr + 1) = new2; + code = 0; + } + else + { + *old1 = *((U64*)ptr); + *old2 = *((U64*)ptr + 1); + code = 1; + } + + _ReleaseSpinLock( &lock ); + + return code; + } + + #endif // defined(GEN_MSC_ASSISTS) && defined(MSC_X86_IA64) + +#else // !defined( _MSVC_ ) +/*------------------------------------------------------------------- + * GNU C or other compiler... (i.e. NON-Microsoft C/C++) + *-------------------------------------------------------------------*/ + #if defined(__i686__) || defined(__pentiumpro__) || \ + defined(__pentium4__) || defined(__athlon__) || \ + defined(__athlon) + #define _ext_ia32 + #endif + + #if defined(__amd64__) + #define _ext_amd64 + #endif + + #if defined(__powerpc__) || defined(__ppc__) || \ + defined(__POWERPC__) || defined(__PPC__) || \ + defined(_POWER) + #define _ext_ppc + #endif + +/*------------------------------------------------------------------- + * Intel pentiumpro/i686 + *-------------------------------------------------------------------*/ +#if defined(_ext_ia32) + +#undef LOCK_PREFIX +#ifdef OPTION_SMP +#define LOCK_PREFIX "lock\n\t" +#else +#define LOCK_PREFIX "" +#endif + + /* + * If PIC is defined then ebx is used as the `thunk' reg + * However cmpxchg8b requires ebx + * In this case we load the value into esi and then + * exchange esi and ebx before and after cmpxchg8b + */ +#undef BREG +#undef XCHG_BREG +#if defined(PIC) && !defined(__CYGWIN__) +#define BREG "S" +#define XCHG_BREG "xchgl %%ebx,%%esi\n\t" +#else +#define BREG "b" +#define XCHG_BREG "" +#endif + +#define cmpxchg1(x,y,z) cmpxchg1_i686(x,y,z) +static __inline__ BYTE cmpxchg1_i686(BYTE *old, BYTE new, void *ptr) { + BYTE code; + __asm__ __volatile__ ( + LOCK_PREFIX + "cmpxchgb %b3,%4\n\t" + "setnz %b0" + : "=q"(code), "=a"(*old) + : "1" (*old), + "q" (new), + "m" (*(BYTE *)ptr) + : "cc" ); + return code; +} + +#define cmpxchg4(x,y,z) cmpxchg4_i686(x,y,z) +static __inline__ BYTE cmpxchg4_i686(U32 *old, U32 new, void *ptr) { + BYTE code; + __asm__ __volatile__ ( + LOCK_PREFIX + "cmpxchgl %3,%4\n\t" + "setnz %b0" + : "=q"(code), "=a"(*old) + : "1" (*old), + "q" (new), + "m" (*(U32 *)ptr) + : "cc" ); + return code; +} + +#define cmpxchg8(x,y,z) cmpxchg8_i686(x,y,z) +static __inline__ BYTE cmpxchg8_i686(U64 *old, U64 new, void *ptr) { + BYTE code; +__asm__ __volatile__ ( + XCHG_BREG + LOCK_PREFIX + "cmpxchg8b %5\n\t" + XCHG_BREG + "setnz %b0" + : "=q"(code), "=A"(*old) + : "1" (*old), + BREG ((unsigned long)new), + "c" ((unsigned long)(new >> 32)), + "m" (*(U64 *)ptr) + : "cc"); + return code; +} + +#define fetch_dw_noswap(x) fetch_dw_i686_noswap(x) +static __inline__ U64 fetch_dw_i686_noswap(void *ptr) +{ + U64 value = *(U64 *)ptr; +__asm__ __volatile__ ( + XCHG_BREG + LOCK_PREFIX + "cmpxchg8b (%4)\n\t" + XCHG_BREG + : "=A" (value) + : "0" (value), + BREG ((unsigned long)value), + "c" ((unsigned long)(value >> 32)), + "D" (ptr)); + return value; +} + +#define store_dw_noswap(x,y) store_dw_i686_noswap(x,y) +static __inline__ void store_dw_i686_noswap(void *ptr, U64 value) { +__asm__ __volatile__ ( + XCHG_BREG + "1:\t" + LOCK_PREFIX + "cmpxchg8b %3\n\t" + "jne 1b\n\t" + XCHG_BREG + : + : "A" (*(U64 *)ptr), + BREG ((unsigned long)value), + "c" ((unsigned long)(value >> 32)), + "m" (*(U64 *)ptr)); +} + +#if defined(OPTION_MULTI_BYTE_ASSIST) && defined(__linux__) +#define MULTI_BYTE_ASSIST +#define MULTI_BYTE_ASSIST_IA32 +#endif + +#endif /* defined(_ext_ia32) */ + +/*------------------------------------------------------------------- + * AMD64 + *-------------------------------------------------------------------*/ +#if defined(_ext_amd64) + +#define cmpxchg1(x,y,z) cmpxchg1_amd64(x,y,z) +static __inline__ BYTE cmpxchg1_amd64(BYTE *old, BYTE new, void *ptr) { +/* returns zero on success otherwise returns 1 */ + BYTE code; + BYTE *ptr_data=ptr; + __asm__ __volatile__ ( + "lock; cmpxchgb %b2,%4\n\t" + "setnz %b0\n\t" + : "=q"(code), "=a"(*old) + : "q"(new), + "1"(*old), + "m"(*ptr_data) + : "cc"); + return code; +} + +#define cmpxchg4(x,y,z) cmpxchg4_amd64(x,y,z) +static __inline__ BYTE cmpxchg4_amd64(U32 *old, U32 new, void *ptr) { +/* returns zero on success otherwise returns 1 */ + BYTE code; + U32 *ptr_data=ptr; + __asm__ __volatile__ ( + "lock; cmpxchgl %2,%4\n\t" + "setnz %b0\n\t" + : "=q"(code), "=a"(*old) + : "q"(new), + "1"(*old), + "m"(*ptr_data) + : "cc"); + return code; +} + +#define cmpxchg8(x,y,z) cmpxchg8_amd64(x,y,z) +static __inline__ BYTE cmpxchg8_amd64(U64 *old, U64 new, void *ptr) { +/* returns zero on success otherwise returns 1 */ + BYTE code; + U64 *ptr_data=ptr; + __asm__ __volatile__ ( + "lock; cmpxchgq %2,%4\n\t" + "setnz %b0\n\t" + : "=q"(code), "=a"(*old) + : "q"(new), + "1"(*old), + "m"(*ptr_data) + : "cc"); + return code; +} + +#endif /* defined(_ext_amd64) */ + +/*------------------------------------------------------------------- + * PowerPC + *-------------------------------------------------------------------*/ +#if defined(_ext_ppc) + +/* From /usr/src/linux/include/asm-ppc/system.h */ + +/* NOTE: IBM's VisualAge compiler likes 1: style labels + but GNU's gcc compiler running on AIX does not. */ + +#if !defined( __GNUC__ ) // (VisualAge presumed) + #define LABEL1 "1:\n" + #define LABEL2 "2:\n" + #define BRNCH2 "2f" + #define BRNCH1 "1b" +#else // (else gcc...) + #define LABEL1 "loop%=:\n" + #define LABEL2 "exit%=:\n" + #define BRNCH2 "exit%=" + #define BRNCH1 "loop%=" +#endif + +/* NOTE: Both VisualAge *and* gcc define __64BIT__ + see: http://gmplib.org/list-archives/gmp-discuss/2008-July/003339.html */ + +#if defined( __64BIT__ ) + +static __inline__ U64 +__cmpxchg_u64(volatile U64 *p, U64 old, U64 new) +{ + U64 prev; + + __asm__ __volatile__ ("\n" +LABEL1 +" ldarx %0,0,%2\n\ + cmpd 0,%0,%3\n\ + bne "BRNCH2"\n\ + stdcx. %4,0,%2\n\ + bne- "BRNCH1"\n" +#ifdef OPTION_SMP +" sync\n" +#endif /* OPTION_SMP */ +LABEL2 + : "=&r" (prev), "=m" (*p) + : "r" (p), "r" (old), "r" (new), "m" (*p) + : "cc", "memory"); + + return prev; +} + +#define cmpxchg8(x,y,z) cmpxchg8_ppc(x,y,z) +static __inline__ BYTE cmpxchg8_ppc(U64 *old, U64 new, void *ptr) { +/* returns zero on success otherwise returns 1 */ +U64 prev = *old; +return (prev != (*old = __cmpxchg_u64((U64*)ptr, prev, new))); +} + +#endif // defined( __64BIT__ ) + +static __inline__ U32 +__cmpxchg_u32(volatile U32 *p, U32 old, U32 new) +{ + U32 prev; + + __asm__ __volatile__ ("\n" +LABEL1 +" lwarx %0,0,%2\n\ + cmpw 0,%0,%3\n\ + bne "BRNCH2"\n\ + stwcx. %4,0,%2\n\ + bne- "BRNCH1"\n" +#ifdef OPTION_SMP +" sync\n" +#endif /* OPTION_SMP */ +LABEL2 + : "=&r" (prev), "=m" (*p) + : "r" (p), "r" (old), "r" (new), "m" (*p) + : "cc", "memory"); + + return prev; +} + +#define cmpxchg4(x,y,z) cmpxchg4_ppc(x,y,z) +static __inline__ BYTE cmpxchg4_ppc(U32 *old, U32 new, void *ptr) { +/* returns zero on success otherwise returns 1 */ +U32 prev = *old; +return (prev != (*old = __cmpxchg_u32((U32*)ptr, prev, new))); +} + +#define cmpxchg1(x,y,z) cmpxchg1_ppc(x,y,z) +static __inline__ BYTE cmpxchg1_ppc(BYTE *old, BYTE new, void *ptr) { +/* returns zero on success otherwise returns 1 */ +long off, shift; +BYTE cc; +U32 *ptr4, val4, old4, new4; + + off = (long)ptr & 3; + shift = (3 - off) * 8; + ptr4 = ptr - off; + val4 = *ptr4; + old4 = (val4 & ~(0xff << shift)) | (*old << shift); + new4 = (val4 & ~(0xff << shift)) | (new << shift); + cc = cmpxchg4_ppc(&old4, new4, ptr4); + *old = (old4 >> shift) & 0xff; + return cc; +} + +#endif /* defined(_ext_ppc) */ + +#endif // !defined( _MSVC_ ) + +/*------------------------------------------------------------------- + * Define the ASSIST_ macros + *-------------------------------------------------------------------*/ +#if defined(cmpxchg1) + #define ASSIST_CMPXCHG1 +#endif + +#if defined(cmpxchg4) + #define ASSIST_CMPXCHG4 +#endif + +#if defined(cmpxchg8) + #define ASSIST_CMPXCHG8 +#endif + +#if defined(cmpxchg16) + #define ASSIST_CMPXCHG16 +#endif + +#if defined(fetch_dw) || defined(fetch_dw_noswap) + #define ASSIST_FETCH_DW +#endif + +#if defined(store_dw) || defined(store_dw_noswap) + #define ASSIST_STORE_DW +#endif + +/*------------------------------------------------------------------- + * Decide if strict alignment is required + *-------------------------------------------------------------------*/ +#if !defined(OPTION_STRICT_ALIGNMENT) && !defined(OPTION_NO_STRICT_ALIGNMENT) + #if !defined(_MSVC_) && !defined(_ext_ia32) && !defined(_ext_amd64) \ + && !defined(_ext_ppc) + #define OPTION_STRICT_ALIGNMENT + #endif +#endif + +/*------------------------------------------------------------------- + * fetch_hw_noswap and fetch_hw + *-------------------------------------------------------------------*/ +#if !defined(fetch_hw_noswap) + #if defined(fetch_hw) + #define fetch_hw_noswap(_p) CSWAP16(fetch_hw((_p))) + #else + #if !defined(OPTION_STRICT_ALIGNMENT) + static __inline__ U16 fetch_hw_noswap(void *ptr) { + return *(U16 *)ptr; + } + #else + static __inline__ U16 fetch_hw_noswap(void *ptr) { + U16 value; + memcpy(&value, (BYTE *)ptr, 2); + return value; + } + #endif + #endif +#endif +#if !defined(fetch_hw) + #define fetch_hw(_p) CSWAP16(fetch_hw_noswap((_p))) +#endif + +/*------------------------------------------------------------------- + * store_hw_noswap and store_hw + *-------------------------------------------------------------------*/ +#if !defined(store_hw_noswap) + #if defined(store_hw) + #define store_hw_noswap(_p, _v) store_hw((_p), CSWAP16(_v)) + #else + #if !defined(OPTION_STRICT_ALIGNMENT) + static __inline__ void store_hw_noswap(void *ptr, U16 value) { + *(U16 *)ptr = value; + } + #else + static __inline__ void store_hw_noswap(void *ptr, U16 value) { + memcpy((BYTE *)ptr, (BYTE *)&value, 2); + } + #endif + #endif +#endif +#if !defined(store_hw) + #define store_hw(_p, _v) store_hw_noswap((_p), CSWAP16((_v))) +#endif + +/*------------------------------------------------------------------- + * fetch_fw_noswap and fetch_fw + *-------------------------------------------------------------------*/ +#if !defined(fetch_fw_noswap) + #if defined(fetch_fw) + #define fetch_fw_noswap(_p) CSWAP32(fetch_fw((_p))) + #else + #if !defined(OPTION_STRICT_ALIGNMENT) + static __inline__ U32 fetch_fw_noswap(const void *ptr) { + return *(U32 *)ptr; + } + #else + static __inline__ U32 fetch_fw_noswap(const void *ptr) { + U32 value; + memcpy(&value, (BYTE *)ptr, 4); + return value; + } + #endif + #endif +#endif +#if !defined(fetch_fw) + #define fetch_fw(_p) CSWAP32(fetch_fw_noswap((_p))) +#endif + +/*------------------------------------------------------------------- + * store_fw_noswap and store_fw + *-------------------------------------------------------------------*/ +#if !defined(store_fw_noswap) + #if defined(store_fw) + #define store_fw_noswap(_p, _v) store_fw((_p), CSWAP32(_v)) + #else + #if !defined(OPTION_STRICT_ALIGNMENT) + static __inline__ void store_fw_noswap(void *ptr, U32 value) { + *(U32 *)ptr = value; + } + #else + static __inline__ void store_fw_noswap(void *ptr, U32 value) { + memcpy((BYTE *)ptr, (BYTE *)&value, 4); + } + #endif + #endif +#endif +#if !defined(store_fw) + #define store_fw(_p, _v) store_fw_noswap((_p), CSWAP32((_v))) +#endif + +/*------------------------------------------------------------------- + * fetch_dw_noswap and fetch_dw + *-------------------------------------------------------------------*/ +#if !defined(fetch_dw_noswap) + #if defined(fetch_dw) + #define fetch_dw_noswap(_p) CSWAP64(fetch_dw((_p))) + #else + #if !defined(OPTION_STRICT_ALIGNMENT) + static __inline__ U64 fetch_dw_noswap(void *ptr) { + return *(U64 *)ptr; + } + #else + static __inline__ U64 fetch_dw_noswap(void *ptr) { + U64 value; + memcpy(&value, (BYTE *)ptr, 8); + return value; + } + #endif + #endif +#endif +#if !defined(fetch_dw) + #define fetch_dw(_p) CSWAP64(fetch_dw_noswap((_p))) +#endif + +/*------------------------------------------------------------------- + * store_dw_noswap and store_dw + *-------------------------------------------------------------------*/ +#if !defined(store_dw_noswap) + #if defined(store_dw) + #define store_dw_noswap(_p, _v) store_dw((_p), CSWAP64(_v)) + #else + #if !defined(OPTION_STRICT_ALIGNMENT) + static __inline__ void store_dw_noswap(void *ptr, U64 value) { + *(U64 *)ptr = value; + } + #else + static __inline__ void store_dw_noswap(void *ptr, U64 value) { + memcpy((BYTE *)ptr, (BYTE *)&value, 8); + } + #endif + #endif +#endif +#if !defined(store_dw) + #define store_dw(_p, _v) store_dw_noswap((_p), CSWAP64((_v))) +#endif + +/*------------------------------------------------------------------- + * cmpxchg1 + *-------------------------------------------------------------------*/ +#ifndef cmpxchg1 +static __inline__ BYTE cmpxchg1(BYTE *old, BYTE new, volatile void *ptr) { + BYTE code; + if (*old == *(BYTE *)ptr) + { + *(BYTE *)ptr = new; + code = 0; + } + else + { + *old = *(BYTE *)ptr; + code = 1; + } + return code; +} +#endif + +/*------------------------------------------------------------------- + * cmpxchg4 + *-------------------------------------------------------------------*/ +#ifndef cmpxchg4 +static __inline__ BYTE cmpxchg4(U32 *old, U32 new, volatile void *ptr) { + BYTE code; + if (*old == *(U32 *)ptr) + { + *(U32 *)ptr = new; + code = 0; + } + else + { + *old = *(U32 *)ptr; + code = 1; + } + return code; +} +#endif + +/*------------------------------------------------------------------- + * cmpxchg8 + *-------------------------------------------------------------------*/ +#ifndef cmpxchg8 +static __inline__ BYTE cmpxchg8(U64 *old, U64 new, volatile void *ptr) { + BYTE code; + if (*old == *(U64 *)ptr) + { + *(U64 *)ptr = new; + code = 0; + } + else + { + *old = *(U64 *)ptr; + code = 1; + } + return code; +} +#endif + +/*------------------------------------------------------------------- + * cmpxchg16 + *-------------------------------------------------------------------*/ +#ifndef cmpxchg16 +static __inline__ int cmpxchg16(U64 *old1, U64 *old2, U64 new1, U64 new2, volatile void *ptr) { + int code; + if (*old1 == *(U64 *)ptr && *old2 == *((U64 *)ptr + 1)) + { + *(U64 *)ptr = new1; + *((U64 *)ptr + 1) = new2; + code = 0; + } + else + { + *old1 = *((U64 *)ptr); + *old2 = *((U64 *)ptr + 1); + code = 1; + } + return code; +} +#endif + +#ifndef BIT +#define BIT(nr) (1<<(nr)) +#endif + +#endif /* _HERCULES_MACHDEP_H */ --- hercules-3.13.orig/.pc/applied-patches +++ hercules-3.13/.pc/applied-patches @@ -0,0 +1,2 @@ +always-strict-alignment.patch +check-if-topmsg-is-initialized.patch --- hercules-3.13.orig/.pc/check-if-topmsg-is-initialized.patch/panel.c +++ hercules-3.13/.pc/check-if-topmsg-is-initialized.patch/panel.c @@ -0,0 +1,3057 @@ +/* PANEL.C (c) Copyright Roger Bowler, 1999-2010 */ +/* Hercules Control Panel Commands */ + +/* Modified for New Panel Display =NP= */ +/*-------------------------------------------------------------------*/ +/* This module is the control panel for the ESA/390 emulator. */ +/* It provides a command interface into hercules, and it displays */ +/* messages that are issued by various hercules components. */ +/*-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------*/ +/* Additional credits: */ +/* breakpoint command contributed by Dan Horak */ +/* devinit command contributed by Jay Maynard */ +/* New Panel Display contributed by Dutch Owen */ +/* HMC system console commands contributed by Jan Jaeger */ +/* Set/reset bad frame indicator command by Jan Jaeger */ +/* attach/detach/define commands by Jan Jaeger */ +/* Panel refresh rate triva by Reed H. Petty */ +/* z/Architecture support - (c) Copyright Jan Jaeger, 1999-2007 */ +/* 64-bit address support by Roger Bowler */ +/* Display subchannel command by Nobumichi Kozawa */ +/* External GUI logic contributed by "Fish" (David B. Trout) */ +/* Socket Devices originally designed by Malcolm Beattie; */ +/* actual implementation by "Fish" (David B. Trout). */ +/*-------------------------------------------------------------------*/ + +#include "hstdinc.h" + +#define _PANEL_C_ +#define _HENGINE_DLL_ + +#include "hercules.h" +#include "devtype.h" +#include "opcode.h" +#include "history.h" +// #include "inline.h" +#include "fillfnam.h" +#include "hconsole.h" + +#define DISPLAY_INSTRUCTION_OPERANDS + +#define PANEL_MAX_ROWS (256) +#define PANEL_MAX_COLS (256) + +int redraw_msgs; /* 1=Redraw message area */ +int redraw_cmd; /* 1=Redraw command line */ +int redraw_status; /* 1=Redraw status line */ + +/*=NP================================================================*/ +/* Global data for new panel display */ +/* (Note: all NPD mods are identified by the string =NP= */ +/*===================================================================*/ + +static int NPDup = 0; /* 1 = new panel is up */ +static int NPDinit = 0; /* 1 = new panel initialized */ +static int NPhelpup = 0; /* 1 = help panel showing */ +static int NPhelppaint = 1; /* 1 = help pnl s/b painted */ +static int NPhelpdown = 0; /* 1 = help pnl coming down */ +static int NPregdisp = 0; /* which regs are displayed: */ + /* 0=gpr, 1=cr, 2=ar, 3=fpr */ +static int NPcmd = 0; /* 1 = NP in command mode */ +static int NPdataentry = 0; /* 1 = NP in data-entry mode */ +static int NPdevsel = 0; /* 1 = device being selected */ +static char NPpending; /* pending data entry cmd */ +static char NPentered[256]; /* Data which was entered */ +static char NPprompt1[40]; /* Left bottom screen prompt */ +static char NPoldprompt1[40]; /* Left bottom screen prompt */ +static char NPprompt2[40]; /* Right bottom screen prompt*/ +static char NPoldprompt2[40]; /* Right bottom screen prompt*/ +static char NPsel2; /* dev sel part 2 cmd letter */ +static char NPdevice; /* Which device is selected */ +static int NPasgn; /* Index to dev being init'ed*/ +static int NPlastdev; /* Number of devices */ +static int NPcpugraph_ncpu; /* Number of CPUs to display */ + +static char *NPregnum[] = {" 0"," 1"," 2"," 3"," 4"," 5"," 6"," 7", + " 8"," 9","10","11","12","13","14","15" + }; +static char *NPregnum64[] = {"0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", "A", "B", "C", "D", "E", "F" + }; + +/* Boolean fields; redraw the corresponding data field if false */ +static int NPcpunum_valid, + NPcpupct_valid, + NPpsw_valid, + NPpswstate_valid, + NPregs_valid, + NPaddr_valid, + NPdata_valid, +#ifdef OPTION_MIPS_COUNTING + NPmips_valid, + NPsios_valid, +#endif // OPTION_MIPS_COUNTING + NPdevices_valid, + NPcpugraph_valid; + +/* Current CPU states */ +static U16 NPcpunum; +static int NPcpupct; +static int NPpswmode; +static int NPpswzhost; +static QWORD NPpsw; +static char NPpswstate[16]; +static int NPregmode; +static int NPregzhost; +static U64 NPregs64[16]; +static U32 NPregs[16]; +static U32 NPaddress; +static U32 NPdata; +#ifdef OPTION_MIPS_COUNTING +static U32 NPmips; +static U32 NPsios; +#else +static U64 NPinstcount; +#endif // OPTION_MIPS_COUNTING +static int NPcpugraph; +static int NPcpugraphpct[MAX_CPU_ENGINES]; + +/* Current device states */ +#define NP_MAX_DEVICES (PANEL_MAX_ROWS - 3) +static int NPonline[NP_MAX_DEVICES]; +static U16 NPdevnum[NP_MAX_DEVICES]; +static int NPbusy[NP_MAX_DEVICES]; +static U16 NPdevtype[NP_MAX_DEVICES]; +static int NPopen[NP_MAX_DEVICES]; +static char NPdevnam[NP_MAX_DEVICES][128]; + +static short NPcurrow, NPcurcol; +static int NPcolorSwitch; +static short NPcolorFore; +static short NPcolorBack; +static int NPdatalen; + +static char *NPhelp[] = { +"All commands consist of one character keypresses. The various commands are", +"highlighted onscreen by bright white versus the gray of other lettering.", +" ", +"Press the escape key to terminate the control panel and go to command mode.", +" ", +"Display Controls: G - General purpose regs C - Control regs", +" A - Access registers F - Floating Point regs", +" I - Display main memory at 'ADDRESS'", +"CPU controls: L - IPL S - Start CPU", +" E - External interrupt P - Stop CPU", +" W - Exit Hercules T - Restart interrupt", +"Storage update: R - Enter ADDRESS to be updated", +" D - Enter DATA to be updated at ADDRESS", +" O - place DATA value at ADDRESS", +" ", +"Peripherals: N - enter a new name for the device file assignment", +" U - send an I/O attention interrupt", +" ", +"In the display of devices, a green device letter means the device is online,", +"a lighted device address means the device is busy, and a green model number", +"means the attached file is open to the device", +" ", +" Press Escape to return to control panel operations", +"" }; + +/////////////////////////////////////////////////////////////////////// + +#define MSG_SIZE PANEL_MAX_COLS /* Size of one message */ +#define MAX_MSGS 2048 /* Number of slots in buffer */ +//#define MAX_MSGS 300 /* (for testing scrolling) */ +#define MSG_LINES (cons_rows - 2) /* #lines in message area */ +#define SCROLL_LINES (MSG_LINES - numkept) /* #of scrollable lines */ +#define CMD_SIZE 256 /* cmdline buffer size */ + +/////////////////////////////////////////////////////////////////////// + +static int cons_rows = 0; /* console height in lines */ +static int cons_cols = 0; /* console width in chars */ +static short cur_cons_row = 0; /* current console row */ +static short cur_cons_col = 0; /* current console column */ +static char *cons_term = NULL; /* TERM env value */ +static char cmdins = 1; /* 1==insert mode, 0==overlay*/ + +static char cmdline[CMD_SIZE+1]; /* Command line buffer */ +static int cmdlen = 0; /* cmdline data len in bytes */ +static int cmdoff = 0; /* cmdline buffer cursor pos */ + +static int cursor_on_cmdline = 1; /* bool: cursor on cmdline */ +static char saved_cmdline[CMD_SIZE+1]; /* Saved command */ +static int saved_cmdlen = 0; /* Saved cmdline data len */ +static int saved_cmdoff = 0; /* Saved cmdline buffer pos */ +static short saved_cons_row = 0; /* Saved console row */ +static short saved_cons_col = 0; /* Saved console column */ + +static int cmdcols = 0; /* visible cmdline width cols*/ +static int cmdcol = 0; /* cols cmdline scrolled righ*/ +static FILE *confp = NULL; /* Console file pointer */ + +/////////////////////////////////////////////////////////////////////// + +#define CMD_PREFIX_STR "Command ==> " /* Keep same len as below! */ +#ifdef OPTION_CMDTGT +#define CMD_PREFIX_STR1 "SCP ======> " /* Keep same len as above! */ +#define CMD_PREFIX_STR2 "PrioSCP ==> " /* Keep same len as above! */ +#endif // OPTION_CMDTGT + +#define CMD_PREFIX_LEN (strlen(CMD_PREFIX_STR)) +#define CMDLINE_ROW ((short)(cons_rows-1)) +#define CMDLINE_COL ((short)(CMD_PREFIX_LEN+1)) + +/////////////////////////////////////////////////////////////////////// + +#define ADJ_SCREEN_SIZE() \ + do { \ + int rows, cols; \ + get_dim (&rows, &cols); \ + if (rows != cons_rows || cols != cons_cols) { \ + cons_rows = rows; \ + cons_cols = cols; \ + cmdcols = cons_cols - CMDLINE_COL; \ + redraw_msgs = redraw_cmd = redraw_status = 1; \ + NPDinit = 0; \ + clr_screen(); \ + } \ + } while (0) + +#define ADJ_CMDCOL() /* (called after modifying cmdoff) */ \ + do { \ + if (cmdoff-cmdcol > cmdcols) { /* past right edge of screen */ \ + cmdcol = cmdoff-cmdcols; \ + } else if (cmdoff < cmdcol) { /* past left edge of screen */ \ + cmdcol = cmdoff; \ + } \ + } while (0) + +#define PUTC_CMDLINE() \ + do { \ + ASSERT(cmdcol <= cmdlen); \ + for (i=0; cmdcol+i < cmdlen && i < cmdcols; i++) \ + draw_char (cmdline[cmdcol+i]); \ + } while (0) + +/////////////////////////////////////////////////////////////////////// + +typedef struct _PANMSG /* Panel message control block structure */ +{ + struct _PANMSG* next; /* --> next entry in chain */ + struct _PANMSG* prev; /* --> prev entry in chain */ + int msgnum; /* msgbuf 0-relative entry# */ + char msg[MSG_SIZE]; /* text of panel message */ +#if defined(OPTION_MSGCLR) + short fg; /* text color */ + short bg; /* screen background color */ +#if defined(OPTION_MSGHLD) + int keep:1; /* sticky flag */ + struct timeval expiration; /* when to unstick if sticky */ +#endif // defined(OPTION_MSGHLD) +#endif // defined(OPTION_MSGCLR) +} +PANMSG; /* Panel message control block structure */ + +static PANMSG* msgbuf; /* Circular message buffer */ +static PANMSG* topmsg; /* message at top of screen */ +static PANMSG* curmsg; /* newest message */ +static int wrapped = 0; /* wrapped-around flag */ +static int numkept = 0; /* count of kept messages */ +static int npquiet = 0; /* screen updating flag */ + +/////////////////////////////////////////////////////////////////////// + +static char *lmsbuf = NULL; /* xxx */ +static int lmsndx = 0; /* xxx */ +static int lmsnum = -1; /* xxx */ +static int lmscnt = -1; /* xxx */ +static int lmsmax = LOG_DEFSIZE/2; /* xxx */ +static int keybfd = -1; /* Keyboard file descriptor */ + +static REGS copyregs, copysieregs; /* Copied regs */ + +/////////////////////////////////////////////////////////////////////// + +#if defined(OPTION_MSGCLR) /* -- Message coloring build option -- */ +#if defined(OPTION_MSGHLD) /* -- Sticky messages build option -- */ + +#define KEEP_TIMEOUT_SECS 120 /* #seconds kept msgs expire */ +static PANMSG* keptmsgs; /* start of keep chain */ +static PANMSG* lastkept; /* last entry in keep chain */ + +/*-------------------------------------------------------------------*/ +/* Remove and Free a keep chain entry from the keep chain */ +/*-------------------------------------------------------------------*/ +static void unkeep( PANMSG* pk ) +{ + if (pk->prev) + pk->prev->next = pk->next; + if (pk->next) + pk->next->prev = pk->prev; + if (pk == keptmsgs) + keptmsgs = pk->next; + if (pk == lastkept) + lastkept = pk->prev; + free( pk ); + numkept--; +} + +/*-------------------------------------------------------------------*/ +/* Allocate and Add a new kept message to the keep chain */ +/*-------------------------------------------------------------------*/ +static void keep( PANMSG* p ) +{ + PANMSG* pk; + ASSERT( p->keep ); + pk = malloc( sizeof(PANMSG) ); + memcpy( pk, p, sizeof(PANMSG) ); + if (!keptmsgs) + keptmsgs = pk; + pk->next = NULL; + pk->prev = lastkept; + if (lastkept) + lastkept->next = pk; + lastkept = pk; + numkept++; + /* Must ensure we always have at least 2 scrollable lines */ + while (SCROLL_LINES < 2) + { + /* Permanently unkeep oldest kept message */ + msgbuf[keptmsgs->msgnum].keep = 0; + unkeep( keptmsgs ); + } +} + +/*-------------------------------------------------------------------*/ +/* Remove a kept message from the kept chain */ +/*-------------------------------------------------------------------*/ +static void unkeep_by_keepnum( int keepnum, int perm ) +{ + PANMSG* pk; + int i; + + /* Validate call */ + if (!numkept || keepnum < 0 || keepnum > numkept-1) + { + ASSERT(FALSE); // bad 'keepnum' passed! + return; + } + + /* Chase keep chain to find kept message to be unkept */ + for (i=0, pk=keptmsgs; pk && i != keepnum; pk = pk->next, i++); + + /* If kept message found, unkeep it */ + if (pk) + { + if (perm) + { + msgbuf[pk->msgnum].keep = 0; + +#if defined(_DEBUG) || defined(DEBUG) + msgbuf[pk->msgnum].fg = COLOR_YELLOW; +#endif // defined(_DEBUG) || defined(DEBUG) + } + unkeep(pk); + } +} +#endif // defined(OPTION_MSGHLD) +#endif // defined(OPTION_MSGCLR) + +#if defined(OPTION_MSGHLD) +/*-------------------------------------------------------------------*/ +/* unkeep messages once expired */ +/*-------------------------------------------------------------------*/ +void expire_kept_msgs(int unconditional) +{ + struct timeval now; + PANMSG *pk = keptmsgs; + int i; + + gettimeofday(&now, NULL); + + while (pk) + { + for (i=0, pk=keptmsgs; pk; i++, pk = pk->next) + { + if (unconditional || now.tv_sec >= pk->expiration.tv_sec) + { + unkeep_by_keepnum(i,1); // remove message from chain + break; // start over again from the beginning + } + } + } +} +#endif // defined(OPTION_MSGHLD) + +#if defined(OPTION_MSGCLR) /* -- Message coloring build option -- */ +/*-------------------------------------------------------------------*/ +/* Get the color name from a string */ +/*-------------------------------------------------------------------*/ + +#define CHECKCOLOR(s, cs, c, cc) if(!strncasecmp(s, cs, sizeof(cs) - 1)) { *c = cc; return(sizeof(cs) - 1); } + +int get_color(char *string, short *color) +{ + CHECKCOLOR(string, "black", color, COLOR_BLACK) + else CHECKCOLOR(string, "cyan", color, COLOR_CYAN) + else CHECKCOLOR(string, "blue", color, COLOR_BLUE) + else CHECKCOLOR(string, "darkgrey", color, COLOR_DARK_GREY) + else CHECKCOLOR(string, "green", color, COLOR_GREEN) + else CHECKCOLOR(string, "lightblue", color, COLOR_LIGHT_BLUE) + else CHECKCOLOR(string, "lightcyan", color, COLOR_LIGHT_CYAN) + else CHECKCOLOR(string, "lightgreen", color, COLOR_LIGHT_GREEN) + else CHECKCOLOR(string, "lightgrey", color, COLOR_LIGHT_GREY) + else CHECKCOLOR(string, "lightmagenta", color, COLOR_LIGHT_MAGENTA) + else CHECKCOLOR(string, "lightred", color, COLOR_LIGHT_RED) + else CHECKCOLOR(string, "lightyellow", color, COLOR_LIGHT_YELLOW) + else CHECKCOLOR(string, "magenta", color, COLOR_MAGENTA) + else CHECKCOLOR(string, "red", color, COLOR_RED) + else CHECKCOLOR(string, "white", color, COLOR_WHITE) + else CHECKCOLOR(string, "yellow", color, COLOR_YELLOW) + else return(0); +} + +/*-------------------------------------------------------------------*/ +/* Read, process and remove the "" colorizing message prefix */ +/* Syntax: */ +/* */ +/* Mandatory prefix "" */ +/* Valid tokens: */ +/* color(fg, bg) specifies the message's color */ +/* keep keeps message on screen until removed */ +/*-------------------------------------------------------------------*/ +void colormsg(PANMSG *p) +{ + int i = 0; // current message text index + int len; // length of color-name token + + if(!strncasecmp(p->msg, "" panel command(s) + i += 4; + while(p->msg[i] == ',') + { + i += 1; // skip , + if(!strncasecmp(&p->msg[i], "color(", 6)) + { + // inspect color command + i += 6; // skip color( + len = get_color(&p->msg[i], &p->fg); + if(!len) + break; // no valid color found + i += len; // skip colorname + if(p->msg[i] != ',') + break; // no , + i++; // skip , + len = get_color(&p->msg[i], &p->bg); + if(!len) + break; // no valid color found + i += len; // skip colorname + if(p->msg[i] != ')') + break; // no ) + i++; // skip ) + } + else if(!strncasecmp(&p->msg[i], "keep", 4)) + { +#if defined(OPTION_MSGHLD) + p->keep = 1; + gettimeofday(&p->expiration, NULL); + p->expiration.tv_sec += sysblk.keep_timeout_secs; +#endif // defined(OPTION_MSGHLD) + i += 4; // skip keep + } + else + break; // rubbish + } + if(p->msg[i] == '>') + { + // Remove "" string from message + i += 1; + memmove(p->msg, &p->msg[i], MSG_SIZE - i); + memset(&p->msg[MSG_SIZE - i], SPACE, i); + return; + } + } + + /* rubbish or no panel command */ + p->fg = COLOR_DEFAULT_FG; + p->bg = COLOR_DEFAULT_BG; +#if defined(OPTION_MSGHLD) + p->keep = 0; +#endif // defined(OPTION_MSGHLD) +} +#endif // defined(OPTION_MSGCLR) + +/*-------------------------------------------------------------------*/ +/* Screen manipulation primitives */ +/*-------------------------------------------------------------------*/ + +static void beep() +{ + console_beep( confp ); +} + +static PANMSG* oldest_msg() +{ + return (wrapped) ? curmsg->next : msgbuf; +} + +static PANMSG* newest_msg() +{ + return curmsg; +} + +static int lines_scrolled() +{ + /* return # of lines 'up' from current line that we're scrolled. */ + if (topmsg->msgnum <= curmsg->msgnum) + return curmsg->msgnum - topmsg->msgnum; + return MAX_MSGS - (topmsg->msgnum - curmsg->msgnum); +} + +static int visible_lines() +{ + return (lines_scrolled() + 1); +} + +static int is_currline_visible() +{ + return (visible_lines() <= SCROLL_LINES); +} + +static int lines_remaining() +{ + return (SCROLL_LINES - visible_lines()); +} + +static void scroll_up_lines( int numlines, int doexpire ) +{ + int i; + +#if defined(OPTION_MSGHLD) + if (doexpire) + expire_kept_msgs(0); +#else + UNREFERENCED(doexpire); +#endif // defined(OPTION_MSGHLD) + + for (i=0; i < numlines && topmsg != oldest_msg(); i++) + { + topmsg = topmsg->prev; + +#if defined(OPTION_MSGHLD) + // If new topmsg is simply the last entry in the keep chain + // then we didn't really backup a line (all we did was move + // our topmsg ptr), so if that's the case then we need to + // continue backing up until we reach a non-kept message. + // Only then is the screen actually scrolled up one line. + + while (1 + && topmsg->keep + && lastkept + && lastkept->msgnum == topmsg->msgnum + ) + { + unkeep( lastkept ); + if (topmsg == oldest_msg()) + break; + topmsg = topmsg->prev; + } +#endif // defined(OPTION_MSGHLD) + } +} + +static void scroll_down_lines( int numlines, int doexpire ) +{ + int i; + +#if defined(OPTION_MSGHLD) + if (doexpire) + expire_kept_msgs(0); +#else + UNREFERENCED(doexpire); +#endif // defined(OPTION_MSGHLD) + + for (i=0; i < numlines && topmsg != newest_msg(); i++) + { +#if defined(OPTION_MSGHLD) + // If the topmsg should be kept and is not already in our + // keep chain, then adding it to our keep chain before + // setting topmsg to the next entry does not really scroll + // the screen any (all it does is move the topmsg ptr), + // so if that's the case then we need to keep doing that + // until we eventually find the next non-kept message. + // Only then is the screen really scrolled down one line. + + while (1 + && topmsg->keep + && (!lastkept || topmsg->msgnum != lastkept->msgnum) + ) + { + keep( topmsg ); + topmsg = topmsg->next; + if (topmsg == newest_msg()) + break; + } +#endif // defined(OPTION_MSGHLD) + if (topmsg != newest_msg()) + topmsg = topmsg->next; + } +} + +static void page_up( int doexpire ) +{ +#if defined(OPTION_MSGHLD) + if (doexpire) + expire_kept_msgs(0); +#else + UNREFERENCED(doexpire); +#endif // defined(OPTION_MSGHLD) + scroll_up_lines( SCROLL_LINES - 1, 0 ); +} +static void page_down( int doexpire ) +{ +#if defined(OPTION_MSGHLD) + if (doexpire) + expire_kept_msgs(0); +#else + UNREFERENCED(doexpire); +#endif // defined(OPTION_MSGHLD) + scroll_down_lines( SCROLL_LINES - 1, 0 ); +} + +static void scroll_to_top_line( int doexpire ) +{ +#if defined(OPTION_MSGHLD) + if (doexpire) + expire_kept_msgs(0); +#else + UNREFERENCED(doexpire); +#endif // defined(OPTION_MSGHLD) + topmsg = oldest_msg(); +#if defined(OPTION_MSGHLD) + while (keptmsgs) + unkeep( keptmsgs ); +#endif // defined(OPTION_MSGHLD) +} + +static void scroll_to_bottom_line( int doexpire ) +{ +#if defined(OPTION_MSGHLD) + if (doexpire) + expire_kept_msgs(0); +#else + UNREFERENCED(doexpire); +#endif // defined(OPTION_MSGHLD) + while (topmsg != newest_msg()) + scroll_down_lines( 1, 0 ); +} + +static void scroll_to_bottom_screen( int doexpire ) +{ +#if defined(OPTION_MSGHLD) + if (doexpire) + expire_kept_msgs(0); +#else + UNREFERENCED(doexpire); +#endif // defined(OPTION_MSGHLD) + scroll_to_bottom_line( 0 ); + page_up( 0 ); +} + +static void do_panel_command( void* cmd ) +{ + if (!is_currline_visible()) + scroll_to_bottom_screen( 1 ); + if (cmd != (void*)cmdline) + strlcpy( cmdline, cmd, sizeof(cmdline) ); + panel_command( cmdline ); + cmdline[0] = '\0'; + cmdlen = 0; + cmdoff = 0; + ADJ_CMDCOL(); +} + +static void do_prev_history() +{ + if (history_prev() != -1) + { + strcpy(cmdline, historyCmdLine); + cmdlen = strlen(cmdline); + cmdoff = cmdlen < cmdcols ? cmdlen : 0; + ADJ_CMDCOL(); + } +} + +static void do_next_history() +{ + if (history_next() != -1) + { + strcpy(cmdline, historyCmdLine); + cmdlen = strlen(cmdline); + cmdoff = cmdlen < cmdcols ? cmdlen : 0; + ADJ_CMDCOL(); + } +} + +static void clr_screen () +{ + clear_screen (confp); +} + +static void get_dim (int *y, int *x) +{ + get_console_dim( confp, y, x); + if (*y > PANEL_MAX_ROWS) + *y = PANEL_MAX_ROWS; + if (*x > PANEL_MAX_COLS) + *x = PANEL_MAX_COLS; +#if defined(WIN32) && !defined( _MSVC_ ) + /* If running from a cygwin command prompt we do + * better with one less row. + */ + if (!cons_term || strcmp(cons_term, "xterm")) + (*y)--; +#endif // defined(WIN32) && !defined( _MSVC_ ) +} + +#if defined(OPTION_EXTCURS) +static int get_keepnum_by_row( int row ) +{ + // PROGRAMMING NOTE: right now all of our kept messages are + // always placed at the very top of the screen (starting on + // line 1), but should we at some point in the future decide + // to use the very top line of the screen for something else + // (such as a title or status line for example), then all we + // need to do is modify the below variable and the code then + // adjusts itself automatically. (I try to avoid hard-coded + // constants whenever possible). -- Fish + + static int keep_beg_row = 1; // screen 1-relative line# of first kept msg + + if (0 + || row < keep_beg_row + || row > (keep_beg_row + numkept - 1) + ) + return -1; + + return (row - keep_beg_row); +} +#endif /*defined(OPTION_EXTCURS)*/ + +static void set_color (short fg, short bg) +{ + set_screen_color (confp, fg, bg); +} + +static void set_pos (short y, short x) +{ + cur_cons_row = y; + cur_cons_col = x; + y = y < 1 ? 1 : y > cons_rows ? cons_rows : y; + x = x < 1 ? 1 : x > cons_cols ? cons_cols : x; + set_screen_pos (confp, y, x); +} + +static int is_cursor_on_cmdline() +{ +#if defined(OPTION_EXTCURS) + get_cursor_pos( keybfd, confp, &cur_cons_row, &cur_cons_col ); + cursor_on_cmdline = + (1 + && cur_cons_row == CMDLINE_ROW + && cur_cons_col >= CMDLINE_COL + && cur_cons_col <= CMDLINE_COL + cmdcols + ); +#else // !defined(OPTION_EXTCURS) + cursor_on_cmdline = 1; +#endif // defined(OPTION_EXTCURS) + return cursor_on_cmdline; +} + +static void cursor_cmdline_home() +{ + cmdoff = 0; + ADJ_CMDCOL(); + set_pos( CMDLINE_ROW, CMDLINE_COL ); +} + +static void cursor_cmdline_end() +{ + cmdoff = cmdlen; + ADJ_CMDCOL(); + set_pos( CMDLINE_ROW, CMDLINE_COL + cmdoff - cmdcol ); +} + +static void save_command_line() +{ + memcpy( saved_cmdline, cmdline, sizeof(saved_cmdline) ); + saved_cmdlen = cmdlen; + saved_cmdoff = cmdoff; + saved_cons_row = cur_cons_row; + saved_cons_col = cur_cons_col; +} + +static void restore_command_line() +{ + memcpy( cmdline, saved_cmdline, sizeof(cmdline) ); + cmdlen = saved_cmdlen; + cmdoff = saved_cmdoff; + cur_cons_row = saved_cons_row; + cur_cons_col = saved_cons_col; +} + +static void draw_text (char *text) +{ + int len; + char *short_text; + + if (cur_cons_row < 1 || cur_cons_row > cons_rows + || cur_cons_col < 1 || cur_cons_col > cons_cols) + return; + len = strlen(text); + if ((cur_cons_col + len - 1) <= cons_cols) + fprintf (confp, "%s", text); + else + { + len = cons_cols - cur_cons_col + 1; + if ((short_text = strdup(text)) == NULL) + return; + short_text[len] = '\0'; + fprintf (confp, "%s", short_text); + free (short_text); + } + cur_cons_col += len; +} + +static void write_text (char *text, int size) +{ + if (cur_cons_row < 1 || cur_cons_row > cons_rows + || cur_cons_col < 1 || cur_cons_col > cons_cols) + return; + if (cons_cols - cur_cons_col + 1 < size) + size = cons_cols - cur_cons_col + 1; + fwrite (text, size, 1, confp); + cur_cons_col += size; +} + +static void draw_char (int c) +{ + if (cur_cons_row < 1 || cur_cons_row > cons_rows + || cur_cons_col < 1 || cur_cons_col > cons_cols) + return; + fputc (c, confp); + cur_cons_col++; +} + +static void draw_fw (U32 fw) +{ + char buf[9]; + sprintf (buf, "%8.8X", fw); + draw_text (buf); +} + +static void draw_dw (U64 dw) +{ + char buf[17]; + sprintf (buf, "%16.16"I64_FMT"X", dw); + draw_text (buf); +} + +static void fill_text (char c, short x) +{ + char buf[PANEL_MAX_COLS+1]; + int len; + + if (x > PANEL_MAX_COLS) x = PANEL_MAX_COLS; + len = x + 1 - cur_cons_col; + if (len <= 0) return; + memset (buf, c, len); + buf[len] = '\0'; + draw_text (buf); +} + +static void draw_button (short bg, short fg, short hfg, char *left, char *mid, char *right) +{ + set_color (fg, bg); + draw_text (left); + set_color (hfg, bg); + draw_text (mid); + set_color (fg, bg); + draw_text (right); +} + +static void set_console_title () +{ + if (!sysblk.pantitle) return; + + #if defined( _MSVC_ ) + w32_set_console_title(sysblk.pantitle); + #else /*!defined(_MSVC_) */ + /* For Unix systems we set the window title by sending a special + escape sequence (depends on terminal type) to the console. + See http://www.faqs.org/docs/Linux-mini/Xterm-Title.html */ + if (!cons_term) return; + if (strcmp(cons_term,"xterm")==0 + || strcmp(cons_term,"rxvt")==0 + || strcmp(cons_term,"dtterm")==0 + || strcmp(cons_term,"screen")==0) + { + fprintf(confp,"%c]0;%s%c",'\033',sysblk.pantitle,'\007'); + } + #endif /*!defined(_MSVC_) */ +} + +/*=NP================================================================*/ +/* Initialize the NP data */ +/*===================================================================*/ + +static void NP_init() +{ + NPdataentry = 0; + strcpy(NPprompt1, ""); + strcpy(NPprompt2, ""); +} + +/*=NP================================================================*/ +/* This draws the initial screen template */ +/*===================================================================*/ + +static void NP_screen_redraw (REGS *regs) +{ + int i, line; + char buf[1024]; + + /* Force all data to be redrawn */ + NPcpunum_valid = NPcpupct_valid = NPpsw_valid = + NPpswstate_valid = NPregs_valid = NPaddr_valid = + NPdata_valid = + NPdevices_valid = NPcpugraph_valid = 0; +#if defined(OPTION_MIPS_COUNTING) + NPmips_valid = NPsios_valid = 0; +#endif /*defined(OPTION_MIPS_COUNTING)*/ + +#if defined(_FEATURE_SIE) + if(regs->sie_active) + regs = regs->guestregs; +#endif /*defined(_FEATURE_SIE)*/ + + /* + * Draw the static parts of the NP screen + */ + set_color (COLOR_LIGHT_GREY, COLOR_BLACK ); + clr_screen (); + + /* Line 1 - title line */ + set_color (COLOR_WHITE, COLOR_BLUE ); + set_pos (1, 1); + draw_text (" Hercules CPU : %"); + fill_text (' ', 30); + draw_text ((char *)get_arch_mode_string(NULL)); + fill_text (' ', 38); + set_color (COLOR_LIGHT_GREY, COLOR_BLUE ); + draw_text ("| "); + set_color (COLOR_WHITE, COLOR_BLUE ); + + /* Center "Peripherals" on the right-hand-side */ + if (cons_cols > 52) + fill_text (' ', 40 + (cons_cols - 52) / 2); + draw_text ("Peripherals"); + fill_text (' ', (short)cons_cols); + + /* Line 2 - peripheral headings */ + set_pos (2, 41); + set_color (COLOR_WHITE, COLOR_BLACK); + draw_char ('U'); + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + draw_text(" Addr Modl Type Assig"); + set_color (COLOR_WHITE, COLOR_BLACK); + draw_char ('n'); + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + draw_text("ment"); + + /* 4th line - PSW */ + NPpswmode = (regs->arch_mode == ARCH_900); + NPpswzhost = +#if defined(_FEATURE_SIE) + !NPpswmode && SIE_MODE(regs) && regs->hostregs->arch_mode == ARCH_900; +#else + 0; +#endif /*defined(_FEATURE_SIE)*/ + set_pos (4, NPpswmode || NPpswzhost ? 19 : 10); + draw_text ("PSW"); + + /* Lines 6 .. 13 : register area */ + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + NPregmode = (regs->arch_mode == ARCH_900 && (NPregdisp == 0 || NPregdisp == 1)); + NPregzhost = +#if defined(_FEATURE_SIE) + (regs->arch_mode != ARCH_900 + && SIE_MODE(regs) && regs->hostregs->arch_mode == ARCH_900 + && (NPregdisp == 0 || NPregdisp == 1)); +#else + 0; +#endif /*defined(_FEATURE_SIE)*/ + if (NPregmode == 1 || NPregzhost) + { + for (i = 0; i < 8; i++) + { + set_pos (i+6, 1); + draw_text (NPregnum64[i*2]); + set_pos (i+6, 20); + draw_text (NPregnum64[i*2+1]); + } + } + else + { + for (i = 0; i < 4; i++) + { + set_pos (i*2+7,9); + draw_text (NPregnum[i*4]); + set_pos (i*2+7,18); + draw_text (NPregnum[i*4+1]); + set_pos (i*2+7,27); + draw_text (NPregnum[i*4+2]); + set_pos (i*2+7,36); + draw_text (NPregnum[i*4+3]); + } + } + + /* Line 14 : register selection */ + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + set_pos (14, 6); + draw_text ("GPR"); + set_pos (14, 14); + draw_text ("CR"); + set_pos (14, 22); + draw_text ("AR"); + set_pos (14, 30); + draw_text ("FPR"); + + /* Line 16 .. 17 : Address and data */ + set_pos (16, 2); + draw_text ("ADD"); + set_color (COLOR_WHITE, COLOR_BLACK); + draw_char ('R'); + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + draw_text ("ESS:"); + set_pos (16, 22); + set_color (COLOR_WHITE, COLOR_BLACK); + draw_char ('D'); + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + draw_text ("ATA:"); + + /* Line 18 : separator */ + set_pos (18, 1); + fill_text ('-', 38); + + /* Lines 19 .. 23 : buttons */ + + set_pos (19, 16); + draw_button(COLOR_BLUE, COLOR_LIGHT_GREY, COLOR_WHITE, " ST", "O", " " ); + set_pos (19, 24); + draw_button(COLOR_BLUE, COLOR_LIGHT_GREY, COLOR_WHITE, " D", "I", "S " ); + set_pos (19, 32); + draw_button(COLOR_BLUE, COLOR_LIGHT_GREY, COLOR_WHITE, " RS", "T", " " ); + +#if defined(OPTION_MIPS_COUNTING) + set_pos (20, 3); + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + draw_text ("MIPS"); + set_pos (20, 9); + draw_text ("SIO/s"); +#endif /*defined(OPTION_MIPS_COUNTING)*/ + + set_pos (22, 2); + draw_button(COLOR_GREEN, COLOR_LIGHT_GREY, COLOR_WHITE, " ", "S", "TR "); + set_pos (22, 9); + draw_button(COLOR_RED, COLOR_LIGHT_GREY, COLOR_WHITE, " ST", "P", " " ); + set_pos (22, 16); + draw_button(COLOR_BLUE, COLOR_LIGHT_GREY, COLOR_WHITE, " ", "E", "XT "); + set_pos (22, 24); + draw_button(COLOR_BLUE, COLOR_LIGHT_GREY, COLOR_WHITE, " IP", "L", " " ); + set_pos (22, 32); + draw_button(COLOR_RED, COLOR_LIGHT_GREY, COLOR_WHITE, " P", "W", "R " ); + + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + + /* CPU busy graph */ + line = 24; + NPcpugraph_ncpu = MIN(cons_rows - line - 2, HI_CPU); + if (HI_CPU > 0) + { + NPcpugraph = 1; + NPcpugraph_valid = 0; + set_pos (line++, 1); + fill_text ('-', 38); + set_pos (line++, 1); + draw_text ("CPU"); + for (i = 0; i < NPcpugraph_ncpu; i++) + { + sprintf (buf, "%02X ", i); + set_pos (line++, 1); + draw_text (buf); + } + } + else + NPcpugraph = 0; + + /* Vertical separators */ + for (i = 2; i <= cons_rows; i++) + { + set_pos (i , 39); + draw_char ('|'); + } + + /* Last line : horizontal separator */ + if (cons_rows >= 24) + { + set_pos (cons_rows, 1); + fill_text ('-', 38); + draw_char ('|'); + fill_text ('-', cons_cols); + } + + /* positions the cursor */ + set_pos (cons_rows, cons_cols); +} + +/*=NP================================================================*/ +/* This refreshes the screen with new data every cycle */ +/*===================================================================*/ + +static void NP_update(REGS *regs) +{ + int i, n; + int mode, zhost; + QWORD curpsw; + U32 addr, aaddr; + DEVBLK *dev; + int online, busy, open; + char *devclass; + char devnam[128]; + char buf[1024]; + + if (NPhelpup == 1) + { + if (NPhelpdown == 1) + { + NP_init(); + NP_screen_redraw(regs); + NPhelpup = 0; + NPhelpdown = 0; + NPhelppaint = 1; + } + else + { + if (NPhelppaint) + { + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + clr_screen (); + for (i = 0; strcmp(NPhelp[i], ""); i++) + { + set_pos (i+1, 1); + draw_text (NPhelp[i]); + } + NPhelppaint = 0; + } + return; + } + } + +#if defined(_FEATURE_SIE) + if(SIE_MODE(regs)) + regs = regs->hostregs; +#endif /*defined(_FEATURE_SIE)*/ + + /* line 1 : cpu number and percent busy */ + if (!NPcpunum_valid || NPcpunum != regs->cpuad) + { + set_color (COLOR_WHITE, COLOR_BLUE); + set_pos (1, 16); + sprintf (buf, "%4.4X:",regs->cpuad); + draw_text (buf); + NPcpunum_valid = 1; + NPcpunum = regs->cpuad; + } + +#if defined(OPTION_MIPS_COUNTING) + if (!NPcpupct_valid || NPcpupct != regs->cpupct) + { + set_color (COLOR_WHITE, COLOR_BLUE); + set_pos (1, 22); + sprintf(buf, "%3d", regs->cpupct); + draw_text (buf); + NPcpupct_valid = 1; + NPcpupct = regs->cpupct; + } +#else // !defined(OPTION_MIPS_COUNTING) + if (!NPcpupct_valid) + { + set_color (COLOR_WHITE, COLOR_BLUE); + set_pos (1, 21); + draw_text (" "); + NPcpupct_valid = 1; + } +#endif /*defined(OPTION_MIPS_COUNTING)*/ + +#if defined(_FEATURE_SIE) + if(regs->sie_active) + regs = regs->guestregs; +#endif /*defined(_FEATURE_SIE)*/ + + mode = (regs->arch_mode == ARCH_900); + zhost = +#if defined(_FEATURE_SIE) + !mode && SIE_MODE(regs) && regs->hostregs->arch_mode == ARCH_900; +#else // !defined(_FEATURE_SIE) + 0; +#endif // defined(_FEATURE_SIE) + + /* Redraw the psw template if the mode changed */ + if (NPpswmode != mode || NPpswzhost != zhost) + { + NPpswmode = mode; + NPpswzhost = zhost; + NPpsw_valid = NPpswstate_valid = 0; + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + set_pos (3, 1); + fill_text (' ',38); + set_pos (4, 1); + fill_text (' ', 38); + set_pos (4, NPpswmode || NPpswzhost ? 19 : 10); + draw_text ("PSW"); + } + + /* Display the psw */ + memset (curpsw, 0, sizeof(QWORD)); + copy_psw (regs, curpsw); + if (!NPpsw_valid || memcmp(NPpsw, curpsw, sizeof(QWORD))) + { + set_color (COLOR_LIGHT_YELLOW, COLOR_BLACK); + set_pos (3, 3); + if (mode) + { + draw_dw (fetch_dw(curpsw)); + set_pos (3, 22); + draw_dw (fetch_dw(curpsw+8)); + } + else if (zhost) + { + draw_fw (fetch_fw(curpsw)); +// draw_fw (0); + draw_fw (fetch_fw(curpsw+4)); /* *JJ */ + set_pos (3, 22); +// draw_fw (fetch_fw(curpsw+4) & 0x80000000 ? 0x80000000 : 0); +// draw_fw (fetch_fw(curpsw+4) & 0x7fffffff); + draw_text("----------------"); /* *JJ */ + } + else + { + draw_fw (fetch_fw(curpsw)); + set_pos (3, 12); + draw_fw (fetch_fw(curpsw+4)); + } + NPpsw_valid = 1; + memcpy (NPpsw, curpsw, sizeof(QWORD)); + } + + /* Display psw state */ + sprintf (buf, "%2d%c%c%c%c%c%c%c%c", + regs->psw.amode64 ? 64 : + regs->psw.amode ? 31 : 24, + regs->cpustate == CPUSTATE_STOPPED ? 'M' : '.', + sysblk.inststep ? 'T' : '.', + WAITSTATE (®s->psw) ? 'W' : '.', + regs->loadstate ? 'L' : '.', + regs->checkstop ? 'C' : '.', + PROBSTATE(®s->psw) ? 'P' : '.', + SIE_MODE(regs) ? 'S' : '.', + mode ? 'Z' : '.'); + if (!NPpswstate_valid || strcmp(NPpswstate, buf)) + { + set_color (COLOR_LIGHT_YELLOW, COLOR_BLACK ); + set_pos (mode || zhost ? 4 : 3, 28); + draw_text (buf); + NPpswstate_valid = 1; + strcpy (NPpswstate, buf); + } + + /* Redraw the register template if the regmode switched */ + mode = (regs->arch_mode == ARCH_900 && (NPregdisp == 0 || NPregdisp == 1)); + zhost = +#if defined(_FEATURE_SIE) + (regs->arch_mode != ARCH_900 + && SIE_MODE(regs) && regs->hostregs->arch_mode == ARCH_900 + && (NPregdisp == 0 || NPregdisp == 1)); +#else // !defined(_FEATURE_SIE) + 0; +#endif /*defined(_FEATURE_SIE)*/ + if (NPregmode != mode || NPregzhost != zhost) + { + NPregmode = mode; + NPregzhost = zhost; + NPregs_valid = 0; + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + if (NPregmode || NPregzhost) + { + /* 64 bit registers */ + for (i = 0; i < 8; i++) + { + set_pos (i+6, 1); + fill_text (' ', 38); + set_pos (i+6, 1); + draw_text (NPregnum64[i*2]); + set_pos (i+6, 20); + draw_text (NPregnum64[i*2+1]); + } + } + else + { + /* 32 bit registers */ + for (i = 0; i < 4; i++) + { + set_pos (i*2+6,1); + fill_text (' ', 38); + set_pos (i*2+7,1); + fill_text (' ', 38); + set_pos (i*2+7,9); + draw_text (NPregnum[i*4]); + set_pos (i*2+7,18); + draw_text (NPregnum[i*4+1]); + set_pos (i*2+7,27); + draw_text (NPregnum[i*4+2]); + set_pos (i*2+7,36); + draw_text (NPregnum[i*4+3]); + } + } + } + + /* Display register values */ + set_color (COLOR_LIGHT_YELLOW, COLOR_BLACK ); + if (NPregmode) + { + /* 64 bit registers */ + for (i = 0; i < 16; i++) + { + switch (NPregdisp) { + case 0: + if (!NPregs_valid || NPregs64[i] != regs->GR_G(i)) + { + set_pos (6 + i/2, 3 + (i%2)*19); + draw_dw (regs->GR_G(i)); + NPregs64[i] = regs->GR_G(i); + } + break; + case 1: + if (!NPregs_valid || NPregs64[i] != regs->CR_G(i)) + { + set_pos (6 + i/2, 3 + (i%2)*19); + draw_dw (regs->CR_G(i)); + NPregs64[i] = regs->CR_G(i); + } + break; + } + } + } + else if (NPregzhost) + { + /* 32 bit registers on 64 bit template */ + for (i = 0; i < 16; i++) + { + switch (NPregdisp) { + case 0: + if (!NPregs_valid || NPregs[i] != regs->GR_L(i)) + { + set_pos (6 + i/2, 3 + (i%2)*19); +// draw_fw (0); + draw_text("--------"); + draw_fw (regs->GR_L(i)); + NPregs[i] = regs->GR_L(i); + } + break; + case 1: + if (!NPregs_valid || NPregs[i] != regs->CR_L(i)) + { + set_pos (6 + i/2, 3 + (i%2)*19); +// draw_fw (0); + draw_text("--------"); + draw_fw (regs->CR_L(i)); + NPregs[i] = regs->CR_L(i); + } + break; + } + } + } + else + { + /* 32 bit registers */ + addr = NPaddress; + for (i = 0; i < 16; i++) + { + switch (NPregdisp) { + default: + case 0: + if (!NPregs_valid || NPregs[i] != regs->GR_L(i)) + { + set_pos (6 + (i/4)*2, 3 + (i%4)*9); + draw_fw (regs->GR_L(i)); + NPregs[i] = regs->GR_L(i); + } + break; + case 1: + if (!NPregs_valid || NPregs[i] != regs->CR_L(i)) + { + set_pos (6 + (i/4)*2, 3 + (i%4)*9); + draw_fw (regs->CR_L(i)); + NPregs[i] = regs->CR_L(i); + } + break; + case 2: + if (!NPregs_valid || NPregs[i] != regs->AR(i)) + { + set_pos (6 + (i/4)*2, 3 + (i%4)*9); + draw_fw (regs->AR(i)); + NPregs[i] = regs->AR(i); + } + break; + case 3: + if (!NPregs_valid || NPregs[i] != regs->fpr[i]) + { + set_pos (6 + (i/4)*2, 3 + (i%4)*9); + draw_fw (regs->fpr[i]); + NPregs[i] = regs->fpr[i]; + } + break; + case 4: + aaddr = APPLY_PREFIXING (addr, regs->PX); + addr += 4; + if (aaddr + 3 > regs->mainlim) + break; + if (!NPregs_valid || NPregs[i] != fetch_fw(regs->mainstor + aaddr)) + { + set_pos (6 + (i/4)*2, 3 + (i%4)*9); + draw_fw (fetch_fw(regs->mainstor + aaddr)); + NPregs[i] = fetch_fw(regs->mainstor + aaddr); + } + break; + } + } + } + + /* Update register selection indicator */ + if (!NPregs_valid) + { + set_pos (14, 6); + set_color (NPregdisp == 0 ? COLOR_LIGHT_YELLOW : COLOR_WHITE, COLOR_BLACK); + draw_char ('G'); + + set_pos (14, 14); + set_color (NPregdisp == 1 ? COLOR_LIGHT_YELLOW : COLOR_WHITE, COLOR_BLACK); + draw_char ('C'); + + set_pos (14, 22); + set_color (NPregdisp == 2 ? COLOR_LIGHT_YELLOW : COLOR_WHITE, COLOR_BLACK); + draw_char ('A'); + + set_pos (14, 30); + set_color (NPregdisp == 3 ? COLOR_LIGHT_YELLOW : COLOR_WHITE, COLOR_BLACK); + draw_char ('F'); + } + + NPregs_valid = 1; + + /* Address & Data */ + if (!NPaddr_valid) + { + set_color (COLOR_LIGHT_YELLOW, COLOR_BLACK); + set_pos (16, 12); + draw_fw (NPaddress); + NPaddr_valid = 1; + } + if (!NPdata_valid) + { + set_color (COLOR_LIGHT_YELLOW, COLOR_BLACK); + set_pos (16, 30); + draw_fw (NPdata); + NPdata_valid = 1; + } + + /* Rates */ +#ifdef OPTION_MIPS_COUNTING + if (!NPmips_valid || sysblk.mipsrate != NPmips) + { + set_color (COLOR_LIGHT_YELLOW, COLOR_BLACK); + set_pos (19, 1); + sprintf(buf, "%3.1d.%2.2d", + sysblk.mipsrate / 1000000, (sysblk.mipsrate % 1000000) / 10000); + draw_text (buf); + NPmips = sysblk.mipsrate; + NPmips_valid = 1; + } + if (!NPsios_valid || NPsios != sysblk.siosrate) + { + set_color (COLOR_LIGHT_YELLOW, COLOR_BLACK); + set_pos (19, 7); + sprintf(buf, "%7d", sysblk.siosrate); + draw_text (buf); + NPsios = sysblk.siosrate; + NPsios_valid = 1; + } +#endif /* OPTION_MIPS_COUNTING */ + + /* Optional cpu graph */ + if (NPcpugraph) + { + for (i = 0; i < NPcpugraph_ncpu; i++) + { + if (!IS_CPU_ONLINE(i)) + { + if (!NPcpugraph_valid || NPcpugraphpct[i] != -2.0) + { + set_color (COLOR_RED, COLOR_BLACK); + set_pos (26+i, 4); + draw_text ("OFFLINE"); + fill_text (' ', 38); + NPcpugraphpct[i] = -2.0; + } + } + else if (sysblk.regs[i]->cpustate != CPUSTATE_STARTED) + { + if (!NPcpugraph_valid || NPcpugraphpct[i] != -1.0) + { + set_color (COLOR_LIGHT_YELLOW, COLOR_BLACK); + set_pos (26+i, 4); + draw_text ("STOPPED"); + fill_text (' ', 38); + NPcpugraphpct[i] = -1.0; + } + } + else if (!NPcpugraph_valid || NPcpugraphpct[i] != sysblk.regs[i]->cpupct) + { + n = (34 * sysblk.regs[i]->cpupct) / 100; + if (n == 0 && sysblk.regs[i]->cpupct > 0) + n = 1; + else if (n > 34) + n = 34; + set_color (n > 17 ? COLOR_WHITE : COLOR_LIGHT_GREY, COLOR_BLACK); + set_pos (26+i, 4); + fill_text ('*', n+3); + fill_text (' ', 38); + NPcpugraphpct[i] = sysblk.regs[i]->cpupct; + } + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + } + NPcpugraph_valid = 1; + } + + /* Process devices */ + for (i = 0, dev = sysblk.firstdev; dev != NULL; i++, dev = dev->nextdev) + { + if (i >= cons_rows - 3) break; + if (!dev->allocated) continue; + + online = (dev->console && dev->connected) || strlen(dev->filename) > 0; + busy = dev->busy != 0 || IOPENDING(dev) != 0; + open = dev->fd > 2; + + /* device identifier */ + if (!NPdevices_valid || online != NPonline[i]) + { + set_pos (i+3, 41); + set_color (online ? COLOR_LIGHT_GREEN : COLOR_LIGHT_GREY, COLOR_BLACK); + draw_char (i < 26 ? 'A' + i : '.'); + NPonline[i] = online; + } + + /* device number */ + if (!NPdevices_valid || dev->devnum != NPdevnum[i] || NPbusy[i] != busy) + { + set_pos (i+3, 43); + set_color (busy ? COLOR_LIGHT_YELLOW : COLOR_LIGHT_GREY, COLOR_BLACK); + sprintf (buf, "%4.4X", dev->devnum); + draw_text (buf); + NPdevnum[i] = dev->devnum; + NPbusy[i] = busy; + } + + /* device type */ + if (!NPdevices_valid || dev->devtype != NPdevtype[i] || open != NPopen[i]) + { + set_pos (i+3, 48); + set_color (open ? COLOR_LIGHT_GREEN : COLOR_LIGHT_GREY, COLOR_BLACK); + sprintf (buf, "%4.4X", dev->devtype); + draw_text (buf); + NPdevtype[i] = dev->devtype; + NPopen[i] = open; + } + + /* device class and name */ + (dev->hnd->query)(dev, &devclass, sizeof(devnam), devnam); + if (!NPdevices_valid || strcmp(NPdevnam[i], devnam)) + { + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + set_pos (i+3, 53); + sprintf (buf, "%-4.4s", devclass); + draw_text (buf); + /* Draw device name only if they're NOT assigning a new one */ + if (0 + || NPdataentry != 1 + || NPpending != 'n' + || NPasgn != i + ) + { + set_pos (i+3, 58); + draw_text (devnam); + fill_text (' ', PANEL_MAX_COLS); + } + } + } + + /* Complete the device state table */ + if (!NPdevices_valid) + { + NPlastdev = i > 26 ? 26 : i - 1; + for ( ; i < NP_MAX_DEVICES; i++) + { + NPonline[i] = NPdevnum[i] = NPbusy[i] = NPdevtype[i] = NPopen[i] = 0; + strcpy (NPdevnam[i], ""); + } + NPdevices_valid = 1; + } + + /* Prompt 1 */ + if (strcmp(NPprompt1, NPoldprompt1)) + { + strcpy(NPoldprompt1, NPprompt1); + if (strlen(NPprompt1) > 0) + { + set_color (COLOR_WHITE, COLOR_BLUE); + set_pos (cons_rows, (40 - strlen(NPprompt1)) / 2); + draw_text (NPprompt1); + } + else if (cons_rows >= 24) + { + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + set_pos (cons_rows, 1); + fill_text ('-', 38); + } + } + + /* Prompt 2 */ + if (strcmp(NPprompt2, NPoldprompt2)) + { + strcpy(NPoldprompt2, NPprompt2); + if (strlen(NPprompt2) > 0) + { + set_color (COLOR_WHITE, COLOR_BLUE); + set_pos (cons_rows, 41); + draw_text (NPprompt2); + } + else if (cons_rows >= 24) + { + set_color (COLOR_LIGHT_GREY, COLOR_BLACK); + set_pos (cons_rows, 41); + fill_text ('-', cons_cols); + } + } + + /* Data entry field */ + if (NPdataentry && redraw_cmd) + { + set_pos (NPcurrow, NPcurcol); + if (NPcolorSwitch) + set_color (NPcolorFore, NPcolorBack); + fill_text (' ', NPcurcol + NPdatalen - 1); + set_pos (NPcurrow, NPcurcol); + PUTC_CMDLINE(); + redraw_cmd = 0; + } + else + /* Position the cursor to the bottom right */ + set_pos(cons_rows, cons_cols); +} + +/* ============== End of the main NP block of code =============*/ + +static void panel_cleanup(void *unused); // (forward reference) + +#ifdef OPTION_MIPS_COUNTING + +/////////////////////////////////////////////////////////////////////// +// "maxrates" command support... + +#define DEF_MAXRATES_RPT_INTVL ( 1440 ) + +DLL_EXPORT U32 curr_high_mips_rate = 0; // (high water mark for current interval) +DLL_EXPORT U32 curr_high_sios_rate = 0; // (high water mark for current interval) + +DLL_EXPORT U32 prev_high_mips_rate = 0; // (saved high water mark for previous interval) +DLL_EXPORT U32 prev_high_sios_rate = 0; // (saved high water mark for previous interval) + +DLL_EXPORT time_t curr_int_start_time = 0; // (start time of current interval) +DLL_EXPORT time_t prev_int_start_time = 0; // (start time of previous interval) + +DLL_EXPORT U32 maxrates_rpt_intvl = DEF_MAXRATES_RPT_INTVL; + +DLL_EXPORT void update_maxrates_hwm() // (update high-water-mark values) +{ + time_t current_time = 0; + U32 elapsed_secs = 0; + + if (curr_high_mips_rate < sysblk.mipsrate) + curr_high_mips_rate = sysblk.mipsrate; + + if (curr_high_sios_rate < sysblk.siosrate) + curr_high_sios_rate = sysblk.siosrate; + + // Save high water marks for current interval... + + time( ¤t_time ); + + elapsed_secs = current_time - curr_int_start_time; + + if ( elapsed_secs >= ( maxrates_rpt_intvl * 60 ) ) + { + prev_high_mips_rate = curr_high_mips_rate; + prev_high_sios_rate = curr_high_sios_rate; + + curr_high_mips_rate = 0; + curr_high_sios_rate = 0; + + prev_int_start_time = curr_int_start_time; + curr_int_start_time = current_time; + } +} +#endif // OPTION_MIPS_COUNTING +/////////////////////////////////////////////////////////////////////// + +REGS *copy_regs(int cpu) +{ + REGS *regs; + + if (cpu < 0 || cpu >= MAX_CPU_ENGINES) + cpu = 0; + + obtain_lock (&sysblk.cpulock[cpu]); + + if ((regs = sysblk.regs[cpu]) == NULL) + { + release_lock(&sysblk.cpulock[cpu]); + return &sysblk.dummyregs; + } + + memcpy (©regs, regs, sysblk.regs_copy_len); + + if (copyregs.hostregs == NULL) + { + release_lock(&sysblk.cpulock[cpu]); + return &sysblk.dummyregs; + } + +#if defined(_FEATURE_SIE) + if (regs->sie_active) + { + memcpy (©sieregs, regs->guestregs, sysblk.regs_copy_len); + copyregs.guestregs = ©sieregs; + copysieregs.hostregs = ©regs; + regs = ©sieregs; + } + else +#endif // defined(_FEATURE_SIE) + regs = ©regs; + + SET_PSW_IA(regs); + + release_lock(&sysblk.cpulock[cpu]); + return regs; +} + +static char *format_int(uint64_t ic) +{ + static char obfr[32]; /* Enough for displaying 2^64-1 */ + char grps[7][4]; /* 7 groups of 3 digits */ + int maxg=0; + int i; + + strcpy(grps[0],"0"); + while(ic>0) + { + int grp; + grp=ic%1000; + ic/=1000; + if(ic==0) + { + sprintf(grps[maxg],"%u",grp); + } + else + { + sprintf(grps[maxg],"%3.3u",grp); + } + maxg++; + } + if(maxg) maxg--; + obfr[0]=0; + for(i=maxg;i>=0;i--) + { + strcat(obfr,grps[i]); + if(i) + { + strcat(obfr,","); + } + } + return obfr; +} + + +/*-------------------------------------------------------------------*/ +/* Panel display thread */ +/* */ +/* This function runs on the main thread. It receives messages */ +/* from the log task and displays them on the screen. It accepts */ +/* panel commands from the keyboard and executes them. It samples */ +/* the PSW periodically and displays it on the screen status line. */ +/*-------------------------------------------------------------------*/ + +#if defined(OPTION_DYNAMIC_LOAD) +void panel_display_r (void) +#else +void panel_display (void) +#endif // defined(OPTION_DYNAMIC_LOAD) +{ +#ifndef _MSVC_ + int rc; /* Return code */ + int maxfd; /* Highest file descriptor */ + fd_set readset; /* Select file descriptors */ + struct timeval tv; /* Select timeout structure */ +#endif // _MSVC_ +int i; /* Array subscripts */ +int len; /* Length */ +REGS *regs; /* -> CPU register context */ +QWORD curpsw; /* Current PSW */ +QWORD prvpsw; /* Previous PSW */ +BYTE prvstate = 0xFF; /* Previous stopped state */ +U64 prvicount = 0; /* Previous instruction count*/ +#if defined(OPTION_MIPS_COUNTING) +U64 prvtcount = 0; /* Previous total count */ +#endif /*defined(OPTION_MIPS_COUNTING)*/ +int prvcpupct = 0; /* Previous cpu percentage */ +#if defined(OPTION_SHARED_DEVICES) +U32 prvscount = 0; /* Previous shrdcount */ +#endif // defined(OPTION_SHARED_DEVICES) +char readbuf[MSG_SIZE]; /* Message read buffer */ +int readoff = 0; /* Number of bytes in readbuf*/ +BYTE c; /* Character work area */ +size_t kbbufsize = CMD_SIZE; /* Size of keyboard buffer */ +char *kbbuf = NULL; /* Keyboard input buffer */ +int kblen; /* Number of chars in kbbuf */ +U32 aaddr; /* Absolute address for STO */ +char buf[1024]; /* Buffer workarea */ + + SET_THREAD_NAME("panel_display"); + + /* Display thread started message on control panel */ + logmsg (_("HHCPN001I Control panel thread started: " + "tid="TIDPAT", pid=%d\n"), + thread_id(), getpid()); + + /* Notify logger_thread we're in control */ + sysblk.panel_init = 1; + + hdl_adsc("panel_cleanup",panel_cleanup, NULL); + history_init(); + + /* Set up the input file descriptors */ + confp = stderr; + keybfd = STDIN_FILENO; + + /* Initialize screen dimensions */ + cons_term = getenv ("TERM"); + get_dim (&cons_rows, &cons_cols); + + /* Clear the command-line buffer */ + memset (cmdline, 0, sizeof(cmdline)); + cmdcols = cons_cols - CMDLINE_COL; + + /* Obtain storage for the keyboard buffer */ + if (!(kbbuf = malloc (kbbufsize))) + { + logmsg(_("HHCPN002S Cannot obtain keyboard buffer: %s\n"), + strerror(errno)); + return; + } + + /* Obtain storage for the circular message buffer */ + msgbuf = malloc (MAX_MSGS * sizeof(PANMSG)); + if (msgbuf == NULL) + { + fprintf (stderr, + _("HHCPN003S Cannot obtain message buffer: %s\n"), + strerror(errno)); + return; + } + + /* Initialize circular message buffer */ + for (curmsg = msgbuf, i=0; i < MAX_MSGS; curmsg++, i++) + { + curmsg->next = curmsg + 1; + curmsg->prev = curmsg - 1; + curmsg->msgnum = i; + memset(curmsg->msg,SPACE,MSG_SIZE); +#if defined(OPTION_MSGCLR) + curmsg->bg = COLOR_DEFAULT_FG; + curmsg->fg = COLOR_DEFAULT_BG; +#if defined(OPTION_MSGHLD) + curmsg->keep = 0; + memset( &curmsg->expiration, 0, sizeof(curmsg->expiration)); +#endif // defined(OPTION_MSGHLD) +#endif // defined(OPTION_MSGCLR) + } + + /* Complete the circle */ + msgbuf->prev = msgbuf + MAX_MSGS - 1; + msgbuf->prev->next = msgbuf; + + /* Indicate "first-time" state */ + curmsg = topmsg = NULL; + wrapped = 0; + numkept = 0; +#if defined(OPTION_MSGHLD) + keptmsgs = lastkept = NULL; +#endif // defined(OPTION_MSGHLD) + + /* Set screen output stream to NON-buffered */ + setvbuf (confp, NULL, _IONBF, 0); + + /* Put the terminal into cbreak mode */ + set_or_reset_console_mode( keybfd, 1 ); + + /* Set console title */ + set_console_title(); + + /* Clear the screen */ + set_color (COLOR_DEFAULT_FG, COLOR_DEFAULT_BG); + clr_screen (); + redraw_msgs = redraw_cmd = redraw_status = 1; + + /* Process messages and commands */ + while ( 1 ) + { +#if defined(OPTION_MIPS_COUNTING) + update_maxrates_hwm(); // (update high-water-mark values) +#endif // defined(OPTION_MIPS_COUNTING) + +#if defined( _MSVC_ ) + /* Wait for keyboard input */ +#define WAIT_FOR_KEYBOARD_INPUT_SLEEP_MILLISECS (20) + for (i=sysblk.panrate/WAIT_FOR_KEYBOARD_INPUT_SLEEP_MILLISECS; i && !kbhit(); i--) + Sleep(WAIT_FOR_KEYBOARD_INPUT_SLEEP_MILLISECS); + + ADJ_SCREEN_SIZE(); + + /* If keyboard input has [finally] arrived, then process it */ + if ( kbhit() ) + { + /* Read character(s) from the keyboard */ + kbbuf[0] = getch(); + kbbuf[kblen=1] = '\0'; + translate_keystroke( kbbuf, &kblen ); + +#else // !defined( _MSVC_ ) + + /* Set the file descriptors for select */ + FD_ZERO (&readset); + FD_SET (keybfd, &readset); + maxfd = keybfd; + + /* Wait for a message to arrive, a key to be pressed, + or the inactivity interval to expire */ + tv.tv_sec = sysblk.panrate / 1000; + tv.tv_usec = (sysblk.panrate * 1000) % 1000000; + rc = select (maxfd + 1, &readset, NULL, NULL, &tv); + if (rc < 0 ) + { + if (errno == EINTR) continue; + fprintf (stderr, + _("HHCPN004E select: %s\n"), + strerror(errno)); + break; + } + + ADJ_SCREEN_SIZE(); + + /* If keyboard input has arrived then process it */ + if (FD_ISSET(keybfd, &readset)) + { + /* Read character(s) from the keyboard */ + kblen = read (keybfd, kbbuf, kbbufsize-1); + + if (kblen < 0) + { + fprintf (stderr, + _("HHCPN005E keyboard read: %s\n"), + strerror(errno)); + break; + } + + kbbuf[kblen] = '\0'; + +#endif // defined( _MSVC_ ) + + /* =NP= : Intercept NP commands & process */ + if (NPDup == 1) + { + if (NPdevsel == 1) + { + NPdevsel = 0; + NPdevice = kbbuf[0]; /* save the device selected */ + kbbuf[0] = NPsel2; /* setup for 2nd part of rtn */ + } + if (NPdataentry == 0 && kblen == 1) + { /* We are in command mode */ + if (NPhelpup == 1) + { + if (kbbuf[0] == 0x1b) + NPhelpdown = 1; + kbbuf[0] = '\0'; + redraw_status = 1; + } + cmdline[0] = '\0'; + cmdlen = 0; + cmdoff = 0; + ADJ_CMDCOL(); + switch(kbbuf[0]) { + case 0x1B: /* ESC */ + NPDup = 0; + restore_command_line(); + ADJ_CMDCOL(); + redraw_msgs = redraw_cmd = redraw_status = 1; + npquiet = 0; // (forced for one paint cycle) + break; + case '?': + NPhelpup = 1; + redraw_status = 1; + break; + case 'S': /* START */ + case 's': + do_panel_command("herc startall"); + break; + case 'P': /* STOP */ + case 'p': + do_panel_command("herc stopall"); + break; + case 'O': /* Store */ + case 'o': + regs = copy_regs(sysblk.pcpu); + aaddr = APPLY_PREFIXING (NPaddress, regs->PX); + if (aaddr > regs->mainlim) + break; + store_fw (regs->mainstor + aaddr, NPdata); + redraw_status = 1; + break; + case 'I': /* Display */ + case 'i': + NPregdisp = 4; + NPregs_valid = 0; + redraw_status = 1; + break; + case 'g': /* display GPR */ + case 'G': + NPregdisp = 0; + NPregs_valid = 0; + redraw_status = 1; + break; + case 'a': /* Display AR */ + case 'A': + NPregdisp = 2; + NPregs_valid = 0; + redraw_status = 1; + break; + case 'c': + case 'C': /* Case CR */ + NPregdisp = 1; + NPregs_valid = 0; + redraw_status = 1; + break; + case 'f': /* Case FPR */ + case 'F': + NPregdisp = 3; + NPregs_valid = 0; + redraw_status = 1; + break; + case 'r': /* Enter address */ + case 'R': + NPdataentry = 1; + redraw_cmd = 1; + NPpending = 'r'; + NPcurrow = 16; + NPcurcol = 12; + NPdatalen = 8; + NPcolorSwitch = 1; + NPcolorFore = COLOR_WHITE; + NPcolorBack = COLOR_BLUE; + strcpy(NPentered, ""); + strcpy(NPprompt1, "Enter Address"); + redraw_status = 1; + break; + case 'd': /* Enter data */ + case 'D': + NPdataentry = 1; + redraw_cmd = 1; + NPpending = 'd'; + NPcurrow = 16; + NPcurcol = 30; + NPdatalen = 8; + NPcolorSwitch = 1; + NPcolorFore = COLOR_WHITE; + NPcolorBack = COLOR_BLUE; + strcpy(NPentered, ""); + strcpy(NPprompt1, "Enter Data Value"); + redraw_status = 1; + break; + case 'l': /* IPL */ + case 'L': + NPdevsel = 1; + NPsel2 = 1; + strcpy(NPprompt2, "Select Device for IPL"); + redraw_status = 1; + break; + case 1: /* IPL - 2nd part */ + i = toupper(NPdevice) - 'A'; + if (i < 0 || i > NPlastdev) { + strcpy(NPprompt2, ""); + redraw_status = 1; + break; + } + sprintf (cmdline, "herc ipl %4.4x", NPdevnum[i]); + do_panel_command(cmdline); + strcpy(NPprompt2, ""); + redraw_status = 1; + break; + case 'u': /* Device interrupt */ + case 'U': + NPdevsel = 1; + NPsel2 = 2; + strcpy(NPprompt2, "Select Device for Interrupt"); + redraw_status = 1; + break; + case 2: /* Device int: part 2 */ + i = toupper(NPdevice) - 'A'; + if (i < 0 || i > NPlastdev) { + strcpy(NPprompt2, ""); + redraw_status = 1; + break; + } + sprintf (cmdline, "herc i %4.4x", NPdevnum[i]); + do_panel_command(cmdline); + strcpy(NPprompt2, ""); + redraw_status = 1; + break; + case 'n': /* Device Assignment */ + case 'N': + NPdevsel = 1; + NPsel2 = 3; + strcpy(NPprompt2, "Select Device to Reassign"); + redraw_status = 1; + break; + case 3: /* Device asgn: part 2 */ + i = toupper(NPdevice) - 'A'; + if (i < 0 || i > NPlastdev) { + strcpy(NPprompt2, ""); + redraw_status = 1; + break; + } + NPdataentry = 1; + redraw_cmd = 1; + NPpending = 'n'; + NPasgn = i; + NPcurrow = 3 + i; + NPcurcol = 58; + NPdatalen = cons_cols - 57; + NPcolorSwitch = 1; + NPcolorFore = COLOR_DEFAULT_LIGHT; + NPcolorBack = COLOR_BLUE; + strcpy(NPentered, ""); + strcpy(NPprompt2, "New Name, or [enter] to Reload"); + redraw_status = 1; + break; + case 'W': /* POWER */ + case 'w': + NPdevsel = 1; + NPsel2 = 4; + strcpy(NPprompt1, "Confirm Powerdown Y or N"); + redraw_status = 1; + break; + case 4: /* POWER - 2nd part */ + if (NPdevice == 'y' || NPdevice == 'Y') + do_panel_command("herc quit"); + strcpy(NPprompt1, ""); + redraw_status = 1; + break; + case 'T': /* Restart */ + case 't': + NPdevsel = 1; + NPsel2 = 5; + strcpy(NPprompt1, "Confirm Restart Y or N"); + redraw_status = 1; + break; + case 5: /* Restart - part 2 */ + if (NPdevice == 'y' || NPdevice == 'Y') + do_panel_command("herc restart"); + strcpy(NPprompt1, ""); + redraw_status = 1; + break; + case 'E': /* Ext int */ + case 'e': + NPdevsel = 1; + NPsel2 = 6; + strcpy(NPprompt1, "Confirm External Interrupt Y or N"); + redraw_status = 1; + break; + case 6: /* External - part 2 */ + if (NPdevice == 'y' || NPdevice == 'Y') + do_panel_command("herc ext"); + strcpy(NPprompt1, ""); + redraw_status = 1; + break; + default: + break; + } + NPcmd = 1; + } else { /* We are in data entry mode */ + if (kbbuf[0] == 0x1B) { + /* Switch back to command mode */ + NPdataentry = 0; + NPaddr_valid = 0; + NPdata_valid = 0; + strcpy(NPprompt1, ""); + strcpy(NPprompt2, ""); + NPcmd = 1; + } + else + NPcmd = 0; + } + if (NPcmd == 1) + kblen = 0; /* don't process as command */ + } + /* =NP END= */ + + /* Process characters in the keyboard buffer */ + for (i = 0; i < kblen; ) + { + /* Test for HOME */ + if (strcmp(kbbuf+i, KBD_HOME) == 0) { + if (NPDup == 1 || !is_cursor_on_cmdline() || cmdlen) { + cursor_cmdline_home(); + redraw_cmd = 1; + } else { + scroll_to_top_line( 1 ); + redraw_msgs = 1; + } + break; + } + + /* Test for END */ + if (strcmp(kbbuf+i, KBD_END) == 0) { + if (NPDup == 1 || !is_cursor_on_cmdline() || cmdlen) { + cursor_cmdline_end(); + redraw_cmd = 1; + } else { + scroll_to_bottom_screen( 1 ); + redraw_msgs = 1; + } + break; + } + + /* Test for CTRL+HOME */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_CTRL_HOME) == 0) { + scroll_to_top_line( 1 ); + redraw_msgs = 1; + break; + } + + /* Test for CTRL+END */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_CTRL_END) == 0) { + scroll_to_bottom_line( 1 ); + redraw_msgs = 1; + break; + } + + /* Process UPARROW */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_UP_ARROW) == 0) + { + do_prev_history(); + redraw_cmd = 1; + break; + } + + /* Process DOWNARROW */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_DOWN_ARROW) == 0) + { + do_next_history(); + redraw_cmd = 1; + break; + } + +#if defined(OPTION_EXTCURS) + /* Process ALT+UPARROW */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_ALT_UP_ARROW) == 0) { + get_cursor_pos( keybfd, confp, &cur_cons_row, &cur_cons_col ); + if (cur_cons_row <= 1) + cur_cons_row = cons_rows + 1; + set_pos( --cur_cons_row, cur_cons_col ); + break; + } + + /* Process ALT+DOWNARROW */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_ALT_DOWN_ARROW) == 0) { + get_cursor_pos( keybfd, confp, &cur_cons_row, &cur_cons_col ); + if (cur_cons_row >= cons_rows) + cur_cons_row = 1 - 1; + set_pos( ++cur_cons_row, cur_cons_col ); + break; + } +#endif // defined(OPTION_EXTCURS) + + /* Test for PAGEUP */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_PAGE_UP) == 0) { + page_up( 1 ); + redraw_msgs = 1; + break; + } + + /* Test for PAGEDOWN */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_PAGE_DOWN) == 0) { + page_down( 1 ); + redraw_msgs = 1; + break; + } + + /* Test for CTRL+UPARROW */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_CTRL_UP_ARROW) == 0) { + scroll_up_lines(1,1); + redraw_msgs = 1; + break; + } + + /* Test for CTRL+DOWNARROW */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_CTRL_DOWN_ARROW) == 0) { + scroll_down_lines(1,1); + redraw_msgs = 1; + break; + } + + /* Process BACKSPACE */ + if (kbbuf[i] == '\b' || kbbuf[i] == '\x7F') { + if (NPDup == 0 && !is_cursor_on_cmdline()) + beep(); + else { + if (cmdoff > 0) { + int j; + for (j = cmdoff-1; j 0) cmdoff--; + ADJ_CMDCOL(); + i++; + redraw_cmd = 1; + break; + } + + /* Process RIGHTARROW */ + if (strcmp(kbbuf+i, KBD_RIGHT_ARROW) == 0) { + if (cmdoff < cmdlen) cmdoff++; + ADJ_CMDCOL(); + i++; + redraw_cmd = 1; + break; + } + +#if defined(OPTION_EXTCURS) + /* Process ALT+LEFTARROW */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_ALT_LEFT_ARROW) == 0) { + get_cursor_pos( keybfd, confp, &cur_cons_row, &cur_cons_col ); + if (cur_cons_col <= 1) + { + cur_cons_row--; + cur_cons_col = cons_cols + 1; + } + if (cur_cons_row < 1) + cur_cons_row = cons_rows; + set_pos( cur_cons_row, --cur_cons_col ); + break; + } + + /* Process ALT+RIGHTARROW */ + if (NPDup == 0 && strcmp(kbbuf+i, KBD_ALT_RIGHT_ARROW) == 0) { + get_cursor_pos( keybfd, confp, &cur_cons_row, &cur_cons_col ); + if (cur_cons_col >= cons_cols) + { + cur_cons_row++; + cur_cons_col = 0; + } + if (cur_cons_row > cons_rows) + cur_cons_row = 1; + set_pos( cur_cons_row, ++cur_cons_col ); + break; + } +#endif // defined(OPTION_EXTCURS) + + /* Process INSERT */ + if (strcmp(kbbuf+i, KBD_INSERT) == 0 ) { + cmdins = !cmdins; + set_console_cursor_shape( confp, cmdins ); + i++; + break; + } + + /* Process ESCAPE */ + if (kbbuf[i] == '\x1B') { + /* If data on cmdline, erase it */ + if ((NPDup == 1 || is_cursor_on_cmdline()) && cmdlen) { + cmdline[0] = '\0'; + cmdlen = 0; + cmdoff = 0; + ADJ_CMDCOL(); + redraw_cmd = 1; + } else { + /* =NP= : Switch to new panel display */ + save_command_line(); + NP_init(); + NPDup = 1; + /* =END= */ + } + break; + } + + /* Process TAB */ + if (kbbuf[i] == '\t' || kbbuf[i] == '\x7F') { + if (NPDup == 1 || !is_cursor_on_cmdline()) { + cursor_cmdline_home(); + redraw_cmd = 1; + } else { + tab_pressed(cmdline, &cmdoff); + cmdlen = strlen(cmdline); + ADJ_CMDCOL(); + i++; + redraw_cmd = 1; + } + break; + } + +#if defined(OPTION_EXTCURS) + /* ENTER key special handling */ + if (NPDup == 0 && kbbuf[i] == '\n') + { + /* Get cursor pos and check if on cmdline */ + if (!is_cursor_on_cmdline()) + { + int keepnum = get_keepnum_by_row( cur_cons_row ); + if (keepnum >= 0) + { +#if defined(OPTION_MSGHLD) + /* ENTER pressed on kept msg; remove msg */ + unkeep_by_keepnum( keepnum, 1 ); +#endif // defined(OPTION_MSGHLD) + redraw_msgs = 1; + break; + } + /* ENTER pressed NOT on cmdline */ + beep(); + break; + } + /* ENTER pressed on cmdline; fall through + for normal ENTER keypress handling... */ + } +#endif // defined(OPTION_EXTCURS) + + /* Process the command when the ENTER key is pressed */ + if (kbbuf[i] == '\n') { + if (cmdlen == 0 && NPDup == 0 && !sysblk.inststep && + sysblk.cmdtgt == 0) { + history_show(); + } else { + cmdline[cmdlen] = '\0'; + /* =NP= create_thread replaced with: */ + if (NPDup == 0) { + if ('#' == cmdline[0] || '*' == cmdline[0]) { + if (!is_currline_visible()) + scroll_to_bottom_screen( 1 ); + history_requested = 0; + do_panel_command(cmdline); + redraw_cmd = 1; + cmdlen = 0; + cmdoff = 0; + ADJ_CMDCOL(); + redraw_cmd = 1; + } else { + history_requested = 0; + do_panel_command(cmdline); + redraw_cmd = 1; + if (history_requested == 1) { + strcpy(cmdline, historyCmdLine); + cmdlen = strlen(cmdline); + cmdoff = cmdlen; + ADJ_CMDCOL(); + NPDup = 0; + NPDinit = 1; + } + } + } else { + NPdataentry = 0; + NPcurrow = cons_rows; + NPcurcol = cons_cols; + NPcolorSwitch = 0; + switch (NPpending) { + case 'r': + sscanf(cmdline, "%x", &NPaddress); + NPaddr_valid = 0; + strcpy(NPprompt1, ""); + break; + case 'd': + sscanf(cmdline, "%x", &NPdata); + NPdata_valid = 0; + strcpy(NPprompt1, ""); + break; + case 'n': + if (strlen(cmdline) < 1) { + strcpy(cmdline, NPdevnam[NPasgn]); + } + strcpy(NPdevnam[NPasgn], ""); + sprintf (NPentered, "herc devinit %4.4x %s", + NPdevnum[NPasgn], cmdline); + do_panel_command(NPentered); + strcpy(NPprompt2, ""); + break; + default: + break; + } + redraw_status = 1; + cmdline[0] = '\0'; + cmdlen = 0; + cmdoff = 0; + ADJ_CMDCOL(); + } + /* =END= */ + redraw_cmd = 1; + } + break; + } /* end if (kbbuf[i] == '\n') */ + + /* Ignore non-printable characters */ + if (!isprint(kbbuf[i])) { + beep(); + i++; + continue; + } + + /* Ignore all other keystrokes not on cmdline */ + if (NPDup == 0 && !is_cursor_on_cmdline()) { + beep(); + break; + } + + /* Append the character to the command buffer */ + ASSERT(cmdlen <= CMD_SIZE-1 && cmdoff <= cmdlen); + if (0 + || (cmdoff >= CMD_SIZE-1) + || (cmdins && cmdlen >= CMD_SIZE-1) + ) + { + /* (no more room!) */ + beep(); + } + else /* (there's still room) */ + { + ASSERT(cmdlen < CMD_SIZE-1 || (!cmdins && cmdoff < cmdlen)); + if (cmdoff >= cmdlen) + { + /* Append to end of buffer */ + ASSERT(!(cmdoff > cmdlen)); // (sanity check) + cmdline[cmdoff++] = kbbuf[i]; + cmdline[cmdoff] = '\0'; + cmdlen++; + } + else + { + ASSERT(cmdoff < cmdlen); + if (cmdins) + { + /* Insert: make room by sliding all + following chars right one position */ + int j; + for (j=cmdlen-1; j>=cmdoff; j--) + cmdline[j+1] = cmdline[j]; + cmdline[cmdoff++] = kbbuf[i]; + cmdlen++; + } + else + { + /* Overlay: replace current position */ + cmdline[cmdoff++] = kbbuf[i]; + } + } + ADJ_CMDCOL(); + redraw_cmd = 1; + } + i++; + } /* end for(i) */ + } /* end if keystroke */ + +FinishShutdown: + + // If we finished processing all of the message data + // the last time we were here, then get some more... + + if ( lmsndx >= lmscnt ) // (all previous data processed?) + { + lmscnt = log_read( &lmsbuf, &lmsnum, LOG_NOBLOCK ); + lmsndx = 0; + } + else if ( lmsndx >= lmsmax ) + { + lmsbuf += lmsndx; // pick up where we left off at... + lmscnt -= lmsndx; // pick up where we left off at... + lmsndx = 0; + } + + // Process all message data or until limit reached... + + // (limiting the amount of data we process a console message flood + // from preventing keyboard from being read since we need to break + // out of the below message data processing loop to loop back up + // to read the keyboard again...) + + /* Read message bytes until newline... */ + while ( lmsndx < lmscnt && lmsndx < lmsmax ) + { + /* Initialize the read buffer */ + if (!readoff || readoff >= MSG_SIZE) { + memset (readbuf, SPACE, MSG_SIZE); + readoff = 0; + } + + /* Read message bytes and copy into read buffer + until we either encounter a newline character + or our buffer is completely filled with data. */ + while ( lmsndx < lmscnt && lmsndx < lmsmax ) + { + /* Read a byte from the message pipe */ + c = *(lmsbuf + lmsndx); lmsndx++; + + /* Break to process received message + whenever a newline is encountered */ + if (c == '\n' || c == '\r') { + readoff = 0; /* (for next time) */ + break; + } + + /* Handle tab character */ + if (c == '\t') { + readoff += 8; + readoff &= 0xFFFFFFF8; + /* Messages longer than one screen line will + be continued on the very next screen line */ + if (readoff >= MSG_SIZE) + break; + else continue; + } + + /* Eliminate non-displayable characters */ + if (!isgraph(c)) c = SPACE; + + /* Stuff byte into message processing buffer */ + readbuf[readoff++] = c; + + /* Messages longer than one screen line will + be continued on the very next screen line */ + if (readoff >= MSG_SIZE) + break; + } /* end while ( lmsndx < lmscnt && lmsndx < lmsmax ) */ + + /* If we have a message to be displayed (or a complete + part of one), then copy it to the circular buffer. */ + if (!readoff || readoff >= MSG_SIZE) { + + /* First-time here? */ + if (curmsg == NULL) { + curmsg = topmsg = msgbuf; + } else { + /* Perform autoscroll if needed */ + if (is_currline_visible()) { + while (lines_remaining() < 1) + scroll_down_lines(1,1); + /* Set the display update indicator */ + redraw_msgs = 1; + } + + /* Go on to next available msg buffer */ + curmsg = curmsg->next; + + /* Updated wrapped indicator */ + if (curmsg == msgbuf) + wrapped = 1; + } + + /* Copy message into next available PANMSG slot */ + memcpy( curmsg->msg, readbuf, MSG_SIZE ); + +#if defined(OPTION_MSGCLR) + /* Colorize and/or keep new message if needed */ + colormsg(curmsg); +#endif // defined(OPTION_MSGCLR) + + } /* end if (!readoff || readoff >= MSG_SIZE) */ + } /* end Read message bytes until newline... */ + + /* Don't read or otherwise process any input + once system shutdown has been initiated + */ + if ( sysblk.shutdown ) + { + if ( sysblk.shutfini ) break; + /* wait for system to finish shutting down */ + usleep(10000); + lmsmax = INT_MAX; + goto FinishShutdown; + } + + /* =NP= : Reinit traditional panel if NP is down */ + if (NPDup == 0 && NPDinit == 1) { + redraw_msgs = redraw_status = redraw_cmd = 1; + set_color (COLOR_DEFAULT_FG, COLOR_DEFAULT_BG); + clr_screen (); + } + /* =END= */ + + /* Obtain the PSW for target CPU */ + regs = copy_regs(sysblk.pcpu); + memset (curpsw, 0x00, sizeof(curpsw)); + copy_psw (regs, curpsw); + + /* Set the display update indicator if the PSW has changed + or if the instruction counter has changed, or if + the CPU stopped state has changed */ + if (memcmp(curpsw, prvpsw, sizeof(curpsw)) != 0 + || prvicount != INSTCOUNT(regs) + || prvcpupct != regs->cpupct +#if defined(OPTION_SHARED_DEVICES) + || prvscount != sysblk.shrdcount +#endif // defined(OPTION_SHARED_DEVICES) + || prvstate != regs->cpustate +#if defined(OPTION_MIPS_COUNTING) + || (NPDup && NPcpugraph && prvtcount != sysblk.instcount) +#endif /*defined(OPTION_MIPS_COUNTING)*/ + ) + { + redraw_status = 1; + memcpy (prvpsw, curpsw, sizeof(prvpsw)); + prvicount = INSTCOUNT(regs); + prvcpupct = regs->cpupct; + prvstate = regs->cpustate; +#if defined(OPTION_SHARED_DEVICES) + prvscount = sysblk.shrdcount; +#endif // defined(OPTION_SHARED_DEVICES) +#if defined(OPTION_MIPS_COUNTING) + prvtcount = sysblk.instcount; +#endif /*defined(OPTION_MIPS_COUNTING)*/ + } + + /* =NP= : Display the screen - traditional or NP */ + /* Note: this is the only code block modified rather */ + /* than inserted. It makes the block of 3 ifs in the */ + /* original code dependent on NPDup == 0, and inserts */ + /* the NP display as an else after those ifs */ + + if (NPDup == 0) { + /* Rewrite the screen if display update indicators are set */ + if (redraw_msgs && !npquiet) + { + /* Display messages in scrolling area */ + PANMSG* p; + + /* Save cursor location */ + saved_cons_row = cur_cons_row; + saved_cons_col = cur_cons_col; + +#if defined(OPTION_MSGHLD) + /* Unkeep kept messages if needed */ + expire_kept_msgs(0); +#endif // defined(OPTION_MSGHLD) + i = 0; +#if defined(OPTION_MSGHLD) + /* Draw kept messages first */ + for (p=keptmsgs; i < (SCROLL_LINES + numkept) && p; i++, p = p->next) + { + set_pos (i+1, 1); +#if defined(OPTION_MSGCLR) + set_color (p->fg, p->bg); +#else // !defined(OPTION_MSGCLR) + set_color (COLOR_DEFAULT_FG, COLOR_DEFAULT_BG); +#endif // defined(OPTION_MSGCLR) + write_text (p->msg, MSG_SIZE); + } +#endif // defined(OPTION_MSGHLD) + + /* Then draw current screen */ + for (p=topmsg; i < (SCROLL_LINES + numkept) && (p != curmsg->next || p == topmsg); i++, p = p->next) + { + set_pos (i+1, 1); +#if defined(OPTION_MSGCLR) + set_color (p->fg, p->bg); +#else // !defined(OPTION_MSGCLR) + set_color (COLOR_DEFAULT_FG, COLOR_DEFAULT_BG); +#endif // defined(OPTION_MSGCLR) + write_text (p->msg, MSG_SIZE); + } + + /* Pad remainder of screen with blank lines */ + for (; i < (SCROLL_LINES + numkept); i++) + { + set_pos (i+1, 1); + set_color (COLOR_DEFAULT_FG, COLOR_DEFAULT_BG); + erase_to_eol( confp ); + } + + /* Display the scroll indicators */ + if (topmsg != oldest_msg()) + { + /* More messages precede top line */ + set_pos (1, cons_cols); + set_color (COLOR_DEFAULT_LIGHT, COLOR_DEFAULT_BG); + draw_text ("+"); + } + if (!is_currline_visible()) + { + /* More messages follow bottom line */ + set_pos (cons_rows-2, cons_cols); + set_color (COLOR_DEFAULT_LIGHT, COLOR_DEFAULT_BG); + draw_text ("V"); + } + + /* restore cursor location */ + cur_cons_row = saved_cons_row; + cur_cons_col = saved_cons_col; + } /* end if(redraw_msgs) */ + + if (redraw_cmd) + { + /* Save cursor location */ + saved_cons_row = cur_cons_row; + saved_cons_col = cur_cons_col; + + /* Display the command line */ + set_pos (CMDLINE_ROW, 1); + set_color (COLOR_DEFAULT_LIGHT, COLOR_DEFAULT_BG); + +#if defined(OPTION_CMDTGT) + switch(sysblk.cmdtgt) + { + case 0: // cmdtgt herc + { + draw_text(CMD_PREFIX_STR); + break; + } + case 1: // cmdtgt scp + { + draw_text(CMD_PREFIX_STR1); + break; + } + case 2: // cmdtgt pscp + { + draw_text(CMD_PREFIX_STR2); + break; + } + } +#else // !defined(OPTION_CMDTGT) + draw_text (CMD_PREFIX_STR); +#endif // defined(OPTION_CMDTGT) + + set_color (COLOR_DEFAULT_FG, COLOR_DEFAULT_BG); + PUTC_CMDLINE (); + fill_text (' ',cons_cols); + + /* restore cursor location */ + cur_cons_row = saved_cons_row; + cur_cons_col = saved_cons_col; + } /* end if(redraw_cmd) */ + + if (redraw_status && !npquiet) + { + /* Save cursor location */ + saved_cons_row = cur_cons_row; + saved_cons_col = cur_cons_col; + + memset (buf, ' ', cons_cols); + len = sprintf (buf, "CPU%4.4X ", sysblk.pcpu); + if (IS_CPU_ONLINE(sysblk.pcpu)) + { + char ibuf[64]; + len += sprintf(buf+len, "PSW=%8.8X%8.8X ", + fetch_fw(curpsw), fetch_fw(curpsw+4)); + if (regs->arch_mode == ARCH_900) + len += sprintf (buf+len, "%16.16"I64_FMT"X ", + fetch_dw (curpsw+8)); +#if defined(_FEATURE_SIE) + else + if( SIE_MODE(regs) ) + { + for(i = 0;i < 16;i++) + buf[len++] = '-'; + buf[len++] = ' '; + } +#endif /*defined(_FEATURE_SIE)*/ + len += sprintf (buf+len, "%2d%c%c%c%c%c%c%c%c", + regs->psw.amode64 ? 64 : + regs->psw.amode ? 31 : 24, + regs->cpustate == CPUSTATE_STOPPED ? 'M' : '.', + sysblk.inststep ? 'T' : '.', + WAITSTATE(®s->psw) ? 'W' : '.', + regs->loadstate ? 'L' : '.', + regs->checkstop ? 'C' : '.', + PROBSTATE(®s->psw) ? 'P' : '.', + SIE_MODE(regs) ? 'S' : '.', + regs->arch_mode == ARCH_900 ? 'Z' : '.'); + buf[len++] = ' '; + sprintf (ibuf, "instcount=%s", format_int(INSTCOUNT(regs))); + if (len + (int)strlen(ibuf) < cons_cols) + len = cons_cols - strlen(ibuf); + strcpy (buf + len, ibuf); + } + else + { + len += sprintf (buf+len,"%s", "Offline"); + buf[len++] = ' '; + } + buf[cons_cols] = '\0'; + set_pos (cons_rows, 1); + set_color (COLOR_LIGHT_YELLOW, COLOR_RED); + draw_text (buf); + + /* restore cursor location */ + cur_cons_row = saved_cons_row; + cur_cons_col = saved_cons_col; + } /* end if(redraw_status) */ + + /* Flush screen buffer and reset display update indicators */ + if (redraw_msgs || redraw_cmd || redraw_status) + { + set_color (COLOR_DEFAULT_FG, COLOR_DEFAULT_BG); + if (NPDup == 0 && NPDinit == 1) + { + NPDinit = 0; + restore_command_line(); + set_pos (cur_cons_row, cur_cons_col); + } + else if (redraw_cmd) + set_pos (CMDLINE_ROW, CMDLINE_COL + cmdoff - cmdcol); + else + set_pos (cur_cons_row, cur_cons_col); + fflush (confp); + redraw_msgs = redraw_cmd = redraw_status = 0; + } + + } else { /* (NPDup == 1) */ + + if (redraw_status || (NPDinit == 0 && NPDup == 1) + || (redraw_cmd && NPdataentry == 1)) { + if (NPDinit == 0) { + NPDinit = 1; + NP_screen_redraw(regs); + NP_update(regs); + fflush (confp); + } + } + /* Update New Panel every panrate interval */ + if (!npquiet) { + NP_update(regs); + fflush (confp); + } + redraw_msgs = redraw_cmd = redraw_status = 0; + } + + /* =END= */ + + /* Force full screen repaint if needed */ + if (!sysblk.npquiet && npquiet) + redraw_msgs = redraw_cmd = redraw_status = 1; + npquiet = sysblk.npquiet; + + } /* end while */ + + ASSERT( sysblk.shutdown ); // (why else would we be here?!) + +} /* end function panel_display */ + +static void panel_cleanup(void *unused) +{ +int i; +PANMSG* p; + + UNREFERENCED(unused); + + log_wakeup(NULL); + + set_screen_color( stderr, COLOR_DEFAULT_FG, COLOR_DEFAULT_BG ); + clear_screen( stderr ); + + /* Scroll to last full screen's worth of messages */ + scroll_to_bottom_screen( 1 ); + + /* Display messages in scrolling area */ + for (i=0, p = topmsg; i < SCROLL_LINES && p != curmsg->next; i++, p = p->next) + { + set_pos (i+1, 1); +#if defined(OPTION_MSGCLR) + set_color (p->fg, p->bg); +#else // !defined(OPTION_MSGCLR) + set_color (COLOR_DEFAULT_FG, COLOR_DEFAULT_BG); +#endif // defined(OPTION_MSGCLR) + write_text (p->msg, MSG_SIZE); + } + + /* Restore the terminal mode */ + set_or_reset_console_mode( keybfd, 0 ); + + /* Position to next line */ + fwrite("\n",1,1,stderr); + + /* Read and display any msgs still remaining in the system log */ + while((lmscnt = log_read(&lmsbuf, &lmsnum, LOG_NOBLOCK))) + fwrite(lmsbuf,lmscnt,1,stderr); + + fflush(stderr); +} --- hercules-3.13.orig/Makefile.am +++ hercules-3.13/Makefile.am @@ -98,13 +98,14 @@ if OPTION_DYNAMIC_LOAD DYNSRC = - LTDL = ltdl.c + LTDL = DYNMOD_LD_FLAGS = -module \ -no-undefined \ $(XSTATIC) \ -export-dynamic \ - -avoid-version + -avoid-version \ + $(LDFLAGS) DYNMOD_LD_ADD = libherc.la \ libhercs.la \ @@ -114,7 +115,8 @@ LIB_LD_FLAGS = -export-dynamic \ $(XSTATIC) \ -no-undefined \ - -avoid-version + -avoid-version \ + $(LDFLAGS) else DYNSRC = $(dyndev_SRC) LTDL = @@ -372,8 +374,7 @@ memrchr.c \ $(dynamic_SRC) \ $(extra_SRC) \ - $(dyndev_SRC) \ - ltdl.c + $(dyndev_SRC) libherc_la_LDFLAGS = $(LIB_LD_FLAGS) @@ -382,6 +383,7 @@ libherct.la \ libhercd.la \ decNumber/libdecNumber.la \ + -lltdl \ softfloat/libsoftfloat.la \ $(LDADD) @@ -440,17 +442,17 @@ hercules_SOURCES = bootstrap.c \ hdlmain.c - hercules_LDADD = libherc.la libhercs.la $(LDADD) + hercules_LDADD = libherc.la libhercs.la libhercd.la libhercu.la -lltdl $(LDADD) hercules_LDFLAGS = $(HLDFLAGS) - hercules_DEPENDENCIES = libherc.la libhercs.la $(HDEPS) + hercules_DEPENDENCIES = libherc.la libhercs.la libhercd.la libhercu.la -lltdl $(HDEPS) if BUILD_SHARED herclin_SOURCES = herclin.c hdlmain.c -herclin_LDADD = libherc.la libhercs.la $(LDADD) +herclin_LDADD = libherc.la libhercs.la libhercd.la libhercu.la -lltdl $(LDADD) herclin_LDFLAGS = $(HLDFLAGS) -herclin_DEPENDENCIES = libherc.la libhercs.la $(HDEPS) +herclin_DEPENDENCIES = libherc.la libhercs.la libhercd.la libhercu.la -lltdl $(HDEPS) endif # @@ -656,7 +658,6 @@ hdl.h \ crypto.h \ sockdev.h \ - ltdl.h \ herc_getopt.h \ service.h \ chsc.h \ --- hercules-3.13.orig/autoconf/hercules.m4 +++ hercules-3.13/autoconf/hercules.m4 @@ -207,6 +207,7 @@ AC_DEFUN([_HC_CHECK_NEED_GETOPT_WRAPPER], [ AC_REQUIRE([AC_PROG_LIBTOOL]) + LT_OUTPUT AC_MSG_CHECKING([whether getopt wrapper kludge is necessary]) if test "$1" != "auto"; then --- hercules-3.13.orig/configure.ac +++ hercules-3.13/configure.ac @@ -15,7 +15,6 @@ AM_CONFIG_HEADER(config.h) # (the file the resulting configure script will produce) AM_MAINTAINER_MODE() AC_CANONICAL_HOST() # (sets $host_cpu, $host_vendor, and $host_os) -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) ############################################################################### # Programs section... @@ -39,151 +38,8 @@ AC_SUBST(modexecdir) -# ----------------------------------------------------------------------------- -# -# AC_LIBTOOL_DLOPEN -# -# Enable checking for dlopen support. This macro should be used if the -# package makes use of the '-dlopen' and '-dlpreopen' flags, otherwise -# libtool will assume that the system does not support dlopening. The -# macro must be called before AC_PROG_LIBTOOL. -# -# ----------------------------------------------------------------------------- - -AC_LIBTOOL_DLOPEN() # (we need libtool's dlopen support) - - -# ----------------------------------------------------------------------------- -# -# AC_LIBTOOL_WIN32_DLL -# -# This macro should be used if the package has been ported to build -# clean dlls on win32 platforms. Usually this means that any library -# data items are exported with __declspec(dllexport) and imported with -# __declspec(dllimport). If this macro is not used, libtool will assume -# that the package libraries are not dll clean and will build only static -# libraries on win32 hosts. -# -# This macro must be called before AC_PROG_LIBTOOL, and provision must -# be made to pass '-no-undefined' to libtool in link mode from the package -# Makefile. Naturally, if you pass '-no-undefined', you must ensure that -# all the library symbols really are defined at link time! -# -# ----------------------------------------------------------------------------- - -AC_LIBTOOL_WIN32_DLL() # (we need Win32 support in libtool) - - -# ----------------------------------------------------------------------------- -# See: 'AC_PROG_LIBTOOL' below. -# ----------------------------------------------------------------------------- - -AC_DISABLE_STATIC() # (forces libtool to build shared - - # libraries instead of static ones) -# ----------------------------------------------------------------------------- -# AC_PROG_LIBTOOL -# -# Add support for the '--enable-shared' and '--disable-shared' -# configure flags. By default, this macro turns on shared libraries -# if they are available, and also enables static libraries if they -# don't conflict with the shared libraries. You can modify these -# defaults by calling either the AC_DISABLE_SHARED or AC_DISABLE_STATIC -# macros. -# -# Hercules REQUIRES shared libraries (i.e. DLLs), so we do indeed use -# the AC_DISABLE_STATIC macro above. -# -# ----------------------------------------------------------------------------- - -AC_PROG_LIBTOOL() # (we build libtool for ourselves) - - -# ----------------------------------------------------------------------------- -# -# AC_LIB_LTDL -# -# Even though libltdl is installed together with libtool, you may wish -# to include libltdl in the distribution of your package, for the convenience -# of users of your package that don't have libtool or libltdl installed. -# -# The most simplistic way to add libltdl to your package is to copy the -# source files, 'ltdl.c' and 'ltdl.h', to a source directory withing your -# package and to build and link them along with the rest of your sources. -# -# To do this, you must add a call to the 'AC_LIB_LTDL' macro to your package's -# 'configure.in' to perform the required configure time checks in order that -# 'ltdl.o' is built correctly. -# -# This method does have its problems though: if you try to link the package -# binaries with an installed libltdl, or a library which depends on libltdl, -# you may have problems with duplicate symbol definitions. -# -# In order to enable this flavor of libltdl, you should add the line -# 'AC_LIBLTDL_CONVENIENCE' to your `configure.in', before 'AC_PROG_LIBTOOL'. -# -# In order to select the installable version of libltdl, you should add a -# call of the macro 'AC_LIBLTDL_INSTALLABLE' to your 'configure.in' before -# 'AC_PROG_LIBTOOL'. This macro will check whether libltdl is already -# installed and, if not, request the libltdl embedded in your package to be -# built and installed. -# -# Whatever macro you use, it is up to you to ensure that your 'configure.in' -# will configure libltdl, using 'AC_CONFIG_SUBDIRS', and that your 'Makefile's -# will start sub-makes within libltdl's directory, using automake's SUBDIRS, -# for example. Both macros define the shell variables LIBLTDL, to the link flag -# that you should use to link with libltdl, and LTDLINCL, to the preprocessor -# flag that you should use to compile with programs that include 'ltdl.h'. It -# is up to you to use 'AC_SUBST' to ensure that this variable will be available -# in 'Makefile's, or add them to variables that are 'AC_SUBST'ed by default, -# such as LIBS and CPPFLAGS. -# -# So, when you want to link a program with libltdl, be it a convenience, -# installed or installable library, just compile with '$(LTDLINCL)' and link -# it with '$(LIBLTDL)', using libtool. -# -# You should probably also add 'AC_LIBTOOL_DLOPEN' to your 'configure.in' before -# 'AC_PROG_LIBTOOL', otherwise libtool will assume no dlopening mechanism is -# supported, and revert to dlpreopening, which is probably not what you want. -# -# The following example shows you how to embed the convenience libltdl -# in your package. In order to use the installable variant just replace -# 'AC_LIBLTDL_CONVENIENCE' with 'AC_LIBLTDL_INSTALLABLE'. We assume that libltdl -# was embedded using 'libtoolize --ltdl': -# -# configure.in: -# -# ... -# dnl Enable building of the convenience library -# dnl and set LIBLTDL accordingly -# AC_LIBLTDL_CONVENIENCE -# dnl Substitute LTDLINCL and LIBLTDL in the Makefiles -# AC_SUBST(LTDLINCL) -# AC_SUBST(LIBLTDL) -# dnl Check for dlopen support -# AC_LIBTOOL_DLOPEN -# dnl Configure libtool -# AC_PROG_LIBTOOL -# dnl Configure libltdl -# AC_CONFIG_SUBDIRS(libltdl) -# ... -# -# Makefile.am: -# -# ... -# SUBDIRS = libltdl -# -# INCLUDES = $(LTDLINCL) -# -# myprog_LDFLAGS = -export-dynamic -# # The quotes around -dlopen below fool automake <= 1.4 into accepting it -# myprog_LDADD = $(LIBLTDL) "-dlopen" self "-dlopen" foo1.la -# myprog_DEPENDENCIES = $(LIBLTDL) foo1.la -# ... -# -# ----------------------------------------------------------------------------- - -AC_LIB_LTDL() # (we need the ltdl libtool library) +LT_INIT([dlopen win32-dll disable-static]) +LTDL_INIT([]) AC_SUBST([LIBTOOL_DEPS]) # (see PROGRAMMING NOTE above) --- hercules-3.13.orig/crypto/Makefile.am +++ hercules-3.13/crypto/Makefile.am @@ -23,7 +23,7 @@ if OPTION_DYNAMIC_LOAD DYNSRC = - LTDL = ../ltdl.c + LTDL = DYNMOD_LD_FLAGS = -module \ -no-undefined \ --- hercules-3.13.orig/debian/README.Debian +++ hercules-3.13/debian/README.Debian @@ -0,0 +1,20 @@ +hercules for Debian +------------------- + +If you want to use virtual networking without running Hercules as +root, you will want to add a statoverride for /usr/bin/hercifc: + +dpkg-statoverride --add --update root 04750 /usr/bin/hercifc + + -- Matt Zimmerman , Thu, 26 Apr 2001 01:46:24 -0400 + +Installing Debian on an emulated S/390 system +--------------------------------------------- +A good introduction on how to install Debian on s390 using hercules has +been written by Josef Sipek: +http://www.josefsipek.net/docs/s390-linux/hercules-s390.html. + +Note that Debian Squeeze and later no longer support running in 31-bit +mode as only 64-bit (s390x) kernels are available. This means that in your +hercules config ARCHMODE must be set to 'ESAME' or 'z/Arch'. + --- hercules-3.13.orig/debian/changelog +++ hercules-3.13/debian/changelog @@ -0,0 +1,375 @@ +hercules (3.13-1) unstable; urgency=medium + + * New upstream release + + -- Philipp Kern Sun, 04 Feb 2018 13:13:08 +0100 + +hercules (3.12-3) unstable; urgency=medium + + * Always compile with strict alignment turned on to avoid a segfault + on start. + * Avoid another segfault when commands are entered before the text + user interface is up. + + -- Philipp Kern Sun, 20 Aug 2017 14:31:31 +0200 + +hercules (3.12-2) unstable; urgency=medium + + * Build-depend on automake instead of automake1.11. (Closes: #865165) + * Packaging cleanups: + - Bump debhelper compatibility level from 7 to 9. + - Use dh-autoreconf. + - Rework debian/rules to use dh instead of raw debhelper. + - Change priority from extra to optional. + + -- Philipp Kern Sun, 06 Aug 2017 14:51:50 +0200 + +hercules (3.12-1) unstable; urgency=medium + + * New upstream release + + -- Philipp Kern Sun, 03 Jan 2016 20:39:30 +0100 + +hercules (3.11-1) unstable; urgency=medium + + * New upstream release + - Updated debian/copyright to fit. + - Updated debian/watch to point to the new homepage of 3.x. + * Take over maintainership of the package: It has not seen a maintainer + upload since 2010. + * Added dpkg-buildflags to the configure invocation to get hardening + flags. Adapted the build system to fit. + * Depend on libcap2-dev on linux-any instead of a manual exclusion list. + (Closes: #634511) + + -- Philipp Kern Sun, 04 Oct 2015 20:41:11 +0200 + +hercules (3.07-2.3) unstable; urgency=medium + + * Non-maintainer upload. + * debian/control: Switch to automake1.11. (Closes: #724388) + + -- Eric Dorland Sun, 16 Feb 2014 14:45:34 -0500 + +hercules (3.07-2.2) unstable; urgency=low + + * Non-maintainer upload. + * Empty dependency_libs (Closes: #621249). + * Add LDFLAGS to really Closes: #615729. + + -- Luk Claes Mon, 13 Jun 2011 16:50:07 +0200 + +hercules (3.07-2.1) unstable; urgency=low + + * Non-maintainer upload. + * Enable external GUI (Closes: #585508) + * Explicit specify needed library (Closes: #615729) + + -- Liang Guo Tue, 29 Mar 2011 09:26:35 +0800 + +hercules (3.07-2) unstable; urgency=low + + * Try again with automake 1.10 (Cloes: #575325) + + -- Peter 'p2' De Schrijver Thu, 25 Mar 2010 00:29:13 +0200 + +hercules (3.07-1) unstable; urgency=low + + * New upstream release (Closes: #573355) + * Integrated multiple fixes from Simon McVittie (Closes: #557162) + * Added dasdinit manpage (Closes: #542143) + * Updated package description (Closes: #569913) + * Updated README.Debian. Thanks to Frans Pop. (Closes: #573355) + * Integrated fix for CVE-2009-3736. Thanks to Thorsten Glaser. (Closes: #559815) + + -- Peter 'p2' De Schrijver Tue, 23 Mar 2010 20:24:26 +0200 + +hercules (3.06-1.2) unstable; urgency=low + + * Non-maintainer upload. + * Use autoreconf in order to use system libltdl instead of the bundled + one (upgrading from 1.x to 2.2). (Closes: #559815) (CVE-2009-3736) + + -- Thorsten Glaser Sun, 24 Jan 2010 00:44:52 +0000 + +hercules (3.06-1.1) unstable; urgency=low + + * Non-maintainer upload. + * Install the private libraries into a private directory, making it + unnecessary to run ldconfig (Closes: #553110) + * Apply patch from Petr Salinger to not build-depend on libcap2-dev on + non-Linux ports (Closes: #544545) + * Apply patch from Martin Michlmayr pre-emptively fixing compilation with + gcc-4.4 (Closes: #513233) + * Put copyright holders and licenses in debian/copyright, not just a pointer + (Policy §12.5) + * Various minor QA, mainly prompted by Lintian warnings: + - modernize watch file (Closes: #529114) + - upgrade debhelper compat level from 3 to 7 (still compatible with stable) + - add ${misc:Depends} to Depends, as per debhelper (>= 4) documentation + - support DEB_BUILD_OPTIONS=noopt + - upgrade config.{guess,sub} during build using autotools-dev + - add the usual --build/--host stuff as per autotools-dev documentation + - debian/menu: modernize menu section (menu-item-uses-apps-section) + - use dh_prep instead of deprecated dh_clean -k + - hercules.doc-base: use appropriate section + - don't ignore errors from make distclean + + -- Simon McVittie Thu, 19 Nov 2009 23:38:37 +0000 + +hercules (3.06-1) unstable; urgency=low + + * New upstream release + * Added configure option --enable-capabilities (Closes: #470460) + + -- Peter De Schrijver (p2) Sat, 17 Jan 2009 19:20:47 +0200 + +hercules (3.05-2) unstable; urgency=low + + * fix license issue (Closes: #473195) + * fixes for late 3.05 issues (Closes: #437107) + * update autoconf foo (Closes: #414519) + + -- Peter De Schrijver (p2) Sun, 30 Mar 2008 15:47:15 +0300 + +hercules (3.05-1) unstable; urgency=low + + * New upstream release. + + -- Peter De Schrijver (p2) Mon, 10 Mar 2008 03:21:44 +0200 + +hercules (3.04.1-3) unstable; urgency=low + + * run hercules with networking as non-root. Thanks to Ivan Warren for the + patch. (Closes: #402191) + + -- Wed, 11 Apr 2007 23:42:16 +0200 + +hercules (3.04.1-2) unstable; urgency=low + + * Fix bizarre compile problem (why does this only happen on ARM ??) (Closes: #414567) + * Add Freebsd support for debian (Closes: #414519) + + -- Tue, 13 Mar 2007 00:39:24 +0100 + +hercules (3.04.1-1) unstable; urgency=low + + * New upstream release (Closes: #381550) + * removed broken de.po (Closes: #313777) + * Suggest x3270 (Closes: #397674) + * Added updated version of joeyh's d-i howto (Closes: #338387) + + -- Peter De Schrijver (p2) Mon, 12 Feb 2007 22:27:12 +0100 + +hercules (3.03.1-1) unstable; urgency=low + + * New upstream release (Closes: #345716) + + -- Peter De Schrijver (p2) Tue, 3 Jan 2006 19:17:21 +0100 + +hercules (3.0.2-1) unstable; urgency=low + + * New maintainer + * New upstream release (Closes: #289121, #184217, #241064, #251287) + * Remove x3270 from suggests (Closes: #318130) + + -- Peter De Schrijver (p2) Mon, 24 Oct 2005 01:38:32 +0200 + +hercules (2.17.1-2) unstable; urgency=low + + * Update config.{guess,sub} (Closes: #182650) + + -- Matt Zimmerman Thu, 27 Feb 2003 09:54:00 -0500 + +hercules (2.17.1-1) unstable; urgency=low + + * New upstream release + + -- Matt Zimmerman Fri, 14 Feb 2003 16:49:17 -0500 + +hercules (2.17-1) unstable; urgency=low + + * New upstream release + + -- Matt Zimmerman Sun, 2 Feb 2003 22:50:16 -0500 + +hercules (2.16.5-1) unstable; urgency=low + + * New upstream release + + -- Matt Zimmerman Tue, 9 Jul 2002 23:09:21 -0400 + +hercules (2.16.4-2) unstable; urgency=medium + + * Apply Greg Smith's fix to CCKD, fixing a bug which could cause + corruption of CCKD volumes + + -- Matt Zimmerman Sat, 6 Jul 2002 18:30:06 -0400 + +hercules (2.16.4-1) unstable; urgency=low + + * New upstream release + + -- Matt Zimmerman Sat, 6 Jul 2002 00:17:38 -0400 + +hercules (2.16.2-1) unstable; urgency=low + + * New upstream release + * Revert our patch to configure.ac, as the FE_INEXACT issue has been + fixed elsewhere in the upstream source + + -- Matt Zimmerman Thu, 23 May 2002 19:49:59 -0400 + +hercules (2.16.1-1) unstable; urgency=low + + * New upstream release + + -- Matt Zimmerman Sun, 5 May 2002 23:43:44 -0400 + +hercules (2.16-2) unstable; urgency=medium + + * Fix bad merge of configure which caused the version number to be + reported as 2.15 + * Install upstream changelog again, now that it has returned + (Closes: #144702) + + -- Matt Zimmerman Sat, 27 Apr 2002 10:29:08 -0400 + +hercules (2.16-1) unstable; urgency=low + + * New upstream release + * Revert to reading hercules.cnf from the current directory to match + upstream behaviour + * Only include hercules.cnf as an example + + -- Matt Zimmerman Tue, 23 Apr 2002 22:02:59 -0400 + +hercules (2.15-4) unstable; urgency=medium + + * Disable IEEE floating point support if FE_INEXACT is not defined by + fenv.h. This will allow hercules to build on ARM + (Closes: #134308) + + -- Matt Zimmerman Sun, 17 Feb 2002 01:01:55 -0500 + +hercules (2.15-3) unstable; urgency=low + + * Build with -ffunction-sections on hppa (Closes: #127243) + + -- Matt Zimmerman Fri, 18 Jan 2002 15:28:46 -0500 + +hercules (2.15-2) unstable; urgency=low + + * Remove debian/conffiles, as we use DH_COMPAT=3. This avoids listing + the same conffile twice + + -- Matt Zimmerman Sun, 30 Dec 2001 14:11:09 -0500 + +hercules (2.15-1) unstable; urgency=low + + * New upstream release. + * Includes fix for the floating-point problem which broke + update-alternatives (Closes: #115415) + * Fix a typo in the description, and add a statement requested by Roger + Bowler, original author. Also clean up and shorted descriptions + somewhat. + * Include bzip2 CCKD support (Closes: #114416) + + -- Matt Zimmerman Sat, 29 Dec 2001 21:27:27 -0500 + +hercules (2.13-3) unstable; urgency=low + + * Correct typo in extended description (also fixed in upstream + documentation) + + -- Matt Zimmerman Thu, 15 Nov 2001 02:30:18 -0500 + +hercules (2.13-2) unstable; urgency=low + + * On powerpc, pass -Dsqrtl=sqrt, since there is no sqrtl and double == + long double. + * On ARM, don't even try to compile the IEEE floating-point routines. + (-DNO_IEEE_SUPPORT) + + -- Matt Zimmerman Sat, 28 Jul 2001 19:20:10 -0400 + +hercules (2.13-1) unstable; urgency=low + + * New upstream version. + + -- Matt Zimmerman Wed, 25 Jul 2001 17:54:35 -0400 + +hercules (2.12-2) unstable; urgency=low + + * Applied patch from LaMont Jones to fix compilation with gcc 3.0 + (Closes: #104595) + + -- Matt Zimmerman Fri, 13 Jul 2001 18:26:34 -0400 + +hercules (2.12-1) unstable; urgency=low + + * New upstream version. Upstream changes are extensive, see CHANGES. + + -- Matt Zimmerman Thu, 21 Jun 2001 14:03:33 -0400 + +hercules (2.11-4) unstable; urgency=low + + * Remove reference to "later in this document" that was accidentally + included in the manual excerpt used for the extended description + (Closes: #98144) + + -- Matt Zimmerman Sun, 20 May 2001 15:57:36 -0400 + +hercules (2.11-3) unstable; urgency=low + + * Fixed priority to match override file + + -- Matt Zimmerman Wed, 2 May 2001 15:19:41 -0400 + +hercules (2.11-2) unstable; urgency=low + + * Added missing \ to menu entry (oops) + + -- Matt Zimmerman Mon, 30 Apr 2001 02:51:28 -0400 + +hercules (2.11-1) unstable; urgency=low + + * New upstream version From the upstream changelog: + - LFPC/SFPC/STFPC IEEE floating point instructions (Jan Jaeger) + - Fixes to CMPSC (Bernard van der Helm) + - Extended translation fac. 2 (PKA/PKU/UNPKA/UNPKU) (Roger Bowler) + - Divide logical (DL/DLR/DLG/DLGR) instructions (Vic Cross) + - Display instruction operands (Roger Bowler) + - Fix to load_psw (Roger Bowler) + - Add hercules.rc initialization file (Willem Konynenberg) + - Fix SIE host interrupt IA backup (Jan Jaeger) + - Fix SSKE RCP index error (Jan Jaeger) + - TP instruction (Roger Bowler) + - Tape datachaining patch (Brandon Hill) + - Patch to bypass Cygwin stack problem (service.c) (Greg Smith) + - Fixes for windows port (Volker Bandke) + - SSK/ISK/RRB fix for 2K storage keys (Valery Pogonchenko and Jan Jaeger) + - TRAP2 TRAP4 and RP instructions (Jan Jaeger) + - Varous fixes for panel.c (Roger Bowler) + - Interval Timer fix (Bob Abeles) + - Deconfigure CPU's in release_config() (Greg Smith) + - Change panel break command to 64 bit (Jan Jaeger) + - Add ALCGR, SLBGR, ALCG, SLBG, ALCR, SLCR, ALC, SLB, AGF, ALGF, SGF, SGFR, AGFR, RRL, RRLG, MSGF, MSGFR, SLGFR instructions (Jan Jaeger) + - Fix MVCLE instruction where op2 len > op1 len (Jan Jaeger) + - Fix various sign/casting problems in esame.c (Jan Jaeger) + - Change constant type in cmpsc.c to prevent warning (Jan Jaeger) + - Fix S/370 interval timer (Valery Pogonchenko and Jay Maynard) + - Correct sign on LLILH (Jan Jaeger) + + * Document command line option -f in manpage + + -- Matt Zimmerman Sun, 29 Apr 2001 14:14:34 -0400 + +hercules (2.10-1) unstable; urgency=low + + * Initial Release (Closes: #95289) + * Includes my small patch to enable tunnel networking on 2.4 kernels + + -- Matt Zimmerman Sat, 28 Apr 2001 23:31:06 -0400 + + --- hercules-3.13.orig/debian/compat +++ hercules-3.13/debian/compat @@ -0,0 +1 @@ +9 --- hercules-3.13.orig/debian/control +++ hercules-3.13/debian/control @@ -0,0 +1,46 @@ +Source: hercules +Section: otherosfs +Priority: optional +Maintainer: Philipp Kern +Build-Depends: debhelper (>= 9~), + dh-autoreconf, + docbook-to-man, + zlib1g-dev, + libbz2-dev, + libcap2-dev [linux-any], + libltdl-dev, + libtool, + autoconf, + automake, + autotools-dev, +Build-Conflicts: autoconf2.13, automake1.4 +Homepage: http://www.hercules-390.eu/ +Standards-Version: 3.6.2 + +Package: hercules +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: x3270 +Description: System/370, ESA/390 and z/Architecture Emulator + Hercules is an open source software implementation of the mainframe System/370 + and ESA/390 architectures, in addition to the new 64-bit z/Architecture. + . + This means that your PC can emulate an IBM mainframe processor. The + mainframe can range from a 360 to a z900 - running in "System/370" + mode, "ESA/390" mode, or "z/Architecture" mode. Hercules executes + S/370, ESA/390, and z/Architecture instructions and channel + programs. It emulates mainframe I/O devices by using PC devices. For + example, 3390 DASD devices are emulated by large files on your hard + disk, and local 3270 screens are emulated by tn3270 sessions. + . + Hercules implements only the raw S/370, ESA/390, and z/Architecture + instruction set; it does not provide any operating system facilities. This + means that you need to provide an operating system or standalone program which + Hercules can load from an emulated disk or tape device. You will have to use a + free software operating system such as Linux, write the operating system or + standalone program yourself, obtain a license from IBM to run one of their + operating systems on your PC, or use IBM programs and operating systems which + have been placed in the public domain. + . + Virtual networking can be accomplished using the TUN/TAP driver in + host Linux kernel. --- hercules-3.13.orig/debian/copyright +++ hercules-3.13/debian/copyright @@ -0,0 +1,381 @@ +The first version of this package was debianized by Matt Zimmerman +on Thu, 26 Apr 2001 01:46:24 -0400. + +The current version was downloaded from http://www.hercules-390.org/ + +Upstream Authors: + + Hercules was created by Roger Bowler and is maintained by Jay + Maynard. Jan Jaeger designed and implemented many of the + advanced features of Hercules, including dynamic + reconfiguration, integrated console, interpretive execution, + and z/Architecture support. + +Copyright: + Copyright 1991-2014 Roger Bowler + Copyright 1995-2005 Free Software Foundation, Inc. + Copyright 1999 Volker Bandke + Copyright 1999-2001 Nobody + Copyright 1999-2009 Peter Kuschnerus + Copyright 1999-2013 Jan Jaeger + Copyright 2000-2009 Leland Lucius + Copyright 2000-2007 Malcolm Beattie + Copyright 2000-2009 Willem Konynenberg + Copyright 2000-2009 Bernard van der Helm + Copyright 2001-2009 Fritz Elfert + Copyright 2001-2010 James M. Morrison + Copyright 2001-2009 Vic Cross + Copyright 2002-2014 David B.Trout + Copyright 2002-2010 Greg Smith + Copyright 2002-2012 James A. Pierson + Copyright 2003-2006 Mark L. Gaubatz + Copyright 2003-2009 Ivan Warren + Copyright 2000-2007 Jay Maynard + Copyright 2010 TurboHercules, SAS + Copyright 2012 Enrico Sorichetti + Copyright 2014 Peter J. Jansen + "and others" + +Licensing: + All materials in this distribution are + copyrighted by Roger Bowler and others. + + Hercules may be distributed under the terms + of the Q Public License Version 1.0 + + Please refer to: + http://www.hercules-390.org/herclic.html + for details. + + In the context of this license, the initial developers of + the software are Roger Bowler, Jan Jaeger, and Jay Maynard. + +(A copy of the Q Public License 1.0 from the referenced web page is appended to +this file. It is the same as the original Trolltech version available from +opensource.org, except that the Choice of Law at the end has been changed +to England.) + +Copyright on differently-licensed parts: + +debian/hercules.sgml: + Copyright 2001 Matt Zimmerman + + Permission is granted to copy, distribute and/or modify this + document under the terms of the GNU Free Documentation License, + Version 1.1 or any later version published by the Free Software + Foundation; with no Invariant Sections, no Front-Cover Texts + and no Back-Cover Texts. + + (On Debian systems, a copy of the GFDL can be found in + /usr/share/common-licenses.) + +crypto/sha2.c, crypto.sha2.h: + Copyright (c) 2000-2001, Aaron D. Gifford + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +crypto/des.c: + PuTTY is copyright 1997-2005 Simon Tatham. + Portions copyright Robert de Bath, Joris van Rantwijk, Delian + Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry, + Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus + Kuhn, and CORE SDI S.A. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE + FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +hercules.m4: + Modeled after 'AC_C99_FLEXIBLE_ARRAY' macro copyright + by Erik de Castro Lopo + + Permission to use, copy, modify, distribute, and sell this file + for any purpose is hereby granted without fee, provided that the + above copyright and this permission notice appear in all copies. + No representations are made about the suitability of this software + for any purpose. It is provided "as is" without express or + implied warranty. + +decNumber/*: + Copyright (c) 1995-2005 International Business Machines Corporation and + others. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, and/or sell copies of the Software, and to permit persons + to whom the Software is furnished to do so, provided that the above + copyright notice(s) and this permission notice appear in all copies of + the Software and that both the above copyright notice(s) and this + permission notice appear in supporting documentation. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + Except as contained in this notice, the name of a copyright holder + shall not be used in advertising or otherwise to promote the sale, use + or other dealings in this Software without prior written authorization + of the copyright holder. + +getopt.c: + * Copyright (c) 1987, 1993, 1994, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + +getopt.h: + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + +parts of hscutl.[ch]: + * Copyright (c) 1998 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +tt32api.h + Copyright (c) Software Development Laboratories, aka "Fish" (David B. Trout) + + Licensed under terms of the ZLIB/LIBPNG Open Source Software License + http://www.opensource.org/licenses/zlib-license.php + + THIS SOFTWARE IS PROVIDED 'AS-IS', WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. + IN NO EVENT WILL THE AUTHOR(S) BE HELD LIABLE FOR ANY DAMAGES ARISING FROM + THE USE OF THIS SOFTWARE. + + Permission is granted to anyone to use this software for any purpose, including + commercial applications, and to alter it and redistribute it freely, subject to + the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not claim + that you wrote the original software. If you use this software in a product, + an acknowledgment in the product documentation would be appreciated but is + not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice nor the above Copyright information may not be removed or altered + from any source distribution. + +util/awssl-v19g: + * Copyright (C) 2002, By Reed H. Petty, rhp@draper.net * + * * + * You are free to make any changes you like to this code for any * + * purpose (including commercial for profit use) PROVIDED that you * + * carry the credits forward into derived works. * + * * + * NO WARRANTY OF ANY KIND IS MADE! USE AT YOUR OWN RISK! * + +part of w32util.c: + Copyright 2000 Petter Reinholdtsen + (with the same copyright/permission notice as crypto/des.c) + +----------------------------------------------------------------------- + +THE Q PUBLIC LICENSE version 1.0 + +Copyright (C) 1999 Trolltech AS, Norway. +Everyone is permitted to copy and +distribute this license document. + +The intent of this license is to establish freedom to share and change the +software regulated by this license under the open source model. + +This license applies to any software containing a notice placed by the +copyright holder saying that it may be distributed under the terms of the Q +Public License version 1.0. Such software is herein referred to as the +Software. This license covers modification and distribution of the Software, +use of third-party application programs based on the Software, and development +of free software which uses the Software. + + Granted Rights + +1. You are granted the non-exclusive rights set forth in this license provided +you agree to and comply with any and all conditions in this license. Whole or +partial distribution of the Software, or software items that link with the +Software, in any form signifies acceptance of this license. + +2. You may copy and distribute the Software in unmodified form provided that +the entire package, including - but not restricted to - copyright, trademark +notices and disclaimers, as released by the initial developer of the Software, +is distributed. + +3. You may make modifications to the Software and distribute your +modifications, in a form that is separate from the Software, such as patches. +The following restrictions apply to modifications: + + a. Modifications must not alter or remove any copyright notices in the + Software. + + b. When modifications to the Software are released under this license, a + non-exclusive royalty-free right is granted to the initial developer of the + Software to distribute your modification in future versions of the Software + provided such versions remain available under these terms in addition to + any other license(s) of the initial developer. + +4. You may distribute machine-executable forms of the Software or +machine-executable forms of modified versions of the Software, provided that +you meet these restrictions: + + a. You must include this license document in the distribution. + + b. You must ensure that all recipients of the machine-executable forms are + also able to receive the complete machine-readable source code to the + distributed Software, including all modifications, without any charge + beyond the costs of data transfer, and place prominent notices in the + distribution explaining this. + + c. You must ensure that all modifications included in the + machine-executable forms are available under the terms of this license. + +5. You may use the original or modified versions of the Software to compile, +link and run application programs legally developed by you or by others. + +6. You may develop application programs, reusable components and other software +items that link with the original or modified versions of the Software. These +items, when distributed, are subject to the following requirements: + + a. You must ensure that all recipients of machine-executable forms of these + items are also able to receive and use the complete machine-readable source + code to the items without any charge beyond the costs of data transfer. + + b. You must explicitly license all recipients of your items to use and + re-distribute original and modified versions of the items in both + machine-executable and source code forms. The recipients must be able to do + so without any charges whatsoever, and they must be able to re-distribute + to anyone they choose. + + c. If the items are not available to the general public, and the initial + developer of the Software requests a copy of the items, then you must + supply one. + + Limitations of Liability + +In no event shall the initial developers or copyright holders be liable for any +damages whatsoever, including - but not restricted to - lost revenue or profits +or other direct, indirect, special, incidental or consequential damages, even +if they have been advised of the possibility of such damages, except to the +extent invariable law, if any, provides otherwise. + + No Warranty + +The Software and this license document are provided AS IS with NO WARRANTY OF +ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE. + + Choice of Law + +This license is governed by the Laws of England. --- hercules-3.13.orig/debian/dirs +++ hercules-3.13/debian/dirs @@ -0,0 +1,4 @@ +usr/bin +usr/share/hercules +usr/share/man/man1 +usr/share/doc/hercules --- hercules-3.13.orig/debian/hercules.doc-base +++ hercules-3.13/debian/hercules.doc-base @@ -0,0 +1,9 @@ +Document: hercules +Title: The Hercules System/370, ESA/390, and z/Architecture Emulator +Author: Jay Maynard +Abstract: This manual describes what hercules is and how to operate it +Section: Emulators + +Format: HTML +Index: /usr/share/doc/hercules/html/index.html +Files: /usr/share/doc/hercules/html/*.html --- hercules-3.13.orig/debian/hercules.examples +++ hercules-3.13/debian/hercules.examples @@ -0,0 +1 @@ +hercules.cnf --- hercules-3.13.orig/debian/hercules.sgml +++ hercules-3.13/debian/hercules.sgml @@ -0,0 +1,138 @@ + manpage.1'. You may view + the manual page with: `docbook-to-man manpage.sgml | nroff -man | + less'. A typical entry in a Makefile or Makefile.am is: + +manpage.1: manpage.sgml + docbook-to-man $< > $@ + --> + + + Matt"> + Zimmerman"> + + April 26, 2001"> + + 1"> + mdz@debian.org"> + + HERCULES"> + + + Debian GNU/Linux"> + GNU"> +]> + + + +
+ &dhemail; +
+ + &dhfirstname; + &dhsurname; + + + 2001 + &dhusername; + + &dhdate; +
+ + &dhucpackage; + + &dhsection; + + + &dhpackage; + + System/370, ESA/390 and z/Architecture Emulator + + + + + &dhpackage; + + + + + + DESCRIPTION + + This manual page documents briefly the + &dhpackage; program. + + This manual page was written for the &debian; distribution + because the original program does not have a manual page. + Instead, it has documentation in HTML format; see below. + + Hercules is an open source + software implementation of the mainframe System/370 and ESA/390 + architectures, in addition to the new 64-bit z/Architecure. + Hercules runs under Linux, Windows 98, Windows NT, and Windows + 2000. + + + + OPTIONS + + + + + + + Use a config file other than + /etc/hercules/hercules.cnf + + + + + + + SEE ALSO + + The programs are documented fully by The Hercules + System/370, ESA/390, and z/Architecture Emulator + available in + /usr/share/doc/hercules/html. + + + + AUTHOR + + Hercules was created by Roger Bowler and is maintained by + Jay Maynard. Jan Jaeger designed and implemented many of the + advanced features of Hercules, including dynamic + reconfiguration, integrated console, interpretive execution, and + z/Architecture support. + + This manual page was written by &dhusername; &dhemail; for + the &debian; system (but may be used by others). Permission is + granted to copy, distribute and/or modify this document under + the terms of the GNU Free Documentation + License, Version 1.1 or any later version published by the Free + Software Foundation; with no Invariant Sections, no Front-Cover + Texts and no Back-Cover Texts. + + +
+ + --- hercules-3.13.orig/debian/links +++ hercules-3.13/debian/links @@ -0,0 +1,20 @@ +usr/share/man/man1/hercules.1 usr/share/man/man1/hercifc.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/dasdisup.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/dasdload.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/dasdls.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/dasdpdsu.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/tapecopy.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/tapelist.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/tapemap.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/tapesplit.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/cckd2ckd.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/cckdcdsk.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/ckd2cckd.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/cckdcomp.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/hetget.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/hetinit.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/hetmap.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/hetupd.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/dmap2hrc.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/tapesplt.1 +usr/share/man/man1/hercules.1 usr/share/man/man1/cckdswap.1 --- hercules-3.13.orig/debian/menu +++ hercules-3.13/debian/menu @@ -0,0 +1,2 @@ +?package(hercules):needs="text" section="Applications/Emulators" \ + title="hercules" command="/usr/bin/hercules" --- hercules-3.13.orig/debian/patches/always-strict-alignment.patch +++ hercules-3.13/debian/patches/always-strict-alignment.patch @@ -0,0 +1,30 @@ +Activate OPTION_STRICT_ALIGNMENT to avoid segfault + +Access is not always aligned when gcc thinks it is, causing a segfault +when MOVDQA accesses a memory address that is not 16 byte aligned. + +Upstream spinhawk commit: +https://github.com/rbowler/spinhawk/commit/a88567da805e945311a42306e7490086274bf8d5 + +Index: hercules-3.12/machdep.h +=================================================================== +--- hercules-3.12.orig/machdep.h ++++ hercules-3.12/machdep.h +@@ -572,14 +572,10 @@ U32 *ptr4, val4, old4, new4; + #endif + + /*------------------------------------------------------------------- +- * Decide if strict alignment is required ++ * Activate OPTION_STRICT_ALIGNMENT to generate different paths ++ * for non-aligned and aligned accesses in certain instructions + *-------------------------------------------------------------------*/ +-#if !defined(OPTION_STRICT_ALIGNMENT) && !defined(OPTION_NO_STRICT_ALIGNMENT) +- #if !defined(_MSVC_) && !defined(_ext_ia32) && !defined(_ext_amd64) \ +- && !defined(_ext_ppc) +- #define OPTION_STRICT_ALIGNMENT +- #endif +-#endif ++#define OPTION_STRICT_ALIGNMENT + + /*------------------------------------------------------------------- + * fetch_hw_noswap and fetch_hw --- hercules-3.13.orig/debian/patches/check-if-topmsg-is-initialized.patch +++ hercules-3.13/debian/patches/check-if-topmsg-is-initialized.patch @@ -0,0 +1,21 @@ +Check if topmsg was initialized before accessing it. + +Without this, Hercules reproducibly fails to start when you type in +a command before the text UI is up, crashing in do_panel_command. + +Index: hercules-3.12/panel.c +=================================================================== +--- hercules-3.12.orig/panel.c ++++ hercules-3.12/panel.c +@@ -508,6 +508,11 @@ static PANMSG* newest_msg() + + static int lines_scrolled() + { ++ /* topmsg is not yet initialized when the text UI is not shown yet, ++ * but this function is still called if a command has been entered ++ * before that. */ ++ if (!topmsg) ++ return 0; + /* return # of lines 'up' from current line that we're scrolled. */ + if (topmsg->msgnum <= curmsg->msgnum) + return curmsg->msgnum - topmsg->msgnum; --- hercules-3.13.orig/debian/patches/series +++ hercules-3.13/debian/patches/series @@ -0,0 +1,2 @@ +always-strict-alignment.patch +check-if-topmsg-is-initialized.patch --- hercules-3.13.orig/debian/rules +++ hercules-3.13/debian/rules @@ -0,0 +1,47 @@ +#!/usr/bin/make -f + +%: + dh $@ --with autoreconf + +# We divert the shared libraries (which are all internal to +# Hercules) into /usr/lib/hercules, which in turn means the plugins would +# normally go in /usr/lib/hercules/hercules. +# +# However, Hercules will actually look in ${prefix}/lib/hercules for +# plugins (and that path makes more sense anyway), so we override it +# at build/install time by changing the make arguments. +# +# Hopefully this will become unnecessary if upstream add a --with-modexecdir +# option or something. It might need changing in new upstream releases if +# they stop hard-coding ${prefix}/lib/hercules. + +CONFIGURE_ARGS := --prefix=/usr --enable-optimization="$(CFLAGS)" \ + --libdir=/usr/lib/hercules \ + --mandir=/usr/share/man/ --enable-cckd-bzip2 --enable-het-bzip2 \ + --enable-custom=Debian --enable-capabilities \ + --enable-external-gui --without-included-ltdl +MAKE_ARGS := modexecdir=/usr/lib/hercules + +export DEB_LDFLAGS_MAINT_APPEND = -lltdl + +override_dh_autoreconf: + dh_autoreconf autoreconf -- -fvi -Im4 -Iautoconf + +override_dh_auto_configure: + dh_auto_configure -- $(CONFIGURE_ARGS) + +override_dh_auto_build: + dh_auto_build -- $(MAKE_ARGS) + /usr/bin/docbook-to-man debian/hercules.sgml > hercules.1 + +override_dh_auto_install: + $(MAKE) install DESTDIR=$(CURDIR)/debian/hercules $(MAKE_ARGS) + sed -i "/dependency_libs/ s/'.*'/''/" `find $(CURDIR)/debian/hercules -name '*.la'` + rm $(CURDIR)/debian/hercules/usr/bin/bldlvlck + rm $(CURDIR)/debian/hercules/usr/bin/herclin + install -m 644 hercules.1 $(CURDIR)/debian/hercules/usr/share/man/man1 + cp -R html $(CURDIR)/debian/hercules/usr/share/doc/hercules + +override_dh_auto_clean: + dh_auto_clean + rm -f hercules.1 --- hercules-3.13.orig/debian/watch +++ hercules-3.13/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://www.hercules-390.eu/ http://downloads.hercules-390.eu/hercules-(.*)\.tar\.gz debian --- hercules-3.13.orig/decNumber/Makefile.am +++ hercules-3.13/decNumber/Makefile.am @@ -37,7 +37,7 @@ endif if OPTION_DYNAMIC_LOAD - LTDL = ../ltdl.c + LTDL = LIB_LD_FLAGS = -export-dynamic \ $(XSTATIC) \ -no-undefined \ --- hercules-3.13.orig/man/Makefile.am +++ hercules-3.13/man/Makefile.am @@ -1,4 +1,4 @@ -man_MANS = cckddiag.1 cckd.4 dasdseq.1 hercules.1 +man_MANS = cckddiag.1 cckd.4 dasdseq.1 cfba2fba.1 dasdcat.1 dasdconv.1 dasdcopy.1 dasdinit.1 fba2cfba.1 hercules.1 EXTRA_DIST = $(man_MANS) --- hercules-3.13.orig/man/cfba2fba.1 +++ hercules-3.13/man/cfba2fba.1 @@ -0,0 +1,48 @@ +.TH "CFBA2FBA" "1" +.SH "NAME" +cfba2fba \- copy a compressed FBA DASD file to a plain FBA DASD file +.SH "SYNOPSIS" +.PP +\fBcfba2fba\fR [\fB-\fIoptions\fR\fP] \fBifile\fR [\fBsf=sfile\fR] \fBofile\fR +.SH "DESCRIPTION" +.PP +This manual page documents the cfba2fba program. +.PP +cfba2fba copies a compressed FBA file to a FBA file. +.SH "PARAMETERS" +.IP "\fBifile\fR " 10 +input compressed FBA DASD file +.IP "\fBsfile\fR " 10 +input compressed FBA shadow file (optional) +.IP "\fBofile\fR " 10 +output fba dasd file +.SH "OPTIONS" +.IP "\fB-v\fR " 10 +display program version and quit +.IP "\fB-h\fR " 10 +display help and quit +.IP "\fB-q\fR " 10 +quiet mode, don't display status +.IP "\fB-r\fR " 10 +replace the output file if it exists +.IP "\fB-lfs\fR " 10 +create single large output file +.IP "\fB-blks n\fR " 10 +size of output file +.SH "SEE ALSO" +.PP +The programs are documented fully by \fIThe Hercules +System/370, ESA/390, and z/Architecture Emulator\fP available in +\fB/usr/share/doc/hercules/html\fP. +.SH "AUTHOR" +Hercules was created by Roger Bowler and is maintained by +Jay Maynard. Jan Jaeger designed and implemented many of the +advanced features of Hercules, including dynamic +reconfiguration, integrated console, interpretive execution, and +z/Architecture support. +.PP +This manual page was written by Peter De Schrijver p2@debian.org for +the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GPL. + --- hercules-3.13.orig/man/dasdcat.1 +++ hercules-3.13/man/dasdcat.1 @@ -0,0 +1,53 @@ +.TH "DASDCAT" "1" +.SH "NAME" +DASDCAT \- display pds datasets and members from a DASD image file +.SH "SYNOPSIS" +.PP +\fBdasdcat\fR [\fB-i\fR \fIdasd_image\fP [\fBsf=\fR\fIshadowfile\fP] \fIpdsname\fP\fB/\fR\fIspec\fP\fB:\fR\fIflags\fP] +.SH "DESCRIPTION" +.PP +This manual page documents the dasdcat program. +.PP +The dasdcat utility displays pds datasets and members from a DASD image file. +.SH "PARAMETERS" +.IP "\fBdasd_image\fR" 10 +input DASD filename +.IP "\fBshadowfile\fR" 10 +associated shadow DASD filename (optional) +.IP "\fBpdsname\fR" 10 +name of the partitioned dataset from which information will be extracted +.IP "\fBspec\fR" 10 +\fBspec\fR can be one of the following : +.RS 10 +.IP "\(bu \fBname\fR" 10 +list PDS member \fBname\fR +.IP "\(bu \fB*\fR" 10 +list all PDS members +.IP "\(bu \fB?\fR" 10 +list the membernames of the PDS +.RE +.IP "\fBflags\fR" 10 +\fBflags\fR can be one of the following : +.RS 10 +.IP "\(bu \fBc\fR" 10 +list members as cards +.IP "\(bu \fBa\fR" 10 +list members in ASCII +.RE +.PP +.SH "SEE ALSO" +The programs are documented fully by \fIThe Hercules +System/370, ESA/390, and z/Architecture Emulator\fP available in +\fB/usr/share/doc/hercules/html\fP. +.SH "AUTHOR" +Hercules was created by Roger Bowler and is maintained by +Jay Maynard. Jan Jaeger designed and implemented many of the +advanced features of Hercules, including dynamic +reconfiguration, integrated console, interpretive execution, and +z/Architecture support. +.PP +This manual page was written by Peter De Schrijver p2@debian.org for +the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GPL. + --- hercules-3.13.orig/man/dasdconv.1 +++ hercules-3.13/man/dasdconv.1 @@ -0,0 +1,40 @@ +.TH "DASDCONV" "1" +.SH "NAME" +DASDCONV \- convert a CKD disk image from HDR-30 to AWSCKD format +.SH "SYNOPSIS" +.PP +\fBdasdconv\fR [\fB-r\fR] [\fB-lfs\fR] [\fB-q\fR]\fP \fIinfile\fP \fIoutfile\fP +.SH "DESCRIPTION" +.PP +This manual page documents the dasdconv program. +.PP +dasdconv converts a CKD disk image from HDR-30 format to AWSCKD format. +.SH "PARAMETERS" +.IP "\fBinfile\fR" 10 +input ckd dasd file in HDR-30 format +.IP "\fBoutfile\fR" 10 +output ckd dasd file in AWSCKD format. If the image is bigger then 2GB multiple files will creates with names suffixed _1, _2, etc. +.SH "OPTIONS" +.IP "\fB-r\fR" 10 +Overwrite the existing outfile. By default no files will be overwritten. +.IP "\fB-lfs\fR" 10 +Output CKD file will be a single file even if it exceeds 2GB in size. +.IP "\fB-q\fR" 10 +Quiet +.SH "SEE ALSO" +.PP +The programs are documented fully by \fIThe Hercules +System/370, ESA/390, and z/Architecture Emulator\fP available in +\fB/usr/share/doc/hercules/html\fP. +.SH "AUTHOR" +Hercules was created by Roger Bowler and is maintained by +Jay Maynard. Jan Jaeger designed and implemented many of the +advanced features of Hercules, including dynamic +reconfiguration, integrated console, interpretive execution, and +z/Architecture support. +.PP +This manual page was written by Peter De Schrijver p2@debian.org for +the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GPL. + --- hercules-3.13.orig/man/dasdcopy.1 +++ hercules-3.13/man/dasdcopy.1 @@ -0,0 +1,60 @@ +.TH "DASDCOPY" "1" +.SH "NAME" +dasdcopy \- copy a DASD file to another DASD file +.SH "SYNOPSIS" +.PP +\fBdasdcopy\fR [\fB-v\fR] [\fB-h\fR] [\fB-q\fR] [\fB-r\fR] [\fB-z\fR] [\fB-bz2\fR] [\fB-0\fR] [\fB-a\fR] [\fB-lfs\fR] [\fB-blks\fR \fIn\fP] [\fB-cyls\fR \fIn\fP] [\fB-o\fR \fItype\fP] \fIifile\fP [\fBsf=\fR\fIsfile\fP] \fIofile\fP +.SH "DESCRIPTION" +.PP +This manual page documents the dasdcopy program. +.PP +dasdcopy copies a DASD file to another DASD file. +.SH "PARAMETERS" +.IP "\fBifile\fR" 10 +input FBA DASD file +.IP "\fBsfile\fR" 10 +input compressed FBA shadow file (optional) +.IP "\fBofile\fR" 10 +output compressed FBA DASD file +.SH "OPTIONS" +.IP "\fB-v\fR" 10 +display program version and quit +.IP "\fB-h\fR" 10 +display help and quit +.IP "\fB-q\fR" 10 +quiet mode, don't display status +.IP "\fB-r\fR" 10 +replace the output file if it exists +.IP "\fB-blks n\fR" 10 +size of output FBA file +.IP "\fB-cyls n\fR" 10 +size of output CKD file +.IP "\fB-z\fR" 10 +compress using output zlib [default] +.IP "\fB-bz2\fR" 10 +compress using output bzip2 +.IP "\fB-0\fR" 10 +don't compress output +.IP "\fB-a\fR" 10 +output ckd file will have alternate cylinders +.IP "\fB-lfs\fR" 10 +output ckd file will be a single file even if it exceeds 2GB in size +.IP "\fB-o type\fR" 10 +output file type (CKD, CCKD, FBA, CFBA) +.SH "SEE ALSO" +.PP +The programs are documented fully by \fIThe Hercules +System/370, ESA/390, and z/Architecture Emulator\fP available in +\fB/usr/share/doc/hercules/html\fP. +.SH "AUTHOR" +Hercules was created by Roger Bowler and is maintained by +Jay Maynard. Jan Jaeger designed and implemented many of the +advanced features of Hercules, including dynamic +reconfiguration, integrated console, interpretive execution, and +z/Architecture support. +.PP +This manual page was written by Peter De Schrijver p2@debian.org for +the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GPL. + --- hercules-3.13.orig/man/dasdinit.1 +++ hercules-3.13/man/dasdinit.1 @@ -0,0 +1,53 @@ +.TH DASDLIST "1" +.SH "NAME" +dasdlist \- build an empty DASD image file +.SH "SYNOPSIS" +.PP +dasdinit [\fB-v\fR] [\fB-z\fR] [\fB-bz2\fR] [\fB-0\fR] [\fB-lfs\fR] [\fB-a\fR] [\fB-r\fR] [\fB-linux\fR] \fIfilename\fP \fIdevtype\fP[\fB-\fR\fImodel\fP] [\fIvolser\fP] [\fIsize\fP] +.PP +This manual page documents the dasdinit program. +.PP +dasdlist builds an empty DASD image file +.SH "PARAMETERS" +.IP "\fBfilename\fR " 10 +name of DASD image file to be created +.IP "\fBdevtype\fR " 10 +emulated device type +.IP "\fBmodel\fR " 10 +emulated device model (optional) +.IP "\fBvolser\fR " 10 +volume serial number (1-6 characters) (only if '-r' option not used) +.IP "\fBsize\fR " 10 +number of cylinders (for CKD devices) or 512-byte sectors (for FBA devices) (optional if device specified) +.SH "OPTIONS" +.IP "\fB-v\fR " 10 +display version info and help +.IP "\fB-z\fR " 10 +build compressed DASD image file using zlib +.IP "\fB-bz2\fR " 10 +build compressed DASD image file using bzip2 +.IP "\fB-0\fR " 10 +build compressed DASD image file with no compression +.IP "\fB-lfs\fR " 10 +build a large (uncompressed) DASD file (if supported) +.IP "\fB-a\fR " 10 +build DASD image file that includes alternate cylinders (option ignored if size is manually specified) +.IP "\fB-r\fR " 10 +build 'raw' DASD image file (no VOL1 or IPL track) +.IP "\fB-linux\fR " 10 +null track images will look like linux dasdfmt'ed images (3390 device type only) +.SH "SEE ALSO" +.PP +\fB/usr/share/doc/hercules/html/hercload.html\fP +.SH "AUTHOR" +Hercules was created by Roger Bowler and is maintained by +Jay Maynard. Jan Jaeger designed and implemented many of the +advanced features of Hercules, including dynamic +reconfiguration, integrated console, interpretive execution, and +z/Architecture support. +.PP +This manual page was written by Peter De Schrijver p2@debian.org for +the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GPL. + --- hercules-3.13.orig/man/fba2cfba.1 +++ hercules-3.13/man/fba2cfba.1 @@ -0,0 +1,50 @@ +.TH "FBA2CFBA" "1" +.SH "NAME" +fba2cfba \- copy a FBA dasd file to a compressed FBA DASD file +.SH "SYNOPSIS" +.PP +\fBfba2cfba\fR [\fB-\fIoptions\fR\fP] \fBifile\fR \fBofile\fR +.SH "DESCRIPTION" +.PP +This manual page documents the fba2cfba program. +.PP +fba2cfba copies a FBA DASD file to a compressed FBA DASD file. +.SH "PARAMETERS" +.IP "\fBifile\fR " 10 +input FBA DASD file +.IP "\fBofile\fR " 10 +output compressed FBA DASD file +.SH "OPTIONS" +.IP "\fB-v\fR " 10 +display program version and quit +.IP "\fB-h\fR " 10 +display help and quit +.IP "\fB-q\fR " 10 +quiet mode, don't display status +.IP "\fB-r\fR " 10 +replace the output file if it exists +.IP "\fB-blks n\fR " 10 +size of output file +.IP "\fB-z\fR " 10 +compress using zlib [default] +.IP "\fB-bz2\fR " 10 +compress using bzip2 +.IP "\fB-0\fR " 10 +don't compress track images +.SH "SEE ALSO" +.PP +The programs are documented fully by \fIThe Hercules +System/370, ESA/390, and z/Architecture Emulator\fP available in +\fB/usr/share/doc/hercules/html\fP. +.SH "AUTHOR" +Hercules was created by Roger Bowler and is maintained by +Jay Maynard. Jan Jaeger designed and implemented many of the +advanced features of Hercules, including dynamic +reconfiguration, integrated console, interpretive execution, and +z/Architecture support. +.PP +This manual page was written by Peter De Schrijver p2@debian.org for +the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GPL. + --- hercules-3.13.orig/man/hercules.1.debdiff +++ hercules-3.13/man/hercules.1.debdiff @@ -0,0 +1,45 @@ +.TH "HERCULES" "1" +.SH "NAME" +hercules \(em System/370, ESA/390 and z/Architecture Emulator +.SH "SYNOPSIS" +.PP +\fBhercules\fR [\fB-f \fIconfig-file\fR\fP] +.SH "DESCRIPTION" +.PP +This manual page documents briefly the +\fBhercules\fR program. +.PP +This manual page was written for the \fBDebian GNU/Linux\fP distribution +because the original program does not have a manual page. +Instead, it has documentation in HTML format; see below. +.PP +\fBHercules\fP is an open source +software implementation of the mainframe System/370 and ESA/390 +architectures, in addition to the new 64-bit z/Architecure. +Hercules runs under Linux, Windows 98, Windows NT, and Windows +2000. +.SH "OPTIONS" +.IP "\fB-f\fP " 10 +Use a config file other than +\fB/etc/hercules/hercules.cnf\fP +.SH "SEE ALSO" +.PP +The programs are documented fully by \fIThe Hercules +System/370, ESA/390, and z/Architecture Emulator\fP available in +\fB/usr/share/doc/hercules/html\fP. +.SH "AUTHOR" +.PP +Hercules was created by Roger Bowler and is maintained by +Jay Maynard. Jan Jaeger designed and implemented many of the +advanced features of Hercules, including dynamic +reconfiguration, integrated console, interpretive execution, and +z/Architecture support. +.PP +This manual page was written by Matt Zimmerman mdz@debian.org for +the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GNU Free Documentation +License, Version 1.1 or any later version published by the Free +Software Foundation; with no Invariant Sections, no Front-Cover +Texts and no Back-Cover Texts. +.\" created by instant / docbook-to-man, Tue 23 Mar 2010, 22:07 --- hercules-3.13.orig/panel.c +++ hercules-3.13/panel.c @@ -508,6 +508,11 @@ static int lines_scrolled() { + /* topmsg is not yet initialized when the text UI is not shown yet, + * but this function is still called if a command has been entered + * before that. */ + if (!topmsg) + return 0; /* return # of lines 'up' from current line that we're scrolled. */ if (topmsg->msgnum <= curmsg->msgnum) return curmsg->msgnum - topmsg->msgnum; --- hercules-3.13.orig/util/dasdlist.1 +++ hercules-3.13/util/dasdlist.1 @@ -0,0 +1,30 @@ +.TH "DASDLIST" "1" +.SH "NAME" +dasdlist +.SH "SYNOPSIS" +.PP +\fBdasdlist\fR \fBfilename\fR [\fBcyl head\fR] +.SH "DESCRIPTION" +.PP +This manual page documents the dasdlist program. +.PP +dasdlist dumps a track from a CKD DASD image file. +.SH "PARAMETERS" +.IP "\fBfilename\fR" 10 +input CKD DASD file +.IP "\fBcyl\fR" 10 +cylinder number of track to dump +.IP "\fBhead\fR" 10 +head number of track to dump +.SH "SEE ALSO" +.PP +The programs are documented fully by \fIThe Hercules +System/370, ESA/390, and z/Architecture Emulator\fPavailable in +\fB/usr/share/doc/hercules/html\fP. +.SH "AUTHOR" +Hercules was created by Roger Bowler and is maintained by +Jay Maynard. Jan Jaeger designed and implemented many of the +advanced features of Hercules, including dynamic +reconfiguration, integrated console, interpretive execution, and +z/Architecture support. +