06.08.2013 Views

pSOSystem System Calls - Read

pSOSystem System Calls - Read

pSOSystem System Calls - Read

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

i_return pSOS+ <strong>System</strong> <strong>Calls</strong><br />

x86<br />

On x86 processors, i_return() is executed by an INT 93H call.<br />

Restoring CPU Registers Prior to Exiting the ISR<br />

The examples below illustrate, for each processor, how an ISR restores CPU<br />

registers before exiting via i_return().<br />

CF<br />

PPC<br />

On ColdFire processors, an ISR must restore all CPU registers, including<br />

the stack pointer, to their state prior to the interrupt. Below is a sample<br />

code fragment for an ISR that internally uses CPU registers D0, D1, D2,<br />

A0, and A2.<br />

TRAP #12<br />

MOVEM.L D0-D2/A0/A2,-(SP)<br />

<br />

MOVEM.L (SP)+,D0-D2/A0/A2<br />

TRAP #13<br />

On PowerPC processors, right before i_return(), the stack pointer<br />

must point to the <strong>pSO<strong>System</strong></strong> standard exception frame allocated by the<br />

interrupt vector code. Registers R29-R31, LR, CR, SRR0 & SRR1 and<br />

SRR2 & SRR3 (for PowerPC 403) have been saved into the frame by the<br />

vector code. The values of registers R0, R2-R13, CTR, XER and MQ (for<br />

PowerPC 601) prior to the interrupt also need to be saved into the frame<br />

by the ISR. i_return() will restore all the saved registers and deallocate<br />

the frame. Below are sample code fragments of the vector code and an<br />

ISR.<br />

Sample vector code:<br />

stwu sp, PS_FRM_SIZE(sp) # Allocate <strong>pSO<strong>System</strong></strong><br />

# exception frame<br />

stw r29, PS_FRM_R29(sp) # Save r29<br />

stw r30, PS_FRM_R30(sp) # Save r30<br />

stw r31, PS_FRM_R31(sp) # Save r31<br />

mfsrr0 r29 #<br />

stw r29, PS_FRM_SRR0(sp) # Save SRR0<br />

mfsrr1 r30 #<br />

stw r30, PS_FRM_SRR1(sp) # Save SRR1<br />

mflr r31 #<br />

stw r31, PS_FRM_LR(sp) # Save LR<br />

mfcr r29 #<br />

stw r29, PS_FRM_CR(sp) # Save CR<br />

1-36 <strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!