PROCEDURE (HIDDEN) cmp$system_deadstart_prolog

  TASK ring=11

"$FORMAT=OFF
TYPE
  deadstart_tasks: list 0..$max_list of name
TYPEND

VAR
  continuation_tasks: deadstart_tasks = ..
        (install_configuration activate_volumes change_logical_configuration)
  deadstart_phase: key installation, reinstallation, continuation ..
     keyend
  force_intervention: boolean
  ignore_status: status
  intervention_occurred: boolean
  installation_tasks: deadstart_tasks = ..
   (install_configuration activate_volumes install_network_commands)
  intervention_step : name
  menu_items: deadstart_tasks
  menu_selection: string
  menu_options: deadstart_tasks = ..
      (install_configuration activate_volumes change_logical_configuration)
  cmv$force_intervention: (xref) boolean
  osv$configuration_prolog_name: (xref) string 0 .. $max_name
  osv$deadstart_phase: (xref) string 0 .. $max_name
  osv$operator_intervention: (xref) boolean
  osv$reinitialize_system_device: (xref) boolean
  prolog_name: name
  reinstallation_tasks: deadstart_tasks = ..
     (install_configuration activate_volumes change_logical_configuration)
  status: status
  tasks: deadstart_tasks
  usecp_selection: string 31
VAREND
"$FORMAT=ON

    IF NOT $variable(cmv$deadstart_simulation, defined) THEN
      WHEN any_fault interrupt DO
        rap$display_message message_module=sysdp_messages ..
              message_name=report_when_fault ..
              message_parameters= osv$command_name to=$output
        display_value osv$status o=$output
        CONTINUE
      WHENEND
    IFEND

    PUSH file_connections
    create_file_connection $errors $job_log status=ignore_status
    create_file_connection $output $job_log status=ignore_status
    create_file_connection $response $job_log status=ignore_status

    PUSH command_list
    create_command_list_entry $local.prolog_library status=ignore_status
    create_command_list_entry $local.osf$ds_library status=ignore_status

    IF osv$deadstart_phase = 'INSTALL' THEN
      IF osv$reinitialize_system_device THEN
        deadstart_phase = reinstallation
        tasks = continuation_tasks
      ELSE
        deadstart_phase = installation
        tasks = installation_tasks
      IFEND
    ELSE
      deadstart_phase = continuation
      tasks = continuation_tasks
    IFEND

    IF deadstart_phase <> continuation THEN
      IF osv$configuration_prolog_name = '' THEN
        prolog_name = $name($mainframe(identifier))
        usecp_selection = 'NONE'
      ELSE
        prolog_name = $name(osv$configuration_prolog_name)
        usecp_selection = osv$configuration_prolog_name
      IFEND

      IF $file($local.prolog_library, opened) THEN
        display_command_information $local.prolog_library//prolog_name ..
              output=$null status=status
        IF (NOT status.normal) AND (osv$configuration_prolog_name <> '') THEN
          rap$display_message message_module=sysdp_messages ..
                message_name=prolog_procedure_missing ..
                message_parameters= osv$configuration_prolog_name to=$output
          prolog_name = none
        ELSEIF (NOT status.normal) THEN
          prolog_name = none
        IFEND
      ELSEIF osv$configuration_prolog_name <> '' THEN
        rap$display_message message_module=sysdp_messages ..
              message_name=prolog_library_missing ..
              message_parameters= osv$configuration_prolog_name to=$output
        prolog_name = none
      ELSE
        prolog_name = none
      IFEND
    ELSE
      prolog_name = none
      usecp_selection = 'NONE'
    IFEND

    IF osv$operator_intervention THEN
      rap$display_message message_module=sysdp_messages ..
            message_name=intervention_requested to=$output
      menu_items = $intersection(menu_options tasks) "
      cmp$ask_for_intervention deadstart_phase=deadstart_phase ..
            menu_items=menu_items prolog_procedure_name=prolog_name ..
            usecp_selection=usecp_selection ..
            intervention_step=intervention_step status=status
      IF NOT status.normal THEN
        rap$display_message message_module=sysdp_messages ..
              message_name=report_menu_fault to=$output
        display_value status
        intervention_step = none
      IFEND
    ELSE
      intervention_step = none
    IFEND

    REPEAT
      intervention_occurred = false
      force_intervention = (intervention_step = $first(tasks))

      IF $first(tasks) = install_configuration THEN
        cmp$install_configuration deadstart_phase= deadstart_phase ..
              operator_intervention_required= force_intervention ..
              prolog_procedure_name= prolog_name ..
              operator_intervention_occurred= intervention_occurred ..
              status=status
      IFEND

      force_intervention = force_intervention OR cmv$force_intervention
      IF $first(tasks) = activate_volumes THEN
        cmp$activate_configuration deadstart_phase= deadstart_phase ..
              operator_intervention_required=force_intervention ..
              prolog_procedure_name=prolog_name ..
              operator_intervention_occurred= intervention_occurred ..
              status=status
      IFEND

      IF $first(tasks) = change_logical_configuration THEN
        IF force_intervention THEN
          cmp$perform_lcu_intervention deadstart_phase=deadstart_phase ..
                status=status
        IFEND
      IFEND

      IF $first(tasks) = install_network_commands THEN
        cmp$install_network_commands prolog_procedure_name=prolog_name ..
              status=status
        IF NOT status.normal THEN
          rap$display_message message_module=sysdp_messages ..
                message_name=report_error
          display_value status o=$output
          status = $status(true)
        IFEND
      IFEND

      IF status.normal THEN
        tasks = $rest(tasks)
        IF force_intervention OR intervention_occurred THEN
          menu_items = $intersection(menu_options tasks)
          IF NOT $nil(menu_items) THEN
            IF force_intervention THEN
              message_name = intervention_requested
            ELSE
              message_name = intervention_due_to_error
            IFEND
            rap$display_message message_module=sysdp_messages ..
                  message_name=message_name to=$output
            cmp$ask_for_intervention deadstart_phase=deadstart_phase ..
                  menu_items=menu_items prolog_procedure_name=prolog_name ..
                  usecp_selection=usecp_selection ..
                  intervention_step=intervention_step status=status
            IF NOT status.normal THEN
              rap$display_message message_module=sysdp_messages ..
                    message_name=report_menu_fault to=$output
              display_value status
              intervention_step = none
            IFEND
          IFEND
        IFEND
      ELSE
        rap$display_message message_module=sysdp_messages ..
              message_name=report_error to=$output
        display_value status
        intervention_step = $first(tasks)
      IFEND

    UNTIL $nil(tasks)


    delete_file $local.cmf$default_configuration status=ignore_status
    delete_file $local.lcu_mainframe_subcommands status=ignore_status
    delete_file $local.lcu_network_subcommands status=ignore_status
    delete_file $local.pcu_subcommands status=ignore_status
    delete_file $local.physical_config status=ignore_status
    delete_file $local.physical_configuration status=ignore_status
  TASKEND

PROCEND cmp$system_deadstart_prolog
