Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
sys.cpp
00001 #include "cmsis.h" 00002 #include <sys/types.h> 00003 #include <errno.h> 00004 00005 extern "C" { 00006 00007 struct SCS3Regions { 00008 unsigned long Dummy; 00009 unsigned long* InitRam; 00010 unsigned long* StartRam; 00011 unsigned long InitSizeRam; 00012 unsigned long ZeroSizeRam; 00013 }; 00014 00015 extern unsigned long __cs3_regions; 00016 extern unsigned long __cs3_heap_start; 00017 00018 int main(void); 00019 void __libc_init_array(void); 00020 void exit(int ErrorCode); 00021 00022 static void *heap_pointer = NULL; 00023 00024 void __cs3_start_c(void) { 00025 static SCS3Regions* pCS3Regions = (SCS3Regions*)&__cs3_regions; 00026 unsigned long* pulDest; 00027 unsigned long* pulSrc; 00028 unsigned long ByteCount; 00029 unsigned long i; 00030 00031 pulSrc = pCS3Regions->InitRam; 00032 pulDest = pCS3Regions->StartRam; 00033 ByteCount = pCS3Regions->InitSizeRam; 00034 if (pulSrc != pulDest) { 00035 for(i = 0 ; i < ByteCount ; i += sizeof(unsigned long)) { 00036 *(pulDest++) = *(pulSrc++); 00037 } 00038 } else { 00039 pulDest = (unsigned long*)(void*)((char*)pulDest + ByteCount); 00040 } 00041 00042 ByteCount = pCS3Regions->ZeroSizeRam; 00043 for(i = 0 ; i < ByteCount ; i += sizeof(unsigned long)) { 00044 *(pulDest++) = 0; 00045 } 00046 00047 heap_pointer = &__cs3_heap_start; 00048 __libc_init_array(); 00049 00050 exit(main()); 00051 } 00052 00053 int _kill(int pid, int sig) { 00054 errno = EINVAL; 00055 return -1; 00056 } 00057 00058 void _exit(int status) { 00059 exit(status); 00060 } 00061 00062 int _getpid(void) { 00063 return 1; 00064 } 00065 00066 void *_sbrk(unsigned int incr) { 00067 void *mem; 00068 00069 unsigned int next = ((((unsigned int)heap_pointer + incr) + 7) & ~7); 00070 if (next > __get_MSP()) { 00071 mem = NULL; 00072 } else { 00073 mem = (void *)heap_pointer; 00074 } 00075 heap_pointer = (void *)next; 00076 00077 return mem; 00078 } 00079 00080 }
Generated on Tue Jul 12 2022 13:47:02 by
1.7.2
