Skip to content

Commit

Permalink
New FACILITY command to replace ARCHLVL command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fish-Git committed Mar 8, 2018
1 parent e5c8bd1 commit c281dea
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 39 deletions.
132 changes: 113 additions & 19 deletions archlvl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1321,22 +1321,22 @@ static const char* get_facname_by_bitno( int bitno, const char** name )
/*-------------------------------------------------------------------*/
static int sort_ftpp_by_bit_number( const void* p1, const void* p2 )
{
const FACTAB* f1 = *( (const FACTAB**) p1 );
const FACTAB* f2 = *( (const FACTAB**) p2 );
const FACTAB* f1 = *((const FACTAB**) p1);
const FACTAB* f2 = *((const FACTAB**) p2);
int rc = (f1->bitno - f2->bitno);
return rc ? rc : strcasecmp( f1->name, f2->name );
}
static int sort_ftpp_by_long_name( const void* p1, const void* p2 )
{
const FACTAB* f1 = *( (const FACTAB**) p1 );
const FACTAB* f2 = *( (const FACTAB**) p2 );
const FACTAB* f1 = *((const FACTAB**) p1);
const FACTAB* f2 = *((const FACTAB**) p2);
return strcasecmp( f1->long_name, f2->long_name );
}

/*-------------------------------------------------------------------*/
/* archlvl_query_all */
/* facility_query_all */
/*-------------------------------------------------------------------*/
static bool archlvl_query_all( const ARCHTAB* at, bool sort_by_long )
static bool facility_query_all( const ARCHTAB* at, bool sort_by_long )
{
const FACTAB* ft; // ptr to FACTAB entry
const FACTAB** ftpp; // ptr to ptr to FACTAB entry
Expand Down Expand Up @@ -1421,9 +1421,9 @@ static bool archlvl_query_all( const ARCHTAB* at, bool sort_by_long )
}

/*-------------------------------------------------------------------*/
/* archlvl_query_raw */
/* facility_query_raw */
/*-------------------------------------------------------------------*/
static void archlvl_query_raw( const ARCHTAB* at )
static void facility_query_raw( const ARCHTAB* at )
{
char buf[ 128 ] = {0};
char wrk[ 20 ];
Expand Down Expand Up @@ -1471,13 +1471,13 @@ static void archlvl_query_raw( const ARCHTAB* at )
}

/*-------------------------------------------------------------------*/
/* archlvl_query (boolean) */
/* facility_query (boolean) */
/*-------------------------------------------------------------------*/
/* */
/* ARCHLVL QUERY [ ALL | SHORT | LONG | <facility> | bit | RAW ] */
/* */
/*-------------------------------------------------------------------*/
static bool archlvl_query( int argc, char* argv[] )
static bool facility_query( int argc, char* argv[] )
{
const ARCHTAB* at;
const FACTAB* ft;
Expand Down Expand Up @@ -1510,14 +1510,14 @@ static bool archlvl_query( int argc, char* argv[] )
))
{
const bool sort_by_long = argc < 3 ? false : CMD( argv[2], LONG, 1 );
return archlvl_query_all( at, sort_by_long );
return facility_query_all( at, sort_by_long );
}

/* Query RAW? */

if (argc == 3 && CMD( argv[2], RAW, 1 ))
{
archlvl_query_raw( at );
facility_query_raw( at );
return true;
}

Expand Down Expand Up @@ -2106,7 +2106,7 @@ static void name( int arch, bool enable ) \
/* itself is disabled, or re-enable the instructions again whenever */
/* the facility is enabled. This is controlled by optional function */
/* pointers defined in the above 'FT2' facilities table which the */
/* 'archlvl_enable_disable' function calls when a facility is either */
/* facility_enable_disable function calls when a facility is either */
/* enabled or disabled. */
/*-------------------------------------------------------------------*/

Expand Down Expand Up @@ -3405,13 +3405,13 @@ BEG_DIS_FAC_INS_FUNC( herc37X )
END_DIS_FAC_INS_FUNC()

