diff --git a/_archdep_templ.c b/_archdep_templ.c index 774d693f4..e018cd385 100644 --- a/_archdep_templ.c +++ b/_archdep_templ.c @@ -199,7 +199,8 @@ static int non_arch_dep_static_helper_two( xxx... ) /* */ /* It is CRITICALLY IMPORTANT to not use any architecture dependent */ /* macros anywhere in any of your non-arch_dep functions. This means */ -/* you CANNOT use GREG, RADR, VADR, etc. anywhere in your function. */ +/* you CANNOT use GREG, RADR, VADR, etc. anywhere in your function, */ +/* nor can you call "ARCH_DEP(func)(args)" anywhere in your code! */ /* */ /* Basically you MUST NOT use any architecture dependent macro that */ /* is #defined in the "feature.h" header. If you you need to use */ diff --git a/config.c b/config.c index f9a0f3f3a..a879d1f5e 100644 --- a/config.c +++ b/config.c @@ -20,6 +20,16 @@ DISABLE_GCC_UNUSED_FUNCTION_WARNING; #include "opcode.h" #include "chsc.h" +/*-------------------------------------------------------------------*/ +/* ARCH_DEP section: compiled multiple times, once for each arch. */ +/*-------------------------------------------------------------------*/ + +// (we have no ARCH_DEP code in this module) + +/*-------------------------------------------------------------------*/ +/* (delineates ARCH_DEP from non-arch_dep) */ +/*-------------------------------------------------------------------*/ + #if !defined( _GEN_ARCH ) #if defined( _ARCH_NUM_2 ) @@ -34,6 +44,40 @@ DISABLE_GCC_UNUSED_FUNCTION_WARNING; #undef _GEN_ARCH #endif +/*-------------------------------------------------------------------*/ +/* (delineates ARCH_DEP from non-arch_dep) */ +/*-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------*/ +/* non-ARCH_DEP section: compiled only ONCE after last arch built */ +/*-------------------------------------------------------------------*/ +/* Note: the last architecture has been built so the normal non- */ +/* underscore FEATURE values are now #defined according to the */ +/* LAST built architecture just built (usually zarch = 900). This */ +/* means from this point onward (to the end of file) you should */ +/* ONLY be testing the underscore _FEATURE values to see if the */ +/* given feature was defined for *ANY* of the build architectures. */ +/*-------------------------------------------------------------------*/ + +/*********************************************************************/ +/* IMPORTANT PROGRAMMING NOTE */ +/*********************************************************************/ +/* */ +/* It is CRITICALLY IMPORTANT to not use any architecture dependent */ +/* macros anywhere in any of your non-arch_dep functions. This means */ +/* you CANNOT use GREG, RADR, VADR, etc. anywhere in your function, */ +/* nor can you call "ARCH_DEP(func)(args)" anywhere in your code! */ +/* */ +/* Basically you MUST NOT use any architecture dependent macro that */ +/* is #defined in the "feature.h" header. If you you need to use */ +/* any of them, then your function MUST be an "ARCH_DEP" function */ +/* that is placed within the ARCH_DEP section at the beginning of */ +/* this module where it can be compiled multiple times, once for */ +/* each of the supported architectures so the macro gets #defined */ +/* to its proper value for the architecture. YOU HAVE BEEN WARNED. */ +/* */ +/*********************************************************************/ + #if defined( HAVE_MLOCKALL ) /*-------------------------------------------------------------------*/ /* configure_memlock - lock or unlock storage */ @@ -129,10 +173,8 @@ BYTE *mainstor; BYTE *storkeys; BYTE *dofree = NULL; char *mfree = NULL; -REGS *regs; U64 storsize; U32 skeysize; -int cpu; /* Ensure all CPUs have been stopped */ if (are_any_cpus_started()) @@ -307,19 +349,8 @@ int cpu; #endif configure_region_reloc(); + initial_cpu_reset_all(); - /* Call initial_cpu_reset for every online processor */ - if (sysblk.cpus) - { - for (cpu = 0; cpu < sysblk.maxcpu; cpu++) - { - if (IS_CPU_ONLINE(cpu)) - { - regs=sysblk.regs[cpu]; - ARCH_DEP(initial_cpu_reset) (regs) ; - } - } - } return 0; } @@ -336,8 +367,6 @@ int configure_xstorage( U64 xpndsize ) BYTE *xpndstor; BYTE *dofree = NULL; char *mfree = NULL; -REGS *regs; -int cpu; /* Ensure all CPUs have been stopped */ if (are_any_cpus_started()) @@ -429,19 +458,7 @@ int cpu; xstorage_clear(); configure_region_reloc(); - - /* Call initial_cpu_reset for every online processor */ - if (sysblk.cpus) - { - for (cpu = 0; cpu < sysblk.maxcpu; cpu++) - { - if (IS_CPU_ONLINE(cpu)) - { - regs=sysblk.regs[cpu]; - ARCH_DEP(initial_cpu_reset) (regs) ; - } - } - } + initial_cpu_reset_all(); #else /*!_FEATURE_EXPANDED_STORAGE*/ UNREFERENCED(xpndsize); diff --git a/ipl.c b/ipl.c index 6bec093cc..1eed913c1 100644 --- a/ipl.c +++ b/ipl.c @@ -30,6 +30,12 @@ #include "hexterns.h" #endif +/*-------------------------------------------------------------------*/ +/* ARCH_DEP section: compiled multiple times, once for each arch. */ +/*-------------------------------------------------------------------*/ + +// Note: non-arch-dep static functions should ideally be at the end +// but you can put them here by using an ifdef similar to the below /*-------------------------------------------------------------------*/ /* Function to reset instruction count and CPU time */ @@ -87,6 +93,20 @@ static INLINE void subsystem_reset() } #endif // _subsystem_reset_ +//------------------------------------------------------------------- +// ARCH_DEP() code +//------------------------------------------------------------------- +// ARCH_DEP (build-architecture / FEATURE-dependent) functions here. +// All BUILD architecture dependent (ARCH_DEP) function are compiled +// multiple times (once for each defined build architecture) and each +// time they are compiled with a different set of FEATURE_XXX defines +// appropriate for that architecture. Use #ifdef FEATURE_XXX guards +// to check whether the current BUILD architecture has that given +// feature #defined for it or not. WARNING: Do NOT use _FEATURE_XXX. +// The underscore feature #defines mean something else entirely. Only +// test for FEATURE_XXX. (WITHOUT the underscore) +//------------------------------------------------------------------- + /*-------------------------------------------------------------------*/ /* Function to perform System Reset (either 'normal' or 'clear') */ /*-------------------------------------------------------------------*/ @@ -714,21 +734,68 @@ int ARCH_DEP( initial_cpu_reset )( REGS* regs ) return rc1; } /* end function initial_cpu_reset */ -#if !defined(_GEN_ARCH) +/*-------------------------------------------------------------------*/ +/* (delineates ARCH_DEP from non-arch_dep) */ +/*-------------------------------------------------------------------*/ -#if defined(_ARCH_NUM_1) - #define _GEN_ARCH _ARCH_NUM_1 - #include "ipl.c" -#endif +#if !defined( _GEN_ARCH ) -#if defined(_ARCH_NUM_2) - #undef _GEN_ARCH - #define _GEN_ARCH _ARCH_NUM_2 - #include "ipl.c" -#endif + #if defined( _ARCH_NUM_1 ) + #define _GEN_ARCH _ARCH_NUM_1 + #include "ipl.c" + #endif + + #if defined( _ARCH_NUM_2 ) + #undef _GEN_ARCH + #define _GEN_ARCH _ARCH_NUM_2 + #include "ipl.c" + #endif + +/*-------------------------------------------------------------------*/ +/* (delineates ARCH_DEP from non-arch_dep) */ +/*-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------*/ +/* non-ARCH_DEP section: compiled only ONCE after last arch built */ +/*-------------------------------------------------------------------*/ +/* Note: the last architecture has been built so the normal non- */ +/* underscore FEATURE values are now #defined according to the */ +/* LAST built architecture just built (usually zarch = 900). This */ +/* means from this point onward (to the end of file) you should */ +/* ONLY be testing the underscore _FEATURE values to see if the */ +/* given feature was defined for *ANY* of the build architectures. */ +/*-------------------------------------------------------------------*/ + +//------------------------------------------------------------------- +// _FEATURE_XXX code +//------------------------------------------------------------------- +// Place any _FEATURE_XXX depdendent functions (WITH the underscore) +// here. You may need to define such functions whenever one or more +// build architectures has a given FEATURE_XXX (WITHOUT underscore) +// defined for it. The underscore means AT LEAST ONE of the build +// architectures #defined that feature. (See featchk.h) You must NOT +// use any #ifdef FEATURE_XXX here. Test for ONLY for _FEATURE_XXX. +// The functions in this area are compiled ONCE (only ONE time) and +// ONLY one time but are always compiled LAST after everything else. +//------------------------------------------------------------------- /*********************************************************************/ -/* Externally Initiated Functions... */ +/* IMPORTANT PROGRAMMING NOTE */ +/*********************************************************************/ +/* */ +/* It is CRITICALLY IMPORTANT to not use any architecture dependent */ +/* macros anywhere in any of your non-arch_dep functions. This means */ +/* you CANNOT use GREG, RADR, VADR, etc. anywhere in your function, */ +/* nor can you call "ARCH_DEP(func)(args)" anywhere in your code! */ +/* */ +/* Basically you MUST NOT use any architecture dependent macro that */ +/* is #defined in the "feature.h" header. If you you need to use */ +/* any of them, then your function MUST be an "ARCH_DEP" function */ +/* that is placed within the ARCH_DEP section at the beginning of */ +/* this module where it can be compiled multiple times, once for */ +/* each of the supported architectures so the macro gets #defined */ +/* to its proper value for the architecture. YOU HAVE BEEN WARNED. */ +/* */ /*********************************************************************/ /*-------------------------------------------------------------------*/ @@ -757,6 +824,27 @@ int load_ipl( U16 lcss, U16 devnum, int cpu, int clear ) return rc; } +/*-------------------------------------------------------------------*/ +/* initial_cpu_reset_all -- do initial_cpu_reset for every processor */ +/*-------------------------------------------------------------------*/ +void initial_cpu_reset_all() +{ + REGS* regs; + int cpu; + + if (sysblk.cpus) + { + for (cpu = 0; cpu < sysblk.maxcpu; cpu++) + { + if (IS_CPU_ONLINE( cpu )) + { + regs = sysblk.regs[ cpu ]; + initial_cpu_reset( regs ) ; + } + } + } +} + /*-------------------------------------------------------------------*/ /* Initial CPU Reset */ /*-------------------------------------------------------------------*/ diff --git a/opcode.h b/opcode.h index 9e55462f8..20c695b4e 100644 --- a/opcode.h +++ b/opcode.h @@ -3094,6 +3094,7 @@ int system_reset ( const int target_mode, const bool clear, co int ARCH_DEP( system_reset ) ( const int target_mode, const bool clear, const bool ipl, const int cpu ); int cpu_reset (REGS *regs); int ARCH_DEP( cpu_reset ) (REGS *regs); +void initial_cpu_reset_all(); int initial_cpu_reset (REGS *regs); int ARCH_DEP( initial_cpu_reset ) (REGS *regs); int ARCH_DEP( common_load_begin ) (int cpu, int clear);