master/domain.c
changeset 2611 f09b0623a2c1
parent 2610 f0fdcce9874b
child 2612 668aa5e31137
equal deleted inserted replaced
2610:f0fdcce9874b 2611:f09b0623a2c1
    77     }
    77     }
    78     domain->expected_working_counter = 0x0000;
    78     domain->expected_working_counter = 0x0000;
    79     domain->working_counter_changes = 0;
    79     domain->working_counter_changes = 0;
    80     domain->redundancy_active = 0;
    80     domain->redundancy_active = 0;
    81     domain->notify_jiffies = 0;
    81     domain->notify_jiffies = 0;
       
    82     memset(domain->offset_used, 0, sizeof(domain->offset_used));
    82 }
    83 }
    83 
    84 
    84 /*****************************************************************************/
    85 /*****************************************************************************/
    85 
    86 
    86 /** Domain destructor.
    87 /** Domain destructor.
   122 void ec_domain_add_fmmu_config(
   123 void ec_domain_add_fmmu_config(
   123         ec_domain_t *domain, /**< EtherCAT domain. */
   124         ec_domain_t *domain, /**< EtherCAT domain. */
   124         ec_fmmu_config_t *fmmu /**< FMMU configuration. */
   125         ec_fmmu_config_t *fmmu /**< FMMU configuration. */
   125         )
   126         )
   126 {
   127 {
       
   128     const ec_slave_config_t *sc;
       
   129     uint32_t logical_domain_offset;
       
   130     unsigned fmmu_data_size;
       
   131 
   127     fmmu->domain = domain;
   132     fmmu->domain = domain;
   128 
   133     sc = fmmu->sc;
   129     domain->data_size += fmmu->data_size;
   134 
       
   135     fmmu_data_size = ec_pdo_list_total_size(
       
   136         &sc->sync_configs[fmmu->sync_index].pdos);
       
   137 
       
   138     if (sc->allow_overlapping_pdos && sc->used_fmmus) {
       
   139         // If we permit overlapped PDOs, and we already have an allocated FMMU
       
   140         // for this slave, alocate the subsequent FMMU offsets by direction
       
   141         logical_domain_offset = domain->offset_used[fmmu->dir];
       
   142     } else {
       
   143         // otherwise, allocate to the furthest extent of any allocated
       
   144         // FMMU on this domain.
       
   145         logical_domain_offset = max(domain->offset_used[EC_DIR_INPUT],
       
   146             domain->offset_used[EC_DIR_OUTPUT]);
       
   147         // rebase the free offsets to the current position
       
   148         domain->offset_used[EC_DIR_INPUT] = logical_domain_offset;
       
   149         domain->offset_used[EC_DIR_OUTPUT] = logical_domain_offset;
       
   150     }
       
   151     // consume the offset space for this FMMU's direction
       
   152     domain->offset_used[fmmu->dir] += fmmu_data_size;
       
   153 
       
   154     ec_fmmu_set_domain_offset_size(fmmu, logical_domain_offset, fmmu_data_size);
       
   155 
   130     list_add_tail(&fmmu->list, &domain->fmmu_configs);
   156     list_add_tail(&fmmu->list, &domain->fmmu_configs);
       
   157     
       
   158     // Determine domain size from furthest extent of FMMU data
       
   159     domain->data_size = max(domain->offset_used[EC_DIR_INPUT],
       
   160             domain->offset_used[EC_DIR_OUTPUT]);
   131 
   161 
   132     EC_MASTER_DBG(domain->master, 1, "Domain %u:"
   162     EC_MASTER_DBG(domain->master, 1, "Domain %u:"
   133             " Added %u bytes.\n",
   163             " Added %u bytes at %u.\n",
   134             domain->index, fmmu->data_size);
   164             domain->index, fmmu->data_size, logical_domain_offset);
   135 }
   165 }
   136 
   166 
   137 /*****************************************************************************/
   167 /*****************************************************************************/
   138 
   168 
   139 /** Allocates a domain datagram pair and appends it to the list.
   169 /** Allocates a domain datagram pair and appends it to the list.
   234     unsigned int datagram_used[EC_DIR_COUNT];
   264     unsigned int datagram_used[EC_DIR_COUNT];
   235     ec_fmmu_config_t *fmmu;
   265     ec_fmmu_config_t *fmmu;
   236     const ec_fmmu_config_t *datagram_first_fmmu = NULL;
   266     const ec_fmmu_config_t *datagram_first_fmmu = NULL;
   237     const ec_datagram_pair_t *datagram_pair;
   267     const ec_datagram_pair_t *datagram_pair;
   238     int ret;
   268     int ret;
   239 
       
   240 #if 0
       
   241     // Determine domain size from furthest extent of FMMU data
       
   242     domain->data_size = 0;
       
   243     list_for_each_entry(fmmu, &domain->fmmu_configs, list) {
       
   244         domain->data_size = max(domain->data_size,
       
   245             fmmu->logical_domain_offset + fmmu->data_size);
       
   246     }
       
   247 #endif
       
   248 
   269 
   249     domain->logical_base_address = base_address;
   270     domain->logical_base_address = base_address;
   250 
   271 
   251     if (domain->data_size && domain->data_origin == EC_ORIG_INTERNAL) {
   272     if (domain->data_size && domain->data_origin == EC_ORIG_INTERNAL) {
   252         if (!(domain->data =
   273         if (!(domain->data =