/*-------------------------------------------------------------------*/
/* archlvl_enable_disable (boolean) */
/* facility_enable_disable (boolean) */
/*-------------------------------------------------------------------*/
/* */
/* ARCHLVL ENABLE | DISABLE <facility> | bit [S/370|ESA/390|z/ARCH] */
/* */
/*-------------------------------------------------------------------*/
static int archlvl_enable_disable( int argc, char* argv[] )
static int facility_enable_disable( int argc, char* argv[] )
{
const ARCHTAB* at;
const FACTAB* ft;
Expand Down Expand Up @@ -3573,14 +3573,75 @@ static int archlvl_enable_disable( int argc, char* argv[] )
}

/*-------------------------------------------------------------------*/
/* archlvl_cmd (public) */
/* facility_cmd (public) */
/*-------------------------------------------------------------------*/
/* */
/* ARCHLVL S/370 | ESA/390 | z/ARCH */
/* ARCHLVL ENABLE | DISABLE <facility> | bit [S/370|ESA/390|z/ARCH] */
/* ARCHLVL QUERY [ ALL | SHORT | LONG | <facility> | bit | RAW ] */
/* */
/*-------------------------------------------------------------------*/
int facility_cmd( int argc, char* argv[], char* cmdline )
{
UNREFERENCED( cmdline );

strupper( argv[0], argv[0] );

/* Correct number of arguments? */

if (argc < 3 || argc > 4)
{
// "Invalid command usage. Type 'help %s' for assistance."
WRMSG( HHC02299, "E", argv[0] );
return -1;
}

/*-----------------------------------------------------*/
/* Query Facility? */
/*-----------------------------------------------------*/

if (CMD( argv[1], QUERY, 1 ))
{
int rc = facility_query( argc, argv ) ? 0 : -1;
return rc;
}

/*-----------------------------------------------------*/
/* Enable/Disable Facility? */
/*-----------------------------------------------------*/

if (0
|| CMD( argv[1], ENABLE, 3 )
|| CMD( argv[1], DISABLE, 3 )
)
{
if (sysblk.ipled)
{
// "Available facilities cannot be changed once system is IPLed"
WRMSG( HHC00889, "E" );
return -1;
}

if (are_any_cpus_started())
{
// "All CPU's must be stopped %s"
WRMSG( HHC02253, "E", "to modify a facility" );
return HERRCPUONL;
}
return facility_enable_disable( argc, argv );
}

// "Invalid command usage. Type 'help %s' for assistance."
WRMSG( HHC02299, "E", argv[0] );
return -1;
}

/*-------------------------------------------------------------------*/
/* archlvl_cmd (public) */
/*-------------------------------------------------------------------*/
/* */
/* ARCHLVL S/370 | ESA/390 | z/ARCH */
/* */
/*-------------------------------------------------------------------*/
int archlvl_cmd( int argc, char* argv[], char* cmdline )
{
bool any_started, storage_reset = false;
Expand All @@ -3600,6 +3661,25 @@ int archlvl_cmd( int argc, char* argv[], char* cmdline )
return 0;
}

#if 0 // Enable the below on/after 2019-12-31

/* Too many arguments? */

if (argc > 2)
{
// "Invalid command usage. Type 'help %s' for assistance."
WRMSG( HHC02299, "E", argv[0] );
return -1;
}

/*-----------------------------------------------------*/
/* Make sure all CPUs are deconfigured or stopped */
/*-----------------------------------------------------*/

any_started = are_any_cpus_started();

#else // Below is DEPRECATED; replace with above on/after 2019-12-31

/* Too many arguments? */

if (argc > 4)
Expand All @@ -3615,7 +3695,11 @@ int archlvl_cmd( int argc, char* argv[], char* cmdline )

