
PROC dum$display_logical_unit_table, display_logical_unit_table, dislut (
  ordinal, ord: integer or key all, a=all
  display_unit_queue, disuq: boolean = FALSE
  output, o: file = $output
  status)

      create_variable ignore_status k=status
      create_variable device_usage_sanctions kind=(string,25) dimension=0..2
          device_usage_sanctions(0) = 'INHIBIT LOGICAL MOUNT'
          device_usage_sanctions(1) = 'INHIBIT READ REQUEST'
          device_usage_sanctions(2) = 'INHIBIT WRITE REQUEST'
      create_variable element_state_mneumonics kind=(string,5) dimension=0..2
          element_state_mneumonics(0) = 'ON'
          element_state_mneumonics(1) = 'OFF'
          element_state_mneumonics(2) = 'DOWN'
      create_variable unit_type_map dimension=1..24
          unit_type_map(1) = 1
          unit_type_map(2) = 2
          unit_type_map(3) = 3
          unit_type_map(4) = 4
          unit_type_map(5) = 5
          unit_type_map(6) = 6
          unit_type_map(7) = 7
          unit_type_map(8) = 8
          unit_type_map(9) = 9
          unit_type_map(10)= 10
          unit_type_map(11) = 11
          unit_type_map(12) = 12
          unit_type_map(13) = 13
          unit_type_map(14) = 14
          unit_type_map(15) = 15
          unit_type_map(16) = 16
          unit_type_map(17) = 256
          unit_type_map(18) = 257
          unit_type_map(19) = 258
          unit_type_map(20) = 259
          unit_type_map(21) = 260
          unit_type_map(22) = 512
          unit_type_map(23) = 513
          unit_type_map(24) = 514
      create_variable unit_type_mneumonics kind=(string,20) dimension=1..24
          unit_type_mneumonics(1) = 'MT 679_5'
          unit_type_mneumonics(2) = 'MT 679_6'
          unit_type_mneumonics(3) = 'MT 679_7'
          unit_type_mneumonics(4) = 'MT 679_2'
          unit_type_mneumonics(5) = 'MT 679_3'
          unit_type_mneumonics(6) = 'MT 679_4'
          unit_type_mneumonics(7) = 'MT 677_2'
          unit_type_mneumonics(8) = 'MT 677_3'
          unit_type_mneumonics(9) = 'MT 677_4'
          unit_type_mneumonics(10) = 'MT 667_2'
          unit_type_mneumonics(11) = 'MT 667_8'
          unit_type_mneumonics(12) = 'MT 667_4'
          unit_type_mneumonics(13) = 'MT 669_2'
          unit_type_mneumonics(14) = 'MT 669_3'
          unit_type_mneumonics(15) = 'MT 669_4'
          unit_type_mneumonics(16) = 'MT 639_1'
          unit_type_mneumonics(17) = 'MS 844_4x'
          unit_type_mneumonics(18) = 'MS 885_1x'
          unit_type_mneumonics(19) = 'MS 885_42'
          unit_type_mneumonics(20) = 'MS 834_2'
          unit_type_mneumonics(21) = 'MS FSD'
          unit_type_mneumonics(22) = 'MDI_1'
          unit_type_mneumonics(23) = 'MAP_1'
          unit_type_mneumonics(24) = 'MAP_CMI_1'
      create_variable unit_queuing_mneumonics kind=(string,15) dimension=0..7
          unit_queuing_mneumonics(0) = 'ONE ENTRY PER QUEUE'
          unit_queuing_mneumonics(1) = 'FIRST IN FIRST OUT'
          unit_queuing_mneumonics(2) = 'FIRST IN LAST OUT'
          unit_queuing_mneumonics(3) = 'UNSUPPORTED'
          unit_queuing_mneumonics(4) = 'UNSUPPORTED'
          unit_queuing_mneumonics(5) = 'UNSUPPORTED'
          unit_queuing_mneumonics(6) = 'UNSUPPORTED'
          unit_queuing_mneumonics(7) = 'UNSUPPORTED'
      create_variable io_function_mneumonics kind=(string,20) dimension=0..13
          io_function_mneumonics(0) = 'READ PAGE'
          io_function_mneumonics(1) = 'WRITE PAGE'
          io_function_mneumonics(2) = 'EXPLICIT READ'
          io_function_mneumonics(3) = 'EXPLICIT WRITE'
          io_function_mneumonics(4) = 'SWAP IN'
          io_function_mneumonics(5) = 'SWAP OUT'
          io_function_mneumonics(6) = 'COMPARE SWAP'
          io_function_mneumonics(7) = 'WRITE VERIFY'
          io_function_mneumonics(8) = 'READ UFT'
          io_function_mneumonics(9) = 'READ MASS STORAGE'
          io_function_mneumonics(10) = 'WRITE MASS STORAGE'
          io_function_mneumonics(11) = 'NO IO'
          io_function_mneumonics(12) = 'WRITE LOCKED PAGE'
          io_function_mneumonics(13) = 'KEYPOINT IO'

      IF $file($value(output) open_position) = '$BOI' THEN
        rewind_file $value(output) status=ignore_status
        output_file = $string($value(output))//'.$ASIS'
      ELSE
        output_file = $string($value(output))
      IFEND

      "CONSTANTS
"
" LOGICAL UNIT TABLE DEFINITIONS
"
         cmc$configured = 0                  "offset of the configured flag
         cmc$logical_unit = 1                "offset of the logical unit
         cmc$interlock =3                    "offset of the interlock
         cmc$unit_interface_table_p = 4      "offset of the unit interface table pointer
         cmc$usage_sanctions = 10            "offset of the usage sanctions
         cmc$assignable_device = 11          "offset of the assignable device
         cmc$assigned = 12                   "offset of the assigned flag
         cmc$job_sequence_number = 13        "offset of the assigned job sequence number
         cmc$temporary_assigned = 18         "offset of the temporary assigned flag
         cmc$temporary_assigned_jsn = 19     "offset of the temporary assigned job sequence number
         cmc$unit_communications_buf_p = 24  "offset of the unit communications buffer pointer
         cmc$state = 37                      "offset of the unit state
"
" UNIT INTERFACE TABLE DEFINITIONS
"
         cmc$uit_logical_unit = 0            "offset of logical unit
         cmc$unit_status = 2                 "offset of the unit status
         cmc$unit_type = 4                   "offset of the unit status
         cmc$queue_count = 6                 "offset of the queue count
         cmc$communications_buff_len = 10    "offset of the communications buffer length
         cmc$communications_buff_rma = 12    "offset of the communications buffer RMA
         cmc$unit_lockword = 16              "offset of the unit lockword
         cmc$unit_queue_lockword = 24        "offset of the unit queue lockword
         cmc$first_unit_request_p = 34       "offset of the first unit queue request
         cmc$first_unit_request_rma = 44     "offset of the first unit queue RMA
"
" IO REQUEST DEFINITIONS
"
         cmc$device_request = 6              "offset of the device request pointer
"
" WIRED UNIT QUEUE REQUEST DEFINITIONS
"
         cmc$address_word_pair_count = 0     "offset of the address word pair count
         cmc$rma_list_p = 2                  "offset of the rma list pointer
         cmc$io_identification = 8           "offset of the io identification
         cmc$global_task_id = 17             "offset of the global task id
         cmc$io_function = 20                "offset of the io function
         cmc$number_of_commands = 21         "offset of the number of commands
         cmc$job_unit_queue_request_p = 22   "offset of the unit queue request pointer
         cmc$unit_queuing_option = 40        "offset of the unit queuing option
         cmc$wired_command_heap = 41         "offset of the wired command heap
         cmc$wired_pp_response = 59          "offset of the wired pp response pointer
         cmc$wired_data_commands = 65        "offset of the wired data command descriptor pointer
         cmc$wired_io_request = 83           "offset of the wired io request pointer
         cmc$subsystem_io_header_size = 96   "size of the wired header part of the queue request
