--- /dev/null
+
+TARGET := $(shell gcc -v 2>&1 | grep Targ | awk '{print $$2}')
+
+KERNEL_SRC = ../../../KernelLand/Kernel/
+
+BIN = ../DiskTool
+# Kernel Sources (compiled with -ffreestanding)
+K_OBJ = vfs/main.o vfs/open.o vfs/acls.o vfs/io.o vfs/dir.o
+K_OBJ += vfs/nodecache.o vfs/mount.o vfs/memfile.o vfs/select.o
+K_OBJ += vfs/fs/root.o vfs/fs/devfs.o
+K_OBJ += drv/proc.o
+# Local kernel soruces (same as above, but located in same directory as Makefile)
+L_OBJ = vfs_handles.o threads.o nativefs.o
+# Native Sources (compiled as usual)
+N_OBJ = main.o script.o logging.o
+
+# Compilation Options
+CFLAGS := -Wall
+CPPFLAGS := -I include/
+K_CPPFLAGS := -I $(KERNEL_SRC)include
+
+# == Start of Magic ==
+OBJ_PREFIX = obj/$(TARGET)/
+K_OBJ_PREFIX = $(OBJ_PREFIX)_Kernel/
+K_OBJ := $(addprefix $(K_OBJ_PREFIX),$(K_OBJ))
+L_OBJ := $(addprefix $(OBJ_PREFIX),$(L_OBJ))
+N_OBJ := $(addprefix $(OBJ_PREFIX),$(N_OBJ))
+
+OBJ := $(N_OBJ) $(L_OBJ) $(K_OBJ)
+
+DEPFILES = $(filter %.o,$(OBJ))
+DEPFILES := $(DEPFILES:%=%.dep)
+
+
+.PHONY: all clean
+
+all: $(BIN)
+
+clean:
+ $(RM) -f $(OBJ) $(DEPFILES) $(BIN)
+
+$(BIN): $(OBJ)
+ $(CC) -o $(BIN) $(OBJ) $(LDFLAGS)
+
+$(K_OBJ): $(K_OBJ_PREFIX)%.o: $(KERNEL_SRC)%.c
+ @mkdir -p $(dir $@)
+ $(CC) -c $< -o $@ -ffreestanding $(CFLAGS) $(CPPFLAGS) $(K_CPPFLAGS) -MMD -MP -MF
[email protected]
+
+$(L_OBJ): $(OBJ_PREFIX)%.o: %.c
+ @mkdir -p $(dir $@)
+ $(CC) -c $< -o $@ -ffreestanding $(CFLAGS) $(CPPFLAGS) $(K_CPPFLAGS) -MMD -MP -MF
[email protected]
+
+$(N_OBJ): $(OBJ_PREFIX)%.o: %.c
+ @mkdir -p $(dir $@)
+
+-include $(DEPFILES)
--- /dev/null
+/*
+ * Acess2 DiskTool utility
+ * - By John Hodge (thePowersGang)
+ *
+ * include/acess.h
+ * - Mock kernel core header
+ */
+#ifndef _DISKTOOL__ACESS_H_
+#define _DISKTOOL__ACESS_H_
+
+#define CONCAT(x,y) x ## y
+#define EXPAND_CONCAT(x,y) CONCAT(x,y)
+#define STR(x) #x
+#define EXPAND_STR(x) STR(x)
+
+extern char __buildnum[];
+#define BUILD_NUM ((int)(Uint)&__buildnum)
+extern const char gsGitHash[];
+
+#define BITS 32
+#define NULL ((void*)0)
+#include <stdint.h>
+
+typedef uintptr_t Uint;
+typedef unsigned int size_t;
+typedef uint64_t off_t;
+typedef char BOOL;
+
+
+typedef uint8_t Uint8;
+typedef uint16_t Uint16;
+typedef uint32_t Uint32;
+typedef uint64_t Uint64;
+
+typedef int8_t Sint8;
+typedef int16_t Sint16;
+typedef int32_t Sint32;
+typedef int64_t Sint64;
+
+typedef uintptr_t tVAddr;
+typedef uint32_t tPAddr;
+
+typedef uint32_t tUID;
+typedef uint32_t tGID;
+typedef uint32_t tTID;
+
+// NOTE: Since this is single-threaded (for now) mutexes can be implimented as simple locks
+typedef char tMutex;
+typedef char tShortSpinlock;
+
+typedef int64_t tTime;
+
+#define PACKED __attribute__((packed))
+#define DEPRECATED
+#define EXPORT(s)
+#define EXPORTV(s)
+
+#include <vfs_ext.h>
+
+// These are actually library functions, but they can't be included, so they're defined manually
+extern void *malloc(size_t bytes);
+extern void *calloc(size_t nmemb, size_t size);
+extern void *realloc(void *oldptr, size_t bytes);
+extern void free(void *buffer);
+
+#include <errno.h>
+
+#include <acess_logging.h>
+
+// Threads
+extern int *Threads_GetErrno(void);
+//extern tPGID Threads_GetPGID(void);
+//extern tPID Threads_GetPID(void);
+extern tTID Threads_GetTID(void);
+extern tUID Threads_GetUID(void);
+extern tGID Threads_GetGID(void);
+
+// Kinda hacky way of not colliding with native errno
+#define errno (*(Threads_GetErrno()))
+
+#include <string.h>
+
+
+#define ENTER(...) do{}while(0)
+#define LOG(...) do{}while(0)
+#define LEAVE(...) do{}while(0)
+#define LEAVE_RET(t,v) return v;
+
+static inline int Mutex_Acquire(tMutex *m) {
+ if(*m) Log_KernelPanic("---", "Double mutex lock");
+ *m = 1;
+ return 0;
+}
+static inline void Mutex_Release(tMutex *m) { *m = 0; }
+
+static inline void SHORTLOCK(tShortSpinlock *Lock) {
+ if(*Lock) Log_KernelPanic("---", "Double short lock");
+ *Lock = 1;
+}
+static inline void SHORTREL(tShortSpinlock *m) { *m = 0; }
+
+#endif
+
--- /dev/null
+
+#ifndef _DISKTOOL__ACESS_LOGGING_H_
+#define _DISKTOOL__ACESS_LOGGING_H_
+
+extern void Log_KernelPanic(const char *Ident, const char *Message, ...) __attribute__((noreturn));
+extern void Log_Panic(const char *Ident, const char *Message, ...);
+extern void Log_Error(const char *Ident, const char *Message, ...);
+extern void Log_Warning(const char *Ident, const char *Message, ...);
+extern void Log_Notice(const char *Ident, const char *Message, ...);
+extern void Log_Log(const char *Ident, const char *Message, ...);
+extern void Log_Debug(const char *Ident, const char *Message, ...);
+
+extern void Warning(const char *Message, ...);
+extern void Log(const char *Message, ...);
+#endif
+
--- /dev/null
+/*
+ *
+ */
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <acess_logging.h>
+
+#define PUTERR(col,type) {\
+ fprintf(stderr, "\e["col"m[%8.8s]"type" ", Ident); \
+ va_list args; va_start(args, Message);\
+ vfprintf(stderr, Message, args);\
+ va_end(args);\
+ fprintf(stderr, "\n"); \
+}
+
+// === CODE ===
+void Log_KernelPanic(const char *Ident, const char *Message, ...) {
+ PUTERR("35", "k")
+ exit(-1);
+}
+void Log_Panic(const char *Ident, const char *Message, ...)
+ PUTERR("37", "p")
+void Log_Error(const char *Ident, const char *Message, ...)
+ PUTERR("32", "e")
+void Log_Warning(const char *Ident, const char *Message, ...)
+ PUTERR("34", "w")
+void Log_Notice(const char *Ident, const char *Message, ...)
+ PUTERR("33", "n")
+void Log_Log(const char *Ident, const char *Message, ...)
+ PUTERR("31", "l")
+void Log_Debug(const char *Ident, const char *Message, ...)
+ PUTERR("31", "d")
+
+void Warning(const char *Message, ...) {
+ const char *Ident = "WARNING";
+ PUTERR("34", "W")
+}
+void Log(const char *Message, ...) {
+ const char *Ident = "LOGLOG";
+ PUTERR("31", "L")
+}
--- /dev/null
+/*
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <string.h>
+
+// === CODE ===
+int main(int argc, char *argv[])
+{
+ return 0;
+}
+
+int *Threads_GetErrno(void)
+{
+ return &errno;
+}
+
+// TODO: Move into a helper lib?
+extern void itoa(char *buf, uint64_t num, int base, int minLength, char pad)
+{
+ char fmt[] = "%0ll*x";
+ switch(base)
+ {
+ case 8: fmt[5] = 'o'; break;
+ case 10: fmt[5] = 'd'; break;
+ case 16: fmt[5] = 'x'; break;
+ }
+ if(pad != '0') {
+ fmt[1] = '%';
+ sprintf(buf, fmt+1, minLength, num);
+ }
+ else {
+ sprintf(buf, fmt, minLength, num);
+ }
+}
+
+int strpos(const char *Str, char Ch)
+{
+ const char *r = strchr(Str, Ch);
+ if(!r) return -1;
+ return r - Str;
+}
--- /dev/null
+/*
+ *
+ */
+#include <acess.h>
+
+// === CODE ===
+Uint32 Threads_WaitEvents(Uint32 Events)
+{
+ Log_KernelPanic("Threads", "Can't use _WaitEvents in DiskTool");
+ return 0;
+}
+
+void Threads_ClearEvent(Uint32 Mask)
+{
+
+}
+
+tUID Threads_GetUID(void) { return 0; }
+tGID Threads_GetGID(void) { return 0; }
+
+int *Threads_GetMaxFD(void) { static int max_fd=32; return &max_fd; }
+char **Threads_GetCWD(void) { static char *cwd; return &cwd; }
+char **Threads_GetChroot(void) { static char *chroot; return &chroot; }
+
--- /dev/null
+/*
+ *
+ */
+#include <vfs_int.h>
+
+// === CODE ===
+tVFS_Handle *VFS_GetHandle(int ID)
+{
+ return NULL;
+}