📄 retarget.c.svn-base
字号:
/*** Copyright (C) ARM Limited, 2001. All rights reserved.*//*** This implements a 'retarget' layer for low-level IO. Typically, this** would contain your own target-dependent implementations of fputc(),** ferror(), etc.** ** This example provides implementations of fputc(), ferror(),** _sys_exit(), _ttywrch() and __user_initial_stackheap().**** Here, semihosting SWIs are used to display text onto the console ** of the host debugger. This mechanism is portable across ARMulator,** Angel, Multi-ICE and EmbeddedICE.**** Alternatively, to output characters from the serial port of an ** ARM Integrator Board (see serial.c), use:**** #define USE_SERIAL_PORT**** or compile with **** -DUSE_SERIAL_PORT*//*****************************************************************************//* This confidential and proprietary software may be used only as authorized *//* by a licensing agreement from STMicroelectronics. *//* In the event of publication, the following notice is applicable: *//* *//* (C) COPYRIGHT 2003 STMicroelectronics *//* Innovative Systems Design Group - Central R&D *//* ALL RIGHTS RESERVED *//* *//* The entire notice above must be reproduced on all authorized copies. *//* *//* -- File: retarget.c *//* -- Author: Francesco Lertora <francesco.lertora@st.com> *//* -- Description: Retarget di funzioni della std. lib. C ARM *//* *//* -- Modification History: - 1.1 (07/05/2003) *//*****************************************************************************/// $Id: retarget.c,v 1.1 2005/05/26 15:51:48 sp_head Exp $// $Log: retarget.c,v $// Revision 1.1 2005/05/26 15:51:48 sp_head// user NI//// Revision 1.1.1.2 2004/12/03 15:34:24 spear// First import from CRD//// Revision 1.1.1.1 2004/12/02 11:07:22 spear// First import from CRD//// // Revision: 1.1 Wed May 7 21:21:46 2003 lert// First Check-In#include <stdio.h>#include <rt_misc.h>#ifdef __thumb/* Thumb Semihosting SWI */#define SemiSWI 0xAB#else/* ARM Semihosting SWI */#define SemiSWI 0x123456#endifextern unsigned int bottom_of_heap;/* 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 void sendchar( char *ch ); // in serial.c*//*int fputc(int ch, FILE *f){ // Place your implementation of fputc here // e.g. write a character to a UART, or to the // debugger console with SWI WriteC char tempch = ch;#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 debugginglabel: 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 config.stack_base = SP; // inherit SP from the execution environment return config;}/*Below is an equivalent example assembler version of __user_initial_stackheap.It will be entered with the value of the stackpointer in r1 (as set in init.s), this does not need to be changed and so can be passed unmodified out of the function. IMPORT bottom_of_heap EXPORT __user_initial_stackheap__user_initial_stackheap LDR r0,=bottom_of_heap MOV pc,lr*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -