User guide

**
** #define USE_SERIAL_PORT
**
** or compile with
**
** -DUSE_SERIAL_PORT
*/
#include <stdio.h>
#include <rt_misc.h>
#ifdef __thumb
/* Thumb Semihosting SWI */
#define SemiSWI 0xAB
#else
/* ARM Semihosting SWI */
#define SemiSWI 0x123456
#endif
/* Write a character */
__swi(SemiSWI) void _WriteC(unsigned op, char *c);
#define WriteC(c) _WriteC (0x3,c)
/* Exit */
__swi(SemiSWI) void _Exit(unsigned op, unsigned except);
#define Exit() _Exit (0x18,0x20026)
struct __FILE { int handle; /* Add whatever you need here */};
FILE __stdout;
extern unsigned int bottom_of_heap;
extern void sendchar( char *ch ); /* in serial.c */
int fputc(int ch, FILE *f)
{
char tempch=ch;
/* Place your implementation of fputc here, for example write a character */
/* to a UART, or to the debugger console with SWI WriteC */
#ifdef USE_SERIAL_PORT
sendchar( &tempch );
#else
WriteC( &tempch );
#endif
return ch;
}
int ferror(FILE *f)
{ /* Your implementation of ferror */
return EOF;
}
void _sys_exit(int return_code)
{
Exit(); /* for debugging */
label: goto label; /* endless loop */
}
void _ttywrch(int ch)
{
char tempch = ch;
#ifdef USE_SERIAL_PORT
sendchar( &tempch );
#else
WriteC( &tempch );
#endif
}
__value_in_regs struct __initial_stackheap __user_initial_stackheap(
unsigned R0, unsigned SP, unsigned R2, unsigned SL)
{
struct __initial_stackheap config;
config.heap_base = (unsigned int)&bottom_of_heap; // defined in heap.s
// placed by scatterfile
Writing Code for ROM
Copyright ?1999 2001 ARM Limited 6-12