diff --git a/TODO b/TODO index 0611116..19b6a49 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,13 @@ -- [x] Fix string_eq +- [ ] String + - [x] Fix string_eq + - [ ] String concat/add + - [ ] push/pop characters + - [ ] case related functions - [ ] Move function signatures to the *.h file - [ ] Sorting stuff +- [ ] Vec + - [ ] Pop + - [ ] getter/setter - [x] Random Libraries - [x] Mersenne Twister - [ ] add in u64 and f64 generation proper diff --git a/src/ableos_std/exit.h b/src/ableos_std/exit.h index 3adcefe..264a3d9 100644 --- a/src/ableos_std/exit.h +++ b/src/ableos_std/exit.h @@ -9,19 +9,29 @@ ExitCode ecode_new(char* ptr){ }; } -typedef ExitCode ExitCodeArray[255]; +// Not thread safe +// Luckily ableOS will not support OSThreads +typedef struct { + u16 count; + ExitCode exit_codes[]; +} ExitCodeArray; typedef struct { ExitCodeArray exit_code_registry; -}ExitCodeRegistry ; +} ExitCodeRegistry; ExitCodeRegistry exit_codes; -int exit_code_count = 0; -void register_exit_code(ExitCode ecode) { - exit_codes.exit_code_registry[exit_code_count] = ecode; - exit_code_count += 1; + +// Register an exit code in ableOS +// Returns: +// - A non-zero u8: When the exit code is registered +// - Zero: something has gone horrible +u16 register_exit_code(ExitCode ecode) { + exit_codes.exit_code_registry.exit_codes[exit_codes.exit_code_registry.count] = ecode; + exit_codes.exit_code_registry.count += 1; + return exit_codes.exit_code_registry.count - 1; } diff --git a/src/ableos_std/math/divide_up.h b/src/ableos_std/math/divide_up.h index 92f0e06..39abff5 100644 --- a/src/ableos_std/math/divide_up.h +++ b/src/ableos_std/math/divide_up.h @@ -1,4 +1,6 @@ /*Sadly sometimes dividing people in half is a bad thing actually*/ + + u8 divide_up_u8(u8 n, u8 d) { if (n % d == 0) { return n / d; diff --git a/src/ableos_std/process.c b/src/ableos_std/process.c index 69e2fed..006cb96 100644 --- a/src/ableos_std/process.c +++ b/src/ableos_std/process.c @@ -9,7 +9,6 @@ typedef enum { } ProcessResponse; ProcessID new_id(u64 host, u64 local) { - return (ProcessID) { .host = host, .local = local @@ -25,12 +24,12 @@ ProcessResponse terminate_process(ProcessID pid) { // This gives the starting process time to set it up ProcessID create_process() { trace("New process created"); - return new_id(0,0); + return new_id(0, 0); } // Start execution of a created process ProcessResponse start_process(ProcessID pid) { - trace("process started"); + trace("Process started."); return AlreadyRunning; } diff --git a/src/ableos_std/start.c b/src/ableos_std/start.c index f2efe8b..31af41d 100644 --- a/src/ableos_std/start.c +++ b/src/ableos_std/start.c @@ -1,8 +1,11 @@ #include + void _start() { + exit_codes.exit_code_registry.count = 0; register_exit_code(ecode_new("Success")); + int exit_code = main(); - char* ptr = exit_codes.exit_code_registry[exit_code].reason.ptr; + char* ptr = exit_codes.exit_code_registry.exit_codes[exit_code].reason.ptr; if (ptr == 0) { printf("Invalid ExitCode"); diff --git a/src/ableos_std/types/sys_id.h b/src/ableos_std/types/sys_id.h index 7176500..39b606c 100644 --- a/src/ableos_std/types/sys_id.h +++ b/src/ableos_std/types/sys_id.h @@ -1,18 +1,28 @@ // All System Resource IDs are declared here // as well as compound IDs + +// The Host Node ID of a Resource in an ableOS Cluster #define HostID u64 + +// The Localized Resource ID in an ableOS Cluster #define LocalID u64 typedef struct { + // The Host Node ID of a Process in an ableOS Cluster HostID host; + // The Local Node ID of a Process in an ableOS Cluster LocalID local; } ProcessID; typedef struct { + // The Host Node ID of a Buffer in an ableOS Cluster HostID host_id; + // The Local Node ID of a Buffer in an ableOS Cluster LocalID local_id; } BufferID; + + BufferID construct_buffer_id(HostID host_id, LocalID local_id){ return (BufferID) { .host_id = host_id, diff --git a/src/main.c b/src/main.c index 3c2f8a8..0165a7b 100644 --- a/src/main.c +++ b/src/main.c @@ -1,9 +1,13 @@ #include #include "ableos_std/ableos_std.c" + + + +// Sadly main must return int or it is a warning. int main() { - register_exit_code(ecode_new("File System Error")); - + u16 fs_exit_error = register_exit_code(ecode_new("File System Error")); + return 0; }