?? RIGHT := 110 ??
?? NEWTITLE := 'NOSVE device management' ??
MODULE dmm$access_active_volume_table;
?? RIGHT := 110 ??
{
{ PURPOSE:
{      This module contains the procedures used to access active volume table entries.
{ DESIGN:
{      Contains procedures to reserve, release, and locate active volume table entries.
{
?? NEWTITLE := 'Global Declarations Referenced By This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc rmd$volume_declarations
*copyc dmt$active_volume_table
*copyc dmt$active_volume_table_index
*copyc dmt$assigned_ms_vol_attributes
*copyc dmt$avt_search_key
*copyc dmt$error_condition_codes
*copyc rmt$device_class
?? POP ??
*copyc dmp$search_avt_by_rvsn
*copyc dmv$active_volume_table
*copyc dmv$null_vsn
?? OLDTITLE ??
?? NEWTITLE := '  dmp$get_rvsn_by_lun', EJECT ??

  PROCEDURE [XDCL] dmp$get_rvsn_by_lun
    (    lun: iot$logical_unit;
     VAR rvsn: rmt$recorded_vsn;
     VAR entry_found: boolean);

    VAR
      avt_index: dmt$active_volume_table_index,
      entry_p: ^dmt$active_volume_table_entry;

    entry_found := FALSE;
    FOR avt_index := LOWERBOUND (dmv$active_volume_table.table_p^)
          TO UPPERBOUND (dmv$active_volume_table.table_p^) DO
      entry_p := ^dmv$active_volume_table.table_p^ [avt_index];
      IF (NOT entry_p^.entry_available) AND (entry_p^.logical_unit_number = lun) THEN
        rvsn := entry_p^.mass_storage.recorded_vsn;
        entry_found := TRUE;
        RETURN; {----->
      IFEND;
    FOREND;

  PROCEND dmp$get_rvsn_by_lun;
?? OLDTITLE ??
?? NEWTITLE := '[xdcl] DMP$SEARCH_ACTIVE_VOLUME_TABLE', EJECT ??
*copy dmh$search_active_volume_table

  PROCEDURE [XDCL] dmp$search_active_volume_table
    (    search_key: dmt$avt_search_key;
     VAR avt_index: dmt$active_volume_table_index;
     VAR active_volume_entry_not_found: boolean);

    VAR
      available_avt_entry_index: dmt$active_volume_table_index,
      avt_entry_p: ^dmt$active_volume_table_entry,
      search_index: dmt$active_volume_table_index;

    active_volume_entry_not_found := FALSE;
    available_avt_entry_index := 0;

    IF dmv$active_volume_table.table_p = NIL THEN
      avt_index := 0;
      active_volume_entry_not_found := TRUE;
      RETURN; {----->
    IFEND;

    CASE search_key.value OF
    = dmc$search_avt_by_rec_vsn =
      FOR search_index := LOWERBOUND (dmv$active_volume_table.table_p^)
            TO UPPERBOUND (dmv$active_volume_table.table_p^) DO
        avt_entry_p := ^dmv$active_volume_table.table_p^ [search_index];

        IF NOT avt_entry_p^.entry_available THEN
          IF avt_entry_p^.mass_storage.recorded_vsn = search_key.recorded_vsn THEN
            avt_index := search_index;
            RETURN; {----->
          IFEND;
        ELSEIF available_avt_entry_index = 0 THEN {Entry is available
          available_avt_entry_index := search_index;
        IFEND;
      FOREND;

    = dmc$search_avt_by_lun =
      FOR search_index := LOWERBOUND (dmv$active_volume_table.table_p^)
            TO UPPERBOUND (dmv$active_volume_table.table_p^) DO
        avt_entry_p := ^dmv$active_volume_table.table_p^ [search_index];

        IF NOT avt_entry_p^.entry_available THEN
          IF avt_entry_p^.logical_unit_number = search_key.logical_unit_number THEN
            avt_index := search_index;
            RETURN; {----->
          IFEND;
        ELSEIF available_avt_entry_index = 0 THEN {Entry is available
          available_avt_entry_index := search_index;
        IFEND;
      FOREND;
    ELSE
    CASEND;

    avt_index := available_avt_entry_index;
    active_volume_entry_not_found := TRUE;

  PROCEND dmp$search_active_volume_table;
?? OLDTITLE ??
?? NEWTITLE := '[xdcl] DMP$GET_ACTIVE_VOL_ATTRIBUTES', EJECT ??
*copy dmh$get_active_vol_attributes

  PROCEDURE [XDCL] dmp$get_active_vol_attributes
    (    required_recorded_vsn: rmt$recorded_vsn;
         search_avt_index: dmt$active_volume_table_index;
     VAR assigned_vol_attributes: dmt$assigned_ms_vol_attributes;
     VAR avt_entry_found: boolean);

    VAR
      assigned_vol_attribute_p: ^dmt$assigned_ms_vol_attribute,
      avt_entry_p: ^dmt$ms_active_vol_table_entry,
      avt_index: dmt$active_volume_table_index,
      index: integer,
      search_of_avt_required: boolean;

    avt_entry_found := FALSE;
    avt_index := search_avt_index;
    search_of_avt_required := TRUE;

    IF (search_avt_index > 0) AND (search_avt_index <= UPPERBOUND (dmv$active_volume_table.table_p^))
{ } AND ((dmv$active_volume_table.table_p^ [search_avt_index].mass_storage.recorded_vsn =
          required_recorded_vsn) OR (required_recorded_vsn = dmv$null_vsn)) THEN
      search_of_avt_required := FALSE;
      IF dmv$active_volume_table.table_p^ [search_avt_index].entry_available THEN
        RETURN; {----->
      IFEND;
    IFEND;

    IF search_of_avt_required THEN
      dmp$search_avt_by_rvsn (required_recorded_vsn, avt_index, avt_entry_found);
      IF NOT avt_entry_found THEN
        RETURN; {----->
      IFEND;
    IFEND;

    avt_entry_found := TRUE;
    avt_entry_p := ^dmv$active_volume_table.table_p^ [avt_index].mass_storage;

    FOR index := 1 TO UPPERBOUND (assigned_vol_attributes) DO
      assigned_vol_attribute_p := ^assigned_vol_attributes [index];
      CASE assigned_vol_attribute_p^.keyword OF

      = dmc$avt_index =
        assigned_vol_attribute_p^.index := avt_index;

      = dmc$ms_allocation_allowed =
        assigned_vol_attribute_p^.allocation_allowed := avt_entry_p^.allocation_allowed AND
              NOT avt_entry_p^.volume_unavailable;

      = dmc$ms_current_log_position =
        assigned_vol_attribute_p^.current_log_position := avt_entry_p^.current_position_offset_in_log;

      = dmc$ms_device_allocation_table =
        assigned_vol_attribute_p^.p_dat := avt_entry_p^.p_device_allocation_table;

      = dmc$ms_device_log_entry_count =
        assigned_vol_attribute_p^.device_log_entry_count := avt_entry_p^.device_log_entry_count;

      = dmc$ms_recorded_vsn =
        assigned_vol_attribute_p^.recorded_vsn := avt_entry_p^.recorded_vsn;

      = dmc$ms_internal_vsn =
        assigned_vol_attribute_p^.internal_vsn := avt_entry_p^.internal_vsn;

      = dmc$ms_device_log =
        assigned_vol_attribute_p^.p_dlog := avt_entry_p^.p_device_log;

      = dmc$ms_allocated_log_size =
        assigned_vol_attribute_p^.allocated_log_size := avt_entry_p^.allocated_log_size;

      = dmc$ms_mainframe_assigned =
        assigned_vol_attribute_p^.mainframe_assigned := avt_entry_p^.mainframe_assigned;

      = dmc$ms_device_file_list_table =
        assigned_vol_attribute_p^.p_dflt := avt_entry_p^.p_device_file_list_table;

      = dmc$ms_volume_directory =
        assigned_vol_attribute_p^.directory_sfid := avt_entry_p^.p_directory;

      = dmc$ms_volume_owner =
        assigned_vol_attribute_p^.volume_owner := avt_entry_p^.volume_owner;

      = dmc$ms_volume_login_table =
        assigned_vol_attribute_p^.p_vlgt := avt_entry_p^.p_login_table;

      = dmc$ms_volume_unavailable =
        assigned_vol_attribute_p^.volume_unavailable := avt_entry_p^.volume_unavailable;

      ELSE
      CASEND;
    FOREND;

  PROCEND dmp$get_active_vol_attributes;
?? OLDTITLE ??
MODEND dmm$access_active_volume_table;
