diff options
author | Christian Cunningham <cc@localhost> | 2022-01-20 23:22:42 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-01-20 23:22:42 -0700 |
commit | 73a80de4228a498b483c8e10ab317920d978d507 (patch) | |
tree | eea73a138a509d7758ef477d4997cf7147233604 /include | |
parent | c2e52566ed53b53227a6fe577a05170766a1ae4c (diff) |
Moved globals to file
Diffstat (limited to 'include')
-rw-r--r-- | include/cpu.h | 10 | ||||
-rw-r--r-- | include/cpu/atomic/swap.h | 2 | ||||
-rw-r--r-- | include/globals.h | 27 | ||||
-rw-r--r-- | include/graphics/drawer.h | 4 | ||||
-rw-r--r-- | include/graphics/lfb.h | 4 | ||||
-rw-r--r-- | include/lib/mem.h | 2 | ||||
-rw-r--r-- | include/sys/core.h | 4 | ||||
-rw-r--r-- | include/sys/kernel.h | 8 | ||||
-rw-r--r-- | include/sys/schedule.h | 12 | ||||
-rw-r--r-- | include/sys/timer.h | 4 |
10 files changed, 33 insertions, 44 deletions
diff --git a/include/cpu.h b/include/cpu.h index eb2cdc0..68638a5 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -1,6 +1,8 @@ #ifndef CPU_H #define CPU_H +extern void _start(void); + static inline unsigned long getmode(void) { unsigned long mode; @@ -10,13 +12,7 @@ static inline unsigned long getmode(void) static inline void setsvc(void) { - unsigned long mode; - asm volatile ( - "mrs %0, cpsr\n" - "bic %0, %0, #0x1F\n" - "orr %0, %0, #0x13\n" - "msr cpsr_c, %0" - : "=r"(mode)); + asm volatile ( "cps #0x13" ); } static inline void setmode(unsigned long mode) diff --git a/include/cpu/atomic/swap.h b/include/cpu/atomic/swap.h index 32717fb..ebaaa1d 100644 --- a/include/cpu/atomic/swap.h +++ b/include/cpu/atomic/swap.h @@ -1,6 +1,6 @@ #ifndef CPU_ATOMIC_SWAP_A_H #define CPU_ATOMIC_SWAP_A_H -#include "../../util/mutex.h" +#include <util/mutex.h> /// https://stackoverflow.com/questions/16329123/use-of-strexeq-instead-of-strex-for-spinlock-implementation-in-arm /// https://elixir.bootlin.com/linux/v4.9/source/arch/arm/include/asm/spinlock.h diff --git a/include/globals.h b/include/globals.h new file mode 100644 index 0000000..0b3eaed --- /dev/null +++ b/include/globals.h @@ -0,0 +1,27 @@ +#ifndef GLOBALS_H +#define GLOBALS_H +#include <lib/mem.h> +#include <sys/schedule.h> + +#ifndef GLOBALS_C +extern unsigned long cntfrq; +extern unsigned long cmdidx; +extern char cmd[2048]; + +extern char* os_info_v; +extern unsigned long exe_cnt; +extern struct Mutex exe_cnt_m; +extern unsigned char rpi_heap[MAX_MM]; +extern void* rpi_heap_top; +extern unsigned long nextpid; +extern unsigned long stimel; +extern unsigned long stimeh; +extern struct Drawer g_Drawer; +extern struct Scheduler scheduler; +extern unsigned long svcsp; +extern struct cpu_context svccpu; +extern unsigned int gwidth, gheight, gpitch, gisrgb; +extern unsigned char stacks_table[MAX_THREADS]; +#endif + +#endif diff --git a/include/graphics/drawer.h b/include/graphics/drawer.h index 6d97163..67abca0 100644 --- a/include/graphics/drawer.h +++ b/include/graphics/drawer.h @@ -6,10 +6,6 @@ struct Drawer { unsigned int y; }; -#ifndef GRAPHICS_DRAWER_C -extern struct Drawer g_Drawer; -#endif - void write_cchar(struct Drawer* d, char s, unsigned int c); void write_char(struct Drawer* d, char s); diff --git a/include/graphics/lfb.h b/include/graphics/lfb.h index a4eef2e..a151a5f 100644 --- a/include/graphics/lfb.h +++ b/include/graphics/lfb.h @@ -4,10 +4,6 @@ #define GG_MAX_X 128 #define GG_MAX_Y 46 -#ifndef GRAPHICS_LFB_C -extern unsigned int width, height, pitch, isrgb; /* dimensions and channel order */ -#endif - void lfb_init(void); void lfb_showpicture(void); diff --git a/include/lib/mem.h b/include/lib/mem.h index 529ecea..ea1be5d 100644 --- a/include/lib/mem.h +++ b/include/lib/mem.h @@ -6,6 +6,7 @@ #define MEM_BASE_SIZE 2 #define MEM_META_SIZE 3 #define NULL 0 +#define MAX_MM 0x100000 struct MemTab { unsigned char size; @@ -20,6 +21,7 @@ struct RotBuffer { unsigned int woffset; }; +void memshow(unsigned char* addr, unsigned int n); void memset(unsigned char* dest, unsigned char value, unsigned int n); void memcpy(unsigned char* src, unsigned char* dest, unsigned int n); unsigned char memcmp(unsigned char* a, unsigned char* b, unsigned int n); diff --git a/include/sys/core.h b/include/sys/core.h index eb1f1e6..c68d8de 100644 --- a/include/sys/core.h +++ b/include/sys/core.h @@ -1,10 +1,6 @@ #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; diff --git a/include/sys/kernel.h b/include/sys/kernel.h deleted file mode 100644 index e724513..0000000 --- a/include/sys/kernel.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef SYS_KERNEL_H -#define SYS_KERNEL_H - -extern unsigned long cntfrq; -extern unsigned long cmdidx; -extern char cmd[2048]; - -#endif diff --git a/include/sys/schedule.h b/include/sys/schedule.h index 58c7312..e1cde57 100644 --- a/include/sys/schedule.h +++ b/include/sys/schedule.h @@ -53,11 +53,6 @@ struct Scheduler { struct LL tlist[PRIORITIES]; }; -#ifndef SYS_SCHEDULE_C -#define SYS_SCHEDULE_C -extern struct Scheduler scheduler; -#endif - void init_scheduler(void); void add_thread(void (*thread_fxn)(void), unsigned char priority); extern void schedule(void); @@ -67,13 +62,6 @@ void cleanup(void); void sched_info(void); struct LL* get_next_thread(void); -static inline void yield(void) -{ - struct Thread* t = scheduler.rthread_ll->data; - t->data.status = THREAD_WAITING; - schedule(); -} - static inline void preserve_stack(struct Thread* thread) { // Get current mode diff --git a/include/sys/timer.h b/include/sys/timer.h index f11fd17..7120c18 100644 --- a/include/sys/timer.h +++ b/include/sys/timer.h @@ -4,10 +4,6 @@ /// Cycles Per Second #define CPS 100 -#ifndef SYS_TIMER_C -extern struct Mutex exe_cnt_m; -#endif - void c_timer(void); #endif |