From 63d57e90b8f69449521dcea7c4fdd293ef7b242e Mon Sep 17 00:00:00 2001 From: sallai Date: Mon, 21 Jul 2008 23:16:04 +0000 Subject: [PATCH] iris tosthreads support fix --- .../chips/rf230/ActiveMessageLayerC.nc | 115 ++++++++++++++ .../chips/rf230/RF230ActiveMessageC.nc | 150 ++++++++++++++++++ .../platforms/iris/ActiveMessageC.nc | 63 ++++++++ 3 files changed, 328 insertions(+) create mode 100644 tos/lib/tosthreads/chips/rf230/ActiveMessageLayerC.nc create mode 100644 tos/lib/tosthreads/chips/rf230/RF230ActiveMessageC.nc create mode 100644 tos/lib/tosthreads/platforms/iris/ActiveMessageC.nc diff --git a/tos/lib/tosthreads/chips/rf230/ActiveMessageLayerC.nc b/tos/lib/tosthreads/chips/rf230/ActiveMessageLayerC.nc new file mode 100644 index 00000000..d7af8622 --- /dev/null +++ b/tos/lib/tosthreads/chips/rf230/ActiveMessageLayerC.nc @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +module ActiveMessageLayerC +{ + provides + { + interface AMSend[am_id_t id]; + interface Receive[am_id_t id]; + interface Receive as ReceiveDefault[am_id_t id]; + interface Receive as Snoop[am_id_t id]; + interface Receive as SnoopDefault[am_id_t id]; + } + uses + { + interface Send as SubSend; + interface Receive as SubReceive; + interface AMPacket; + interface ActiveMessageConfig as Config; + } +} + +implementation +{ +/*----------------- Send -----------------*/ + + command error_t AMSend.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len) + { + error_t error; + + error = call Config.checkPacket(msg); + if( error != SUCCESS ) + return error; + + call AMPacket.setSource(msg, call AMPacket.address()); + call AMPacket.setGroup(msg, call AMPacket.localGroup()); + call AMPacket.setType(msg, id); + call AMPacket.setDestination(msg, addr); + + return call SubSend.send(msg, len); + } + + inline event void SubSend.sendDone(message_t* msg, error_t error) + { + signal AMSend.sendDone[call AMPacket.type(msg)](msg, error); + } + + inline command error_t AMSend.cancel[am_id_t id](message_t* msg) + { + return call SubSend.cancel(msg); + } + + default event void AMSend.sendDone[am_id_t id](message_t* msg, error_t error) + { + } + + inline command uint8_t AMSend.maxPayloadLength[am_id_t id]() + { + return call SubSend.maxPayloadLength(); + } + + inline command void* AMSend.getPayload[am_id_t id](message_t* msg, uint8_t len) + { + return call SubSend.getPayload(msg, len); + } + +/*----------------- Receive -----------------*/ + + event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len) + { + am_id_t type = call AMPacket.type(msg); + + msg = call AMPacket.isForMe(msg) + ? signal Receive.receive[type](msg, payload, len) + : signal Snoop.receive[type](msg, payload, len); + + return msg; + } + + default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) { + return signal ReceiveDefault.receive[id](msg, payload, len); + } + + default event message_t* ReceiveDefault.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) { + return msg; + } + + default event message_t* Snoop.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) { + return signal SnoopDefault.receive[id](msg, payload, len); + } + + default event message_t* SnoopDefault.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) { + return msg; + } +} diff --git a/tos/lib/tosthreads/chips/rf230/RF230ActiveMessageC.nc b/tos/lib/tosthreads/chips/rf230/RF230ActiveMessageC.nc new file mode 100644 index 00000000..e30af9ce --- /dev/null +++ b/tos/lib/tosthreads/chips/rf230/RF230ActiveMessageC.nc @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +#include + +configuration RF230ActiveMessageC +{ + provides + { + interface SplitControl; + + interface AMSend[am_id_t id]; + interface Receive[am_id_t id]; + interface Receive as ReceiveDefault[am_id_t id]; + interface Receive as Snoop[am_id_t id]; + interface Receive as SnoopDefault[am_id_t id]; + + interface Packet; + interface AMPacket; + interface PacketAcknowledgements; + interface LowPowerListening; + + interface PacketField as PacketLinkQuality; + interface PacketField as PacketTransmitPower; + interface PacketField as PacketRSSI; + + interface PacketTimeStamp as PacketTimeStampRadio; + interface PacketTimeStamp as PacketTimeStampMilli; + } +} + +implementation +{ + components RF230ActiveMessageP, RF230PacketC, IEEE154PacketC, RadioAlarmC; + +#ifdef RF230_DEBUG + components AssertC; +#endif + + RF230ActiveMessageP.IEEE154Packet -> IEEE154PacketC; + RF230ActiveMessageP.Packet -> RF230PacketC; + RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; + + Packet = RF230PacketC; + AMPacket = RF230PacketC; + PacketAcknowledgements = RF230PacketC; + PacketLinkQuality = RF230PacketC.PacketLinkQuality; + PacketTransmitPower = RF230PacketC.PacketTransmitPower; + PacketRSSI = RF230PacketC.PacketRSSI; + PacketTimeStampRadio = RF230PacketC; + PacketTimeStampMilli = RF230PacketC; + LowPowerListening = LowPowerListeningLayerC; + + components ActiveMessageLayerC; +#ifdef TFRAMES_ENABLED + components new DummyLayerC() as IEEE154NetworkLayerC; +#else + components IEEE154NetworkLayerC; +#endif +#ifdef LOW_POWER_LISTENING + components LowPowerListeningLayerC; +#else + components new DummyLayerC() as LowPowerListeningLayerC; +#endif + components MessageBufferLayerC; + components UniqueLayerC; + components TrafficMonitorLayerC; +#ifdef RF230_SLOTTED_MAC + components SlottedCollisionLayerC as CollisionAvoidanceLayerC; +#else + components RandomCollisionLayerC as CollisionAvoidanceLayerC; +#endif + components SoftwareAckLayerC; + components new DummyLayerC() as CsmaLayerC; + components RF230LayerC; + + SplitControl = LowPowerListeningLayerC; + AMSend = ActiveMessageLayerC; + Receive = ActiveMessageLayerC.Receive; + ReceiveDefault = ActiveMessageLayerC.ReceiveDefault; + Snoop = ActiveMessageLayerC.Snoop; + SnoopDefault = ActiveMessageLayerC.SnoopDefault; + + ActiveMessageLayerC.Config -> RF230ActiveMessageP; + ActiveMessageLayerC.AMPacket -> IEEE154PacketC; + ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC; + ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC; + + IEEE154NetworkLayerC.SubSend -> UniqueLayerC; + IEEE154NetworkLayerC.SubReceive -> LowPowerListeningLayerC; + + // the UniqueLayer is wired at two points + UniqueLayerC.Config -> RF230ActiveMessageP; + UniqueLayerC.SubSend -> LowPowerListeningLayerC; + + LowPowerListeningLayerC.SubControl -> MessageBufferLayerC; + LowPowerListeningLayerC.SubSend -> MessageBufferLayerC; + LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC; +#ifdef LOW_POWER_LISTENING + LowPowerListeningLayerC.PacketSleepInterval -> RF230PacketC; + LowPowerListeningLayerC.IEEE154Packet -> IEEE154PacketC; + LowPowerListeningLayerC.PacketAcknowledgements -> RF230PacketC; +#endif + + MessageBufferLayerC.Packet -> RF230PacketC; + MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC; + MessageBufferLayerC.RadioReceive -> UniqueLayerC; + MessageBufferLayerC.RadioState -> TrafficMonitorLayerC; + + UniqueLayerC.SubReceive -> TrafficMonitorLayerC; + + TrafficMonitorLayerC.Config -> RF230ActiveMessageP; + TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC; + TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC; + TrafficMonitorLayerC.SubState -> RF230LayerC; + + CollisionAvoidanceLayerC.Config -> RF230ActiveMessageP; + CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC; + CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC; + + SoftwareAckLayerC.Config -> RF230ActiveMessageP; + SoftwareAckLayerC.SubSend -> CsmaLayerC; + SoftwareAckLayerC.SubReceive -> RF230LayerC; + + CsmaLayerC.Config -> RF230ActiveMessageP; + CsmaLayerC -> RF230LayerC.RadioSend; + CsmaLayerC -> RF230LayerC.RadioCCA; + + RF230LayerC.RF230Config -> RF230ActiveMessageP; +} diff --git a/tos/lib/tosthreads/platforms/iris/ActiveMessageC.nc b/tos/lib/tosthreads/platforms/iris/ActiveMessageC.nc new file mode 100644 index 00000000..de7d7558 --- /dev/null +++ b/tos/lib/tosthreads/platforms/iris/ActiveMessageC.nc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +configuration ActiveMessageC +{ + provides + { + interface SplitControl; + + interface AMSend[uint8_t id]; + interface Receive[uint8_t id]; + interface Receive as ReceiveDefault[am_id_t id]; + interface Receive as Snoop[uint8_t id]; + interface Receive as SnoopDefault[am_id_t id]; + interface Packet; + interface AMPacket; + + interface PacketAcknowledgements; + interface LowPowerListening; + + interface PacketTimeStamp as PacketTimeStampMicro; + interface PacketTimeStamp as PacketTimeStampMilli; + } +} + +implementation +{ + components RF230ActiveMessageC as MAC; + + SplitControl = MAC; + AMSend = MAC; + Receive = MAC.Receive; + ReceiveDefault = MAC.ReceiveDefault; + Snoop = MAC.Snoop; + SnoopDefault = MAC.SnoopDefault; + Packet = MAC; + AMPacket = MAC; + + PacketAcknowledgements = MAC; + LowPowerListening = MAC; + PacketTimeStampMilli = MAC; + PacketTimeStampMicro = MAC; +} -- 2.39.2