diff --git a/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/ram_libc.c b/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/ram_libc.c new file mode 100644 index 0000000..2cb15f9 --- /dev/null +++ b/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/ram_libc.c @@ -0,0 +1,280 @@ +/* + * ram_libc.o + * pvvx 2016 + */ + +#include "rtl_bios_data.h" +#include "va_list.h" + +//------------------------------------------------------------------------- +// 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); +// Extern Calls: +// extern int init_rom_libgloss_ram_map(_DWORD) +// extern int _rom_mallocr_init_v1_00(void) +// extern int __rtl_vfprintf_r_v1_00(_DWORD, _DWORD, _DWORD) +// extern int __rtl_fflush_r_v1_00(_DWORD, _DWORD) +// extern int __rtl_memchr_v1_00(_DWORD, _DWORD, _DWORD) +// extern int __rtl_memcmp_v1_00(_DWORD, _DWORD, _DWORD) +// extern int __rtl_memcpy_v1_00(_DWORD, _DWORD, _DWORD) +// extern int __rtl_memmove_v1_00(_DWORD, _DWORD, _DWORD) +// extern int __rtl_memset_v1_00(_DWORD, _DWORD, _DWORD) +// extern int __rtl_strcat_v1_00(_DWORD, _DWORD) +// extern int __rtl_strchr_v1_00(_DWORD, _DWORD) +// extern int __rtl_strcmp_v1_00(_DWORD, _DWORD) +// extern int __rtl_strcpy_v1_00(_DWORD, _DWORD) +// extern int __rtl_strlen_v1_00(_DWORD) +// extern int __rtl_strncat_v1_00(_DWORD, _DWORD, _DWORD) +// extern int __rtl_strncmp_v1_00(_DWORD, _DWORD, _DWORD) +// extern int __rtl_strncpy_v1_00(_DWORD, _DWORD, _DWORD) +// extern int __rtl_strstr_v1_00(_DWORD, _DWORD) +// extern int __rtl_strsep_v1_00(_DWORD, _DWORD) +// extern int __rtl_strtok_v1_00(_DWORD, _DWORD) + +//------------------------------------------------------------------------- +// Data declarations + +extern struct _reent * _rtl_impure_ptr; + +int libc_has_init; +// extern rtl_impure_ptr +// extern impure_ptr + +//------------------------------------------------------------------------- +// Function + +//----- rtl_libc_init() +void rtl_libc_init(void) { + __rom_mallocr_init_v1_00(); + init_rom_libgloss_ram_map(); +} + +//----- rtl_snprintf() +int rtl_snprintf(char *str, size_t size, const char *fmt, ...) { + va_list args; + va_start (args, fmt); + int result; + int w; + FILE f; + if (!libc_has_init) { + rtl_libc_init(); + libc_has_init = 1; + } + if (size >= 0) { + f._flags = 520; + if (size) + w = size - 1; + else + w = 0; + f._w = w; /* write space left for putc() */ + f._bf._size = w; + f._file = -1; /* fileno, if Unix descriptor, else -1 */ + f._p = str; /* current position in (some) buffer */ + f._bf._base = str; + result = __rtl_vfprintf_r_v1_00(_rtl_impure_ptr, &f, fmt, args); + if (result + 1 < 0) + _rtl_impure_ptr->_errno = 139; + if (size) + *f._p = 0; + } else { + _rtl_impure_ptr->_errno = 139; + result = -1; + } + return result; +} + +//----- rtl_sprintf() +int rtl_sprintf(char *str, const char *fmt, ...) { + FILE f; + + if (!libc_has_init) { + rtl_libc_init(); + libc_has_init = 1; + } + f._flags = 520; + f._w = 0x7FFFFFFF; + f._bf._size = 0x7FFFFFFF; + f._file = -1; + f._p = str; + f._bf._base = str; + va_list args; + va_start (args, fmt); + int result = __rtl_vfprintf_r_v1_00(_rtl_impure_ptr, &f, fmt, args); + *f._p = 0; +// va_end (args); + return result; +} + +//----- rtl_printf() +int rtl_printf(const char *fmt, ...) { + if (!libc_has_init) { + rtl_libc_init(); + libc_has_init = 1; + } + va_list args; + va_start (args, fmt); + int result = __rtl_vfprintf_r_v1_00(_rtl_impure_ptr, + _rtl_impure_ptr->_stdout, fmt, args); + __rtl_fflush_r_v1_00(_rtl_impure_ptr, _rtl_impure_ptr->_stdout); + // va_end (args); + return result; +} + +//----- rtl_vprintf() +int rtl_vprintf(const char *fmt, void *param) { + if (!libc_has_init) { + rtl_libc_init(); + libc_has_init = 1; + } + int result = __rtl_vfprintf_r_v1_00(_rtl_impure_ptr, + _rtl_impure_ptr->_stdout, fmt, *(va_list *)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 result; + int w; + int v11; + FILE f; + + if (!libc_has_init) { + rtl_libc_init(); + libc_has_init = 1; + } + if (size >= 0) { + if (size) + w = size - 1; + else + w = 0; + f._flags = 520; + f._p = str; + f._bf._base = str; + f._w = w; + f._bf._size = w; + f._file = -1; + result = __rtl_vfprintf_r_v1_00(_rtl_impure_ptr, &f, fmt, *(va_list *)param); + if (result + 1 < 0) + _rtl_impure_ptr->_errno = 139; + if (size) + *f._p = 0; + } else { + _rtl_impure_ptr->_errno = 139; + result = -1; + } + return result; +} + +//----- rtl_vfprintf() +int rtl_vfprintf(FILE *fp, const char *fmt0, va_list ap) { + if (!libc_has_init) { + rtl_libc_init(); + libc_has_init = 1; + } + return __rtl_vfprintf_r_v1_00(_rtl_impure_ptr, fp, fmt0, ap); +} + +//----- rtl_memchr() +void * rtl_memchr(const void * src_void , int c , size_t length) { + return __rtl_memchr_v1_00(src_void, c, length); +} + +//----- rtl_memcmp() +int rtl_memcmp(const void *m1, const void *m2, size_t n) { + return __rtl_memcmp_v1_00(m1, m2, n); +} + +//----- rtl_memcpy() +void * rtl_memcpy(void *dst0, const void *src0, size_t len0) { + return __rtl_memcpy_v1_00(dst0, src0, len0); +} + +//----- rtl_memmove() +void * rtl_memmove(void *dst_void, const void *src_void, size_t length) { + return __rtl_memmove_v1_00(dst_void, src_void, length); +} + +//----- rtl_memset() +void * rtl_memset(void *m, int c, size_t n) { + return __rtl_memset_v1_00(m, c, n); +} + +//----- rtl_strcat() +char * rtl_strcat(char *s1, const char *s2) { + return (char *) __rtl_strcat_v1_00(s1, s2); +} + +//----- rtl_strchr() +char * rtl_strchr(const char *s1, int i) { + return (char *) __rtl_strchr_v1_00(s1, i); +} + +//----- rtl_strcmp() +int rtl_strcmp(const char *s1, const char *s2) { + return __rtl_strcmp_v1_00(s1, s2); +} + +//----- rtl_strcpy() +char * rtl_strcpy(char *dst0, const char *src0) { + return (char *) __rtl_strcpy_v1_00(dst0, src0); +} + +//----- rtl_strlen() +size_t rtl_strlen(const char *str) { + return __rtl_strlen_v1_00(str); +} + +//----- rtl_strncat() +char * rtl_strncat(char *s1, const char *s2, size_t n) { + return (char *) __rtl_strncat_v1_00(s1, s2, n); +} + +//----- rtl_strncmp() +int rtl_strncmp(const char *s1, const char *s2, size_t n) { + return __rtl_strncmp_v1_00(s1, s2, n); +} + +//----- rtl_strncpy() +char * rtl_strncpy(char *dst0, const char *src0, size_t count) { + return (char *) __rtl_strncpy_v1_00(dst0, src0, count); +} + +//----- rtl_strstr() +char * rtl_strstr(const char *searchee, const char *lookfor) { + return (char *) __rtl_strstr_v1_00(searchee, lookfor); +} + +//----- rtl_strsep() +char * rtl_strsep(char **source_ptr, const char *delim) { + return (char *) __rtl_strsep_v1_00(source_ptr, delim); +} + +//----- rtl_strtok() +char * rtl_strtok(char *s, const char *delim) { + return (char *) __rtl_strtok_v1_00(s, delim); +} + diff --git a/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/ram_libgloss_retarget.c b/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/ram_libgloss_retarget.c new file mode 100644 index 0000000..f9193bd --- /dev/null +++ b/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/ram_libgloss_retarget.c @@ -0,0 +1,125 @@ +/* + * ram_libgloss_retarget.o + * pvvx 2016 + */ + +#include "rtl_bios_data.h" + +//------------------------------------------------------------------------- +// Function declarations + +int ram_libgloss_close(int fildes); +int ram_libgloss_fstat(int fildes, struct stat *st); +int ram_libgloss_isatty(int file); +int ram_libgloss_lseek(int file, int ptr, int dir); +int ram_libgloss_read(int file, char *ptr, int len); +char *ram_libgloss_sbrk(int incr); +int ram_libgloss_write(int file, const char *ptr, int len); +int ram_libgloss_open(char *file, int flags, int mode); +void init_rom_libgloss_ram_map(void); +// Extern Calls: +//extern int HalSerialPutcRtl8195a(); +//extern int rtl_strcmp(); +extern char end; + +//------------------------------------------------------------------------- +// Data declarations + +char *heap_end; +// extern __rtl_errno; +// extern end; +// extern rom_libgloss_ram_map; + +//----- ram_libgloss_close() +int ram_libgloss_close(int fildes) { + __rtl_errno = 88; + return -1; +} + +//----- ram_libgloss_fstat() +int ram_libgloss_fstat(int fildes, struct stat *st) { + int result; + + if ((unsigned int) fildes > 2) { + __rtl_errno = 9; + result = -1; + } else { + st->st_mode = 0x2000; + result = 0; + } + return result; +} + +//----- ram_libgloss_isatty() +int ram_libgloss_isatty(int file) { + int result; + + if (file <= 2) + result = 1; + else + result = -1; + return result; +} + +//----- ram_libgloss_lseek() +int ram_libgloss_lseek(int file, int ptr, int dir) { + __rtl_errno = 88; + return -1; +} + +//----- ram_libgloss_read() +int ram_libgloss_read(int file, char *ptr, int len) { + __rtl_errno = 88; + return -1; +} + +//----- ram_libgloss_sbrk() +char *ram_libgloss_sbrk(int incr) { + char *prev_heap_end; + + if (!heap_end) + heap_end = (char *) &end; + prev_heap_end = heap_end; + heap_end += incr; + return prev_heap_end; +} + +//----- ram_libgloss_write() +int ram_libgloss_write(int file, const char *ptr, int len) { + int i; + for (i = 0; i < len; ++i) + HalSerialPutcRtl8195a(ptr[i]); + return len; +} + +//----- ram_libgloss_open() +int ram_libgloss_open(char *file, int flags, int mode) { +// file->_p + int result = rtl_strcmp(file, "/stdin"); + + if (result) { + if (rtl_strcmp(file, "/stdout")) { + if (rtl_strcmp(file, "/stderr")) + result = -1; + else + result = 2; + } else { + result = 1; + } + } else + result = 0; + return result; +} + +//----- init_rom_libgloss_ram_map() +void init_rom_libgloss_ram_map(void) { + rom_libgloss_ram_map.libgloss_close = ram_libgloss_close; + rom_libgloss_ram_map.libgloss_fstat = ram_libgloss_fstat; + rom_libgloss_ram_map.libgloss_isatty = ram_libgloss_isatty; + rom_libgloss_ram_map.libgloss_lseek = ram_libgloss_lseek; + rom_libgloss_ram_map.libgloss_open = ram_libgloss_open; + rom_libgloss_ram_map.libgloss_read = ram_libgloss_read; + rom_libgloss_ram_map.libgloss_write = ram_libgloss_write; + rom_libgloss_ram_map.libgloss_sbrk = ram_libgloss_sbrk; +} + diff --git a/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/rtl_eabi_cast_ram.c b/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/rtl_eabi_cast_ram.c new file mode 100644 index 0000000..409c06c --- /dev/null +++ b/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/rtl_eabi_cast_ram.c @@ -0,0 +1,228 @@ +/* + * rtl_eabi_cast_ram.o + * pvvx 2016 + */ + +#include "basic_types.h" + +//------------------------------------------------------------------------- +// Function declarations + +int rtl_dtoi(double d); +int rtl_dtoui(double d); +float rtl_i2f(int val); +int rtl_i2d(int val); +float rtl_ui2f(unsigned int val); +int rtl_ui2d(unsigned int val); +char *rtl_itoa(int value, char *string, int radix); +char *rtl_ltoa(int value, char *string, int radix); +char *rtl_utoa(unsigned int value, char *string, int radix); +char *rtl_ultoa(unsigned int value, char *string, int radix); +int rtl_ftol(float f); +int rtl_ftod(float f); +float rtl_dtof(double d); +float rtl_fadd(float a, float b); +float rtl_fsub(float a, float b); +float rtl_fmul(float a, float b); +float rtl_fdiv(float a, float b); +int rtl_dadd(double a, double b); +int rtl_dsub(double a, double b); +int rtl_dmul(double a, double b); +int rtl_ddiv(double a, double b); +int rtl_dcmpeq(double a, double b); +int rtl_dcmplt(double a, double b); +int rtl_dcmple(double a, double b); +int rtl_dcmpgt(double a, double b); +int rtl_fcmplt(float a, float b); +int rtl_fcmpgt(float a, float b); + +// Extern Calls: + +// int _rtl_dtoi_v1_00(); +// int _rtl_dtoui_v1_00(); +// int _rtl_itof_v1_00(); +// int _rtl_itod_v1_00(); +// int _rtl_uitof_v1_00(); +// int _rtl_uitod_v1_00(); +// int _rtl_ltoa_v1_00(); +// int _rtl_ultoa_v1_00(); +// int _rtl_ftol_v1_00(); +// int _rtl_ftod_v1_00(); +// int _rtl_dtof_v1_00(); +// int _rtl_fadd_v1_00(); +// int _rtl_fsub_v1_00(); +// int _rtl_fmul_v1_00(); +// int _rtl_fdiv_v1_00(); +// int _rtl_dadd_v1_00(); +// int _rtl_dsub_v1_00(); +// int _rtl_dmul_v1_00(); +// int _rtl_ddiv_v1_00(); +// int _rtl_dcmpeq_v1_00(); +// int _rtl_dcmplt_v1_00(); +// int _rtl_dcmple_v1_00(); +// int _rtl_dcmpgt_v1_00(); +// int _rtl_fcmplt_v1_00(); +// int _rtl_fcmpgt_v1_00(); + + +//----- rtl_dtoi() +int rtl_dtoi(double d) +{ + return _rtl_dtoi_v1_00(d); +} + +//----- rtl_dtoui() +int rtl_dtoui(double d) +{ + return _rtl_dtoui_v1_00(d); +} + +//----- rtl_i2f() +float rtl_i2f(int val) +{ + return _rtl_itof_v1_00(val); +} + +//----- rtl_i2d() +int rtl_i2d(int val) +{ + return _rtl_itod_v1_00(val); +} + +//----- rtl_ui2f() +float rtl_ui2f(unsigned int val) +{ + return _rtl_uitof_v1_00(val); +} + +//----- rtl_ui2d() +int rtl_ui2d(unsigned int val) +{ + return _rtl_uitod_v1_00(val); +} + +//----- rtl_itoa() +char *rtl_itoa(int value, char *string, int radix) +{ + return (char *)_rtl_ltoa_v1_00(value, string, radix); +} + +//----- rtl_ltoa() +char *rtl_ltoa(int value, char *string, int radix) +{ + return (char *)_rtl_ltoa_v1_00(value, string, radix); +} + +//----- rtl_utoa() +char *rtl_utoa(unsigned int value, char *string, int radix) +{ + return (char *)_rtl_ultoa_v1_00(value, string, radix); +} + +//----- rtl_ultoa() +char *rtl_ultoa(unsigned int value, char *string, int radix) +{ + return (char *)_rtl_ultoa_v1_00(value, string, radix); +} + +//----- rtl_ftol() +int rtl_ftol(float f) +{ + return _rtl_ftol_v1_00(f); +} + +//----- rtl_ftod() +int rtl_ftod(float f) +{ + return _rtl_ftod_v1_00(f); +} + +//----- rtl_dtof() +float rtl_dtof(double d) +{ + return _rtl_dtof_v1_00(d); +} + +//----- rtl_fadd() +float rtl_fadd(float a, float b) +{ + return _rtl_fadd_v1_00(a, b); +} + +//----- rtl_fsub() +float rtl_fsub(float a, float b) +{ + return _rtl_fsub_v1_00(a, b); +} + +//----- rtl_fmul() +float rtl_fmul(float a, float b) +{ + return _rtl_fmul_v1_00(a, b); +} + +//----- rtl_fdiv() +float rtl_fdiv(float a, float b) +{ + return _rtl_fdiv_v1_00(a, b); +} + +//----- rtl_dadd() +int rtl_dadd(double a, double b) +{ + return _rtl_dadd_v1_00(a, b); +} + +//----- rtl_dsub() +int rtl_dsub(double a, double b) +{ + return _rtl_dsub_v1_00(a, b); +} + +//----- rtl_dmul() +int rtl_dmul(double a, double b) +{ + return _rtl_dmul_v1_00(a, b); +} + +//----- rtl_ddiv() +int rtl_ddiv(double a, double b) +{ + return _rtl_ddiv_v1_00(a, b); +} + +//----- rtl_dcmpeq() +int rtl_dcmpeq(double a, double b) +{ + return _rtl_dcmpeq_v1_00(a, b); +} + +//----- rtl_dcmplt() +int rtl_dcmplt(double a, double b) +{ + return _rtl_dcmplt_v1_00(a, b); +} + +//----- rtl_dcmple() +int rtl_dcmple(double a, double b) +{ + return _rtl_dcmple_v1_00(a, b); +} + +//----- rtl_dcmpgt() +int rtl_dcmpgt(double a, double b) +{ + return _rtl_dcmpgt_v1_00(a, b); +} + +//----- rtl_fcmplt() +int rtl_fcmplt(float a, float b) +{ + return _rtl_fcmplt_v1_00(a, b); +} + +//----- rtl_fcmpgt() +int rtl_fcmpgt(float a, float b) +{ + return _rtl_fcmpgt_v1_00(a, b); +} diff --git a/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/rtl_math_ram.c b/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/rtl_math_ram.c new file mode 100644 index 0000000..6477415 --- /dev/null +++ b/RTL00_SDKV35a/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/rtl_math_ram.c @@ -0,0 +1,46 @@ +/* + * rtl_math_ram..o + * pvvx 2016 + */ + +#include "basic_types.h" + +//------------------------------------------------------------------------- +// Function declarations + +float rtl_fabsf(float a); +int rtl_fabs(double a); +float rtl_cos_f32(float a); +float rtl_sin_f32(float a); + +// Extern Calls: + +// int _rtl_fabsf_v1_00(); +// int _rtl_fabs_v1_00(); +// int _rtl_cos_f32_v1_00(); +// int _rtl_sin_f32_v1_00(); + + +//----- rtl_fabsf() +float rtl_fabsf(float a) +{ + return _rtl_fabsf_v1_00(a); +} + +//----- rtl_fabs() +int rtl_fabs(double a) +{ + return _rtl_fabs_v1_00(a); +} + +//----- rtl_cos_f32() +float rtl_cos_f32(float a) +{ + return _rtl_cos_f32_v1_00(a); +} + +//----- rtl_sin_f32() +float rtl_sin_f32(float a) +{ + return _rtl_sin_f32_v1_00(a); +} diff --git a/flasher/RTL_Reset.JLinkScript b/flasher/RTL_Reset.JLinkScript index 303f367..40a863d 100644 --- a/flasher/RTL_Reset.JLinkScript +++ b/flasher/RTL_Reset.JLinkScript @@ -1,3 +1,7 @@ +r0 +trst0 +r1 +trst1 h r w4 0x40000210,0x00211157