From: sdhsdh Date: Sun, 27 Sep 2009 22:39:48 +0000 (+0000) Subject: - move platform-specific constants to blip-platform.h (makes micaz otb) X-Git-Tag: rc_6_tinyos_2_1_1~220 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=cd239b7b74dd2e5bbd538531e92e445e20058f76 - move platform-specific constants to blip-platform.h (makes micaz otb) - fix byte-order bug on big endian linux platforms --- diff --git a/support/sdk/c/blip/lib6lowpan/6lowpan.h b/support/sdk/c/blip/lib6lowpan/6lowpan.h index c93d6cf3..636c341d 100644 --- a/support/sdk/c/blip/lib6lowpan/6lowpan.h +++ b/support/sdk/c/blip/lib6lowpan/6lowpan.h @@ -32,6 +32,8 @@ #define __6LOWPAN_H__ #include + +#include "blip-platform.h" /* * Typedefs and static library data. */ @@ -185,16 +187,4 @@ struct topology_header_package { struct topology_entry topo[0]; }; -enum { - IP_NUMBER_FRAGMENTS = 12, -}; - -#ifndef BLIP_L2_RETRIES -#define BLIP_L2_RETRIES 5 -#endif - -#ifndef BLIP_L2_DELAY -#define BLIP_L2_DELAY 15 -#endif - #endif diff --git a/support/sdk/c/blip/lib6lowpan/Makefile.am b/support/sdk/c/blip/lib6lowpan/Makefile.am index af31e9e1..f6248ab0 100644 --- a/support/sdk/c/blip/lib6lowpan/Makefile.am +++ b/support/sdk/c/blip/lib6lowpan/Makefile.am @@ -2,8 +2,7 @@ AM_CFLAGS = -DPC noinst_LIBRARIES = lib6lowpan.a -noinst_lib6lowpandir = $(includedir)/lib6lowpan-2.1.1 -noinst_lib6lowpan_HEADERS = 6lowpan.h devconf.h IEEE154Packet.h in_cksum.h \ - ip.h ip_malloc.h lib6lowpan.h TrackFlows.h -lib6lowpan_a_SOURCES = lib6lowpan.c lib6lowpanIP.c lib6lowpanFrag.c $(lib6lowpan_HEADERS) +lib6lowpan_h = 6lowpan.h devconf.h IEEE154Packet.h in_cksum.h \ + ip.h ip_malloc.h lib6lowpan.h TrackFlows.h blip-platform.h +lib6lowpan_a_SOURCES = lib6lowpan.c lib6lowpanIP.c lib6lowpanFrag.c $(lib6lowpan_h) diff --git a/support/sdk/c/blip/lib6lowpan/blip-platform.h b/support/sdk/c/blip/lib6lowpan/blip-platform.h new file mode 100644 index 00000000..d93029c3 --- /dev/null +++ b/support/sdk/c/blip/lib6lowpan/blip-platform.h @@ -0,0 +1,62 @@ +/* + * "Copyright (c) 2008, 2009 The Regents of the University of California. + * 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 UNIVERSITY OF CALIFORNIA 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 UNIVERSITY OF + * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA 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 UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + * + */ +#ifndef _BLIP_PLATFORM_H +#define _BLIP_PLATFORM_H + +/* this file has platform-specific configuration settings that don't + belong anywhere else */ + +/* bring in */ +#if defined(PC) +// use library versions if on linux +#include +#include +#else +// if we're not on a pc, assume little endian for now +#define __LITTLE_ENDIAN 1234 +#define __BYTE_ORDER __LITTLE_ENDIAN +#endif + +/* buffer sizes are defined here. */ +#if !defined(PLATFORM_MICAZ) +#define IP_MALLOC_HEAP_SIZE 1500 +enum { + IP_NUMBER_FRAGMENTS = 14, +}; +#else +#define IP_MALLOC_HEAP_SIZE 500 +enum { + IP_NUMBER_FRAGMENTS = 4, +}; +#endif + + +#ifndef BLIP_L2_RETRIES +#define BLIP_L2_RETRIES 5 +#endif + +#ifndef BLIP_L2_DELAY +#define BLIP_L2_DELAY 15 +#endif + + +#endif diff --git a/support/sdk/c/blip/lib6lowpan/ip.h b/support/sdk/c/blip/lib6lowpan/ip.h index 33568712..6a4be2cd 100644 --- a/support/sdk/c/blip/lib6lowpan/ip.h +++ b/support/sdk/c/blip/lib6lowpan/ip.h @@ -33,6 +33,7 @@ #endif #include "6lowpan.h" +#include "blip-platform.h" enum { /* diff --git a/support/sdk/c/blip/lib6lowpan/ip_malloc.h b/support/sdk/c/blip/lib6lowpan/ip_malloc.h index 02e3e2e4..6249e6a3 100644 --- a/support/sdk/c/blip/lib6lowpan/ip_malloc.h +++ b/support/sdk/c/blip/lib6lowpan/ip_malloc.h @@ -24,13 +24,13 @@ #define IP_MALLOC_H_ #include +#include // align on this number of byte boundarie#s #define IP_MALLOC_ALIGN 2 #define IP_MALLOC_LEN 0x0fff #define IP_MALLOC_FLAGS 0x7000 #define IP_MALLOC_INUSE 0x8000 -#define IP_MALLOC_HEAP_SIZE 1500 extern uint8_t heap[IP_MALLOC_HEAP_SIZE]; typedef uint16_t bndrt_t; diff --git a/support/sdk/c/blip/lib6lowpan/nwbyte.h b/support/sdk/c/blip/lib6lowpan/nwbyte.h index 44d0ea82..f94b3a5b 100644 --- a/support/sdk/c/blip/lib6lowpan/nwbyte.h +++ b/support/sdk/c/blip/lib6lowpan/nwbyte.h @@ -1,17 +1,10 @@ #ifndef _NWBYTE_H #define _NWBYTE_H_ -#if !defined(PC) -// if we're not on a pc, assume little endian for now -#define __LITTLE_ENDIAN 1234 -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif +#include "blip-platform.h" /* define normal network byte-orders routines */ #if defined(PC) -// use library versions if on linux -#include -#include #define ntoh16(X) ntohs(X) #define hton16(X) htons(X) @@ -25,7 +18,7 @@ #define hton16(X) (((((uint16_t)(X)) << 8) | ((uint16_t)(X) >> 8)) & 0xffff) /* this is much more efficient since gcc can insert swpb now. */ -static uint32_t __attribute__((unused)) ntoh32(uint32_t i) { +static inline uint32_t __attribute__((unused)) ntoh32(uint32_t i) { uint16_t lo = (uint16_t)i; uint16_t hi = (uint16_t)(i >> 16); lo = (lo << 8) | (lo >> 8); @@ -53,8 +46,8 @@ static uint32_t __attribute__((unused)) ntoh32(uint32_t i) { #endif #else -// assume big-endian byte-order -#define leton16(X) (X) +// big-endian byte-order +#define leton16(X) (((((uint16_t)(X)) << 8) | ((uint16_t)(X) >> 8)) & 0xffff) #define htole16(X) (((((uint16_t)(X)) << 8) | ((uint16_t)(X) >> 8)) & 0xffff) #endif