"
" MASS STORAGE QUEUE REQUEST DEFINITIONS
"
"
" PP REQUEST DEFINITIONS
"
         cmc$req_next_request = 2            "offset of the next request pointer
         cmc$req_next_request_rma = 12       "offset of the next request RMA
         cmc$req_request_length = 16         "offset of the request length
         cmc$req_logical_unit = 18           "offset of the logical unit
         cmc$req_recovery_interrupt = 20     "offset of the recovery/interrupt
         cmc$req_priority = 21               "offset of the priority
         cmc$req_alert_mask = 22             "offset of the alert mask
         cmc$start_of_pp_commands = 32       "starting byte of the pp commands

      logical_unit_table_p = $sa(cmv$logical_unit_table)
      logical_unit_table = $mem(logical_unit_table_p 6 m)
      logical_unit_table_entry_size = $mem(logical_unit_table_p+14 4 m)
      number_of_entries = $mem(logical_unit_table_p+6 4 m) / logical_unit_table_entry_size
      start_lut_ordinal = $mem(logical_unit_table_p+10 4 m)
      last_lut_ordinal = start_lut_ordinal + number_of_entries - 1

      display_queue = $value(display_unit_queue)

      IF $value_kind(ordinal) = 'INTEGER' THEN
        start_lut_ordinal = $value(ordinal)
        IF start_lut_ordinal > last_lut_ordinal THEN
           put_line ' Ordinal is beyond end of Logical Unit Table ' $fname(output_file)
           EXIT_PROC
        IFEND
        IF start_lut_ordinal < 0 THEN
           put_line ' Ordinal is < starting ordinal of Logical Unit Table ' $fname(output_file)
           EXIT_PROC
        IFEND
        last_lut_ordinal = start_lut_ordinal
      IFEND

      put_line '1Processing Logical Unit Table ' $fname(output_file)
      put_line '1                             LOGICAL UNIT TABLE' o=$fname(output_file)

      FOR lut_ordinal = start_lut_ordinal TO last_lut_ordinal DO
          logical_unit_table_entry = logical_unit_table + ..
              ((lut_ordinal - 1) * logical_unit_table_entry_size)
          entry_in_use = ($mem(logical_unit_table_entry+cmc$configured 1 m) = 1)
          IF entry_in_use THEN
             configured = 'CONFIGURED'
          ELSE
             configured = 'NOT CONFIGURED'
          IFEND
          putl ' Logical Unit Table Entry - '//$strrep(lut_ordinal)//'    '//configured ..
               o=$fname(output_file)
          IF entry_in_use THEN
             logical_unit_number = $mem(logical_unit_table_entry+cmc$logical_unit 2 m)
             interlock = ($mem(logical_unit_table_entry+cmc$interlock 1 m) = 1)
             IF interlock THEN
                interlock_set='SET'
             ELSE
                interlock_set = 'NOT SET'
             IFEND
             unit_interface_table = $mem(logical_unit_table_entry+cmc$unit_interface_table_p 6 m)
             usage_sanctions = $mem(logical_unit_table_entry+cmc$usage_sanctions 1 m)
             IF usage_sanctions > 2 THEN
                device_usage_sanction = 'UNDEFINED - '//$strrep(usage_sanctions,16)//'(16)'
             ELSE
                device_usage_sanction = device_usage_sanctions(usage_sanctions)
             IFEND
             assignable_device = ($mem(logical_unit_table_entry+cmc$assignable_device 1 m) = 1)
             IF assignable_device THEN
                  assignable = 'YES'
             ELSE
                  assignable = 'NO'
             IFEND
             IF assignable_device THEN
                device_assigned = ($mem(logical_unit_table_entry+cmc$assigned 1 m) = 1)
                IF device_assigned THEN
                   assigned_job_sequence_number = $mem(logical_unit_table_entry+cmc$job_sequence_number 5 m)
                IFEND
                temporary_assigned = ($mem(logical_unit_table_entry+cmc$temporary_assigned 1 m) = 1)
                IF temporary_assigned THEN
                   temporary_assigned_job_seq_num = $mem(logical_unit_table_entry+cmc$temporary_assigned_jsn 5 m)
                IFEND
             IFEND
             communications_buffer_p = $mem(logical_unit_table_entry+cmc$unit_communications_buf_p 6 m)
             element_state = $mem(logical_unit_table_entry+cmc$state 1 m)
             IF element_state > 2 THEN
                element_state_mneumonic = 'UNDEFINED - '//$strrep(element_state,16)//'(16)'
             ELSE
                element_state_mneumonic = element_state_mneumonics(element_state)
             IFEND


             putl '       Logical unit - '//$strrep(logical_unit_number) o=$fname(output_file)
             putl '       Interlock - '//interlock_set o=$fname(output_file)
             putl '       Unit interface table pointer - '//$strrep(unit_interface_table,16)//'(16)' ..
                      o=$fname(output_file)
             putl '       Usage sanctions - '//device_usage_sanction o=$fname(output_file)
             putl '       Assignable device - '//assignable o=$fname(output_file)
             IF assignable_device THEN
               IF device_assigned THEN
                  putl '          Device assigned to - '//$strrep(assigned_job_sequence_number,16) o=$fname(output_file)
               IFEND
               IF temporary_assigned THEN
                  putl '          Device assigned to - '//$strrep(temporary_assigned_job_seq_num,16) o=$fname(output_file)
               IFEND
             IFEND
             putl '       Communications buffer pointer - '//$strrep(communications_buffer_p,16)//'(16)' o=$fname(output_file)
             putl '       Element state - '//element_state_mneumonic o=$fname(output_file)


               logical_unit = $mem(unit_interface_table+cmc$uit_logical_unit 2 m)
               element_disabled =(( $mem(unit_interface_table+cmc$unit_status 2 m) / 080000000(16)) = 1)
               IF element_disabled THEN
                    disabled = 'YES'
               ELSE
                    disabled = 'NO'
               IFEND
               unit_type = $mem(unit_interface_table+cmc$unit_type 2 m)
               unit_mneumonic = 'UNDEFINED UNIT - '//$strrep(unit_type,16)//'(16)'
               FOR index = 1 to 24 DO
                IF unit_type_map(index) = unit_type THEN
                  unit_mneumonic = unit_type_mneumonics(index)
                  EXIT
                IFEND
               FOREND
               queue_count = $mem(unit_interface_table+cmc$queue_count 1 m)
               communications_buffer_length = $mem(unit_interface_table+cmc$communications_buff_len 2 m)
               communications_buffer_rma = $mem(unit_interface_table+cmc$communications_buff_rma 4 m)
               unit_lockword = $mem(unit_interface_table+cmc$unit_lockword 8 m)
               unit_queue_lockword = $mem(unit_interface_table+cmc$unit_queue_lockword 8 m)
               unit_queue_request_p = $mem(unit_interface_table+cmc$first_unit_request_p 6 m)
               unit_queue_request_rma = $mem(unit_interface_table+cmc$first_unit_request_rma 4 m)
               putl '           UNIT INTERFACE TABLE' o=$fname(output_file)
               putl '              Logical Unit - '//$strrep(logical_unit)//'   Unit type - '//unit_mneumonic ..
                 o=$fname(output_file)
               putl '              Element disabled - '//disabled//'    Queue count - '//$strrep(queue_count,16) ..
                 o=$fname(output_file)
               putl '              Communications table length  '//$strrep(communications_buffer_length,16)//'(16)'//..
