Specifications

Embedded System Tools Guide (EDK 6.2i) www.xilinx.com 177
UG111 (v1.4) January 30, 2004 1-800-255-7778
MicroBlaze GNU Compiler
R
object files instead of the standard files, use the -B directory-name command line
option while invoking mb-gcc.
According to the C standard specification, all global and static variables need to be
initialized to 0. This is a common functionality required by all the crt’s above. Hence
another routine _crtinit is defined in crtinit.o file. This file is part of the libc.a library.
The _crtinit routine will initialize memory in the bss section of the program, defined by the
default linker script. If you intend to provide your own linker script, you will need to
compile a new _crtinit routine. The default crtinit.S file is provided in assembly source
format as a part of the Embedded Development Kit.
Command Line Arguments
MicroBlaze programs can not take in command line arguments. The command line
arguments argc and argv are initialized to 0 by the C runtime routines.
Interrupt Handlers
Interrupt handlers need to be compiled in a different manner as compared to the normal
sub-routine calls. In addition to saving non-volatiles, interrupt handlers have to save the
volatile registers which are being used. Interrupt handler should also store the value of the
machine status register (RMSR), when an interrupt occurs.
_interrupt_handler attribute
In order to distinguish an interrupt handler from a sub-routine, mb-gcc looks for an
attribute (interrupt_handler) in the declaration of the code. This attribute is defined as
follows:
void function_name () __attribute__ ((interrupt_handler));
Note: Attribute for interrupt handler is to be given only in the prototype and not the definition.
Interrupt handlers might also call other functions, which might use volatile registers. In
order to maintain the correct values in the volatile registers, the interrupt handler saves all
the volatiles, if the handler is a non-leaf function
(1)
.
Interrupt handlers can also be defined in the MicroBlaze Hardware Specification (MHS)
and the MicroBlaze Software Specification (MSS) file. These definitions would
automatically add the attributes to the interrupt handler functions. For more information
please refer MicroBlaze Interrupt Management document.
The interrupt handler uses the instruction rtid for returning to the interrupted function.
_save_volatiles attribute
The MicroBlaze compiler provides the attribute save_volatiles, which is similar to the
_interrupt_handler attribute, but returns using rtsd instead of rtid.
This attributes save all the volatiles for non-leaf functions and only the used volatiles in
case of leaf functions.
void function_name () __attribute__((save_volatiles));
The attributes with their functions are tabulated in Table 11-8.
1. Functions which have calls to other sub-routines are called non-leaf functions.