This commit is contained in:
pvvx 2017-03-18 15:52:14 +03:00
parent 02f846fa9a
commit 8face3e309
158 changed files with 43738 additions and 3116 deletions

View file

@ -10,6 +10,7 @@
#include <basic_types.h>
#include <diag.h>
#include <stdarg.h>
extern int __rtl_errno;
@ -23,10 +24,10 @@ void init_rom_libgloss_ram_map(void);
//
extern int rtl_printf(IN const char* fmt, ...);
extern int rtl_vprintf(const char *fmt, void *param);
extern int rtl_vprintf(const char *fmt, va_list param);
extern int rtl_sprintf(char* str, const char* fmt, ...);
extern int rtl_snprintf(char* str, size_t size, const char* fmt, ...);
extern int rtl_vsnprintf(char *str, size_t size, const char *fmt, void *param);
extern int rtl_vsnprintf(char *str, size_t size, const char *fmt, va_list param);
//
// RTL library functions for string

View file

@ -0,0 +1,166 @@
/*
* RAM->ROM Calls
*/
#ifndef _INC_RTL_RR_LIBC_
#define _INC_RTL_RR_LIBC_
//#undef malloc
#define malloc(size) pvPortMalloc(size)
//#undef free
#define free(pbuf) vPortFree(pbuf)
//extern void* pvPortReAlloc( void *pv, size_t xWantedSize )
#define realloc(pv, xWantedSize) pvPortReAlloc(pv, xWantedSize)
#define calloc(nelements, elementSize) calloc_freertos(nelements, elementSize)
#define snprintf rtl_snprintf
#define sprintf rtl_sprintf
#define printf rtl_printf
#define vprintf rtl_vprintf
#define vsnprintf rtl_vsnprintf
#define vfprintf rtl_vfprintf
#define memchr rtl_memchr
#define memcmp rtl_memcmp
#define memcpy rtl_memcpy
#define memmove rtl_memmove
#define memset rtl_memset
#define strcat rtl_strcat
#define strchr rtl_strchr
#define strcmp rtl_strcmp
#define strcpy rtl_strcpy
#define strlen rtl_strlen
#define strncat rtl_strncat
#define strncmp rtl_strncmp
#define strncpy rtl_strncpy
#define strstr rtl_strstr
#define strsep rtl_strsep
#define strtok rtl_strtok
#if 0 // __aeabi_
#define dtoi rtl_dtoi
#define dtoui rtl_dtoui
#define i2f rtl_i2f
#define i2d rtl_i2d
#define ui2f rtl_ui2f
#define ui2d rtl_ui2d
#define itoa rtl_itoa
#define ltoa rtl_ltoa
#define utoa rtl_utoa
#define ultoa rtl_ultoa
#define ftol rtl_ftol
#define ftod rtl_ftod
#define dtof rtl_dtof
#define fadd rtl_fadd
#define fsub rtl_fsub
#define fmul rtl_fmul
#define fdiv rtl_fdiv
#define dadd rtl_dadd
#define dsub rtl_dsub
#define dmul rtl_dmul
#define ddiv rtl_ddiv
#define dcmpeq rtl_dcmpeq
#define dcmplt rtl_dcmplt
#define dcmple rtl_dcmple
#define dcmpgt rtl_dcmpgt
#define fcmplt rtl_fcmplt
#define fcmpgt rtl_fcmpgt
#define fabsf rtl_fabsf
#define fabs rtl_fabs
#define cos_f32 rtl_cos_f32
#define sin_f32 rtl_sin_f32
#endif
#if 0
extern void *calloc_freertos(size_t nelements, size_t elementSize);
// ram_libc.c
extern void rtl_libc_init(void);
extern int rtl_snprintf(char *str, size_t size, const char *fmt, ...);
extern int rtl_sprintf(char *str, const char *fmt, ...);
extern int rtl_printf(const char *fmt, ...);
extern int rtl_vprintf(const char *fmt, void *param);
extern int rtl_vsnprintf(char *str, size_t size, const char *fmt, void *param);
extern int rtl_vfprintf(FILE *fp, const char *fmt0, va_list ap);
extern void * rtl_memchr(const void * src_void , int c , size_t length);
extern int rtl_memcmp(const void *m1, const void *m2, size_t n);
extern void * rtl_memcpy(void *dst0, const void *src0, size_t len0);
extern void * rtl_memmove(void *dst_void, const void *src_void, size_t length);
extern void * rtl_memset(void *m, int c, size_t n);
extern char * rtl_strcat(char *s1, const char *s2);
extern char * rtl_strchr(const char *s1, int i);
extern int rtl_strcmp(const char *s1, const char *s2);
extern char * rtl_strcpy(char *dst0, const char *src0);
extern size_t rtl_strlen(const char *str);
extern char * rtl_strncat(char *s1, const char *s2, size_t n);
extern int rtl_strncmp(const char *s1, const char *s2, size_t n);
extern char * rtl_strncpy(char *dst0, const char *src0, size_t count);
extern char * rtl_strstr(const char *searchee, const char *lookfor);
extern char * rtl_strsep(char **source_ptr, const char *delim);
extern char * rtl_strtok(char *s, const char *delim);
//rtl_eabi_cast_ram.c
extern int rtl_dtoi(double d);
extern int rtl_dtoui(double d);
extern float rtl_i2f(int val);
extern int rtl_i2d(int val);
extern float rtl_ui2f(unsigned int val);
extern int rtl_ui2d(unsigned int val);
extern char *rtl_itoa(int value, char *string, int radix);
extern char *rtl_ltoa(int value, char *string, int radix);
extern char *rtl_utoa(unsigned int value, char *string, int radix);
extern char *rtl_ultoa(unsigned int value, char *string, int radix);
extern int rtl_ftol(float f);
extern int rtl_ftod(float f);
extern float rtl_dtof(double d);
extern float rtl_fadd(float a, float b);
extern float rtl_fsub(float a, float b);
extern float rtl_fmul(float a, float b);
extern float rtl_fdiv(float a, float b);
extern int rtl_dadd(double a, double b);
extern int rtl_dsub(double a, double b);
extern int rtl_dmul(double a, double b);
extern int rtl_ddiv(double a, double b);
extern int rtl_dcmpeq(double a, double b);
extern int rtl_dcmplt(double a, double b);
extern int rtl_dcmple(double a, double b);
extern int rtl_dcmpgt(double a, double b);
extern int rtl_fcmplt(float a, float b);
extern int rtl_fcmpgt(float a, float b);
// rtl_math_ram.c
extern float rtl_fabsf(float a);
extern int rtl_fabs(double a);
extern float rtl_cos_f32(float a);
extern float rtl_sin_f32(float a);
// ram_pvvx_libc.c
extern int snprintf(char *str, size_t size, const char *fmt, ...);
extern int sprintf(char *str, const char *fmt, ...);
extern int printf(const char *fmt, ...);
extern int vprintf(const char * fmt, __VALIST param);
extern int vsnprintf(char *str, size_t size, const char *fmt, __VALIST param);
extern int vfprintf(FILE *fp, const char *fmt0, va_list ap);
extern void * memchr(const void * src_void , int c , size_t length);
extern int memcmp(const void *m1, const void *m2, size_t n);
extern void * memcpy(void *dst0, const void *src0, size_t len0);
extern void * memmove(void *dst_void, const void *src_void, size_t length);
extern void * memset(void *m, int c, size_t n);
extern char * strcat(char *s1, const char *s2);
extern char * strchr(const char *s1, int i);
extern int strcmp(const char *s1, const char *s2);
extern char * strcpy(char *dst0, const char *src0);
extern size_t strlen(const char *str);
extern char * strncat(char *s1, const char *s2, size_t n);
extern int strncmp(const char *s1, const char *s2, size_t n);
extern char * strncpy(char *dst0, const char *src0, size_t count);
extern char * strstr(const char *searchee, const char *lookfor);
extern char * strsep(char **source_ptr, const char *delim);
extern char * strtok(char *s, const char *delim);
extern int sscanf(const char *buf, const char *fmt, ...);
extern char toupper(char ch);
extern int _stricmp (const char *s1, const char *s2);
extern unsigned long long __aeabi_llsr(unsigned long long val, unsigned int shift);
#endif
#endif // _INC_RTL_RR_LIBC_

