?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Dump Analyzer : Display Buffer Controlware Command' ??
MODULE dum$display_buffer_controlware;

{ PURPOSE:
{   This module contains the code for the display_buffer_controlware command.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc due$exception_condition_codes
?? POP ??
*copyc clp$close_display
*copyc clp$convert_integer_to_string
*copyc clp$evaluate_parameters
*copyc clp$open_display_reference
*copyc dup$display_data
*copyc dup$new_page_procedure
*copyc dup$retrieve_bc_entry
*copyc osp$append_status_integer
*copyc osp$append_status_parameter
*copyc osp$disestablish_cond_handler
*copyc osp$establish_block_exit_hndlr
*copyc osp$set_status_abnormal
?? EJECT ??
*copyc duv$dump_environment_p
*copyc duv$execution_environment
*copyc duv$title_data
?? OLDTITLE ??
?? NEWTITLE := 'dup$display_buffer_controlware', EJECT ??

{ PURPOSE:
{   This procedure displays the buffer controlware.
{ NOTE:
{   This procedure refers to a "word".  The definition of a word for this procedure is a two byte data
{   structure.

  PROCEDURE [XDCL] dup$display_buffer_controlware
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE display_buffer_controlware, disbc (
{   channel_number, cn: integer 0..33 = $required
{   output, o: file = $optional
{   title, t: string 1..31 = 'display_buffer_controlware'
{   display_option, do: list 1..2 of key
{       (numeric c) (ascii a) (display_code dc)
{     keyend = (numeric ascii)
{   status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??
  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 9] of clt$pdt_parameter_name,
      parameters: array [1 .. 5] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$integer_type_qualifier,
      recend,
      type2: record
        header: clt$type_specification_header,
      recend,
      type3: record
        header: clt$type_specification_header,
        qualifier: clt$string_type_qualifier,
        default_value: string (28),
      recend,
      type4: record
        header: clt$type_specification_header,
        qualifier: clt$list_type_qualifier_v2,
        element_type_spec: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 6] of clt$keyword_specification,
        recend,
        default_value: string (15),
      recend,
      type5: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [92, 1, 22, 11, 33, 2, 293],
    clc$command, 9, 5, 1, 0, 0, 0, 5, ''], [
    ['CHANNEL_NUMBER                 ',clc$nominal_entry, 1],
    ['CN                             ',clc$abbreviation_entry, 1],
    ['DISPLAY_OPTION                 ',clc$nominal_entry, 4],
    ['DO                             ',clc$abbreviation_entry, 4],
    ['O                              ',clc$abbreviation_entry, 2],
    ['OUTPUT                         ',clc$nominal_entry, 2],
    ['STATUS                         ',clc$nominal_entry, 5],
    ['T                              ',clc$abbreviation_entry, 3],
    ['TITLE                          ',clc$nominal_entry, 3]],
    [
{ PARAMETER 1
    [1, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 20, clc$required_parameter,
  0, 0],
{ PARAMETER 2
    [6, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$optional_parameter, 0
  , 0],
{ PARAMETER 3
    [9, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 8,
  clc$optional_default_parameter, 0, 28],
{ PARAMETER 4
    [3, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 245,
  clc$optional_default_parameter, 0, 15],
{ PARAMETER 5
    [7, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$integer_type], [0, 33, 10]],
{ PARAMETER 2
    [[1, 0, clc$file_type]],
{ PARAMETER 3
    [[1, 0, clc$string_type], [1, 31, FALSE],
    '''display_buffer_controlware'''],
{ PARAMETER 4
    [[1, 0, clc$list_type], [229, 1, 2, 0, FALSE, FALSE],
      [[1, 0, clc$keyword_type], [6], [
      ['A                              ', clc$abbreviation_entry, clc$normal_usage_entry, 2],
      ['ASCII                          ', clc$nominal_entry, clc$normal_usage_entry, 2],
      ['C                              ', clc$abbreviation_entry, clc$normal_usage_entry, 1],
      ['DC                             ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
      ['DISPLAY_CODE                   ', clc$nominal_entry, clc$normal_usage_entry, 3],
      ['NUMERIC                        ', clc$nominal_entry, clc$normal_usage_entry, 1]]
      ]
    ,
    '(numeric ascii)'],
{ PARAMETER 5
    [[1, 0, clc$status_type]]];
?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$channel_number = 1,
      p$output = 2,
      p$title = 3,
      p$display_option = 4,
      p$status = 5;

    VAR
      pvt: array [1 .. 5] of clt$parameter_value;

    VAR
      cell_p: ^cell,
      channel_number: 0 .. duc$de_maximum_channels,
      display_control: clt$display_control,
      end_of_input_file: boolean,
      entry_p: ^dut$de_buffer_controlware_entry,
      ignore_status: ost$status,
      integer_string: ost$string,
      output_display_opened: boolean,
      radix: 8 .. 16,
      restart_file_buffer_p: ^SEQ ( * ),
      restart_file_seq_p: ^SEQ ( * ),
      ring_attributes: amt$ring_attributes;

*copy dup$abort_handler
?? NEWTITLE := 'clean_up', EJECT ??

{ PURPOSE:
{   This procedure is called from the abort handler to close the file.

    PROCEDURE [INLINE] clean_up;

      VAR
        ignore_status: ost$status;

      IF output_display_opened THEN
        clp$close_display (display_control, ignore_status);
      IFEND;

    PROCEND clean_up;
?? OLDTITLE ??
?? EJECT ??

    status.normal := TRUE;
    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;  {---->
    IFEND;

    IF duv$dump_environment_p = NIL THEN
      osp$set_status_abnormal (duc$dump_analyzer_id, due$no_restart_file, '', status);
      RETURN;  {---->
    IFEND;

    channel_number := pvt [p$channel_number].value^.integer_value.value;
    dup$retrieve_bc_entry (channel_number, entry_p);
    IF entry_p = NIL THEN
      osp$set_status_abnormal (duc$dump_analyzer_id, due$data_not_on_dump,
            'The buffer controlware for channel', status);
      osp$append_status_integer (osc$status_parameter_delimiter, channel_number, 10, FALSE, status);
      osp$append_status_parameter (osc$status_parameter_delimiter, 'is', status);
      RETURN;  {---->
    IFEND;

    output_display_opened := FALSE;
    osp$establish_block_exit_hndlr (^abort_handler);

   /display_opened/
    BEGIN

      { Prepare the output display file.

      IF pvt [p$output].specified THEN
        ring_attributes.r1 := #RING (^ring_attributes);
        ring_attributes.r2 := #RING (^ring_attributes);
        ring_attributes.r3 := #RING (^ring_attributes);
        clp$open_display_reference (pvt [p$output].value^.file_value^, ^dup$new_page_procedure, fsc$list,
              ring_attributes, display_control, status);
        IF NOT status.normal THEN
          EXIT /display_opened/;  {---->
        IFEND;
        output_display_opened := TRUE;
      ELSE
        display_control := duv$execution_environment.output_file.display_control;
        display_control.line_number := display_control.page_length + 1;
      IFEND;

      duv$title_data.build_title := TRUE;
      IF pvt [p$title].specified THEN
        duv$title_data.command_name := pvt [p$title].value^.string_value^;
      ELSE
        duv$title_data.command_name := 'display_buffer_controlware ';
        clp$convert_integer_to_string (channel_number, 10, FALSE, integer_string, ignore_status);
        duv$title_data.command_name (28, integer_string.size) :=
              integer_string.value (1, integer_string.size);
      IFEND;

      { Retrieve a pointer to the buffer controlware data on the restart file.

      restart_file_seq_p := duv$execution_environment.data_file_p^.segment_pointer.sequence_pointer;
      cell_p := #ADDRESS (#RING (restart_file_seq_p), #SEGMENT (restart_file_seq_p), entry_p^.first_byte);
      RESET restart_file_seq_p TO cell_p;
      NEXT restart_file_buffer_p: [[REP entry_p^.words OF dut$de_buffer_controlware_word]] IN
            restart_file_seq_p;
      IF restart_file_buffer_p = NIL THEN
        osp$set_status_abnormal (duc$dump_analyzer_id, due$nil_pointer, '', status);
        EXIT /display_opened/;  {---->
      IFEND;
      RESET restart_file_buffer_p;

      { Determine the radix.

      IF entry_p^.channel_type = duc$de_7155_adapter THEN
        radix := 8;
      ELSE
        radix := 16;
      IFEND;

      { Display the data.

      dup$display_data (pvt [p$display_option].value, FALSE, radix, 0, entry_p^.words, display_control,
            restart_file_buffer_p, end_of_input_file, status);

    END /display_opened/;

    IF output_display_opened THEN
      clp$close_display (display_control, ignore_status);
    IFEND;
    osp$disestablish_cond_handler;

  PROCEND dup$display_buffer_controlware;
MODEND dum$display_buffer_controlware;
