Domains als Liste verwaltet.
--- a/master/domain.h Tue Feb 28 11:36:29 2006 +0000
+++ b/master/domain.h Tue Feb 28 13:07:05 2006 +0000
@@ -44,6 +44,7 @@
struct ec_domain
{
+ struct list_head list; /**< Listenkopf */
ec_master_t *master; /**< EtherCAT-Master, zu der die Domäne gehört. */
unsigned char *data; /**< Prozessdaten */
--- a/master/globals.h Tue Feb 28 11:36:29 2006 +0000
+++ b/master/globals.h Tue Feb 28 13:07:05 2006 +0000
@@ -23,14 +23,11 @@
#define EC_SYNC_SIZE 8 /**< Größe einer Sync-Manager-Konfigurationsseite */
#define EC_FMMU_SIZE 16 /**< Größe einer FMMU-Konfigurationsseite */
#define EC_MAX_FMMUS 16 /**< Maximale Anzahl FMMUs pro Slave */
-
#define EC_MAX_DATA_SIZE (EC_MAX_FRAME_SIZE \
- EC_FRAME_HEADER_SIZE \
- EC_COMMAND_HEADER_SIZE \
- EC_COMMAND_FOOTER_SIZE) /**< Maximale Datengröße */
-#define EC_MASTER_MAX_DOMAINS 10 /**< Maximale Anzahl Domänen eines Masters */
-
#ifndef NULL
#define NULL ((void *) 0) /**< NULL-Define, falls noch nicht definiert. */
#endif
--- a/master/master.c Tue Feb 28 11:36:29 2006 +0000
+++ b/master/master.c Tue Feb 28 13:07:05 2006 +0000
@@ -35,12 +35,13 @@
master->slave_count = 0;
master->device_registered = 0;
master->command_index = 0x00;
- master->domain_count = 0;
master->debug_level = 0;
master->bus_time = 0;
master->frames_lost = 0;
master->frames_delayed = 0;
master->t_last_cyclic_output = 0;
+
+ INIT_LIST_HEAD(&master->domains);
}
/*****************************************************************************/
@@ -71,15 +72,16 @@
/**< Zeiger auf den zurückzusetzenden Master */
)
{
- unsigned int i;
+ ec_domain_t *domain, *next;
ec_master_clear_slaves(master);
- for (i = 0; i < master->domain_count; i++) {
- ec_domain_clear(master->domains[i]);
- kfree(master->domains[i]);
- }
- master->domain_count = 0;
+ // Domain-Liste leeren
+ list_for_each_entry_safe(domain, next, &master->domains, list) {
+ ec_domain_clear(domain);
+ kfree(domain);
+ }
+ INIT_LIST_HEAD(&master->domains);
master->command_index = 0;
master->debug_level = 0;
@@ -418,19 +420,14 @@
{
ec_domain_t *domain;
- if (master->domain_count >= EC_MASTER_MAX_DOMAINS) {
- EC_ERR("Maximum number of domains reached!\n");
- return NULL;
- }
-
if (!(domain = (ec_domain_t *) kmalloc(sizeof(ec_domain_t), GFP_KERNEL))) {
EC_ERR("Error allocating domain memory!\n");
return NULL;
}
ec_domain_init(domain, master, mode, timeout_us);
- master->domains[master->domain_count] = domain;
- master->domain_count++;
+
+ list_add_tail(&domain->list, &master->domains);
return domain;
}
@@ -462,16 +459,15 @@
// Domains erstellen
domain_offset = 0;
- for (i = 0; i < master->domain_count; i++) {
- domain = master->domains[i];
+ list_for_each_entry(domain, &master->domains, list) {
if (ec_domain_alloc(domain, domain_offset)) {
- EC_ERR("Failed to allocate domain %i!\n", i);
+ EC_ERR("Failed to allocate domain %X!\n", (u32) domain);
return -1;
}
frame_count = domain->data_size / EC_MAX_FRAME_SIZE + 1;
if (!domain->data_size) frame_count = 0;
- EC_INFO("Domain %i - Allocated %i bytes (%i Frame(s))\n", i,
- domain->data_size, frame_count);
+ EC_INFO("Domain %X - Allocated %i bytes (%i Frame(s))\n",
+ (u32) domain, domain->data_size, frame_count);
domain_offset += domain->data_size;
}
--- a/master/master.h Tue Feb 28 11:36:29 2006 +0000
+++ b/master/master.h Tue Feb 28 13:07:05 2006 +0000
@@ -11,6 +11,8 @@
#ifndef _EC_MASTER_H_
#define _EC_MASTER_H_
+#include <linux/list.h>
+
#include "device.h"
#include "slave.h"
#include "frame.h"
@@ -32,8 +34,7 @@
ec_device_t device; /**< EtherCAT-Gerät */
unsigned int device_registered; /**< Ein Geraet hat sich registriert. */
uint8_t command_index; /**< Aktueller Kommando-Index */
- ec_domain_t *domains[EC_MASTER_MAX_DOMAINS]; /**< Prozessdatendomänen */
- unsigned int domain_count; /**< Anzahl Domänen */
+ struct list_head domains; /**< Liste der Prozessdatendomänen */
int debug_level; /**< Debug-Level im Master-Code */
unsigned int bus_time; /**< Letzte Bus-Zeit in Mikrosekunden */
unsigned int frames_lost; /**< Anzahl verlorener Frames */
--- a/todo.txt Tue Feb 28 11:36:29 2006 +0000
+++ b/todo.txt Tue Feb 28 13:07:05 2006 +0000
@@ -3,7 +3,6 @@
$Id$
-- Domains in Listen
- Asynchroner Betrieb
- Typeninformation aus Master entfernen?
- Ethernet over EtherCAT (EoE)