File diff suppressed because it is too large Load diff

View file

@ -10,30 +10,31 @@
//-------------------------------------------------------------------------
// Function declarations
//void rtl_libc_init();
//int rtl_snprintf(char *str, size_t size, const char *fmt, ...);
//int rtl_sprintf(char *str, const char *fmt, ...);
//int rtl_printf(const char *fmt, ...);
//int rtl_vprintf(const char *fmt, void *param);
//int rtl_vsnprintf(char *str, size_t size, const char *fmt, void *param);
//int rtl_vfprintf(FILE *fp, const char *fmt0, va_list ap);
//int rtl_memchr(const void *src_void, int c, size_t length);
//int rtl_memcmp(const void *m1, const void *m2, size_t n);
//int rtl_memcpy(void *dst0, const void *src0, size_t len0);
//int rtl_memmove(void *dst_void, const void *src_void, size_t length);
//int rtl_memset(void *m, int c, size_t n);
//char * rtl_strcat(char *s1, const char *s2);
//char * rtl_strchr(const char *s1, int i);
//int rtl_strcmp(const char *s1, const char *s2);
//char * rtl_strcpy(char *dst0, const char *src0);
//int rtl_strlen(const char *str);
//char * rtl_strncat(char *s1, const char *s2, size_t n);
//int rtl_strncmp(const char *s1, const char *s2, size_t n);
//char * rtl_strncpy(char *dst0, const char *src0, size_t count);
//char * rtl_strstr(const char *searchee, const char *lookfor);
//char * rtl_strsep(char **source_ptr, const char *delim);
//char * rtl_strtok(char *s, const char *delim);
#if 0
void rtl_libc_init(void);
int rtl_snprintf(char *str, size_t size, const char *fmt, ...);
int rtl_sprintf(char *str, const char *fmt, ...);
int rtl_printf(const char *fmt, ...);
int rtl_vprintf(const char *fmt, void *param);
int rtl_vsnprintf(char *str, size_t size, const char *fmt, void *param);
int rtl_vfprintf(FILE *fp, const char *fmt0, va_list ap);
void * rtl_memchr(const void * src_void , int c , size_t length);
int rtl_memcmp(const void *m1, const void *m2, size_t n);
void * rtl_memcpy(void *dst0, const void *src0, size_t len0);
void * rtl_memmove(void *dst_void, const void *src_void, size_t length);
void * rtl_memset(void *m, int c, size_t n);
char * rtl_strcat(char *s1, const char *s2);
char * rtl_strchr(const char *s1, int i);
int rtl_strcmp(const char *s1, const char *s2);
char * rtl_strcpy(char *dst0, const char *src0);
size_t rtl_strlen(const char *str);
char * rtl_strncat(char *s1, const char *s2, size_t n);
int rtl_strncmp(const char *s1, const char *s2, size_t n);
char * rtl_strncpy(char *dst0, const char *src0, size_t count);
char * rtl_strstr(const char *searchee, const char *lookfor);
char * rtl_strsep(char **source_ptr, const char *delim);
char * rtl_strtok(char *s, const char *delim);
#endif
// Extern Calls:
// extern int init_rom_libgloss_ram_map(_DWORD)
// extern int _rom_mallocr_init_v1_00(void)
@ -149,20 +150,20 @@ int rtl_printf(const char *fmt, ...) {
}
//----- rtl_vprintf()
int rtl_vprintf(const char *fmt, void *param) {
int rtl_vprintf(const char *fmt, va_list param) {
#if CHECK_LIBC_INIT
if (!libc_has_init) {
rtl_libc_init();
}
#endif
int result = __rtl_vfprintf_r_v1_00(_rtl_impure_ptr,
_rtl_impure_ptr->_stdout, fmt, *(va_list *)param);
_rtl_impure_ptr->_stdout, fmt, param);
__rtl_fflush_r_v1_00(_rtl_impure_ptr, _rtl_impure_ptr->_stdout);
return result;
}
//----- rtl_vsnprintf()
int rtl_vsnprintf(char *str, size_t size, const char *fmt, void *param) {
int rtl_vsnprintf(char *str, size_t size, const char *fmt, va_list param) {
int result;
int w;
int v11;
@ -183,7 +184,7 @@ int rtl_vsnprintf(char *str, size_t size, const char *fmt, void *param) {
f._w = w;
f._bf._size = w;
f._file = -1;
result = __rtl_vfprintf_r_v1_00(_rtl_impure_ptr, &f, fmt, *(va_list *)param);
result = __rtl_vfprintf_r_v1_00(_rtl_impure_ptr, &f, fmt, param);
if (result + 1 < 0)
_rtl_impure_ptr->_errno = 139;
if (size)

View file

@ -8,33 +8,38 @@
#include "va_list.h"
#define CHECK_LIBC_INIT 0
//-------------------------------------------------------------------------
// Function declarations
//void libc_init();
//int snprintf(char *str, size_t size, const char *fmt, ...);
//int sprintf(char *str, const char *fmt, ...);
//int printf(const char *fmt, ...);
//int vprintf(const char *fmt, void *param);
//int vsnprintf(char *str, size_t size, const char *fmt, void *param);
//int vfprintf(FILE *fp, const char *fmt0, va_list ap);
//int memchr(const void *src_void, int c, size_t length);
//int memcmp(const void *m1, const void *m2, size_t n);
//int memcpy(void *dst0, const void *src0, size_t len0);
//int memmove(void *dst_void, const void *src_void, size_t length);
//int memset(void *m, int c, size_t n);
//char * strcat(char *s1, const char *s2);
//char * strchr(const char *s1, int i);
//int strcmp(const char *s1, const char *s2);
//char * strcpy(char *dst0, const char *src0);
//int strlen(const char *str);
//char * strncat(char *s1, const char *s2, size_t n);
//int strncmp(const char *s1, const char *s2, size_t n);
//char * strncpy(char *dst0, const char *src0, size_t count);
//char * strstr(const char *searchee, const char *lookfor);
//char * strsep(char **source_ptr, const char *delim);
//char * strtok(char *s, const char *delim);
#if 0
int snprintf(char *str, size_t size, const char *fmt, ...);
int sprintf(char *str, const char *fmt, ...);
int printf(const char *fmt, ...);
int vprintf(const char * fmt, __VALIST param);
int vsnprintf(char *str, size_t size, const char *fmt, __VALIST param);
int vfprintf(FILE *fp, const char *fmt0, va_list ap);
void * memchr(const void * src_void , int c , size_t length);
int memcmp(const void *m1, const void *m2, size_t n);
void * memcpy(void *dst0, const void *src0, size_t len0);
void * memmove(void *dst_void, const void *src_void, size_t length);
void * memset(void *m, int c, size_t n);
char * strcat(char *s1, const char *s2);
char * strchr(const char *s1, int i);
int strcmp(const char *s1, const char *s2);
char * strcpy(char *dst0, const char *src0);
size_t strlen(const char *str);
char * strncat(char *s1, const char *s2, size_t n);
int strncmp(const char *s1, const char *s2, size_t n);
char * strncpy(char *dst0, const char *src0, size_t count);
char * strstr(const char *searchee, const char *lookfor);
char * strsep(char **source_ptr, const char *delim);
char * strtok(char *s, const char *delim);
int sscanf(const char *buf, const char *fmt, ...);
char toupper(char ch);
int _stricmp (const char *s1, const char *s2);
unsigned long long __aeabi_llsr(unsigned long long val, unsigned int shift);
#endif
// Extern Calls:
// extern int init_rom_libgloss_ram_map(_DWORD)
// extern int _rom_mallocr_init_v1_00(void)
@ -68,7 +73,6 @@ extern int libc_has_init;
//-------------------------------------------------------------------------
// Function
//----- snprintf()
int snprintf(char *str, size_t size, const char *fmt, ...) {
va_list args;
@ -104,6 +108,7 @@ int snprintf(char *str, size_t size, const char *fmt, ...) {
return result;
}
#ifndef ENAC_FLOAT
//----- sprintf()
int sprintf(char *str, const char *fmt, ...) {
FILE f;
@ -145,17 +150,17 @@ int printf(const char *fmt, ...) {
//----- vprintf()
int vprintf(const char * fmt, __VALIST param) {
//int vprintf(const char *fmt, void *param) {
#if CHECK_LIBC_INIT
if (!libc_has_init) {
rtl_libc_init();
}
#endif
#endif
int result = __rtl_vfprintf_r_v1_00(_rtl_impure_ptr,
_rtl_impure_ptr->_stdout, fmt, param);
__rtl_fflush_r_v1_00(_rtl_impure_ptr, _rtl_impure_ptr->_stdout);
return result;
}
#endif // ENAC_FLOAT
//----- vsnprintf()
int vsnprintf(char *str, size_t size, const char *fmt, __VALIST param) {
@ -310,3 +315,226 @@ unsigned long long __aeabi_llsr(unsigned long long val, unsigned int shift)
return ((unsigned long long)hi << 32) | lo;
}
/*
#undef __VFP_FP__
#if defined(__VFP_FP__)
typedef long __jmp_buf[10 + 8 + 1]; // d8-d15 fpu + fpscr
#else
typedef long __jmp_buf[10];
#endif
int setjmp(__jmp_buf buf) __attribute__ ((noinline));
int setjmp(__jmp_buf buf)
{
register void * r0 __asm__("r0") = buf;
__asm__(
"mov %%ip, %%sp\n"
"stmia %[store]!, {%%r4-%%r9, %%sl, %%fp, %%ip, %%lr}\n"
#if defined(__VFP_FP__)
"vstmia %[store]!, {%%d8-%%d15}\n"
"vmrs %%r1, fpscr\n"
"str %%r1, [%[store]], #4\n"
#endif
"mov.w %r0, #0\n"
: : [store] "r" (r0) :);
}
void longjmp(__jmp_buf buf, long value) __attribute__((noreturn));
void longjmp(__jmp_buf buf, long value)
{
__asm__(
"ldmia %[load]!, {%%r4-%%r9, %%sl, %%fp, %%ip, %%lr}\n"
#if defined(__VFP_FP__)
"vldmia %[load]!, {%%d8-%%d15}\n"
"ldr %%r0, [%[load]], #4\n"
"vmsr fpscr, %%r0\n"
#endif
"mov %%sp, %%ip\n"
"movs %%r0, %%r1\n"
"it eq\n"
"moveq %%r0, #1\n"
"bx lr\n"
: : [load] "r" (buf), [value] "r" (value):);
__builtin_unreachable();
}
*/
extern __attribute__ ((long_call)) unsigned int Rand(void);
unsigned int rand(void)
{
return Rand();
}
//----- rtl_dtoi()
int __aeabi_dtoi(double d)
{
return __rtl_dtoi_v1_00(d);
}
//----- __aeabi_dtoui()
int __aeabi_dtoui(double d)
{
return __rtl_dtoui_v1_00(d);
}
//----- __aeabi_i2f()
float __aeabi_i2f(int val)
{
return __rtl_itof_v1_00(val);
}
//----- __aeabi_i2d()
int __aeabi_i2d(int val)
{
return __rtl_itod_v1_00(val);
}
//----- __aeabi_ui2f()
float __aeabi_ui2f(unsigned int val)
{
return __rtl_uitof_v1_00(val);
}
//----- __aeabi_ui2d()
int __aeabi_ui2d(unsigned int val)
{
return __rtl_uitod_v1_00(val);
}
//----- __aeabi_itoa()
char * __aeabi_itoa(int value, char *string, int radix)
{
return (char *)__rtl_ltoa_v1_00(value, string, radix);
}
//----- __aeabi_ltoa()
char * __aeabi_ltoa(int value, char *string, int radix)
{
return (char *)__rtl_ltoa_v1_00(value, string, radix);
}
//----- __aeabi_utoa()
char * __aeabi_utoa(unsigned int value, char *string, int radix)
{
return (char *)__rtl_ultoa_v1_00(value, string, radix);
}
//----- __aeabi_ultoa()
char * __aeabi_ultoa(unsigned int value, char *string, int radix)
{
return (char *)__rtl_ultoa_v1_00(value, string, radix);
}
//----- __aeabi_ftol()
int __aeabi_ftol(float f)
{
return __rtl_ftol_v1_00(f);
}
//----- __aeabi_ftod()
int __aeabi_ftod(float f)
{
return __rtl_ftod_v1_00(f);
}
//----- __aeabi_dtof()
float __aeabi_dtof(double d)
{
return __rtl_dtof_v1_00(d);
}
//----- __aeabi_fadd()
float __aeabi_fadd(float a, float b)
{
return __rtl_fadd_v1_00(a, b);
}
//----- __aeabi_fsub()
float __aeabi_fsub(float a, float b)
{
return __rtl_fsub_v1_00(a, b);
}
//----- __aeabi_fmul()
float __aeabi_fmul(float a, float b)
{
return __rtl_fmul_v1_00(a, b);
}
//----- __aeabi_fdiv()
float __aeabi_fdiv(float a, float b)
{
return __rtl_fdiv_v1_00(a, b);
}
//----- __aeabi_dadd()
int __aeabi_dadd(double a, double b)
{
return __rtl_dadd_v1_00(a, b);
}
//----- __aeabi_dsub()
int __aeabi_dsub(double a, double b)
{
return __rtl_dsub_v1_00(a, b);
}
//----- __aeabi_dmul()
int __aeabi_dmul(double a, double b)
{
return __rtl_dmul_v1_00(a, b);
}
//----- __aeabi_ddiv()
int __aeabi_ddiv(double a, double b)
{
return __rtl_ddiv_v1_00(a, b);
}
//----- __aeabi_dcmpeq()
int __aeabi_dcmpeq(double a, double b)
{
return __rtl_dcmpeq_v1_00(a, b);
}
//----- __aeabi_dcmplt()
int __aeabi_dcmplt(double a, double b)
{
return __rtl_dcmplt_v1_00(a, b);
}
//----- __aeabi_dcmple()
int __aeabi_dcmple(double a, double b)
{
return __rtl_dcmple_v1_00(a, b);
}
//----- __aeabi_dcmpgt()
int __aeabi_dcmpgt(double a, double b)
{
return __rtl_dcmpgt_v1_00(a, b);
}
//----- __aeabi_fcmplt()
int __aeabi_fcmplt(float a, float b)
{
return __rtl_fcmplt_v1_00(a, b);
}
//----- __aeabi_fcmpgt()
int __aeabi_fcmpgt(float a, float b)
{
return __rtl_fcmpgt_v1_00(a, b);
}