if (CMD( argv[1], QUERY, 1 ))
{
int rc = archlvl_query( argc, argv ) ? 0 : -1;
int rc = facility_query( argc, argv ) ? 0 : -1;
// "Note: Enabling/Disabling/Querying facilities via 'ARCHLVL' is deprecated."
// " Please use the new FACILITY command instead."
WRMSG( HHC00887, "W" );
WRMSG( HHC00888, "W" );
return rc;
}

Expand All @@ -3634,6 +3718,8 @@ int archlvl_cmd( int argc, char* argv[], char* cmdline )
|| CMD( argv[1], DISABLE, 3 )
)
{
int rc;

if (sysblk.ipled)
{
// "Available facilities cannot be changed once system is IPLed"
Expand All @@ -3647,9 +3733,17 @@ int archlvl_cmd( int argc, char* argv[], char* cmdline )
WRMSG( HHC02253, "E", "to modify a facility" );
return HERRCPUONL;
}
return archlvl_enable_disable( argc, argv );

rc = facility_enable_disable( argc, argv );
// "Note: Enabling/Disabling/Querying facilities via 'ARCHLVL' is deprecated."
// " Please use the new FACILITY command instead."
WRMSG( HHC00887, "W" );
WRMSG( HHC00888, "W" );
return rc;
}

#endif // Delete the above on/after 2019-12-31

/*-----------------------------------------------------*/
/* Set Architecture */
/*-----------------------------------------------------*/
Expand Down
38 changes: 20 additions & 18 deletions cmdtab.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,15 @@
#define aia_cmd_desc "Display AIA fields"
#define alrf_cmd_desc "Command deprecated: Use \"archlvl enable|disable|query asn_lx_reuse\" instead"
#define ar_cmd_desc "Display access registers"
#define archlvl_cmd_desc "Set Arch Mode or Enable/Disable/Query Facility"

#define archlvl_cmd_desc "Set or Query current Architecture Mode"
#define archlvl_cmd_help \
\
"Format: ARCHLVL S/370 | ESA/390 | z/ARCH\n" \
" ARCHLVL ENABLE | DISABLE <facility> | bit [S/370|ESA/390|z/ARCH]\n" \
" ARCHLVL QUERY [ ALL | SHORT | LONG | <facility> | bit | RAW ]\n" \
"Format: ARCHLVL S/370 | ESA/390 | z/ARCH\n" \
"\n" \
"Entering the command without arguments displays the current architecture\n" \
"mode. Entering the command with an argument sets the architecture mode\n" \
"to the given value, or enables, disables or queries the given facility.\n" \
"\n" \
"Use the ARCHLVL QUERY command to obtain the list of facility names that\n" \
"can then be used in a ARCHLVL ENABLE/DISABLE <facility> command.\n"
"mode. Entering the command with an argument sets the architecture mode.\n" \
"To enable/disable/query facilities please use the new FACILITY command.\n"

#define archmode_cmd_desc "Deprecated. Use the archlvl command instead"
#define asnlx_cmd_desc "Command deprecated: Use \"archlvl enable|disable|query asn_lx_reuse\" instead"
Expand Down Expand Up @@ -184,6 +180,8 @@
"options and statistics, and to set new cckd options.\n" \
"Type \"cckd help\" for additional information.\n"

#define cctape_cmd_desc "Display a printer's current cctape"
#define cctape_cmd_help "Format: \"cctape <devnum>\""
#define cf_cmd_desc "Configure current CPU online or offline"
#define cf_cmd_help \
\
Expand Down Expand Up @@ -519,11 +517,14 @@
#define exit_cmd_desc "(Synonym for 'quit')"
#define ext_cmd_desc "Generate external interrupt"
#define f_cmd_desc "Mark frames unusable/usable"
#define facility_cmd_desc "Enable, Disable or Query Facilities"
#define facility_cmd_help \
\
"Format: FACILITY ENABLE | DISABLE <facility> | bit [ archlvl ]\n" \
" FACILITY QUERY [ ALL | SHORT | LONG | <facility> | bit | RAW ]\n"

