[Tinyos-commits] CVS: tinyos-1.x/tos/lib/VM/languages/motlle/mate
MotllePlatform.h, NONE, 1.1 MemoryM.nc, 1.7, 1.8 Motlle.h, 1.6,
1.7 MotlleDecoderM.nc, 1.3, 1.4 MotlleValues.nc, 1.4, 1.5
David Gay
idgay at users.sourceforge.net
Wed Nov 23 15:16:25 PST 2005
Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22964
Modified Files:
MemoryM.nc Motlle.h MotlleDecoderM.nc MotlleValues.nc
Added Files:
MotllePlatform.h
Log Message:
telosb support - better handling of alignment issues
--- NEW FILE: MotllePlatform.h ---
/*
* Copyright (c) 2004-2005 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/* For each platform, you should define the following constants:
MOTLLE_STACK_ALIGNMENT: enough alignment for the svalue and all
stack frame types.
MOTLLE_HEAP_ALIGNMENT: enough alignment for all heap-stored objects,
and must also take account of the current value encoding
Also, you should #define
PLATFORM_LITTLE_ENDIAN if your platform is little-endian.
PLATFORM_REQUIRES_ALIGNMENT except if your platform supports unaligned
reads.
*/
#if defined(PLATFORM_MICA) || defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2DOT) || defined(PLATFORM_MICAZ)
enum {
MOTLLE_STACK_ALIGNMENT = 1,
MOTLLE_HEAP_ALIGNMENT = 2
};
#define PLATFORM_LITTLE_ENDIAN
#undef PLATFORM_REQUIRES_ALIGNMENT
#elif defined(PLATFORM_TELOS) || defined(PLATFORM_TELOSB)
enum {
MOTLLE_STACK_ALIGNMENT = 2,
MOTLLE_HEAP_ALIGNMENT = 2
};
#define PLATFORM_LITTLE_ENDIAN
#define PLATFORM_REQUIRES_ALIGNMENT
#else
#error "Unsupported platform. Add appropriate definitions to this file (MotllePlatform.h)"
#endif
Index: MemoryM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/MemoryM.nc,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** MemoryM.nc 22 Nov 2005 23:25:22 -0000 1.7
--- MemoryM.nc 23 Nov 2005 23:16:23 -0000 1.8
***************
*** 46,54 ****
};
- struct memory_header {
- uint8_t nglobals;
- //svalue entry;
- };
-
MateCapsule mcapsule;
--- 46,49 ----
***************
*** 63,66 ****
--- 58,79 ----
uint8_t gcpro;
+ MINLINE command uint8_t *GC.base() { /* Return base of GC area */
+ #ifdef PLATFORM_REQUIRES_ALIGNMENT
+ return (uint8_t *)ALIGN((intptr_t)mcapsule.data, MOTLLE_HEAP_ALIGNMENT);
+ #else
+ return (uint8_t *)mcapsule.data + 1; // for the globals count
+ #endif
+ }
+
+ MINLINE uint8_t *capsule_end() {
+ return (uint8_t *)ALIGN_DOWN((intptr_t)mcapsule.data + sizeof mcapsule.data, MOTLLE_STACK_ALIGNMENT);
+ }
+
+ command mvalue GC.entry_point() {
+ //return call V.read(&((struct memory_header *)call GC.base())->entry);
+ // 1st object, for now
+ return call V.make_pointer(call V.make_pvalue(call GC.base() + sizeof(uint16_t)));
+ }
+
void reset_splimit() {
splimit = gc_heap + (posgc - gc_heap) * 2;
***************
*** 113,124 ****
event result_t Virus.capsuleInstalled(MateCapsuleID id, MateCapsule *capsule) {
! struct memory_header *header = (struct memory_header *)mcapsule.data;
! uint8_t i, nglobals = header->nglobals;
- gvars = mcapsule.data + mcapsule.dataSize;
// initialise globals to null
for (i = 0; i < nglobals; i++)
call G.write(i, call T.nil());
- posgc = gc_heap = gvars + sizeof(svalue) * nglobals;
for (i = 0; i < MATE_HANDLER_NUM; i++)
signal HandlerStore.handlerChanged[i]();
--- 126,148 ----
event result_t Virus.capsuleInstalled(MateCapsuleID id, MateCapsule *capsule) {
! uint8_t i, nglobals = (uint8_t)mcapsule.data[0];
!
! gvars = call GC.base() + mcapsule.dataSize - 1;
! posgc = gc_heap = gvars + sizeof(svalue) * nglobals;
! #ifdef PLATFORM_REQUIRES_ALIGNMENT
! /* Don't write past the capsule. We'll abort out in the next test
! anyway. */
! if (gvars <= capsule_end())
! memmove(call GC.base(), mcapsule.data + 1, mcapsule.dataSize - 1);
! #endif
! if (gc_heap > capsule_end())
! {
! gvars = NULL;
! return SUCCESS;
! }
// initialise globals to null
for (i = 0; i < nglobals; i++)
call G.write(i, call T.nil());
for (i = 0; i < MATE_HANDLER_NUM; i++)
signal HandlerStore.handlerChanged[i]();
***************
*** 145,158 ****
#endif
- MINLINE command uint8_t *GC.base() { /* Return base of GC area */
- return mcapsule.data + sizeof(struct memory_header);
- }
-
- command mvalue GC.entry_point() {
- //return call V.read(&((struct memory_header *)call GC.base())->entry);
- // 1st object, for now
- return call V.make_pointer(call V.make_pvalue(call GC.base() + sizeof(uint16_t)));
- }
-
/* Returns TRUE if ptr is in a mutable object (i.e., above gc_heap)
*/
--- 169,172 ----
***************
*** 233,241 ****
memmove(sp, old_sp, sizeof(svalue) * stack_move_count);
! return fp == (uint8_t *)(mcapsule.data + sizeof mcapsule.data);
}
command void S.reset(MateContext *context) {
! sp = fp = mcapsule.data + sizeof mcapsule.data;
reset_splimit();
}
--- 247,255 ----
memmove(sp, old_sp, sizeof(svalue) * stack_move_count);
! return fp == capsule_end();
}
command void S.reset(MateContext *context) {
! sp = fp = capsule_end();
reset_splimit();
}
***************
*** 415,419 ****
/* Forward the motlle stack */
scansp = sp; scanfp = fp;
! while (scansp < (uint8_t *)mcapsule.data + sizeof mcapsule.data)
{
s = call MotlleFrame.gc_forward[frame_kind(scanfp)](NULL, scanfp + BASE_FRAME_SIZE, scanfp, scansp);
--- 429,433 ----
/* Forward the motlle stack */
scansp = sp; scanfp = fp;
! while (scansp < capsule_end())
{
s = call MotlleFrame.gc_forward[frame_kind(scanfp)](NULL, scanfp + BASE_FRAME_SIZE, scanfp, scansp);
Index: Motlle.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/Motlle.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Motlle.h 1 Nov 2005 02:28:11 -0000 1.6
--- Motlle.h 23 Nov 2005 23:16:23 -0000 1.7
***************
*** 135,144 ****
MOTLLE_MAP_FRAME = unique("MotlleFrame"),
MOTLLE_FOREACH_FRAME = unique("MotlleFrame"),
- /* MOTLLE_STACK_ALIGNMENT must be aligned enough for the svalue and all
- stack frame types. */
- MOTLLE_STACK_ALIGNMENT = 1,
- /* HEAP_ALIGNMENT must be aligned enough for all heap-stored objects,
- and must also take account of the current value encoding */
- MOTLLE_HEAP_ALIGNMENT = 2,
MOTLLE_GCPRO_SIZE = 8
};
--- 135,138 ----
***************
*** 158,162 ****
(var1) = call GC.gcpopfetch())
! #define ALIGN(n, m) (((n) + (m) - 1) & ~((m) - 1))
enum {
--- 152,157 ----
(var1) = call GC.gcpopfetch())
! #define ALIGN_DOWN(n, m) ((n) & ~((m) - 1))
! #define ALIGN(n, m) ALIGN_DOWN(((n) + (m) - 1), (m))
enum {
***************
*** 168,169 ****
--- 163,166 ----
GLOBAL_MOTLLE_LOCK = unique("MateLock")
};
+
+ #include "MotllePlatform.h"
Index: MotlleDecoderM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/MotlleDecoderM.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** MotlleDecoderM.nc 1 Nov 2005 02:28:11 -0000 1.3
--- MotlleDecoderM.nc 23 Nov 2005 23:16:23 -0000 1.4
***************
*** 17,24 ****
implementation {
MINLINE uint8_t b(MateContext *context) {
! uint16_t pc = context->pc;
!
! context->pc++;
! return (call GC.base())[pc];
}
--- 17,21 ----
implementation {
MINLINE uint8_t b(MateContext *context) {
! return (call GC.base())[context->pc++];
}
***************
*** 50,55 ****
MINLINE command mvalue C.read_value(MateContext *context) {
! // values are little-endian
! mvalue v = call V.read((svalue *)&(call GC.base())[context->pc]);
context->pc += sizeof(svalue);
--- 47,51 ----
MINLINE command mvalue C.read_value(MateContext *context) {
! mvalue v = call V.read_unaligned((svalue *)&(call GC.base())[context->pc]);
context->pc += sizeof(svalue);
Index: MotlleValues.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/MotlleValues.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MotlleValues.nc 1 Nov 2005 02:28:11 -0000 1.4
--- MotlleValues.nc 23 Nov 2005 23:16:23 -0000 1.5
***************
*** 17,20 ****
--- 17,21 ----
interface MotlleValues {
command mvalue read(svalue *location);
+ command mvalue read_unaligned(svalue *location);
command void write(svalue *location, mvalue x);
More information about the Tinyos-commits
mailing list