[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/pxa27x/lib
absvec.h, NONE, 1.1 bufferManagement.c, NONE,
1.1 bufferManagement.h, NONE, 1.1 bufferManagementHelper.h,
NONE, 1.1 dcremove.h, NONE, 1.1 fft.h, NONE, 1.1 frequency.c,
NONE, 1.1 frequency.h, NONE, 1.1 paramtask.c, NONE,
1.1 processVibration.h, NONE, 1.1 window.h, NONE, 1.1 Makefile,
1.5, 1.6 criticalSection.h, 1.1, 1.2 downsample.c, 1.2,
1.3 downsample.h, 1.1, 1.2 paramtask.h, 1.1, 1.2 profile.c,
1.2, 1.3 profile.h, 1.1, 1.2 queue.c, 1.4, 1.5 queue.h, 1.4,
1.5 systemUtil.c, 1.1, 1.2 systemUtil.h, 1.1, 1.2 utils.c, 1.1, 1.2
Lama Nachman
lnachman at users.sourceforge.net
Sun Mar 4 16:06:12 PST 2007
Update of /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv14090/lib
Modified Files:
Makefile criticalSection.h downsample.c downsample.h
paramtask.h profile.c profile.h queue.c queue.h systemUtil.c
systemUtil.h utils.c
Added Files:
absvec.h bufferManagement.c bufferManagement.h
bufferManagementHelper.h dcremove.h fft.h frequency.c
frequency.h paramtask.c processVibration.h window.h
Log Message:
Pushed latest tree
--- NEW FILE: absvec.h ---
int absvec(short* x, unsigned short L);
unsigned long isqrt(unsigned long x);
--- NEW FILE: bufferManagement.c ---
#include "bufferManagement.h"
#include "assert.h"
#include "criticalSection.h"
#include "systemUtil.h"
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
int initBufferSet(bufferSet_t *pBS, buffer_t *pB, uint8_t **buffers, uint32_t numBuffers, uint32_t bufferSize){
int i;
DECLARE_CRITICAL_SECTION();
assert(pBS);
assert(pB);
assert(buffers);
CRITICAL_SECTION_BEGIN();
pBS->pB = pB;
pBS->numBuffers = numBuffers;
pBS->bufferSize = bufferSize;
for(i=0;i<numBuffers; i++){
buffer_t *currentBufferStruct;
uint8_t *currentBuffer;
currentBufferStruct = &(pBS->pB[i]);
currentBuffer = ((uint8_t*)buffers) + i*bufferSize;
currentBufferStruct->inuse = FALSE;
currentBufferStruct->buf = currentBuffer;
}
CRITICAL_SECTION_END();
return 1;
}
uint32_t getBufferLevel(bufferSet_t *pBS){
int i;
uint32_t ret =0;
DECLARE_CRITICAL_SECTION();
CRITICAL_SECTION_BEGIN();
for(i=0;i< (pBS->numBuffers); i++){
assert(pBS->pB);
assert(pBS->pB[i].buf);
if(pBS->pB[i].inuse == FALSE){
ret++;
}
}
CRITICAL_SECTION_END();
return ret;
}
uint8_t *getNextBuffer(bufferSet_t* pBS){
int i;
assert(pBS);
assert(pBS->pB);
DECLARE_CRITICAL_SECTION();
uint8_t *ret = NULL;
CRITICAL_SECTION_BEGIN();
for(i=0;i < (pBS->numBuffers) ; i++){
if(pBS->pB[i].inuse == FALSE){
pBS->pB[i].inuse = TRUE;
ret = pBS->pB[i].buf;
//only assert if we're going to actually return this buffer
assert(pBS->pB[i].buf);
break;
}
}
CRITICAL_SECTION_END();
return ret;
}
int returnBuffer(bufferSet_t *pBS, uint8_t *buf){
int i,ret=0;
DECLARE_CRITICAL_SECTION();
assert(pBS);
assert(pBS->pB);
CRITICAL_SECTION_BEGIN();
for(i=0;i < (pBS->numBuffers); i++){
assert(pBS->pB[i].buf);
if(pBS->pB[i].buf == buf){
pBS->pB[i].inuse = FALSE;
ret = 1;
}
}
CRITICAL_SECTION_END();
if(ret==0){
printFatalErrorMsgHex("Attempted to return buffer to wrong bufferSet [buf bufferSet]=",2, buf, (uint32_t)pBS);
}
return ret;
}
int initBufferInfoSet(bufferInfoSet_t *pBIS, bufferInfoInfo_t *pBII, uint32_t numBIs){
int i;
DECLARE_CRITICAL_SECTION();
assert(pBIS);
assert(pBII);
CRITICAL_SECTION_BEGIN();
pBIS->numBuffers = numBIs;
pBIS->pBII = pBII;
for(i=0;i<numBIs; i++){
pBIS->pBII[i].inuse = FALSE;
}
CRITICAL_SECTION_END();
return 1;
}
bufferInfo_t *getNextBufferInfo(bufferInfoSet_t *pBIS){
int i;
DECLARE_CRITICAL_SECTION();
bufferInfo_t *ret = NULL;
assert(pBIS);
assert(pBIS->pBII);
CRITICAL_SECTION_BEGIN();
for(i=0;i < (pBIS->numBuffers); i++){
if(pBIS->pBII[i].inuse == FALSE){
pBIS->pBII[i].inuse = TRUE;
ret = &(pBIS->pBII[i].BI);
break;
}
}
CRITICAL_SECTION_END();
return ret;
}
int returnBufferInfo(bufferInfoSet_t *pBIS, bufferInfo_t *pBI){
int i, ret=0;
DECLARE_CRITICAL_SECTION();
assert(pBIS);
assert(pBIS->pBII);
assert(pBI);
CRITICAL_SECTION_BEGIN();
for(i=0;i < (pBIS->numBuffers); i++){
if(&(pBIS->pBII[i].BI) == pBI){
pBIS->pBII[i].inuse = FALSE;
ret = 1;
break;
}
}
CRITICAL_SECTION_END();
if(ret==0){
printFatalErrorMsgHex("Attempted to return bufferInfo to wrong bufferInfoSet [bufferInfoSet bufferInfo] = ",2, pBIS, pBI);
}
return ret;
}
int initTimestampedBufferInfoSet(timestampedBufferInfoSet_t *pBIS, timestampedBufferInfoInfo_t *pBII, uint32_t numBIs){
int i;
DECLARE_CRITICAL_SECTION();
assert(pBIS);
assert(pBII);
CRITICAL_SECTION_BEGIN();
pBIS->numBuffers = numBIs;
pBIS->pBII = pBII;
for(i=0;i<numBIs; i++){
pBIS->pBII[i].inuse = FALSE;
}
CRITICAL_SECTION_END();
return 1;
}
uint32_t getTimestampedBufferInfoLevel(timestampedBufferInfoSet_t *pBIS){
int i;
uint32_t ret = 0;
DECLARE_CRITICAL_SECTION();
assert(pBIS);
assert(pBIS->pBII);
CRITICAL_SECTION_BEGIN();
for(i=0;i< (pBIS->numBuffers); i++){
if(pBIS->pBII[i].inuse == FALSE){
ret++;
}
}
CRITICAL_SECTION_END();
return ret;
}
timestampedBufferInfo_t *getNextTimestampedBufferInfo(timestampedBufferInfoSet_t *pBIS){
int i;
DECLARE_CRITICAL_SECTION();
timestampedBufferInfo_t *ret = NULL;
assert(pBIS);
assert(pBIS->pBII);
CRITICAL_SECTION_BEGIN();
for(i=0;i < (pBIS->numBuffers); i++){
if(pBIS->pBII[i].inuse == FALSE){
pBIS->pBII[i].inuse = TRUE;
ret = &(pBIS->pBII[i].BI);
assert(ret);
break;
}
}
CRITICAL_SECTION_END();
return ret;
}
int returnTimestampedBufferInfo(timestampedBufferInfoSet_t *pBIS, timestampedBufferInfo_t *pBI){
int i, ret=0;
DECLARE_CRITICAL_SECTION();
assert(pBIS);
assert(pBIS->pBII);
assert(pBI);
CRITICAL_SECTION_BEGIN();
for(i=0;i < (pBIS->numBuffers); i++){
if(&(pBIS->pBII[i].BI) == pBI){
pBIS->pBII[i].inuse = FALSE;
ret = 1;
break;
}
}
CRITICAL_SECTION_END();
if(ret==0){
printFatalErrorMsg("Attempted to return timestamedBufferInfo to wrong timestampdBufferInfoSet [bufferInfoSet bufferInfo] = ",2, pBIS, pBI);
}
return ret;
}
--- NEW FILE: bufferManagement.h ---
#ifndef __BUFFER_H__
#define __BUFFER_H__
#include "inttypes.h"
/**********************
The concept of buffer exposed here consists of several main ideas
1.) a structure that contains a pointer to a buffer and an inuse flag called a buffer_t
an array of buffer_t's is initialized by calling initBufferArray and passing in a pointer to your array of buffers
and the number of buffers
2.) a structure that contains a pointer to a buffer, the number of bytes that it points to, and it's origin called a
bufferInfo_t. This structure is intended for dispatching a buffer once it has been returned from a source that
needs to record the number of bytes in a buffer and where it came from. Usage example for the origin
field is the case where multiple send functions actually call the same lower level send function, but some state
keeping info needs to be kept about where the buffer originally came from
3.) a structure that contains a bufferInfo and an inuse flag called a bufferInfoInfo_t. This structure is intended
to allow for the allocation of a bufferInfo structure from a pool of bufferInfo structures in the case where a
memory allocator can not be used to allocate a new bufferInfo_t structure, such as in an ISR.
usage:
BufferInfoInfo's
1.) instantiate an array of bufferInfoInfo_t's of some length.
2.) Initialize the bufferInfoInfo's by calling initBufferInfo(bufferInfoInfo_t *pBII, uint32_t numBIIs);
Bufferss
1.) instantiate an array of uint8_t buffers[] (i.e. a uint8_t buffer[my length][numbuffers].
2.) instantiate an array of buffer_t's of the same length as numbuffers
3.) Initialize the buffer's by calling initBuffer(buffer_t *pB, uint8_t **buffers, uint32_t numBuffers);
************************/
//this enumeration type is intended to be extended as new sources get created. This will facilitate tracking of buffers
//in memory
typedef enum {
originSendData = 0,
originSendDataAlloc,
} sendOrigin_t;
typedef struct bufferInfo_t{
uint8_t *pBuf;
uint32_t numBytes;
sendOrigin_t origin;
} bufferInfo_t;
typedef struct timestampedBufferInfo_t{
uint8_t *pBuf;
uint64_t timestamp;
uint32_t numBytes;
sendOrigin_t origin;
} timestampedBufferInfo_t;
typedef struct bufferInfoInfo_t{
bufferInfo_t BI;
char inuse;
} bufferInfoInfo_t;
typedef struct timestampedBufferInfoInfo_t{
timestampedBufferInfo_t BI;
char inuse;
} timestampedBufferInfoInfo_t;
typedef struct buffer_t{
uint8_t *buf;
char inuse;
} buffer_t;
/**
*A buffer set is a structure that contains a pointer to an array of buffer_ts and a unsigned integer
*that contains the number of buffer_ts that the array points to
*
*
**/
typedef struct bufferSet_t{
uint32_t numBuffers;
uint32_t bufferSize;
buffer_t *pB;
} bufferSet_t;
typedef struct bufferInfoSet_t{
uint32_t numBuffers;
bufferInfoInfo_t *pBII;
} bufferInfoSet_t;
typedef struct timestampedBufferInfoSet_t{
uint32_t numBuffers;
timestampedBufferInfoInfo_t *pBII;
} timestampedBufferInfoSet_t;
int initBufferSet(bufferSet_t *pBS, buffer_t *pB, uint8_t **buffers, uint32_t numBuffers, uint32_t bufferSize);
uint32_t getBufferLevel(bufferSet_t *pBS);
uint8_t *getNextBuffer(bufferSet_t* pBS);
/**
* return a buffer to a buffer_t array
*
* @ return 1 if successful, 0 if not successful (if this buffer was not part of this buffer_t array
*
**/
int returnBuffer(bufferSet_t *pBS, uint8_t *buf);
int initBufferInfoSet(bufferInfoSet_t *pBIS,
bufferInfoInfo_t *pBII,
uint32_t numBIIs);
bufferInfo_t *getNextBufferInfo(bufferInfoSet_t *pBII);
/**
* return a bufferInfo_t to a bufferInfoInfo_t array
*
* @ return 1 if successful, 0 if not successful (if this bufferInfo_t was not part of this bufferInfoInfo_t array
*
**/
int returnBufferInfo(bufferInfoSet_t *pBII, bufferInfo_t *pBI);
int initTimestampedBufferInfoSet(timestampedBufferInfoSet_t *pBIS,
timestampedBufferInfoInfo_t *pBII,
uint32_t numBIIs);
uint32_t getTimestampedBufferInfoLevel(timestampedBufferInfoSet_t *pBS);
timestampedBufferInfo_t *getNextTimestampedBufferInfo(timestampedBufferInfoSet_t *pBII);
/**
* return a bufferInfo_t to a bufferInfoInfo_t array
*
* @ return 1 if successful, 0 if not successful (if this bufferInfo_t was not part of this bufferInfoInfo_t array
*
**/
int returnTimestampedBufferInfo(timestampedBufferInfoSet_t *pBII, timestampedBufferInfo_t *pBI);
#endif // __BUFFER_H__
--- NEW FILE: bufferManagementHelper.h ---
#ifndef __BUFFERMANAGEMENTHELPER_H__
#define __BUFFERMANAGEMENTHELPER_H__
#define DMA_BUFFER_SIZE(_x) ((((_x)+31)>>5)<<5)
#define DMA_ABLE_BUFFER(_x) ( (((uint32_t)(_x)) > 0x5c00000) && (((uint32_t)(_x)) < 0x5c040000) && ((((uint32_t)(_x))& 0x1f)== 0) )
#define DECLARE_BUFFER(_name, _number,_size) \
bufferInfoSet_t _name##BufferInfoSet; \
bufferInfoInfo_t _name##BufferInfoInfo[_number]; \
bufferSet_t _name##BufferSet; \
buffer_t _name##BufferStructs[_number]; \
uint8_t _name##Buffers[_number][_size];
#define DECLARE_DMABUFFER(_name, _number,_size) \
bufferInfoSet_t _name##BufferInfoSet; \
bufferInfoInfo_t _name##BufferInfoInfo[_number]; \
bufferSet_t _name##BufferSet; \
buffer_t _name##BufferStructs[_number]; \
uint8_t _name##Buffers[_number][DMA_BUFFER_SIZE(_size)] __attribute__((aligned(32)));
#define DECLARE_TIMESTAMPEDDMABUFFER(_name, _number,_size) \
timestampedBufferInfoSet_t _name##TimestampedBufferInfoSet; \
timestampedBufferInfoInfo_t _name##TimestampedBufferInfoInfo[_number]; \
bufferSet_t _name##BufferSet; \
buffer_t _name##BufferStructs[_number]; \
uint8_t _name##Buffers[_number][DMA_BUFFER_SIZE(_size)] __attribute__((aligned(32)));
#define INIT_BUFFER(_name, _number,_size) \
do{ \
initBufferInfoSet(& _name##BufferInfoSet, _name##BufferInfoInfo, _number); \
initBufferSet(& _name##BufferSet, \
_name##BufferStructs, \
(uint8_t **) _name##Buffers, \
_number, \
_size);} \
while(0)
#define INIT_DMABUFFER(_name, _number,_size) \
do { \
initBufferInfoSet(& _name##BufferInfoSet, _name##BufferInfoInfo, _number); \
initBufferSet(& _name ## BufferSet, \
_name ## BufferStructs, \
(uint8_t **) _name ## Buffers, \
_number, \
DMA_BUFFER_SIZE(_size));} \
while(0)
#define INIT_TIMESTAMPEDDMABUFFER(_name, _number,_size) \
do { \
initTimestampedBufferInfoSet(& _name##TimestampedBufferInfoSet, _name##TimestampedBufferInfoInfo, _number); \
initBufferSet(& _name ## BufferSet, \
_name ## BufferStructs, \
(uint8_t **) _name ## Buffers, \
_number, \
DMA_BUFFER_SIZE(_size));} \
while(0)
#endif // __BUFFERMANAGEMENTHELPER_H__
--- NEW FILE: dcremove.h ---
int dcremove(short* x, unsigned long L);
--- NEW FILE: fft.h ---
void FFT_calibrate (short x[], long nx, short *sh, short firstTime);
void FFT_radix2 (short x[], long nx, short *index);
void bitrev_index(short *index, long n);
--- NEW FILE: frequency.c ---
#include "criticalSection.h"
#include "frequency.h"
#include "pxa27x_registers_def.h"
#if 0
typedef struct{
uint32_t CCCR;
uint32_t CLKCFG;
}frequencyInfo_t;
const frequencyInfo_t frequencyInfo[4] = {
{CCCR_L(8) | CCCR_2N(2) | }};
#endif
#define CLKCFG_B (1<<3)
#define CLKCFG_HT (1<<2)
#define CLKCFG_F (1<<1)
#define CLKCFG_T (1)
void writeCLKCFG(uint32_t value){
asm volatile (
"mcr p14,0,%0,c6,c0,0\n\t"
:
: "r" (value)
);
return;
}
uint32_t readCLKCFG(){
uint32_t result;
asm volatile (
"mrc p14,0,%0,c6,c0,0\n\t"
:"=r" (result)
);
return result;
}
uint32_t getSystemFrequency(){
uint32_t clkcfg = readCLKCFG();
uint32_t frequency;
if((CCSR & CCSR_CPDIS_S)){
return 13;
}
else{
frequency = 13 * (CCSR & 0x1f);
frequency *= (clkcfg & CLKCFG_T) ? ((CCSR >> 7) & 0x7)/2 : 1;
if( (clkcfg & CLKCFG_HT) && (clkcfg & CLKCFG_T)){
return frequency/2;
}
else{
return frequency;
}
}
}
uint32_t getSystemBusFrequency(){
uint32_t clkcfg = readCLKCFG();
if((CCSR & CCSR_CPDIS_S)){
return 13;
}
else{
if(clkcfg & CLKCFG_B){
return 13 * (CCSR & 0x1f);
}
else{
return (13 * (CCSR & 0x1f))/2;
}
}
}
--- NEW FILE: frequency.h ---
#ifndef __FREQUENCY_H__
#define __FREQUENCY_H__
#include "inttypes.h"
uint32_t getSystemFrequency();
uint32_t getSystemBusFrequency();
void writeCLKCFG(uint32_t value);
uint32_t readCLKCFG();
#endif // __FREQUENCY_H__
--- NEW FILE: paramtask.c ---
#include "criticalSection.h"
#include "queue.h"
#include "pxa27x_registers_def.h"
#include "systemUtil.h"
/*
* TOS_parampost (thread_pointer, argument)
*
* Put the task pointer into the next free slot.
* Return 1 if successful, 0 if there is no free slot.
*
* This function uses a critical section to protect TOSH_sched_free.
* As tasks can be posted in both interrupt and non-interrupt context,
* this is necessary.
*/
extern uint32_t sys_max_tasks, sys_task_bitmask;
extern uint8_t TOSH_sched_full, TOSH_sched_free;
extern queue_t paramtaskQueue;
typedef struct {
void (*tp) ();
void *postingFunction;
uint32_t timestamp;
uint32_t executeTime;
} TOSH_sched_entry_T;
extern TOSH_sched_entry_T TOSH_queue[];
unsigned char TOS_parampost(void (*tp) (), uint32_t arg) {
DECLARE_CRITICAL_SECTION();
uint8_t tmp;
// dbg(DBG_SCHED, ("TOSH_post: %d 0x%x\n", TOSH_sched_free, (int)tp));
CRITICAL_SECTION_BEGIN();
tmp = TOSH_sched_free;
if (TOSH_queue[tmp].tp == 0x0) {
#ifdef TASK_QUEUE_DEBUG
occupancy++;
if (occupancy > max_occupancy) {
max_occupancy = occupancy;
}
#endif
if(pushqueue(¶mtaskQueue, arg)){
TOSH_sched_free = (tmp + 1) & sys_task_bitmask;
TOSH_queue[tmp].tp = tp;
TOSH_queue[tmp].postingFunction = (void *)__builtin_return_address(0);
TOSH_queue[tmp].timestamp = OSCR0;
TOSH_queue[tmp].executeTime = 0;
}
else{
printFatalErrorMsg("paramtaskqueue full",0);
}
CRITICAL_SECTION_END();
return 0x1;
}
else {
#ifdef TASK_QUEUE_DEBUG
failed_post++;
#endif
CRITICAL_SECTION_END();
printFatalErrorMsg("TaskQueue Full. Size = ", 1,sys_max_tasks);
return 0x0;
}
}
--- NEW FILE: processVibration.h ---
#ifndef __PROCESS_VIBRATION_H__
#define __PROCESS_VIBRATION_H__
#define PROCVIB_DONE_DEF 1
#define PROCVIB_MORE_DEF 2
enum
{
PROCVIB_DONE = PROCVIB_DONE_DEF,
PROCVIB_MORE = PROCVIB_MORE_DEF
};
typedef struct {
// input parameters required for initialization
unsigned short FftFlag; // 1=>do FFT, 0=>time domain samples
unsigned short GseFlag; // 1=>do gSE, 0=>don't do gSE
unsigned short DMAsize; // size of each DMA transfer
unsigned short Navg; // number of averages
unsigned short WinFunc; // 0=>rectangular, 1=>Hanning
unsigned short dummy;
unsigned long Fs; // native sampling frequency of A/D
unsigned long FsDesired; // desired sampling rate
unsigned long NumOutputPts; // FFT resolution (lines)
unsigned long NumCaptPts; // number of points captured @ FsDesired
// This parameter gives flexibility to
// specify zero-padding
// For time-dom capts, should = NumOutputPts
// parameters required for processing...these are filled in by initVibration
unsigned long OverallAcc; // accumulator for overall averaging
unsigned short RtDecFactor; // realtime dec factor
unsigned short pw; // log2(Lfft)
unsigned long Lfft; // Length of FFT
unsigned long NumRtCaptPts; // number of points captured after RT dec
unsigned short NavgCmplt; // number of averages completed
short fftsh; // scaling factor, fftoutput * 2^(-fftsh)
double ResampFactor; // Fine resampling factor
short fftidx[300]; // FFT bit-reverse indices
// resampler states
const short *Imp; // Filter coefficients
const short *ImpD; // ImpD[n] = Imp[n+1]-Imp[n]
unsigned short LpScl; // Unity-gain scale factor
unsigned short Nwing; // Filter table size
unsigned short Nmult; // Filter length for up-conversions
} vibStates_t;
int initVibration(vibStates_t *vibSt, short largeFilter) ;
int processVibFrame(short *x, vibStates_t *vs, long *specAvg, float *scale,
unsigned short *overall, unsigned short *NavgCmplt) ;
#endif
--- NEW FILE: window.h ---
int window(short* x, unsigned long L) ;
Index: Makefile
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/Makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile 25 Oct 2006 15:32:47 -0000 1.5
--- Makefile 5 Mar 2007 00:06:08 -0000 1.6
***************
*** 1,8 ****
#variable definitions
SRCS = $(call find-source-files,".")
INCLUDE_DIRS = -I$(TOSDIR)/platform/pxa27x -I$(TOSDIR)/platform/pxa27x/lib/DSP -I$(TOSDIR)/platform/pxa27x/lib/
CC = xscale-elf-gcc
! CFLAGS = -g -O2 $(INCLUDE_DIRS)
AS = xscale-elf-as
--- 1,10 ----
#variable definitions
+ OBJS = $(call find-object-files,".")
SRCS = $(call find-source-files,".")
+
INCLUDE_DIRS = -I$(TOSDIR)/platform/pxa27x -I$(TOSDIR)/platform/pxa27x/lib/DSP -I$(TOSDIR)/platform/pxa27x/lib/
CC = xscale-elf-gcc
! CFLAGS = -g -O2 -Wall $(INCLUDE_DIRS)
AS = xscale-elf-as
***************
*** 10,14 ****
AR = xscale-elf-ar
! ARFLAGS = rvs
INTEL_FILES = c:/imote2/srcs
--- 12,16 ----
AR = xscale-elf-ar
! ARFLAGS = -rvs
INTEL_FILES = c:/imote2/srcs
***************
*** 21,28 ****
#function to find subdirectories that contains source
# $(find-source-dirs, base-directory-to-search)
! define find-source-files
$(sort $(subst .s,.o,$(subst .c,.o,$(shell find $1 -name "*.[c,s]"))))
endef
#function to determin if a directory exists
# $(does-dir-exist, dir)
--- 23,36 ----
#function to find subdirectories that contains source
# $(find-source-dirs, base-directory-to-search)
! define find-object-files
$(sort $(subst .s,.o,$(subst .c,.o,$(shell find $1 -name "*.[c,s]"))))
endef
+ #function to find subdirectories that contains source
+ # $(find-source-dirs, base-directory-to-search)
+ define find-source-files
+ $(sort $(shell find $1 -name "*.[c,s]"))
+ endef
+
#function to determin if a directory exists
# $(does-dir-exist, dir)
***************
*** 38,43 ****
#always make the library for debugging
.PHONY: libimote2.a
!
! libimote2.a: $(SRCS)
$(AR) $(ARFLAGS) $@ $?
clean:
--- 46,51 ----
#always make the library for debugging
.PHONY: libimote2.a
! .PHONY: $(SRCS)
! libimote2.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $?
clean:
Index: criticalSection.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/criticalSection.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** criticalSection.h 25 Oct 2006 15:32:47 -0000 1.1
--- criticalSection.h 5 Mar 2007 00:06:08 -0000 1.2
***************
*** 1,4 ****
--- 1,8 ----
#ifndef __CRITICAL_SECTION_H__
#define __CRITICAL_SECTION_H__
+ #include "inttypes.h"
+
+ extern inline uint32_t __nesc_atomic_start(void);
+ extern inline void __nesc_atomic_end(uint32_t);
#define DECLARE_CRITICAL_SECTION() uint32_t fInterruptFlags
Index: downsample.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/downsample.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** downsample.c 10 Oct 2006 23:27:40 -0000 1.2
--- downsample.c 5 Mar 2007 00:06:08 -0000 1.3
***************
*** 5,14 ****
#include "downsample.h"
#include "coef.inc"
! #define DMASIZE 4096
! //#define WMMX_ENABLE 1
!
! downsampleTempBuffer_t *tempbuf;
extern void firdecim_s(short int factor_M, long int H_size, short int* p_H,
short int* p_Z, long int num_inp, short int *p_inp,
--- 5,13 ----
#include "downsample.h"
#include "coef.inc"
+ #include <string.h>
+ #define WMMX_ENABLE 1
! //downsampleTempBuffer_t *tempbuf;
extern void firdecim_s(short int factor_M, long int H_size, short int* p_H,
short int* p_Z, long int num_inp, short int *p_inp,
***************
*** 28,32 ****
st->states168[i]=0;
}
! tempbuf = tempBuf;
return 1;
}
--- 27,31 ----
st->states168[i]=0;
}
! st->tempbuf = tempBuf;
return 1;
}
***************
*** 100,106 ****
// PARAMS:
// DownsampStates *d := filter states of decimation filters
! // short int *inbuf := pointer to input buffer
! // long int Nsamp := number of input samples
! // short int *outbuf := pointer to output buffer
// (output length is Nsamp/K)
// short int K := decimation factor (from 2 to 256, powers of 2 only)
--- 99,105 ----
// PARAMS:
// DownsampStates *d := filter states of decimation filters
! // short int *inbuf := pointer to input buffer : must be aligned on an 8 byte boundary
! // long int Nsamp := number of input samples : must be a power of and an integer multiple of K
! // short int *outbuf := pointer to output buffer : no restriction on alignment
// (output length is Nsamp/K)
// short int K := decimation factor (from 2 to 256, powers of 2 only)
***************
*** 132,155 ****
case 8:
firdecim_s(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! tempbuf,SC4X56);
! firdecim_s(2,LEN2X88,h2x88,d->states88b,Nsamp/4,tempbuf,
outbuf,SC2X88);
break;
case 16:
firdecim_s(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! tempbuf,SC4X56);
! firdecim_s(4,LEN4X168,h4x168,d->states168,Nsamp/4,tempbuf,
outbuf,SC4X168);
break;
case 32:
firdecim_s(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! tempbuf,SC8X88);
! firdecim_s(4,LEN4X168,h4x168,d->states168,Nsamp/8,tempbuf,
outbuf,SC4X168);
break;
case 64:
firdecim_s(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! tempbuf,SC4X56);
! firdecim_s(4,LEN4X56,h4x56,d->states88b,Nsamp/4,tempbuf,
inbuf,SC4X56);
firdecim_s(4,LEN4X168,h4x168,d->states168,Nsamp/16,inbuf,
--- 131,154 ----
case 8:
firdecim_s(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC4X56);
! firdecim_s(2,LEN2X88,h2x88,d->states88b,Nsamp/4,d->tempbuf,
outbuf,SC2X88);
break;
case 16:
firdecim_s(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC4X56);
! firdecim_s(4,LEN4X168,h4x168,d->states168,Nsamp/4,d->tempbuf,
outbuf,SC4X168);
break;
case 32:
firdecim_s(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC8X88);
! firdecim_s(4,LEN4X168,h4x168,d->states168,Nsamp/8,d->tempbuf,
outbuf,SC4X168);
break;
case 64:
firdecim_s(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC4X56);
! firdecim_s(4,LEN4X56,h4x56,d->states88b,Nsamp/4,d->tempbuf,
inbuf,SC4X56);
firdecim_s(4,LEN4X168,h4x168,d->states168,Nsamp/16,inbuf,
***************
*** 158,163 ****
case 128:
firdecim_s(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! tempbuf,SC8X88);
! firdecim_s(4,LEN4X56,h4x56,d->states88b,Nsamp/8,tempbuf,
inbuf,SC4X56);
firdecim_s(4,LEN4X168,h4x168,d->states168,Nsamp/32,inbuf,
--- 157,162 ----
case 128:
firdecim_s(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC8X88);
! firdecim_s(4,LEN4X56,h4x56,d->states88b,Nsamp/8,d->tempbuf,
inbuf,SC4X56);
firdecim_s(4,LEN4X168,h4x168,d->states168,Nsamp/32,inbuf,
***************
*** 166,171 ****
case 256:
firdecim_s(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! tempbuf,SC8X88);
! firdecim_s(8,LEN8X88,h8x88,d->states88b,Nsamp/8,tempbuf,
inbuf,SC8X88);
firdecim_s(4,LEN4X168,h4x168,d->states168,Nsamp/64,inbuf,
--- 165,170 ----
case 256:
firdecim_s(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC8X88);
! firdecim_s(8,LEN8X88,h8x88,d->states88b,Nsamp/8,d->tempbuf,
inbuf,SC8X88);
firdecim_s(4,LEN4X168,h4x168,d->states168,Nsamp/64,inbuf,
***************
*** 183,206 ****
case 8:
firdecim(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! tempbuf,SC4X56);
! firdecim(2,LEN2X88,h2x88,d->states88b,Nsamp/4,tempbuf,
outbuf,SC2X88);
break;
case 16:
firdecim(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! tempbuf,SC4X56);
! firdecim(4,LEN4X168,h4x168,d->states168,Nsamp/4,tempbuf,
outbuf,SC4X168);
break;
case 32:
firdecim(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! tempbuf,SC8X88);
! firdecim(4,LEN4X168,h4x168,d->states168,Nsamp/8,tempbuf,
outbuf,SC4X168);
break;
case 64:
firdecim(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! tempbuf,SC4X56);
! firdecim(4,LEN4X56,h4x56,d->states88b,Nsamp/4,tempbuf,
inbuf,SC4X56);
firdecim(4,LEN4X168,h4x168,d->states168,Nsamp/16,inbuf,
--- 182,205 ----
case 8:
firdecim(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC4X56);
! firdecim(2,LEN2X88,h2x88,d->states88b,Nsamp/4,d->tempbuf,
outbuf,SC2X88);
break;
case 16:
firdecim(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC4X56);
! firdecim(4,LEN4X168,h4x168,d->states168,Nsamp/4,d->tempbuf,
outbuf,SC4X168);
break;
case 32:
firdecim(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC8X88);
! firdecim(4,LEN4X168,h4x168,d->states168,Nsamp/8,d->tempbuf,
outbuf,SC4X168);
break;
case 64:
firdecim(4,LEN4X56,h4x56,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC4X56);
! firdecim(4,LEN4X56,h4x56,d->states88b,Nsamp/4,d->tempbuf,
inbuf,SC4X56);
firdecim(4,LEN4X168,h4x168,d->states168,Nsamp/16,inbuf,
***************
*** 209,214 ****
case 128:
firdecim(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! tempbuf,SC8X88);
! firdecim(4,LEN4X56,h4x56,d->states88b,Nsamp/8,tempbuf,
inbuf,SC4X56);
firdecim(4,LEN4X168,h4x168,d->states168,Nsamp/32,inbuf,
--- 208,213 ----
case 128:
firdecim(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC8X88);
! firdecim(4,LEN4X56,h4x56,d->states88b,Nsamp/8,d->tempbuf,
inbuf,SC4X56);
firdecim(4,LEN4X168,h4x168,d->states168,Nsamp/32,inbuf,
***************
*** 217,222 ****
case 256:
firdecim(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! tempbuf,SC8X88);
! firdecim(8,LEN8X88,h8x88,d->states88b,Nsamp/8,tempbuf,
inbuf,SC8X88);
firdecim(4,LEN4X168,h4x168,d->states168,Nsamp/64,inbuf,
--- 216,221 ----
case 256:
firdecim(8,LEN8X88,h8x88,d->states88a,Nsamp,inbuf,
! d->tempbuf,SC8X88);
! firdecim(8,LEN8X88,h8x88,d->states88b,Nsamp/8,d->tempbuf,
inbuf,SC8X88);
firdecim(4,LEN4X168,h4x168,d->states168,Nsamp/64,inbuf,
Index: downsample.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/downsample.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** downsample.h 10 Oct 2006 21:35:34 -0000 1.1
--- downsample.h 5 Mar 2007 00:06:08 -0000 1.2
***************
*** 2,13 ****
#define __DOWNSAMPLE_H__
typedef struct {
! short states88a[88];
! short states88b[88];
! short states168[168];
} downsampleStates_t __attribute__ ((aligned(8)));
- typedef short downsampleTempBuffer_t __attribute__ ((aligned(8)));
-
int downsampleInit(downsampleStates_t *downsampSt, downsampleTempBuffer_t *tempBuf);
int downsample(downsampleStates_t *downsampSt, short int *inbuf, long int Nsamp,
--- 2,14 ----
#define __DOWNSAMPLE_H__
+ typedef short downsampleTempBuffer_t __attribute__ ((aligned(8)));
+
typedef struct {
! short states88a[88];
! short states88b[88];
! short states168[168];
! downsampleTempBuffer_t *tempbuf;
} downsampleStates_t __attribute__ ((aligned(8)));
int downsampleInit(downsampleStates_t *downsampSt, downsampleTempBuffer_t *tempBuf);
int downsample(downsampleStates_t *downsampSt, short int *inbuf, long int Nsamp,
Index: paramtask.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/paramtask.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** paramtask.h 10 Oct 2006 02:31:55 -0000 1.1
--- paramtask.h 5 Mar 2007 00:06:08 -0000 1.2
***************
*** 2,23 ****
#define __PARAMTASK_H__
#define DEFINE_PARAMTASK(funcname) \
! task void _##funcname##veneer(){\
uint32_t argument;\
atomic{popqueue(¶mtaskQueue,&argument);}\
funcname(argument);}
! #define POST_PARAMTASK(funcname, arg) \
! {\
! atomic{\
! if(pushqueue(¶mtaskQueue, (uint32_t)arg)){ \
! post _##funcname##veneer(); \
! } \
! else{ \
! trace(DBG_USR1,"FATAL_ERROR: paramtaskqueue full\r\n"); \
! }\
! }\
! }
--- 2,14 ----
#define __PARAMTASK_H__
+ unsigned char TOS_parampost(void (*tp) (), uint32_t arg) __attribute__((C,spontaneous));
#define DEFINE_PARAMTASK(funcname) \
! void _##funcname##veneer(){\
uint32_t argument;\
atomic{popqueue(¶mtaskQueue,&argument);}\
funcname(argument);}
! #define POST_PARAMTASK(funcname, arg) TOS_parampost(_##funcname##veneer,(uint32_t)arg)
Index: profile.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/profile.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** profile.c 10 Oct 2006 02:29:11 -0000 1.2
--- profile.c 5 Mar 2007 00:06:08 -0000 1.3
***************
*** 1,3 ****
--- 1,4 ----
#include "profile.h"
+ #include "trace.h"
profileInfo_t globalProfileInfo;
***************
*** 109,111 ****
--- 110,115 ----
globalProfileInfo.cycles, CPI, IC_mrate, DC_mrate);
}
+ if(printmask == profilePrintCycles){
+ trace(1ULL<<27,"CYC=%d\r\n", globalProfileInfo.cycles);
+ }
}
Index: profile.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/profile.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** profile.h 6 Sep 2005 18:19:12 -0000 1.1
--- profile.h 5 Mar 2007 00:06:08 -0000 1.2
***************
*** 7,12 ****
typedef enum{
! profilePrintAll
! } profilePrintInfo_t;
--- 7,14 ----
typedef enum{
! profilePrintAll =0,
! profilePrintCycles
!
! } profilePrintInfo_t;
Index: queue.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/queue.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** queue.c 25 Oct 2006 15:32:47 -0000 1.4
--- queue.c 5 Mar 2007 00:06:08 -0000 1.5
***************
*** 18,21 ****
--- 18,38 ----
}
+ int pushptrqueue(ptrqueue_t *queue, void *val){
+ //check to see if there is room in the queue
+ uint16_t availableslots = (queue->head <= queue->tail) ? queue->size - queue->tail + queue->head: queue->head - queue->tail;
+ //available entries in the queue is really size-1 since we need to guard against aliasing
+ if(availableslots > 1 ){
+ queue->entries[queue->tail] = val;
+ queue->tail++;
+ if(queue->tail >= queue->size){
+ queue->tail = 0;
+ }
+ return 1;
+ }
+ else{
+ return 0;
+ }
+ }
+
//get the value without removing it from the queue
int peekqueue(queue_t *queue, uint32_t *val) {
***************
*** 31,34 ****
--- 48,64 ----
}
+ void *peekptrqueue(ptrqueue_t *queue, int *status) {
+
+ if(queue->head != queue->tail){
+ *status = 1;
+ return queue->entries[queue->head];
+ }
+ else{
+ *status = 0;
+ //queue is empty
+ return 0;
+ }
+ }
+
int getCurrentQueueSize(queue_t *queue){
***************
*** 37,40 ****
--- 67,76 ----
}
+ int getCurrentPtrQueueSize(ptrqueue_t *queue){
+
+ return (queue->head <= queue->tail) ? queue->size - queue->tail + queue->head: queue->head - queue->tail;
+
+ }
+
int popqueue(queue_t *queue, uint32_t *val) {
if(queue->head != queue->tail){
***************
*** 53,56 ****
--- 89,111 ----
}
+ void *popptrqueue(ptrqueue_t *queue, int *status) {
+ void *ret;
+
+ if(queue->head != queue->tail){
+ ret = queue->entries[queue->head];
+ *status = 1;
+ queue->head++;
+ if(queue->head >= queue->size){
+ queue->head = 0;
+ }
+ return ret;
+ }
+ else{
+ *status = 0;
+ //queue is empty
+ return 0;
+ }
+ }
+
void initqueue(queue_t *queue, uint32_t size) {
queue->head = 0;
***************
*** 58,59 ****
--- 113,120 ----
queue->size = size;
}
+
+ void initptrqueue(ptrqueue_t *queue, uint32_t size) {
+ queue->head = 0;
+ queue->tail = 0;
+ queue->size = size;
+ }
Index: queue.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/queue.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** queue.h 25 Oct 2006 15:32:47 -0000 1.4
--- queue.h 5 Mar 2007 00:06:08 -0000 1.5
***************
*** 16,19 ****
--- 16,26 ----
} queue_t;
+ typedef struct{
+ void *entries[QUEUE_SIZE];
+ uint16_t head, tail;
+ uint16_t size;
+ } ptrqueue_t;
+
+
/**********
*function to push an argument into a queue
***************
*** 25,28 ****
--- 32,36 ----
***********/
int pushqueue(queue_t *queue, uint32_t val);
+ int pushptrqueue(ptrqueue_t *queue, void *val);
/**********
***************
*** 35,38 ****
--- 43,47 ----
***********/
int popqueue(queue_t *queue, uint32_t *val);
+ void *popptrqueue(ptrqueue_t *queue, int *status);
/**********
***************
*** 46,50 ****
***********/
int peekqueue(queue_t *queue, uint32_t *val);
!
/**********
--- 55,59 ----
***********/
int peekqueue(queue_t *queue, uint32_t *val);
! void *peekptrqueue(ptrqueue_t *queue, int *status);
/**********
***************
*** 57,62 ****
--- 66,73 ----
***********/
void initqueue(queue_t *queue, uint32_t size);
+ void initptrqueue(ptrqueue_t *queue, uint32_t size);
int getCurrentQueueSize(queue_t *queue);
+ int getCurrentPtrQueueSize(ptrqueue_t *queue);
#endif
Index: systemUtil.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/systemUtil.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** systemUtil.c 25 Oct 2006 15:32:47 -0000 1.1
--- systemUtil.c 5 Mar 2007 00:06:08 -0000 1.2
***************
*** 2,11 ****
#include "systemUtil.h"
#include "pxa27x_registers_def.h"
#define RESET_DELAY 10000 // delay in 1/3.25 MHz increments = ~3 ms
! const char csFatalError[] = "FATAL ERROR: ";
const char csRebootMsg[] = "Rebooting...";
static void configureUART(){
--- 2,35 ----
#include "systemUtil.h"
#include "pxa27x_registers_def.h"
+ #include "frequency.h"
+ #include <string.h>
+ #include "queue.h"
+ #include "bufferManagement.h"
+ #include "arm_defs.h"
+ #include <stdarg.h>
#define RESET_DELAY 10000 // delay in 1/3.25 MHz increments = ~3 ms
! const char csFatalError[] = "FATAL ERROR at ";
const char csRebootMsg[] = "Rebooting...";
+ void _malloc_stats_r(void *reent){
+ return;
+ }
+
+ void disable_interrupts(void){
+ uint32_t result = 0;
+ uint32_t temp = 0;
+
+ asm volatile (
+ "mrs %0,CPSR\n\t"
+ "orr %1,%2,%4\n\t"
+ "msr CPSR_cf,%3"
+ : "=r" (result) , "=r" (temp)
+ : "0" (result) , "1" (temp) , "i" (ARM_CPSR_INT_MASK)
+ );
+ return;
+ }
+
static void configureUART(){
***************
*** 43,50 ****
}
// print one byte in hex
static void printHex(uint8_t num){
! uint32_t i;
!
switch(num & 0xF){
case 0:
--- 67,78 ----
}
+ static void printStringZ(const char *str){
+ uint32_t len = strlen(str);
+ printString(str,len);
+ }
+
// print one byte in hex
static void printHex(uint8_t num){
!
switch(num & 0xF){
case 0:
***************
*** 125,154 ****
}
void printAssertMsg(const char* file, uint32_t line, char *condition){
configureUART();
! printString(csFatalError, strlen(csFatalError));
! printString(file,strlen(file));
printChar(':');
printDecimal(line);
! printString(": Assertion failed: ",strlen(": Assertion failed: "));
! printString(condition, strlen(condition));
printChar('\r');
printChar('\n');
!
resetNode();
}
! void printFatalErrorMsg(const char *msg, uint32_t status){
! uint32_t i, len;
configureUART();
! printString(csFatalError, strlen(csFatalError));
! printString(msg, strlen(msg));
! printDecimal(status);
printChar('\r');
printChar('\n');
resetNode();
--- 153,475 ----
}
+
+ static void reportSystemFrequency(){
+
+ //print out the system specs at the time of failure
+ printStringZ("System Frequency [CORE:BUS] was ");
+ printDecimal(getSystemFrequency());
+ printChar(':');
+ printDecimal(getSystemBusFrequency());
+ printChar('\r');
+ printChar('\n');
+
+ return;
+ }
+ extern uint32_t sys_max_tasks, sys_task_bitmask;
+ extern uint8_t TOSH_sched_full;
+
+ static void dumpTaskQueue(){
+ int i;
+ uint8_t entry;
+ extern uint32_t TOSH_queue;
+ uint32_t *queue = &TOSH_queue;
+
+ printStringZ("\r\ntask queue dump\r\n");
+
+ entry = TOSH_sched_full;
+ for (i = 0; i < sys_max_tasks; i++){
+ #if 0
+ if(queue[entry*3] == NULL){
+ printStringZ("TotalNumber of used taskQueue entries = ");
+ printDecimal(i);
+ printStringZ("\r\n");
+ }
+
+ #endif// else{
+ printStringZ("task ");
+ printHex32(queue[entry*4]);
+ printStringZ(" posted by ");
+ printHex32(queue[entry*4 + 1]);
+ printStringZ(" at ");
+ printDecimal(queue[entry*4 + 2]);
+ printStringZ(" ran for ");
+ printDecimal(queue[entry*4 + 3]);
+ printStringZ("\r\n");
+ // }
+ entry = (entry + 1) & sys_task_bitmask;
+ }
+ }
+
+ static void reportSystemState(){
+
+ uint32_t mode, oldmode;
+
+ asm volatile (
+ "mrs %0,CPSR\n\t"
+ : "=r" (mode)
+ );
+
+ printStringZ("Died while in ");
+ switch(mode & 0x1F){
+ case 0x10:
+ //User
+ printStringZ("USER");
+ asm volatile (
+ "mrs %0,SPSR\n\t"
+ : "=r" (oldmode)
+ );
+
+ break;
+ case 0x11:
+ //FIQ
+ printStringZ("FIQ");
+ asm volatile (
+ "mrs %0,SPSR\n\t"
+ : "=r" (oldmode)
+ );
+
+ break;
+ case 0x12:
+ //IRQ
+ printStringZ("IRQ");
+ asm volatile (
+ "mrs %0,SPSR\n\t"
+ : "=r" (oldmode)
+ );
+
+ break;
+ case 0x13:
+ //Super
+ printStringZ("SUPERVISOR");
+ asm volatile (
+ "mrs %0,SPSR\n\t"
+ : "=r" (oldmode)
+ );
+
+ break;
+ case 0x17:
+ //abort
+ printStringZ("ABORT");
+ asm volatile (
+ "mrs %0,SPSR\n\t"
+ : "=r" (oldmode)
+ );
+
+ break;
+ case 0x1b:
+ //Undef
+ printStringZ("UNDEF");
+ asm volatile (
+ "mrs %0,SPSR\n\t"
+ : "=r" (oldmode)
+ );
+
+ break;
+ case 0x1f:
+ //System:
+ printStringZ("SYSTEM");
+ asm volatile (
+ "mrs %0,SPSR\n\t"
+ : "=r" (oldmode)
+ );
+
+ break;
+ default:
+ printStringZ("UNKNOWN");
+ asm volatile (
+ "mrs %0,SPSR\n\t"
+ : "=r" (oldmode)
+ );
+
+ break;
+ }
+ printStringZ(" mode\r\n");
+
+ printStringZ("OldMode was ");
+ switch(oldmode & 0x1F){
+ case 0x10:
+ //User
+ printStringZ("USER");
+
+ break;
+ case 0x11:
+ //FIQ
+ printStringZ("FIQ");
+
+ break;
+ case 0x12:
+ //IRQ
+ printStringZ("IRQ");
+
+ break;
+ case 0x13:
+ //Super
+ printStringZ("SUPERVISOR");
+
+ break;
+ case 0x17:
+ //abort
+ printStringZ("ABORT");
+
+ break;
+ case 0x1b:
+ //Undef
+ printStringZ("UNDEF");
+
+ break;
+ case 0x1f:
+ //System:
+ printStringZ("SYSTEM");
+
+ break;
+ default:
+ printStringZ("UNKNOWN");
+
+ break;
+ }
+ printStringZ(" mode\r\n");
+ }
+
+ /**
+ r11 = current stack frame
+ [r11] = current pc
+ [r11]-1 = current lr
+ [r11] -2 = previous sp
+ [r11] -3 = previous fp
+
+
+
+ **/
+
+ static void flushDebugUart(){
+ extern ptrqueue_t outgoingQueue;
+ bufferInfo_t *pBI;
+ int status;
+
+ printStringZ("\r\nFlushing DebugUART\r\n");
+
+
+ pBI = popptrqueue(&outgoingQueue, &status);
+ while(status == 1){
+ printString(pBI->pBuf,pBI->numBytes);
+ pBI = popptrqueue(&outgoingQueue, &status);
+ }
+
+ }
+
+ static void unwindStack(){
+ uint32_t *fp, *sp, pc, lr;
+ volatile uint32_t stackLimit;
+
+ printStringZ("\r\nstack dump\r\n");
+ stackLimit = 0x5c040000;
+ asm volatile (
+ "mov %0,R11\n\t"
+ : "=r" (fp)
+ );
+
+ while(fp < (uint32_t *)stackLimit){
+ pc = *fp;
+ lr = *(fp-1);
+ sp = (uint32_t *)*(fp-2);
+ fp = (uint32_t *)*(fp-3);
+
+ printStringZ("function ");
+ printHex32(pc);
+ printStringZ(" called by ");
+ printHex32(lr);
+ printStringZ("\r\n");
+ }
+ }
+
+ static void dumpCore(){
+
+ reportSystemFrequency();
+ reportSystemState();
+ unwindStack();
+ dumpTaskQueue();
+
+ flushDebugUart();
+ }
+
+
void printAssertMsg(const char* file, uint32_t line, char *condition){
+ uint32_t currentTime = OSCR0;
+ disable_interrupts();
configureUART();
! printStringZ(csFatalError);
! printDecimal(currentTime);
! printStringZ(": ");
! printStringZ(file);
printChar(':');
printDecimal(line);
! printStringZ(": Assertion failed: ");
! printStringZ(condition);
printChar('\r');
printChar('\n');
!
! dumpCore();
!
resetNode();
}
! void printFatalErrorMsgHex(const char *msg, uint32_t numArgs, ...){
! uint32_t currentTime= OSCR0;
! uint32_t i;
! va_list args;
!
! disable_interrupts();
! configureUART();
+
+ va_start(args, numArgs);
+ printStringZ(csFatalError);
+ printDecimal(currentTime);
+ printStringZ(": ");
+ printStringZ(msg);
+
+ for(i=0; i<numArgs; i++){
+ printHex32(va_arg(args,uint32_t));
+ printStringZ(" ");
+ }
+
+ va_end(args);
+
+ printChar('\r');
+ printChar('\n');
+
+ dumpCore();
+
+ resetNode();
+ }
+
+ void printFatalErrorMsg(const char *msg, uint32_t numArgs, ...){
+ uint32_t currentTime= OSCR0;
+ uint32_t i;
+ va_list args;
+
+ disable_interrupts();
configureUART();
!
! va_start(args, numArgs);
! printStringZ(csFatalError);
! printDecimal(currentTime);
! printStringZ(": ");
! printStringZ(msg);
!
! for(i=0; i<numArgs; i++){
! printDecimal(va_arg(args,uint32_t));
! printStringZ(" ");
! }
!
! va_end(args);
!
printChar('\r');
printChar('\n');
+
+ dumpCore();
resetNode();
***************
*** 159,163 ****
configureUART();
! printString(csRebootMsg, strlen(csRebootMsg));
printChar('\r');
printChar('\n');
--- 480,484 ----
configureUART();
! printStringZ(csRebootMsg);
printChar('\r');
printChar('\n');
Index: systemUtil.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/systemUtil.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** systemUtil.h 25 Oct 2006 15:32:47 -0000 1.1
--- systemUtil.h 5 Mar 2007 00:06:08 -0000 1.2
***************
*** 9,16 ****
*****/
! void printFatalErrorMsg(const char *msg, uint32_t status);
!
void resetNode();
#endif // __SYSTEM_UTIL_H__
--- 9,30 ----
*****/
! void printFatalErrorMsg(const char *msg, uint32_t numArgs, ...);
! void printFatalErrorMsgHex(const char *msg, uint32_t numArgs, ...);
void resetNode();
+ struct mallinfo {
+ int arena; /* total space allocated from system */
+ int ordblks; /* number of non-inuse chunks */
+ int smblks; /* unused -- always zero */
+ int hblks; /* number of mmapped regions */
+ int hblkhd; /* total space in mmapped regions */
+ int usmblks; /* unused -- always zero */
+ int fsmblks; /* unused -- always zero */
+ int uordblks; /* total allocated space */
+ int fordblks; /* total non-inuse space */
+ int keepcost; /* top-most, releasable (via malloc_trim) space */
+ };
+
+ struct mallinfo mallinfo() __attribute__((C,spontaneous));
#endif // __SYSTEM_UTIL_H__
Index: utils.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/lib/utils.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** utils.c 25 Oct 2006 15:32:51 -0000 1.1
--- utils.c 5 Mar 2007 00:06:08 -0000 1.2
***************
*** 5,8 ****
--- 5,9 ----
+ extern _PTR memalign(size_t, size_t);
/*
* These functions are equivalent to the standard lib functions, except that
More information about the Tinyos-beta-commits
mailing list