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.
vendor/NXP/LPC1768/cmsis/GCC_CS/sys.cpp@10:3bc89ef62ce7, 2013-06-14 (annotated)
- Committer:
- emilmont
- Date:
- Fri Jun 14 17:49:17 2013 +0100
- Revision:
- 10:3bc89ef62ce7
Unify mbed library sources
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 10:3bc89ef62ce7 | 1 | #include "cmsis.h" |
emilmont | 10:3bc89ef62ce7 | 2 | #include <sys/types.h> |
emilmont | 10:3bc89ef62ce7 | 3 | #include <errno.h> |
emilmont | 10:3bc89ef62ce7 | 4 | |
emilmont | 10:3bc89ef62ce7 | 5 | extern "C" { |
emilmont | 10:3bc89ef62ce7 | 6 | |
emilmont | 10:3bc89ef62ce7 | 7 | struct SCS3Regions { |
emilmont | 10:3bc89ef62ce7 | 8 | unsigned long Dummy; |
emilmont | 10:3bc89ef62ce7 | 9 | unsigned long* InitRam; |
emilmont | 10:3bc89ef62ce7 | 10 | unsigned long* StartRam; |
emilmont | 10:3bc89ef62ce7 | 11 | unsigned long InitSizeRam; |
emilmont | 10:3bc89ef62ce7 | 12 | unsigned long ZeroSizeRam; |
emilmont | 10:3bc89ef62ce7 | 13 | }; |
emilmont | 10:3bc89ef62ce7 | 14 | |
emilmont | 10:3bc89ef62ce7 | 15 | extern unsigned long __cs3_regions; |
emilmont | 10:3bc89ef62ce7 | 16 | extern unsigned long __cs3_heap_start; |
emilmont | 10:3bc89ef62ce7 | 17 | |
emilmont | 10:3bc89ef62ce7 | 18 | int main(void); |
emilmont | 10:3bc89ef62ce7 | 19 | void __libc_init_array(void); |
emilmont | 10:3bc89ef62ce7 | 20 | void exit(int ErrorCode); |
emilmont | 10:3bc89ef62ce7 | 21 | |
emilmont | 10:3bc89ef62ce7 | 22 | static void *heap_pointer = NULL; |
emilmont | 10:3bc89ef62ce7 | 23 | |
emilmont | 10:3bc89ef62ce7 | 24 | void __cs3_start_c(void) { |
emilmont | 10:3bc89ef62ce7 | 25 | static SCS3Regions* pCS3Regions = (SCS3Regions*)&__cs3_regions; |
emilmont | 10:3bc89ef62ce7 | 26 | unsigned long* pulDest; |
emilmont | 10:3bc89ef62ce7 | 27 | unsigned long* pulSrc; |
emilmont | 10:3bc89ef62ce7 | 28 | unsigned long ByteCount; |
emilmont | 10:3bc89ef62ce7 | 29 | unsigned long i; |
emilmont | 10:3bc89ef62ce7 | 30 | |
emilmont | 10:3bc89ef62ce7 | 31 | pulSrc = pCS3Regions->InitRam; |
emilmont | 10:3bc89ef62ce7 | 32 | pulDest = pCS3Regions->StartRam; |
emilmont | 10:3bc89ef62ce7 | 33 | ByteCount = pCS3Regions->InitSizeRam; |
emilmont | 10:3bc89ef62ce7 | 34 | if (pulSrc != pulDest) { |
emilmont | 10:3bc89ef62ce7 | 35 | for(i = 0 ; i < ByteCount ; i += sizeof(unsigned long)) { |
emilmont | 10:3bc89ef62ce7 | 36 | *(pulDest++) = *(pulSrc++); |
emilmont | 10:3bc89ef62ce7 | 37 | } |
emilmont | 10:3bc89ef62ce7 | 38 | } else { |
emilmont | 10:3bc89ef62ce7 | 39 | pulDest = (unsigned long*)(void*)((char*)pulDest + ByteCount); |
emilmont | 10:3bc89ef62ce7 | 40 | } |
emilmont | 10:3bc89ef62ce7 | 41 | |
emilmont | 10:3bc89ef62ce7 | 42 | ByteCount = pCS3Regions->ZeroSizeRam; |
emilmont | 10:3bc89ef62ce7 | 43 | for(i = 0 ; i < ByteCount ; i += sizeof(unsigned long)) { |
emilmont | 10:3bc89ef62ce7 | 44 | *(pulDest++) = 0; |
emilmont | 10:3bc89ef62ce7 | 45 | } |
emilmont | 10:3bc89ef62ce7 | 46 | |
emilmont | 10:3bc89ef62ce7 | 47 | heap_pointer = &__cs3_heap_start; |
emilmont | 10:3bc89ef62ce7 | 48 | __libc_init_array(); |
emilmont | 10:3bc89ef62ce7 | 49 | |
emilmont | 10:3bc89ef62ce7 | 50 | exit(main()); |
emilmont | 10:3bc89ef62ce7 | 51 | } |
emilmont | 10:3bc89ef62ce7 | 52 | |
emilmont | 10:3bc89ef62ce7 | 53 | int _kill(int pid, int sig) { |
emilmont | 10:3bc89ef62ce7 | 54 | errno = EINVAL; |
emilmont | 10:3bc89ef62ce7 | 55 | return -1; |
emilmont | 10:3bc89ef62ce7 | 56 | } |
emilmont | 10:3bc89ef62ce7 | 57 | |
emilmont | 10:3bc89ef62ce7 | 58 | void _exit(int status) { |
emilmont | 10:3bc89ef62ce7 | 59 | exit(status); |
emilmont | 10:3bc89ef62ce7 | 60 | } |
emilmont | 10:3bc89ef62ce7 | 61 | |
emilmont | 10:3bc89ef62ce7 | 62 | int _getpid(void) { |
emilmont | 10:3bc89ef62ce7 | 63 | return 1; |
emilmont | 10:3bc89ef62ce7 | 64 | } |
emilmont | 10:3bc89ef62ce7 | 65 | |
emilmont | 10:3bc89ef62ce7 | 66 | void *_sbrk(unsigned int incr) { |
emilmont | 10:3bc89ef62ce7 | 67 | void *mem; |
emilmont | 10:3bc89ef62ce7 | 68 | |
emilmont | 10:3bc89ef62ce7 | 69 | unsigned int next = ((((unsigned int)heap_pointer + incr) + 7) & ~7); |
emilmont | 10:3bc89ef62ce7 | 70 | if (next > __get_MSP()) { |
emilmont | 10:3bc89ef62ce7 | 71 | mem = NULL; |
emilmont | 10:3bc89ef62ce7 | 72 | } else { |
emilmont | 10:3bc89ef62ce7 | 73 | mem = (void *)heap_pointer; |
emilmont | 10:3bc89ef62ce7 | 74 | } |
emilmont | 10:3bc89ef62ce7 | 75 | heap_pointer = (void *)next; |
emilmont | 10:3bc89ef62ce7 | 76 | |
emilmont | 10:3bc89ef62ce7 | 77 | return mem; |
emilmont | 10:3bc89ef62ce7 | 78 | } |
emilmont | 10:3bc89ef62ce7 | 79 | |
emilmont | 10:3bc89ef62ce7 | 80 | } |