PROCEDURE dum$display_fmd, display_fmd, disfmd (
  pva: integer = $optional
  output, o: file = $output
  display_option, do: key
      (brief, b), (full, f)
    keyend = brief
  next_fmd_p: (VAR) integer
  help, h: file = $null
  status)


" Create and set parameter to eliminate looping if called by Display_All_FMDS with a bad pva."
  IF $specified(next_fmd_p) THEN
    next_fmd_p = 0ffff80000000(16)
  IFEND

  "$FORMAT=OFF"
  VAR
    when_status: status
  VAREND
  "$FORMAT=ON"

  WHEN any_fault DO
    when_status = $previous_status
    putl ' Invoked DISFMD condition handler due to the following abnormal status:'
    disv when_status
    putl ' Enter commands, "exit_proc" to abort, or "exit_proc with when_status" to abort with status'
    include_file command prompt='disfmd_ch'
  WHENEND

  IF $specified(help) THEN
COLLECT_TEXT o=help until='HELPEND'
DISPLAY_FMD or DISFMD

  This procedure will display the file medium descriptor when given a
process virtual address to the entry.

PARAMETERS:

PVA: integer
  This parameter passes the processor virtual address of the FMD to
be displayed.  This parameter is required.

OUTPUT, O: file
  This parameter selects the file name to receive the data.  This para-
meter is defaulted to $output.  If a file name other than $output is
entered the data will be formated correctly for printer disposition and
will be sent to the file  "$asis".

DISPLAY_OPTIONS, DO: key full, f, brief, b
  This parameter selects the option of displaying the contents of memory
and the description of the selected fields (full), or the brief mode of
the descriptions only.  This parameter defaults to brief.

STATUS

WARNINGS/KNOWN DEFICIENCIES:


ERROR HANDLER
  When any fatal error is encountered a condition handler is invoked and
the following messages will appear:
 "Invoked DISFMD condition handler due to the following abnormal status:"
 "< the error status message >"
 "Enter commands, "exit_proc" to abort, or "exit_proc with when_status"
  to abort with status"
To exit the handler enter:    "exit_proc"
To exit the handler with status, enter:   "exit_proc with when_status"

HELPEND
    EXIT_PROC
  IFEND

  IF NOT $specified(pva) THEN
    EXIT_PROC WITH $status(false, 'US', 8, 'Parameter PVA is required')
  IFEND

  "$FORMAT=OFF"
  VAR
    output_file: file

" The following offsets were obtained from the output of the command Display_Symbol_Table
" for the type DMT$FILE_MEDIUM_DESCRIPTOR.

    in_use_offset: integer = 0(16)
    sfid_offset: integer = 1(16)
    avt_index_offset: integer = 5(16)
    dfl_index_offset: integer = 7(16)
    delete_logging_count_offset: integer = 0a(16)
    volume_assigned_offset: integer = 0c(16)
    fmd_allocated_length_offset: integer = 0d(16)
    bytes_per_mau_offset: integer = 13(16)
    daus_per_cylinder_offset: integer = 15(16)
    daus_per_allocation_unit_offset: integer = 16(16)
    internal_vsn_offset: integer = 17(16)
    maus_per_dau_offset: integer = 22(16)
    maus_per_transfer_unit_offset: integer = 23(16)
    p_next_fmd_offset: integer = 25(16)
    dmt$allocation_styles: array 0..9 of string 1..$max_name = ('dmc$a0', 'dmc$a1', 'dmc$a2', 'dmc$a3', ..
          'dmc$a4', 'dmc$a5', 'dmc$a6', 'dmc$a7', 'dmc$a8', 'dmc$acyl')
    allocation_style_offset: integer = 2b(16)
    fmd_length: integer = 44
  VAREND
  "$FORMAT=ON"

  IF $file(output open_position) = '$BOI' THEN
    output_file = output.$asis
  ELSE
    output_file = output
  IFEND

  pointer_fmd = pva

  IF output = :$local.$output THEN
    put_line '1FILE MEDIUM DESCRIPTOR' o=output_file
  IFEND

  IF display_option = 'FULL' THEN
    display_memory (pointer_fmd) b=fmd_length title=' FILE MEDIUM DESCRIPTOR' o=output_file
  IFEND

  put_line '  ' o=output_file
  IF $memory(pointer_fmd+in_use_offset, 1) = 1 THEN
    put_line ' in use = TRUE' o=output_file
  ELSE
    put_line ' in use = FALSE' o=output_file
  IFEND

  put_line ' sfid = '//$strrep($memory(pointer_fmd+sfid_offset, 4), 16)//'(16)' o=output_file

  put_line ' avt_index = '//$strrep($memory(pointer_fmd+avt_index_offset, 2), 16)//'(16)' o=output_file

  put_line ' device_file_list_index (dfl_index) = '//..
$strrep($memory(pointer_fmd+dfl_index_offset, 3), 16)//'(16)' o=output_file

  put_line ' delete_logging_count = '//..
$strrep($memory(pointer_fmd+delete_logging_count_offset 2), 16)//'(16)' o=output_file

  IF $memory(pointer_fmd+volume_assigned_offset, 1) = 1 THEN
    put_line ' volume assigned = TRUE' o=output_file
  ELSE
    put_line ' volume assigned = FALSE' o=output_file
  IFEND

  put_line ' fmd_allocated_length = '//..
$strrep($memory(pointer_fmd+fmd_allocated_length_offset, 6), 16)//'(16)' o=output_file

  put_line ' bytes_per_mau = '//$strrep($memory(pointer_fmd+bytes_per_mau_offset 2), 16)//'(16)' o=output_file

  put_line ' daus_per_cylinder = '//$strrep($memory(pointer_fmd+daus_per_cylinder_offset 1), 16)//'(16)' ..
        o=output_file

  put_line ' daus_per_allocation_unit = '//..
$strrep($memory(pointer_fmd+daus_per_allocation_unit_offset 1), 16)//'(16)' o=output_file

  display_binary_unique_name pva=pointer_fmd+internal_vsn_offset o=output cs=' internal vsn = '

  put_line ' maus_per_dau = '//$strrep($memory(pointer_fmd+maus_per_dau_offset 1), 16)//'(16)' o=output_file

  put_line ..
        ' maus_per_transfer = '//$strrep($memory(pointer_fmd+maus_per_transfer_unit_offset 2), 16)//'(16)' ..
        o=output_file

  put_line ' p_next_fmd = '//$strrep($memory(pointer_fmd+p_next_fmd_offset, 6), 16)//'(16)' o=output_file

  put_line ' allocation_style = '//dmt$allocation_styles($memory(pointer_fmd+allocation_style_offset 1)) ..
        o=output_file

  IF $specified(next_fmd_p) THEN
    next_fmd_p = $memory(pointer_fmd+p_next_fmd_offset, 6)
  IFEND

PROCEND dum$display_fmd