'Communications buffer RMA - '//$strrep(communications_buffer_rma,16) o=(output_file)
               putl '              Unit Lockword - '//$strrep(unit_lockword,16) o=$fname(output_file)
               putl '              Unit Request Queue Lockword - '//$strrep(unit_queue_lockword,16) o=$fname(output_file)
               putl '              Pointer to first unit request queue entry - '//$strrep(unit_queue_request_p,16)//'(16)' ..
                 o=$fname(output_file)
               putl '              RMA of first unit queue request entry - '//$strrep(unit_queue_request_rma,16)//'(16)' ..
                  o=$fname(output_file)
          IFEND
          IF display_queue THEN
             putl '           UNIT QUEUE   ' o=$fname(output_file)
             io_request = unit_queue_request_p
             WHILE io_request <> 0ffff80000000(16)
               unit_queue_request = $mem(io_request+cmc$device_request 6 m)
               putl '             Queue request - '//$strrep(unit_qeuue_request,16)//'(16)' o=$fname(output_file)
               IF $SUBSTR(unit_mneumonic,1,3) = 'MAP' THEN
                 address_word_pair_count = $mem(unit_queue_request+cmc$address_word_pair_count 2 m)
                 rma_list_p = $mem(unit_queue_request+cmc$rma_list_p 6 m)
                 io_identification = $strrep($mem(unit_queue_request+cmc$io_identification 8 m),16)//..
                   $strrep($mem(unit_queue_request+cmc$io_identification+9 1 m),16)
                 global_task_id = $strrep($mem(unit_queue_request+cmc$global_task_id 3 m),16)
                 io_function = $mem(unit_queue_request+cmc$io_function 1 m)
                 IF io_function > 13 THEN
                    io_function_mneumonic = 'UNDEFINED    '//$strrep(io_funcion,16)//'(16)'
                 ELSE
                    io_function_mneumonic = io_function_mneumonics(io_function)
                 IFEND
                 number_of_commands = $mem(unit_queue_request+cmc$number_of_commands 1 m)
                 job_unit_queue_p = $mem(unit_queue_request+cmc$job_unit_queue_request_p 6 m)
                 unit_queuing_option = $mem(unit_queue_request+cmc$unit_queuing_option 1 m)
                 IF unit_queuing_option > 7 THEN
                      unit_queue_option = 'UNDEFINED   '//$strrep(unit_queuing_option,16)//'(16)'
                 ELSE
                      unit_queue_option = unit_queuing_mneumonics(unit_queuing_option)
                 IFEND
                 wired_command_heap = $mem(unit_queue_request+cmc$wired_command_heap 6 m)
                 wired_pp_response_p = $mem(unit_queue_request+cmc$wired_pp_response 6 m)
                 wired_data_command_descriptors = $mem(unit_queue_request+cmc$wired_data_commands 6 m)
                 wired_io_request = $mem(unit_queue_request+cmc$wired_io_request 6 m)
                 pp_request = unit_queue_request + cmc$subsystem_io_header_size

                 putl '                Address word pair count - '//$strrep(address_word_pair_count) o=$fname(output_file)
                 putl '                RMA list pointer  '//$strrep(rma_list_p,16)//'(16)' o=$fname(output_file)
                 putl '                IO identification - '//io_identification o=$fname(output_file)
                 putl '                Global task id - '//global_task_id o=$fname(output_file)
                 putl '                IO function - '//$strrep(io_function_mneumonic) o=$fname(output_file)
                 putl '                Number of commands - '//$strrep(number_of_commands) o=$fname(output_file)
                 putl '                Job unit queue request pointer - '//$strrep(job_unit_queue_p,16)//'(16)' o=$fname(output_file)
                 putl '                Unit queuing control - '//unit_queue_option o=$fname(output_file)
                 putl '                Wired command heap pointer - '//$strrep(wired_command_heap,16)//'(16)' ..
                     o=$fname(output_file)
                 putl '                Wired pp response pointer - '//$strrep(wired_pp_response,16)//'(16)' ..
                     o=$fname(output_file)
                 putl '                Wired data command descriptors pointer - '//$strrep(wired_data_command_descriptors,16)//'(16)' ..
                     o=$fname(output_file)
                 putl '                Wired io request pointer - '//$strrep(wired_io_request,16)//'(16)' ..
                     o=$fname(output_file)
              IFEND
              next_request = $mem(pp_request+cmc$req_next_request 6 m)
              next_request_rma = $mem(pp_request+cmc$req_next_request_rma 4 m)
              request_length = $mem(pp_request+cmc$req_request_length 2 m)
              logical_unit_from_pp_request = $mem(pp_request+cmc$req_logical_unit 2 m)
              recovery_interrupt = $mem(pp_request+cmc$req_recovery_interrupt 1 m)
              priority = $mem(pp_request+cmc$req_priority 1 m)
              alert_mask = $mem(pp_request+cmc$req_alert_mask 1 m)
              pp_commands = pp_request + cmc$start_of_pp_commands
              putl '                  Request length - '//$strrep(requst_length,16)//'(16)' o=$fname(output_file)
              putl '                  Recovery interrupt - '//$strrep(recovery_interrupt,16)//'(16)' o=$fname(output_file)
              putl '                  Priority - '//$strrep(priority,16) o=$fname(output_file)
              putl '                  Alert mask - '//$strrep(alert_mask) o=$fname(output_file)
              putl '                  PP commands ' o=$fname(output_file)
              io_request = next_request
            WHILEND
            putl '           END OF QUEUE  ' o=$fname(output_file)
          IFEND
      FOREND
PROCEND dum$display_logical_unit_table
