mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
bogdanm
Date:
Mon Aug 19 18:17:02 2013 +0300
Revision:
19:398f4c622e1b
Sync with official mbed library release 66

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 19:398f4c622e1b 1 #include "cmsis.h"
bogdanm 19:398f4c622e1b 2 #include <sys/types.h>
bogdanm 19:398f4c622e1b 3 #include <errno.h>
bogdanm 19:398f4c622e1b 4
bogdanm 19:398f4c622e1b 5 extern "C" {
bogdanm 19:398f4c622e1b 6
bogdanm 19:398f4c622e1b 7 struct SCS3Regions {
bogdanm 19:398f4c622e1b 8 unsigned long Dummy;
bogdanm 19:398f4c622e1b 9 unsigned long* InitRam;
bogdanm 19:398f4c622e1b 10 unsigned long* StartRam;
bogdanm 19:398f4c622e1b 11 unsigned long InitSizeRam;
bogdanm 19:398f4c622e1b 12 unsigned long ZeroSizeRam;
bogdanm 19:398f4c622e1b 13 };
bogdanm 19:398f4c622e1b 14
bogdanm 19:398f4c622e1b 15 extern unsigned long __cs3_regions;
bogdanm 19:398f4c622e1b 16 extern unsigned long __cs3_heap_start;
bogdanm 19:398f4c622e1b 17
bogdanm 19:398f4c622e1b 18 int main(void);
bogdanm 19:398f4c622e1b 19 void __libc_init_array(void);
bogdanm 19:398f4c622e1b 20 void exit(int ErrorCode);
bogdanm 19:398f4c622e1b 21
bogdanm 19:398f4c622e1b 22 static void *heap_pointer = NULL;
bogdanm 19:398f4c622e1b 23
bogdanm 19:398f4c622e1b 24 void __cs3_start_c(void) {
bogdanm 19:398f4c622e1b 25 static SCS3Regions* pCS3Regions = (SCS3Regions*)&__cs3_regions;
bogdanm 19:398f4c622e1b 26 unsigned long* pulDest;
bogdanm 19:398f4c622e1b 27 unsigned long* pulSrc;
bogdanm 19:398f4c622e1b 28 unsigned long ByteCount;
bogdanm 19:398f4c622e1b 29 unsigned long i;
bogdanm 19:398f4c622e1b 30
bogdanm 19:398f4c622e1b 31 pulSrc = pCS3Regions->InitRam;
bogdanm 19:398f4c622e1b 32 pulDest = pCS3Regions->StartRam;
bogdanm 19:398f4c622e1b 33 ByteCount = pCS3Regions->InitSizeRam;
bogdanm 19:398f4c622e1b 34 if (pulSrc != pulDest) {
bogdanm 19:398f4c622e1b 35 for(i = 0 ; i < ByteCount ; i += sizeof(unsigned long)) {
bogdanm 19:398f4c622e1b 36 *(pulDest++) = *(pulSrc++);
bogdanm 19:398f4c622e1b 37 }
bogdanm 19:398f4c622e1b 38 } else {
bogdanm 19:398f4c622e1b 39 pulDest = (unsigned long*)(void*)((char*)pulDest + ByteCount);
bogdanm 19:398f4c622e1b 40 }
bogdanm 19:398f4c622e1b 41
bogdanm 19:398f4c622e1b 42 ByteCount = pCS3Regions->ZeroSizeRam;
bogdanm 19:398f4c622e1b 43 for(i = 0 ; i < ByteCount ; i += sizeof(unsigned long)) {
bogdanm 19:398f4c622e1b 44 *(pulDest++) = 0;
bogdanm 19:398f4c622e1b 45 }
bogdanm 19:398f4c622e1b 46
bogdanm 19:398f4c622e1b 47 heap_pointer = &__cs3_heap_start;
bogdanm 19:398f4c622e1b 48 __libc_init_array();
bogdanm 19:398f4c622e1b 49 exit(main());
bogdanm 19:398f4c622e1b 50 }
bogdanm 19:398f4c622e1b 51
bogdanm 19:398f4c622e1b 52 int _kill(int pid, int sig) {
bogdanm 19:398f4c622e1b 53 errno = EINVAL;
bogdanm 19:398f4c622e1b 54 return -1;
bogdanm 19:398f4c622e1b 55 }
bogdanm 19:398f4c622e1b 56
bogdanm 19:398f4c622e1b 57 void _exit(int status) {
bogdanm 19:398f4c622e1b 58 exit(status);
bogdanm 19:398f4c622e1b 59 }
bogdanm 19:398f4c622e1b 60
bogdanm 19:398f4c622e1b 61 int _getpid(void) {
bogdanm 19:398f4c622e1b 62 return 1;
bogdanm 19:398f4c622e1b 63 }
bogdanm 19:398f4c622e1b 64
bogdanm 19:398f4c622e1b 65 void *_sbrk(unsigned int incr) {
bogdanm 19:398f4c622e1b 66 void *mem;
bogdanm 19:398f4c622e1b 67
bogdanm 19:398f4c622e1b 68 unsigned int next = ((((unsigned int)heap_pointer + incr) + 7) & ~7);
bogdanm 19:398f4c622e1b 69 if (next > __get_MSP()) {
bogdanm 19:398f4c622e1b 70 mem = NULL;
bogdanm 19:398f4c622e1b 71 } else {
bogdanm 19:398f4c622e1b 72 mem = (void *)heap_pointer;
bogdanm 19:398f4c622e1b 73 }
bogdanm 19:398f4c622e1b 74 heap_pointer = (void *)next;
bogdanm 19:398f4c622e1b 75
bogdanm 19:398f4c622e1b 76 return mem;
bogdanm 19:398f4c622e1b 77 }
bogdanm 19:398f4c622e1b 78
bogdanm 19:398f4c622e1b 79 }