Up the maximum count of error codes in ableOS

main
able 2024-01-24 05:13:42 -06:00
parent d150e77aaa
commit 8f4e7cfc87
7 changed files with 48 additions and 13 deletions

9
TODO
View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -1,8 +1,11 @@
#include <stdlib.h>
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");

View File

@ -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,

View File

@ -1,9 +1,13 @@
#include <stdio.h>
#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;
}