diff options
author | Christian Cunningham <cc@localhost> | 2022-01-05 14:27:09 -0800 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-01-05 14:27:09 -0800 |
commit | 866a6ca0e749f4446b7fdc7579a6d553df85ec10 (patch) | |
tree | d259223d85c224d649c6c38675e99b155d50cf48 /include/sys/core.h | |
parent | 3a8ed19bf83f11ff00c4904fab2cc083b7e33478 (diff) |
Moved includes to its own directory
Diffstat (limited to 'include/sys/core.h')
-rw-r--r-- | include/sys/core.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/include/sys/core.h b/include/sys/core.h new file mode 100644 index 0000000..2d611b3 --- /dev/null +++ b/include/sys/core.h @@ -0,0 +1,55 @@ +#ifndef SYS_CORE_H +#define SYS_CORE_H + +#ifndef SYS_CORE_C +extern char* os_info_v; +#endif + +static inline unsigned long load32(unsigned long addr) +{ + return *(volatile unsigned long*)addr; +} + +static inline void store32(unsigned long value, unsigned long addr) +{ + *(volatile unsigned long*)addr = value; +} + +static inline void delay(unsigned long cycles) +{ + asm volatile("__delay_%=: subs %[cycles], %[cycles], #1;bne __delay_%=\n" + : "=r"(cycles): [cycles]"0"(cycles) : "cc"); +} + +static inline void preserveregs(void) +{ + asm volatile("push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11}"); +} + +static inline void restoreregs(void) +{ + asm volatile("pop {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11}"); +} + +static inline void* getsp(void) +{ + void* out; + asm volatile ("mov %0, sp" : "=r"(out)); + return out; +} + +static inline void setsp(void* in) +{ + asm volatile ("mov sp, %0" :: "r"(in)); +} + +static inline void* heap_end(void) +{ + unsigned long value; + asm volatile ("ldr %0, =__bss_end": "=r"(value)); + return (void*)value; +} + +void sysinit(void); + +#endif |