#define fcb_cmd_desc "Display a printer's current FCB"
#define fcb_cmd_help "Format: \"fcb <devnum>\""
#define cctape_cmd_desc "Display a printer's current cctape"
#define cctape_cmd_help "Format: \"cctape <devnum>\""

#define fpc_cmd_desc "Display or alter floating point control register"
#define fpc_cmd_help \
\
Expand Down Expand Up @@ -1582,7 +1583,7 @@ COMMAND( "cmdlvl", cmdlvl_cmd, SYSALL,
COMMAND( "cmdsep", cmdsep_cmd, SYSALL, cmdsep_cmd_desc, cmdsep_cmd_help )
COMMAND( "help", HelpCommand, SYSALL, help_cmd_desc, help_cmd_help )
COMMAND( "hst", History, SYSALL, hst_cmd_desc, hst_cmd_help )
CMDABBR( "message", 1, msg_cmd, SYSALL, message_cmd_desc, message_cmd_help )
CMDABBR( "message", 1, msg_cmd, SYSALL, message_cmd_desc, message_cmd_help )
COMMAND( "msg", msg_cmd, SYSALL, msg_cmd_desc, NULL )
COMMAND( "msglevel", msglevel_cmd, SYSALL, msglevel_cmd_desc, msglevel_cmd_help )
COMMAND( "msglvl", msglevel_cmd, SYSALL, msglvl_cmd_desc, NULL )
Expand All @@ -1603,9 +1604,9 @@ COMMAND( "log", log_cmd, SYSCMD,
COMMAND( "logopt", logopt_cmd, SYSCMD, logopt_cmd_desc, logopt_cmd_help )
COMMAND( "mt", mt_cmd, SYSCMD, mt_cmd_desc, mt_cmd_help )
COMMAND( "pantitle", pantitle_cmd, SYSCMD, pantitle_cmd_desc, pantitle_cmd_help )
CMDABBR( "qcpuid", 5, qcpuid_cmd, SYSCMD, qcpuid_cmd_desc, qcpuid_cmd_help )
CMDABBR( "qcpuid", 5, qcpuid_cmd, SYSCMD, qcpuid_cmd_desc, qcpuid_cmd_help )
COMMAND( "qpid", qpid_cmd, SYSCMD, qpid_cmd_desc, NULL )
CMDABBR( "qports", 5, qports_cmd, SYSCMD, qports_cmd_desc, NULL )
CMDABBR( "qports", 5, qports_cmd, SYSCMD, qports_cmd_desc, NULL )
COMMAND( "qproc", qproc_cmd, SYSCMD, qproc_cmd_desc, NULL )
COMMAND( "qstor", qstor_cmd, SYSCMD, qstor_cmd_desc, NULL )
COMMAND( "start", start_cmd, SYSCMD, start_cmd_desc, start_cmd_help )
Expand Down Expand Up @@ -1693,15 +1694,15 @@ COMMAND( "cpumodel", cpumodel_cmd, SYSCFGNDIAG8,
COMMAND( "cpuprio", cpuprio_cmd, SYSCFGNDIAG8, cpuprio_cmd_desc, NULL )
COMMAND( "cpuserial", cpuserial_cmd, SYSCFGNDIAG8, cpuserial_cmd_desc, NULL )
COMMAND( "cpuverid", cpuverid_cmd, SYSCFGNDIAG8, cpuverid_cmd_desc, NULL )
CMDABBR( "defstore", 7, defstore_cmd, SYSCFGNDIAG8, defstore_cmd_desc, defstore_cmd_help )
CMDABBR( "defstore", 7, defstore_cmd, SYSCFGNDIAG8, defstore_cmd_desc, defstore_cmd_help )
COMMAND( "devprio", devprio_cmd, SYSCFGNDIAG8, devprio_cmd_desc, NULL )
COMMAND( "diag8cmd", diag8_cmd, SYSCFGNDIAG8, diag8_cmd_desc, diag8_cmd_help )
COMMAND( "engines", engines_cmd, SYSCFGNDIAG8, engines_cmd_desc, NULL )
COMMAND( "hercprio", hercprio_cmd, SYSCFGNDIAG8, hercprio_cmd_desc, NULL )
COMMAND( "lparname", lparname_cmd, SYSCFGNDIAG8, lparname_cmd_desc, lparname_cmd_help )
COMMAND( "lparnum", lparnum_cmd, SYSCFGNDIAG8, lparnum_cmd_desc, lparnum_cmd_help )
COMMAND( "mainsize", mainsize_cmd, SYSCFGNDIAG8, mainsize_cmd_desc, mainsize_cmd_help )
CMDABBR( "manufacturer", 8, stsi_manufacturer_cmd, SYSCFGNDIAG8, manuf_cmd_desc, NULL )
CMDABBR( "manufacturer", 8, stsi_manufacturer_cmd, SYSCFGNDIAG8, manuf_cmd_desc, NULL )
COMMAND( "model", stsi_model_cmd, SYSCFGNDIAG8, model_cmd_desc, model_cmd_help )
COMMAND( "plant", stsi_plant_cmd, SYSCFGNDIAG8, plant_cmd_desc, NULL )
COMMAND( "shcmdopt", shcmdopt_cmd, SYSCFGNDIAG8, shcmdopt_cmd_desc, shcmdopt_cmd_help )
Expand All @@ -1713,6 +1714,7 @@ COMMAND( "xpndsize", xpndsize_cmd, SYSCFGNDIAG8,
COMMAND( "yroffset", yroffset_cmd, SYSCFGNDIAG8, yroffset_cmd_desc, NULL )

COMMAND( "archlvl", archlvl_cmd, SYSCMDNOPERNDIAG8, archlvl_cmd_desc, archlvl_cmd_help )
CMDABBR( "facility", 3, facility_cmd, SYSCMDNOPERNDIAG8, facility_cmd_desc, facility_cmd_help )
COMMAND( "archmode", archlvl_cmd, SYSCMDNOPERNDIAG8, archmode_cmd_desc, NULL )

COMMAND( "exit", quit_cmd, SYSALLNDIAG8, exit_cmd_desc, NULL )
Expand Down Expand Up @@ -1778,7 +1780,7 @@ COMMAND( "exec", exec_cmd, SYSCMD,
#endif /* defined(HAVE_OBJECT_REXX) || defined(HAVE_REGINA_REXX) */

#if defined( ENABLE_BUILTIN_SYMBOLS )
CMDABBR( "qpfkeys", 3, qpfkeys_cmd, SYSCMD, qpfkeys_cmd_desc, NULL )
CMDABBR( "qpfkeys", 3, qpfkeys_cmd, SYSCMD, qpfkeys_cmd_desc, NULL )
COMMAND( "defsym", defsym_cmd, SYSCMDNOPER, defsym_cmd_desc, defsym_cmd_help )
COMMAND( "delsym", delsym_cmd, SYSCMDNOPER, delsym_cmd_desc, delsym_cmd_help )
#endif /* #if defined( ENABLE_BUILTIN_SYMBOLS ) */
Expand Down
4 changes: 2 additions & 2 deletions msgenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,8 @@ LOGM_DLL_IMPORT int panel_command_capture( char* cmd, char** resp );
#define HHC00884 "Channel Report queue: (empty)"
#define HHC00885 "Channel Report queue:"
#define HHC00886 "CRW 0x%8.8X: %s"
//efine HHC00887 (available)
//efine HHC00888 (available)
#define HHC00887 "Note: Enabling/Disabling/Querying facilities via 'ARCHLVL' is deprecated."
#define HHC00888 " Please use the new FACILITY command instead."
#define HHC00889 "Available facilities cannot be changed once system is IPLed"
#define HHC00890 "Cannot %s facility %s without first %s facility %s"
#define HHC00891 "%3d %02X %02X %c%c%c%c%c %-27s %s"
Expand Down

0 comments on commit c281dea

Please sign in to comment.