Chapter 3. Using the Monitor/Debug Firmware
3-39
System Call Functions
3.5 System Call Functions
An additional utility within the dBUG firmware is a function called the System Call handler. This
function can be called by the user program to utilize various routines within dBUG, to perform a
special task, and to return control to dBUG. This section describes the System Call handler and
how it is used.
There are 6 System Call functions. These are: OUT_CHAR, IN_CHAR, IN_STAT,
ISR_REGISTER, ISR_REMOVE and EXIT_TO_dBUG. The system call interface accepts an
opcode in r10 to indicate which operation is to be performed. Various results are returned, usually
in r3. When these routines are invoked, the following is true: sprg0 contains r31 and sprg1 contains
LR.
3.5.1 OUT_CHAR
This function (function code 0x0020) sends a character, which is in r3, to terminal. The system call
interface accepts an opcode in r10 to indicate which operation is to be performed.
Assembly example:
/* assume r3 contains the character */
addi r10, r0, 0x0020
Selects the function
sc
The character in r3 is sent to terminal
C example:
/* assume r3 contains the character */
void board_out_char (int ch)
{
asm(“
addi r10, r0, 0x0020”); Selects the function
asm(“
sc”);
The character in r3 is sent to terminal
}
3.5.2 IN_CHAR
This function (function code 0x0000) returns an input character (from terminal) to the caller. The
returned character is in r3.
Assembly example:
/* the character is returned to the user in r3*/
addi r10, r0, 0x0000
Selects the function
sc
The character is returned in r3
C example:
int board_in_char (void)
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
.
..