ON 20081104@11:48:38 AM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/index.htm#39756.4921064815
Isaac Marino Bavaresco[IMB-yahoo-J86] Code:
/techref/member/IMB-yahoo-J86/generic_pointers.htm
ON 20081104@11:49:40 AM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/generic_pointers.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\generic_pointers.htm&version=0
ON 20081104@11:57:33 AM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/generic_pointers.htm#39756.4982986111
Isaac Marino Bavaresco[IMB-yahoo-J86] Says
Tested in extended mode only, in a PIC18 with more than 64Ki Words of program memory.
//==============================================================================
/*
Copyright (c) 2007-2008, Isaac Marino Bavaresco
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Neither the name of the author nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//==============================================================================
// isaacbavaresco@yahoo.com.br
//==============================================================================
#ifndef __GENERICPOINTER_H__
#define __GENERICPOINTER_H__
//==============================================================================
#define RAM far ram
#define ROM const far rom
#define GENERIC far rom
#define MAKE_GEN_PTR_RAM_T(p,t) ((t GENERIC*)((unsigned short long)(p)|0x800000))
#define MAKE_GEN_PTR_RAM(p) ((void GENERIC*)((unsigned short long)(p)|0x800000))
#define MAKE_GEN_PTR_ROM(p) ((void ROM*)((unsigned short long)(p)&0x7fffff))
#define READ_GEN_PTR(p) (((unsigned char RAM*)&(p))[2]&0x80 ? *(char RAM*)(p):*(char ROM*)(p))
#define WRITE_GEN_PTR(p,c) {if(((far unsigned char RAM*)&(p))[2]&0x80)*(char ram*)(p)=(c)}
#define IS_GEN_PTR_TO_RAM(p) (((far unsigned char RAM*)&(p))[2]&0x80)
#define IS_GEN_PTR_TO_ROM(p) (!(((far unsigned char RAM*)&(p))[2]&0x80))
//==============================================================================
#endif // __GENERICPOINTER_H__
//==============================================================================
ON 20081104@2:19:18 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/heap-mgmt.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\heap-mgmt.htm&version=15
ON 20081104@2:20:09 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/malloc.asm.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\malloc.asm.htm&version=3
ON 20081104@2:20:36 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/malloc.asm.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\malloc.asm.htm&version=4
ON 20081104@2:22:19 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/free.asm.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\free.asm.htm&version=2
ON 20081104@2:45:51 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/generic_pointers.htm#39756.615162037
Isaac Marino Bavaresco[IMB-yahoo-J86] Code:
/techref/member/IMB-yahoo-J86/memcpy.asm.htm
ON 20081104@3:41:37 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/memcpy.asm.htm#39756.6538888889
Isaac Marino Bavaresco[IMB-yahoo-J86] Says
This file is a replacement for the Microchip MPLAB-C18 library's 'memcpy' function.
It takes advantage of my 'generic pointer' implementation, which may copy from both RAM or ROM (FLASH) to RAM.
The Macros and definitions needed to use the 'generic pointers' are located in the file 'genericpointer.h'.
Usage example:
#include "genericpointer.h"
void RAM *memcpy( void RAM *dst, const void GENERIC *src, size_t n );
char Buffer[32];
const char ROM Msg1[] = "This message is in ROM";
char RAM Msg2[] = "This message is in RAM.";
char GENERIC *pMsg;
void SomeFunction( const char GENERIC *p )
{
// 'p' is already a generic pointer.
memcpy( Buffer, p, sizeof Buffer );
// A rom pointer is essentially a generic pointer.
memcpy( Buffer, Msg1, sizeof Buffer );
// A ram pointer needs to be converted.
memcpy( Buffer, MAKE_GEN_PTR_RAM( Msg2 ), sizeof Buffer );
// Direct conversion.
pMsg = Msg1;
// Conversion needed.
pMsg = MAKE_GEN_PTR_RAM( Msg2 );
// A generic pointer may point to RAM or ROM.
if( IS_GEN_PTR_TO_RAM( pMsg ))
// We will write through it only if it points to RAM.
memcpy( (char RAM*)pMsg, p, 16 );
}
This code works only in extended mode.
;===============================================================================
; Copyright (c) 2007-2008, Isaac Marino Bavaresco
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Neither the name of the author nor the
; names of its contributors may be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;===============================================================================
; isaacbavaresco@yahoo.com.br
;===============================================================================
#include "P18CXXX.INC"
;===============================================================================
radix decimal
;===============================================================================
STRING CODE
;===============================================================================
n equ 0
src equ 2
dst equ 5
; void RAM *memcpy( void RAM *dst, const void GENERIC *src, size_t n );
global memcpy
memcpy: movff FSR2L,POSTINC1 ; *FSR1++ = FSR2;
movff FSR2H,POSTINC1
movff FSR1L,FSR2L ; FSR2 = FSR1
movff FSR1H,FSR2H
subfsr 2,9 ; FSR2 -= 9;
movf [dst+0],w ; PROD = FSR0 = dst;
movwf FSR0L,ACCESS
movwf PRODL,ACCESS
movf [dst+1],w
movwf FSR0H,ACCESS
movwf PRODH,ACCESS
;-------------------------------------------------------------------------------
rlcf [src+2],w ; if( (unsigned short long)src & 0x800000UL )
bnc InROM ; {
;-------------------------------------------------------------------------------
InRAM: movsf [n+0],TBLPTRL ; TBLPTR = n;
movsf [n+1],TBLPTRH
movf [src+0],w ; FSR2 = src;
movsf [src+1],FSR2H
movwf FSR2L,ACCESS
bra InRAMStart ; while( TBLPTR-- )
InRAMLoop: movff POSTINC2,POSTINC0 ; *FSR0++ = *FSR2++;
InRAMStart: movlw 0
decf TBLPTRL,f,ACCESS
subwfb TBLPTRH,f,ACCESS
bc InRAMLoop
bra Epilog ; }
;-------------------------------------------------------------------------------
; else
; {
InROM: movsf [src+0],TBLPTRL ; TBLPTR = src;
movsf [src+1],TBLPTRH
movsf [src+2],TBLPTRU
bra InROMStart
InROMLoop: tblrd *+
movff TABLAT,POSTINC0
InROMStart: movlw 0
decf [n+0],f
subwfb [n+1],f
bc InROMLoop
;-------------------------------------------------------------------------------
Epilog: subfsr 1,1
movff POSTDEC1,FSR2H
movff INDF1,FSR2L
return 0
;===============================================================================
end
;===============================================================================
ON 20081104@3:44:34 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/generic_pointers.htm#39756.6559375
Isaac Marino Bavaresco[IMB-yahoo-J86] Code:
/techref/member/IMB-yahoo-J86/genericpointer.h.htm
ON 20081104@3:46:08 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/genericpointer.h.htm#39756.657025463
Isaac Marino Bavaresco[IMB-yahoo-J86] Says
//==============================================================================
/*
Copyright (c) 2007-2008, Isaac Marino Bavaresco
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Neither the name of the author nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//==============================================================================
// isaacbavaresco@yahoo.com.br
//==============================================================================
#ifndef __GENERICPOINTER_H__
#define __GENERICPOINTER_H__
//==============================================================================
#define RAM far ram
#define ROM const far rom
#define GENERIC far rom
#define MAKE_GEN_PTR_RAM_T(p,t) ((t GENERIC*)((unsigned short long)(p)|0x800000))
#define MAKE_GEN_PTR_RAM(p) ((void GENERIC*)((unsigned short long)(p)|0x800000))
#define MAKE_GEN_PTR_ROM(p) ((void ROM*)((unsigned short long)(p)&0x7fffff))
#define READ_GEN_PTR(p) (((unsigned char RAM*)&(p))[2]&0x80 ? *(char RAM*)(p):*(char ROM*)(p))
#define WRITE_GEN_PTR(p,c) {if(((far unsigned char RAM*)&(p))[2]&0x80)*(char ram*)(p)=(c)}
#define IS_GEN_PTR_TO_RAM(p) (((far unsigned char RAM*)&(p))[2]&0x80)
#define IS_GEN_PTR_TO_ROM(p) (!(((far unsigned char RAM*)&(p))[2]&0x80))
//==============================================================================
#endif // __GENERICPOINTER_H__
//==============================================================================
ON 20081104@3:47:04 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/generic_pointers.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\generic_pointers.htm&version=4
ON 20081104@4:24:20 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/generic_pointers.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\generic_pointers.htm&version=5
ON 20081104@7:36:43 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/index.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\index.htm&version=4
ON 20081104@7:39:43 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/index.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\index.htm&version=5
ON 20081104@7:41:16 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/index.htm#39756.8203125
Isaac Marino Bavaresco[IMB-yahoo-J86] Code:
/techref/member/IMB-yahoo-J86/math_data_tmp_data.htm
ON 20081104@7:52:12 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/math_data_tmp_data.htm#39756.8279050926
Isaac Marino Bavaresco[IMB-yahoo-J86] Says
The port of FreeRTOS for PIC18 with MPLAB-C18 has some problems when saving and restoring the compiler-generated memory sections "MATH_DATA" and ".tmpdata".
It appears that the FreeRTOS author have only an old version of the MPLAB-C18, and the new versions manage these sections diferently.
The older versions (I don't know what) appear to keep the "MATH_DATA" and ".tmpdata" sections at the very beginning of the RAM. The versions I am using with FreeRTOS (3.xx onwards) let the linker put them at will. Their size appears to change also.
I found a solution that appears to be version-independent (until now at least).
ON 20081104@7:52:55 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/math_data_tmp_data.htm#39756.8284027778
Isaac Marino Bavaresco[IMB-yahoo-J86] Code:
/techref/member/IMB-yahoo-J86/sections.asm.htm
ON 20081104@7:56:57 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/sections.asm.htm#39756.8312037037
Isaac Marino Bavaresco[IMB-yahoo-J86] Says
; I found the following message in Microchip's support site. The URL is:
; http://support2.microchip.com/KBSearch/KB_Ticket.aspx?ID=Tt6UJ9A0003LM
;
; Unfortunately these pseudo-instructions don't work as inline assembly,
; so I had to make this separate .asm module.
; The functions are used inside 'port.c' and are called by 'pxPortInitialiseStack'
; (GetTMPDATALen, GetTMPDATAStrt, GetMATHDATALen, GetMATHDATAStrt) and
; by the macros 'portSAVE_CONTEXT' (SaveTMP_MATH) and 'portRESTORE_CONTEXT'
; (RestoreTMP_MATH').
;-------------------------------------------------------------------------------
; Start of the message:
;-------------------------------------------------------------------------------
;
; Issue
;
; I'm developping a RTOS for the PIC18F258 using MPLAB-C18. I need to save in the
; task context the "MATH_DATA" and ".tmpdata" sections. But their address and size
; are only known after linking. The question is: How can I know the address and
; size of both sections at run time?
;
; Thanks
;
; Solution
; You CAN get the section location and size at runtime using MPASM.
; There are a few undocumented operators and pseudo-instructions.
;
; The SCNSZ operators give you the size of the section.
; The SCNSTART operators give you the starting address of a section.
; The SCNEND operators give you the ending address of a section.
; The SCNSTART_LFSR pseudo-instruction gives you an LFSR instruction with the starting address of the section.
; The SCNEND_LFSR pseudo-instruction gives you an LFSR instruction with the ending address of the section.
;
; Example:
; CODE
; movlw SCNSZ_LOW .tmpdata
; movlw SCNSZ_HIGH .tmpdata
; movlw SCNSZ_UPPER .tmpdata
; movlw SCNSTART_LOW .tmpdata
; movlw SCNSTART_HIGH .tmpdata
; movlw SCNSTART_UPPER .tmpdata
; movlw SCNEND_LOW .tmpdata
; movlw SCNEND_HIGH .tmpdata
; movlw SCNEND_UPPER .tmpdata
;
; SCNSTART_LFSR 0, .tmpdata
; SCNEND_LFSR 0, .tmpdata
;
; END
;
; These operators and pseudo-instructions will be documented in the next revision
; of the MPASM User's Guide.
;
;-------------------------------------------------------------------------------
; End of the message
;-------------------------------------------------------------------------------
;===============================================================================
; Copyright (c) 2007-2008, Isaac Marino Bavaresco
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Neither the name of the author nor the
; names of its contributors may be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;===============================================================================
; isaacbavaresco@yahoo.com.br
;===============================================================================
#include
;===============================================================================
radix decimal
;===============================================================================
code
;===============================================================================
global GetTMPDATAStrt
GetTMPDATAStrt: movlw SCNSTART_LOW .tmpdata
movwf PRODL
movlw SCNSTART_HIGH .tmpdata
movwf PRODH
return 0
;===============================================================================
global GetTMPDATALen
GetTMPDATALen: movlw SCNSZ_LOW .tmpdata
return 0
;===============================================================================
global GetMATHDATAStrt
GetMATHDATAStrt:movlw SCNSTART_LOW MATH_DATA
movwf PRODL
movlw SCNSTART_HIGH MATH_DATA
movwf PRODH
return 0
;===============================================================================
global GetMATHDATALen
GetMATHDATALen: movlw SCNSZ_LOW MATH_DATA
return 0
;===============================================================================
global SaveTMP_MATH
SaveTMP_MATH:
SCNSTART_LFSR 0, .tmpdata
movlw SCNSZ_LOW .tmpdata
SaveLoop1: movff POSTINC0,PREINC1
addlw -1
bnz SaveLoop1
SCNSTART_LFSR 0, MATH_DATA
movlw SCNSZ_LOW MATH_DATA
SaveLoop2: movff POSTINC0,PREINC1
addlw -1
bnz SaveLoop2
return 0
;===============================================================================
global RestoreTMP_MATH
RestoreTMP_MATH:
SCNEND_LFSR 0, MATH_DATA
movlw SCNSZ_LOW MATH_DATA
RestoreLoop1: movff POSTDEC1,POSTDEC0
addlw -1
bnz RestoreLoop1
SCNEND_LFSR 0, .tmpdata
movlw SCNSZ_LOW .tmpdata
RestoreLoop2: movff POSTDEC1,POSTDEC0
addlw -1
bnz RestoreLoop2
return 0
;===============================================================================
end
;===============================================================================
ON 20081104@7:59:44 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/math_data_tmp_data.htm#39756.8331481482
Isaac Marino Bavaresco[IMB-yahoo-J86] Code:
/techref/member/IMB-yahoo-J86/port.c.diff.htm
ON 20081104@8:14:04 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/port.c.diff.htm#39756.8430902778
Isaac Marino Bavaresco[IMB-yahoo-J86] Says
This is file "port.c.diff". It contains the differences between the file "FreeRTOS\Source\portable\MPLAB\PIC18F\port.c" version 5.1.0 and my modifications that solve the problem with saving/restoring the sections
"MATH_DATA" and ".tmpdata".
This patch file may be applied using TortoiseMerge, which comes with TortoiseSVN.
--- C:\Lixao\port.c sex out 24 19:57:00 2008
+++ C:\Lixao\port.mod.c qua nov 5 03:01:28 2008
@@ -140,6 +140,13 @@
*/
static void prvLowInterrupt( void );
+extern unsigned char ram * GetMATHDATAStrt ( void );
+extern unsigned char GetMATHDATALen ( void );
+extern unsigned char ram * GetTMPDATAStrt ( void );
+extern unsigned char GetTMPDATALen ( void );
+extern void SaveTMP_MATH ( void );
+extern void RestoreTMP_MATH ( void );
+
/*
* Macro that pushes all the registers that make up the context of a task onto
* the stack, then saves the new top of stack into the TCB.
@@ -196,31 +203,6 @@
MOVFF PRODL, PREINC1 \
MOVFF PCLATU, PREINC1 \
MOVFF PCLATH, PREINC1 \
- /* Store the .tempdata and MATH_DATA areas as described above. */ \
- CLRF FSR0L, 0 \
- CLRF FSR0H, 0 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF POSTINC0, PREINC1 \
- MOVFF INDF0, PREINC1 \
- MOVFF FSR0L, PREINC1 \
- MOVFF FSR0H, PREINC1 \
/* Store the hardware stack pointer in a temp register before we \
modify it. */ \
MOVFF STKPTR, FSR0L \
@@ -241,6 +223,9 @@
/* Store the number of addresses on the hardware stack (from the \
temporary register). */ \
MOVFF FSR0L, PREINC1 \
+ \
+ call SaveTMP_MATH,0 \
+ \
MOVF PREINC1, 1, 0 \
_endasm \
\
@@ -273,6 +258,9 @@
/* How many return addresses are there on the hardware stack? Discard \
the first byte as we are pointing to the next free space. */ \
MOVFF POSTDEC1, FSR0L \
+ \
+ call RestoreTMP_MATH,0 \
+ \
MOVFF POSTDEC1, FSR0L \
_endasm \
\
@@ -293,29 +281,6 @@
} \
\
_asm \
- /* Restore the .tmpdata and MATH_DATA memory. */ \
- MOVFF POSTDEC1, FSR0H \
- MOVFF POSTDEC1, FSR0L \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, POSTDEC0 \
- MOVFF POSTDEC1, INDF0 \
/* Restore the other registers forming the tasks context. */ \
MOVFF POSTDEC1, PCLATH \
MOVFF POSTDEC1, PCLATU \
@@ -368,18 +333,8 @@
{
unsigned portLONG ulAddress;
unsigned portCHAR ucBlock;
+portSTACK_TYPE ram *p;
- /* Place a few bytes of known values on the bottom of the stack.
- This is just useful for debugging. */
-
- *pxTopOfStack = 0x11;
- pxTopOfStack++;
- *pxTopOfStack = 0x22;
- pxTopOfStack++;
- *pxTopOfStack = 0x33;
- pxTopOfStack++;
-
-
/* Simulate how the stack would look after a call to vPortYield() generated
by the compiler.
@@ -451,20 +406,6 @@
*pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* PCLATH. */
pxTopOfStack++;
- /* Next the .tmpdata and MATH_DATA sections. */
- for( ucBlock = 0; ucBlock <= portCOMPILER_MANAGED_MEMORY_SIZE; ucBlock++ )
- {
- *pxTopOfStack = ( portSTACK_TYPE ) ucBlock;
- *pxTopOfStack++;
- }
-
- /* Store the top of the global data section. */
- *pxTopOfStack = ( portSTACK_TYPE ) portCOMPILER_MANAGED_MEMORY_SIZE; /* Low. */
- pxTopOfStack++;
-
- *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* High. */
- pxTopOfStack++;
-
/* The only function return address so far is the address of the
task. */
ulAddress = ( unsigned portLONG ) pxCode;
@@ -488,6 +429,14 @@
*pxTopOfStack = ( portSTACK_TYPE ) 1;
pxTopOfStack++;
+ /* Next the .tmpdata section. */
+ for( ucBlock = GetTMPDATALen(), p = GetTMPDATAStrt(); ucBlock; ucBlock--, pxTopOfStack++, p++ )
+ *pxTopOfStack = *p;
+
+ /* Next the MATH_DATA section. */
+ for( ucBlock = GetMATHDATALen(), p = GetMATHDATAStrt(); ucBlock; ucBlock--, pxTopOfStack++, p++ )
+ *pxTopOfStack = *p;
+
return pxTopOfStack;
}
/*-----------------------------------------------------------*/
ON 20081105@11:38:01 AM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/heap-mgmt.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\heap-mgmt.htm&version=16
ON 20081106@2:03:30 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/port.c.diff.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\port.c.diff.htm&version=1
ON 20081106@2:06:56 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/genericpointer.h.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\genericpointer.h.htm&version=1
ON 20081106@2:09:56 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/sections.asm.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\sections.asm.htm&version=1
ON 20081106@2:46:53 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/SimpleRTOS.h.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\SimpleRTOS.h.htm&version=4
ON 20081106@3:25:41 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/SimpleRTOS.c.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\SimpleRTOS.c.htm&version=4
ON 20081106@3:26:55 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/SimpleRTOS.c.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\SimpleRTOS.c.htm&version=5
ON 20081106@3:51:05 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/TestMain.c.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\TestMain.c.htm&version=2
ON 20081106@3:52:33 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/TestMain.c.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\TestMain.c.htm&version=3
ON 20081106@4:04:33 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/TestTasks.c.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\TestTasks.c.htm&version=3
ON 20081106@4:28:26 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/memcpy.asm.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\memcpy.asm.htm&version=1
ON 20081106@4:49:16 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/memcpy.asm.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\memcpy.asm.htm&version=2
ON 20081106@4:55:45 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/memcpy.asm.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\memcpy.asm.htm&version=3
ON 20081106@5:08:28 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/port.c.diff.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\port.c.diff.htm&version=2
ON 20081106@5:24:06 PM at page:
http://www.piclist.com/techref/member/IMB-yahoo-J86/index.htm#
Isaac Marino Bavaresco[IMB-yahoo-J86] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\IMB-yahoo-J86\index.htm&version=7