?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Deadstart : Start processors' ??
MODULE dsm$start_all_cpus;

{ PURPOSE:
{   This module contains the procedure that is used to start additional processors during deadstart.  It will
{   request to start all CPUs, except the deadstart CPU, which is on according to CTI.  Also, it contains
{   procedures which will change the way memory is purged in the event of the addition or removal of a
{   processor to/from the mainframe configuration.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc osc$multiprocessor_constants
*copyc osc$processor_defined_registers
*copyc ost$processor_id
?? POP ??
*copyc dsp$get_cpu_attributes
*copyc dsp$start_additional_cpu
*copyc osp$get_global_cpu_model_def
?? EJECT ??
*IF $variable(mmv$test_forced_use_cache_maps, declared) <> 'UNKNOWN'
*copyc mmv$force_use_of_cache_and_maps;
*ELSE
{ -------- Variable declarations for forcing the use of cache and maps omitted at compile time --------
*IFEND
*copyc mmv$multiple_caches
*copyc mmv$multiple_page_maps
*copyc mtv$all_cpus_have_been_started
*copyc mtv$cst0
*copyc mtv$scb
*copyc osv$cpus_physically_configured
*copyc tmv$multiple_cpus_active
?? OLDTITLE ??
?? NEWTITLE := 'dsp$start_all_cpus', EJECT ??

{ PURPOSE:
{   This procedure will start additional CPUS during deadstart.
{
{ WARNING!
{   This procedure is to be called during deadstart ONLY!.  Any other call to this procedure elsewhere will
{   produce unpredictable results, although there is a good possibility that the system will crash.

  PROCEDURE [XDCL, #GATE] dsp$start_all_cpus;

    VAR
      cpu_attributes: dst$cpu_attributes,
      cpu_index: 0 .. (osc$max_number_of_processors - 1),
      global_processor_model_def: ost$processor_model_definition;




    dsp$get_cpu_attributes (cpu_attributes);

    mtv$scb.vector_simulation_control.all_vector_divides_degraded := TRUE;
    FOR cpu_index := 0 TO osv$cpus_physically_configured - 1 DO

      { Don't "start" the processor which is executing this code.

      IF cpu_index <> #READ_REGISTER (osc$pr_maintenance_id) THEN
        IF mtv$cst0 [cpu_index].next_processor_state = cmc$on THEN
          osp$get_global_cpu_model_def (global_processor_model_def);
          mmv$multiple_caches := global_processor_model_def.cache_present;
          mmv$multiple_page_maps := global_processor_model_def.maps_present;
          dsp$start_additional_cpu (cpu_index);
        IFEND;

        IF NOT cpu_attributes.cpu [cpu_index].vectors_not_available THEN
          mtv$scb.vector_simulation_control.all_vector_divides_degraded := FALSE;
        IFEND;

        mtv$cst0 [cpu_index].processor_state := mtv$cst0 [cpu_index].next_processor_state;

        { TMV$MULTIPLE_CPUS_ACTIVE is the variable used to prevent any harmful system effects from a site
        { setting DEDICATE_A_CPU_TO_NOS TRUE and only having one cpu present. The SETSA mechanism is not
        { smart enough to detect when this would be a harmful action. The variable OSV$MULTIPROCESSOR_RUNNING
        { has the same meaning; however, the setting and resetting of OSV$MULTIPROCESSOR_RUNNING is too late.
        { There is too large of a window in which we could potentially never run NOS/VE tasks again.

        IF mtv$cst0 [cpu_index].processor_state = cmc$on THEN
          tmv$multiple_cpus_active := TRUE;
          mtv$cst0 [cpu_index].dispatching_priority_integer := 0;
        IFEND;
      ELSE
        IF NOT cpu_attributes.cpu [cpu_index].vectors_not_available THEN
          mtv$scb.vector_simulation_control.all_vector_divides_degraded := FALSE;
        IFEND;
      IFEND;
    FOREND;

    mtv$all_cpus_have_been_started := TRUE;

*IF $variable(mmv$test_forced_use_cache_maps, declared) <> 'UNKNOWN'

    { The following code is benchmark code to force use of cache and/or maps during benchmark runs.

    mmv$multiple_caches := mmv$multiple_caches OR mmv$force_use_of_cache_and_maps;
    mmv$multiple_page_maps := mmv$multiple_page_maps OR mmv$force_use_of_cache_and_maps;
*ELSE
{ -------- Code for forcing the use of cache and maps omitted at compile time --------
*IFEND

  PROCEND dsp$start_all_cpus;
?? OLDTITLE ??
MODEND dsm$start_all_cpus;
