diff --git a/master/Makefile.am b/master/Makefile.am index 1a0ef30a..2b8bbf77 100644 --- a/master/Makefile.am +++ b/master/Makefile.am @@ -67,6 +67,7 @@ noinst_HEADERS = \ sdo_request.c sdo_request.h \ slave.c slave.h \ slave_config.c slave_config.h \ + smp.h \ soe_errors.c \ soe_request.c soe_request.h \ sync.c sync.h \ diff --git a/master/fsm_master.c b/master/fsm_master.c index 36a29e2f..11e1e58e 100644 --- a/master/fsm_master.c +++ b/master/fsm_master.c @@ -32,6 +32,7 @@ #ifdef EC_EOE #include "ethernet.h" #endif +#include "smp.h" #include "fsm_master.h" #include "fsm_foe.h" diff --git a/master/globals.h b/master/globals.h index 4343a9ed..afa2a808 100644 --- a/master/globals.h +++ b/master/globals.h @@ -24,14 +24,12 @@ /****************************************************************************/ -#ifndef __EC_MASTER_GLOBALS_H__ -#define __EC_MASTER_GLOBALS_H__ +#ifndef MASTER_GLOBALS_H_ +#define MASTER_GLOBALS_H_ #include "../globals.h" #include "../include/ecrt.h" -#include - /***************************************************************************** * EtherCAT master ****************************************************************************/ @@ -173,8 +171,7 @@ typedef struct { */ typedef enum { EC_DC_32, /**< 32 bit. */ - EC_DC_64 /*< 64 bit for system time, system time offset and - port 0 receive time. */ + EC_DC_64 /*< 64 bit for system time, time offset and port receive time. */ } ec_slave_dc_range_t; /** EtherCAT slave sync signal configuration. @@ -254,28 +251,6 @@ extern const char *ec_device_names[2]; // only main and backup! /****************************************************************************/ -/* Define SMP macros on kernel versions where they did not exist yet. - */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 47) - -#define smp_store_release(p, v) \ -do { \ - smp_mb(); \ - ACCESS_ONCE(*p) = (v); \ -} while (0) - -#define smp_load_acquire(p) \ -({ \ - typeof(*p) ___p1 = ACCESS_ONCE(*p); \ - smp_mb(); \ - ___p1; \ -}) - -#endif - -/****************************************************************************/ - extern char *ec_master_version_str; /****************************************************************************/ @@ -335,4 +310,4 @@ typedef struct ec_slave ec_slave_t; /**< \see ec_slave. */ /****************************************************************************/ -#endif +#endif // MASTER_GLOBALS_H_ diff --git a/master/master.c b/master/master.c index f92f1869..0c5e653b 100644 --- a/master/master.c +++ b/master/master.c @@ -43,6 +43,7 @@ #include "slave_config.h" #include "device.h" #include "datagram.h" +#include "smp.h" #ifdef EC_EOE #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) diff --git a/master/smp.h b/master/smp.h new file mode 100644 index 00000000..f8c8fe35 --- /dev/null +++ b/master/smp.h @@ -0,0 +1,56 @@ +/***************************************************************************** + * + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH + * + * This file is part of the IgH EtherCAT master. + * + * The file is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; version 2.1 of the License. + * + * This file is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this file. If not, see . + * + ****************************************************************************/ + +/** \file + * Definitions of Kernel SMP macros. + */ + +/****************************************************************************/ + +#ifndef MASTER_SMP_H_ +#define MASTER_SMP_H_ + +#include + +/****************************************************************************/ + +/* Define SMP macros on kernel versions where they did not exist yet. + */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 47) + +#define smp_store_release(p, v) \ +do { \ + smp_mb(); \ + ACCESS_ONCE(*p) = (v); \ +} while (0) + +#define smp_load_acquire(p) \ +({ \ + typeof(*p) ___p1 = ACCESS_ONCE(*p); \ + smp_mb(); \ + ___p1; \ +}) + +#endif + +/****************************************************************************/ + +#endif // MASTER_SMP_H_