diff options
Diffstat (limited to 'lib/inc')
-rw-r--r-- | lib/inc/mem.h | 13 | ||||
-rw-r--r-- | lib/inc/sys.h | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/inc/mem.h b/lib/inc/mem.h index e2d574f..9399b54 100644 --- a/lib/inc/mem.h +++ b/lib/inc/mem.h @@ -5,8 +5,17 @@ #include <def.h> -#define malloc(n) ((void *)((HEAP += n) - n)) // TODO: Implement real/better malloc/free -#define free(x) +// Huh +#ifdef kernel +#define malloc(n) (void *)((HEAP += n) - n) // TODO: Implement real/better malloc/free +#define free(ptr) +#elif defined(userspace) +#include <sys.h> +#define malloc(n) (void *)sys1(SYS_MALLOC, n) +#define free(ptr) (void)(sys1(SYS_FREE, (int)ptr)) +#else +#error "No lib target specified. Please use -Dkernel or -Duserspace" +#endif // TODO: Use malloc as syscall u32 HEAP; diff --git a/lib/inc/sys.h b/lib/inc/sys.h index aaeb6ca..aefaead 100644 --- a/lib/inc/sys.h +++ b/lib/inc/sys.h @@ -4,7 +4,7 @@ #ifndef SYS_H #define SYS_H -enum sys { SYS_HALT, SYS_EXEC }; +enum sys { SYS_LOOP, SYS_MALLOC, SYS_FREE, SYS_EXEC }; int sys0(enum sys num); int sys1(enum sys num, int d1); |