[En-Nut-Discussion] Coldfire Nut/OS port

Dusan Ferbas dferbas at etech.cz
Fri May 26 22:40:11 CEST 2006


Hi guys,

to speed up discussion on Coldfire port, I am sending the context 
switch routine. I would like to take part in porting the rest, but I 
have no time/budget for this. Any idea ?

Harald, I attended the Freescale seminar a month ago. Very 
impressive, mainly processor expert and the way of runtime debugging. 
Nothing special about Coldfire, only theory. The seminar was 
concentrated on 8-bit platform. Of course they have NE64 (eth. on 
chip), but for this uProc only Viola TCP currently exists.

>Hi Bengt,
>
>At 11:04 24.05.2006 +0200, you wrote:
>>Well, I guess that much of the effort is done by just implementing the
>>context switch.
>
>A hard job without ICE Debugger.
>
>>By taking the 32-bit ARM branch of Nut/OS much of the rest should be
>>reusable. Maybe this is integrated in the mainstream nowadays. I must
>>confess I haven't read Nut code for a while.
>
>I've the same opinion on this. However, almost all device
>drivers need to be rewritten as well. The most important
>and most simple is devDebug.
>
>
>>I can however support with some basic Coldfire knowledge and do some coding,
>>but I don't think I got the time to do the administrating stuff.
>
>I am generally interested and btw. I'll attend the Freescale Seminar on
>June 1st in Dortmund, Germany:
>http://www.freescale.com/files/abstract/article/ABENDSEMINARE2005_TIC.html
>
>Harald

Dusan 
-------------- next part --------------
;   file    "misc.s"
;
; Based on misc.src from Z3200E, Z90-SI project
;
;
        .text           ; CODE SECTION

; the `standard' miscellaneous functions provided at the assembly level
        .global _resume         ; stack swap to a ready to run socket

; This routine cannot change SR to disable interrupts because
; SR change can be a result of thread context switch.
; As interrupts use stack care should be taken about it.
; This means that all the time interrupts can us current
; stack pointer without any data loss.

; Perform a stack swap operation (resume a sleeping stack).
;
;        resume (tfp,ffp)
; sp+4  frame *tfp;     /* frame (stack) pointer of stack to resume */
; sp+8  frame *ffp;     /* pointer to frame pointer of stack to sleep */
;
; a stack to be resumed has the following frame image
;
;+70 [ffp]				From Frame Pointer
;+66 [tfp]				To  Frame Pointer
;+62 [returnaddr]		to caller of resume() or initial `transaction'
;+60 [sr value]			Status Register to restore (a u16)
;+28 [D7 value] D7 +28  D6 +32  D5 +36  D4 +40  D3 +44  D2 +48  D1 +52  D0 +56
;+00 [A6 value]         A6 +00  A5 +04  A4 +08  A3 +12  A2 +16  A1 +20  A0 +24
; The frame pointer a7 points to the base of the Address Registers save part
; and must agree with the pro_t structure in misc.h !
;
FFP		.equ	 70				; a7 bias to ffp parameter
TFP		.equ	 66				; a7 bias to tfp parameter
SAREA   .equ     62				; space for SMASK + sr
IAREA   .equ     60				; space for SMASK. sr in RTE stack
SRB		.equ	 60				; a7 bias to Status Register short cell
PRB		.equ	  0				; a7 bias to saved Processor Registers

_resume:
; ----- check ffp to see if we are to put the current stack to sleep
    sub.l   #SAREA,a7           ; get `normalized' stack addressing
                                ; ("allocate" space on my stack)
                                ; if we will be interrupted now allocated area
                                ; will not be touched so we can play there whatever we need
    tst.l   FFP(a7)             ; ffp non zero if we are to sleep
    beq     switch              ; no stack to put to sleep
;
; ----- save the registers of this stack and update it's pro_t struct
;
    movem.l A0-A6/D0-D7,PRB(a7) ; save the the data & address registers
    move.w  sr,d0
    move.w	d0,SRB(a7)          ; save the status register
    move.l  FFP(a7),a0          ; get the pointer to sleep frame ptr
    move.l  a7,(a0)             ; mark sleeping task top of stack
;
; ----- swap to the stack pointed to by the tfp parameter
;
switch:
    move.l	TFP(a7),a7          ; a real quick stack swap
    move.w	SRB(a7),d0
    move.w	d0,sr	            ; pop restore status register (u16)
    movem.l	PRB(a7),A0-A6/D0-D7 ; pop restore data and address registers
    add.l   #SAREA,a7           ; release space on stack
    							; (if we will be interrupted now,
    							;  context will be saved onto proper stack area)
    rts                         ; reinstate the next stack to run

    .end


More information about the En-Nut-Discussion mailing list