diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/kernel/include/memory.h b/src/kernel/include/memory.h index 60d8c0e..8a679d7 100644 --- a/src/kernel/include/memory.h +++ b/src/kernel/include/memory.h @@ -3,6 +3,16 @@ #include +typedef struct AllocationBlock { + uint8_t data[3948]; + uint32_t allocatedFine[32]; + uint32_t allocatedCoarse; + uint32_t blockSize; + struct AllocationBlock *next; + struct AllocationBlock *previous; + uint32_t magic; +} AllocationBlock; + typedef struct { uint32_t present : 1; uint32_t writable : 1; diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/kernel/include/memory.h b/src/kernel/include/memory.h index 60d8c0e..8a679d7 100644 --- a/src/kernel/include/memory.h +++ b/src/kernel/include/memory.h @@ -3,6 +3,16 @@ #include +typedef struct AllocationBlock { + uint8_t data[3948]; + uint32_t allocatedFine[32]; + uint32_t allocatedCoarse; + uint32_t blockSize; + struct AllocationBlock *next; + struct AllocationBlock *previous; + uint32_t magic; +} AllocationBlock; + typedef struct { uint32_t present : 1; uint32_t writable : 1; diff --git a/src/kernel/include/stringmap.h b/src/kernel/include/stringmap.h new file mode 100644 index 0000000..9ab2af0 --- /dev/null +++ b/src/kernel/include/stringmap.h @@ -0,0 +1,10 @@ +#ifndef STRINGMAP_H +#define STRINGMAP_H + +#include "stdint.h" + +extern uintptr_t insertString(char *string, uintptr_t size); +extern char *retrieveString(uintptr_t stringId, uintptr_t *size); +extern void discardString(uintptr_t stringId); + +#endif diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/kernel/include/memory.h b/src/kernel/include/memory.h index 60d8c0e..8a679d7 100644 --- a/src/kernel/include/memory.h +++ b/src/kernel/include/memory.h @@ -3,6 +3,16 @@ #include +typedef struct AllocationBlock { + uint8_t data[3948]; + uint32_t allocatedFine[32]; + uint32_t allocatedCoarse; + uint32_t blockSize; + struct AllocationBlock *next; + struct AllocationBlock *previous; + uint32_t magic; +} AllocationBlock; + typedef struct { uint32_t present : 1; uint32_t writable : 1; diff --git a/src/kernel/include/stringmap.h b/src/kernel/include/stringmap.h new file mode 100644 index 0000000..9ab2af0 --- /dev/null +++ b/src/kernel/include/stringmap.h @@ -0,0 +1,10 @@ +#ifndef STRINGMAP_H +#define STRINGMAP_H + +#include "stdint.h" + +extern uintptr_t insertString(char *string, uintptr_t size); +extern char *retrieveString(uintptr_t stringId, uintptr_t *size); +extern void discardString(uintptr_t stringId); + +#endif diff --git a/src/kernel/include/util.h b/src/kernel/include/util.h index a5e3154..44ed622 100644 --- a/src/kernel/include/util.h +++ b/src/kernel/include/util.h @@ -12,6 +12,7 @@ #define MIN(x, y) (x < y ? x : y) #define PAGE_COUNT(x) (((x - 1) / 4096) + 1) +#define BITS(x) (sizeof(x) * 8) extern bool stringEquals(char *string1, char *string2); extern char *combineStrings(char *string1, char *string2); diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/kernel/include/memory.h b/src/kernel/include/memory.h index 60d8c0e..8a679d7 100644 --- a/src/kernel/include/memory.h +++ b/src/kernel/include/memory.h @@ -3,6 +3,16 @@ #include +typedef struct AllocationBlock { + uint8_t data[3948]; + uint32_t allocatedFine[32]; + uint32_t allocatedCoarse; + uint32_t blockSize; + struct AllocationBlock *next; + struct AllocationBlock *previous; + uint32_t magic; +} AllocationBlock; + typedef struct { uint32_t present : 1; uint32_t writable : 1; diff --git a/src/kernel/include/stringmap.h b/src/kernel/include/stringmap.h new file mode 100644 index 0000000..9ab2af0 --- /dev/null +++ b/src/kernel/include/stringmap.h @@ -0,0 +1,10 @@ +#ifndef STRINGMAP_H +#define STRINGMAP_H + +#include "stdint.h" + +extern uintptr_t insertString(char *string, uintptr_t size); +extern char *retrieveString(uintptr_t stringId, uintptr_t *size); +extern void discardString(uintptr_t stringId); + +#endif diff --git a/src/kernel/include/util.h b/src/kernel/include/util.h index a5e3154..44ed622 100644 --- a/src/kernel/include/util.h +++ b/src/kernel/include/util.h @@ -12,6 +12,7 @@ #define MIN(x, y) (x < y ? x : y) #define PAGE_COUNT(x) (((x - 1) / 4096) + 1) +#define BITS(x) (sizeof(x) * 8) extern bool stringEquals(char *string1, char *string2); extern char *combineStrings(char *string1, char *string2); diff --git a/src/kernel/memory/malloc.h b/src/kernel/memory/malloc.h index 16e0c80..b9f010a 100644 --- a/src/kernel/memory/malloc.h +++ b/src/kernel/memory/malloc.h @@ -1,20 +1,11 @@ #ifndef ALLOC_H #define ALLOC_H +#include #include #define ALLOCATION_MAGIC 0x44BB33DD -typedef struct AllocationBlock { - uint8_t data[3948]; - uint32_t allocatedFine[32]; - uint32_t allocatedCoarse; - uint32_t blockSize; - struct AllocationBlock *next; - struct AllocationBlock *previous; - uint32_t magic; -} AllocationBlock; - typedef AllocationBlock *AllocationData[12]; #endif diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/kernel/include/memory.h b/src/kernel/include/memory.h index 60d8c0e..8a679d7 100644 --- a/src/kernel/include/memory.h +++ b/src/kernel/include/memory.h @@ -3,6 +3,16 @@ #include +typedef struct AllocationBlock { + uint8_t data[3948]; + uint32_t allocatedFine[32]; + uint32_t allocatedCoarse; + uint32_t blockSize; + struct AllocationBlock *next; + struct AllocationBlock *previous; + uint32_t magic; +} AllocationBlock; + typedef struct { uint32_t present : 1; uint32_t writable : 1; diff --git a/src/kernel/include/stringmap.h b/src/kernel/include/stringmap.h new file mode 100644 index 0000000..9ab2af0 --- /dev/null +++ b/src/kernel/include/stringmap.h @@ -0,0 +1,10 @@ +#ifndef STRINGMAP_H +#define STRINGMAP_H + +#include "stdint.h" + +extern uintptr_t insertString(char *string, uintptr_t size); +extern char *retrieveString(uintptr_t stringId, uintptr_t *size); +extern void discardString(uintptr_t stringId); + +#endif diff --git a/src/kernel/include/util.h b/src/kernel/include/util.h index a5e3154..44ed622 100644 --- a/src/kernel/include/util.h +++ b/src/kernel/include/util.h @@ -12,6 +12,7 @@ #define MIN(x, y) (x < y ? x : y) #define PAGE_COUNT(x) (((x - 1) / 4096) + 1) +#define BITS(x) (sizeof(x) * 8) extern bool stringEquals(char *string1, char *string2); extern char *combineStrings(char *string1, char *string2); diff --git a/src/kernel/memory/malloc.h b/src/kernel/memory/malloc.h index 16e0c80..b9f010a 100644 --- a/src/kernel/memory/malloc.h +++ b/src/kernel/memory/malloc.h @@ -1,20 +1,11 @@ #ifndef ALLOC_H #define ALLOC_H +#include #include #define ALLOCATION_MAGIC 0x44BB33DD -typedef struct AllocationBlock { - uint8_t data[3948]; - uint32_t allocatedFine[32]; - uint32_t allocatedCoarse; - uint32_t blockSize; - struct AllocationBlock *next; - struct AllocationBlock *previous; - uint32_t magic; -} AllocationBlock; - typedef AllocationBlock *AllocationData[12]; #endif diff --git a/src/kernel/stringmap/stringmap.c b/src/kernel/stringmap/stringmap.c new file mode 100644 index 0000000..6e0cea1 --- /dev/null +++ b/src/kernel/stringmap/stringmap.c @@ -0,0 +1,59 @@ +#include +#include +#include + +typedef void **MapLayer; + +static void *rootLayer[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +uintptr_t hashString(char *string, uintptr_t size) { + uintptr_t hash = 0; + for (uintptr_t i = 0; i < size; i++) { + hash = 257 * hash + string[i]; + } + return hash; +} + +uintptr_t insertString(char *string, uintptr_t size) { + uintptr_t hash = hashString(string, size); + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(hash >> startBit) & 0xF]; + if (!nextLayer) { + nextLayer = malloc(sizeof(uintptr_t) * 16); + memset(nextLayer, 0, sizeof(uintptr_t) * 16); + currentLayer[(hash >> startBit) & 0xF] = nextLayer; + } + currentLayer = nextLayer; + } + currentLayer[hash >> (BITS(uintptr_t) - 4)] = string; + return hash; +} + +char *retrieveString(uintptr_t stringId, uintptr_t *size) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + *size = 0; + return NULL; + } + currentLayer = nextLayer; + } + char *result = currentLayer[stringId >> (BITS(uintptr_t) - 4)]; + *size = strlen(result); + return result; +} + +void discardString(uintptr_t stringId) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < sizeof(uintptr_t) - 4; + startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + return; + } + currentLayer = nextLayer; + } + currentLayer[stringId >> (sizeof(uintptr_t) - 4)] = NULL; +} diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/kernel/include/memory.h b/src/kernel/include/memory.h index 60d8c0e..8a679d7 100644 --- a/src/kernel/include/memory.h +++ b/src/kernel/include/memory.h @@ -3,6 +3,16 @@ #include +typedef struct AllocationBlock { + uint8_t data[3948]; + uint32_t allocatedFine[32]; + uint32_t allocatedCoarse; + uint32_t blockSize; + struct AllocationBlock *next; + struct AllocationBlock *previous; + uint32_t magic; +} AllocationBlock; + typedef struct { uint32_t present : 1; uint32_t writable : 1; diff --git a/src/kernel/include/stringmap.h b/src/kernel/include/stringmap.h new file mode 100644 index 0000000..9ab2af0 --- /dev/null +++ b/src/kernel/include/stringmap.h @@ -0,0 +1,10 @@ +#ifndef STRINGMAP_H +#define STRINGMAP_H + +#include "stdint.h" + +extern uintptr_t insertString(char *string, uintptr_t size); +extern char *retrieveString(uintptr_t stringId, uintptr_t *size); +extern void discardString(uintptr_t stringId); + +#endif diff --git a/src/kernel/include/util.h b/src/kernel/include/util.h index a5e3154..44ed622 100644 --- a/src/kernel/include/util.h +++ b/src/kernel/include/util.h @@ -12,6 +12,7 @@ #define MIN(x, y) (x < y ? x : y) #define PAGE_COUNT(x) (((x - 1) / 4096) + 1) +#define BITS(x) (sizeof(x) * 8) extern bool stringEquals(char *string1, char *string2); extern char *combineStrings(char *string1, char *string2); diff --git a/src/kernel/memory/malloc.h b/src/kernel/memory/malloc.h index 16e0c80..b9f010a 100644 --- a/src/kernel/memory/malloc.h +++ b/src/kernel/memory/malloc.h @@ -1,20 +1,11 @@ #ifndef ALLOC_H #define ALLOC_H +#include #include #define ALLOCATION_MAGIC 0x44BB33DD -typedef struct AllocationBlock { - uint8_t data[3948]; - uint32_t allocatedFine[32]; - uint32_t allocatedCoarse; - uint32_t blockSize; - struct AllocationBlock *next; - struct AllocationBlock *previous; - uint32_t magic; -} AllocationBlock; - typedef AllocationBlock *AllocationData[12]; #endif diff --git a/src/kernel/stringmap/stringmap.c b/src/kernel/stringmap/stringmap.c new file mode 100644 index 0000000..6e0cea1 --- /dev/null +++ b/src/kernel/stringmap/stringmap.c @@ -0,0 +1,59 @@ +#include +#include +#include + +typedef void **MapLayer; + +static void *rootLayer[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +uintptr_t hashString(char *string, uintptr_t size) { + uintptr_t hash = 0; + for (uintptr_t i = 0; i < size; i++) { + hash = 257 * hash + string[i]; + } + return hash; +} + +uintptr_t insertString(char *string, uintptr_t size) { + uintptr_t hash = hashString(string, size); + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(hash >> startBit) & 0xF]; + if (!nextLayer) { + nextLayer = malloc(sizeof(uintptr_t) * 16); + memset(nextLayer, 0, sizeof(uintptr_t) * 16); + currentLayer[(hash >> startBit) & 0xF] = nextLayer; + } + currentLayer = nextLayer; + } + currentLayer[hash >> (BITS(uintptr_t) - 4)] = string; + return hash; +} + +char *retrieveString(uintptr_t stringId, uintptr_t *size) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + *size = 0; + return NULL; + } + currentLayer = nextLayer; + } + char *result = currentLayer[stringId >> (BITS(uintptr_t) - 4)]; + *size = strlen(result); + return result; +} + +void discardString(uintptr_t stringId) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < sizeof(uintptr_t) - 4; + startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + return; + } + currentLayer = nextLayer; + } + currentLayer[stringId >> (sizeof(uintptr_t) - 4)] = NULL; +} diff --git a/src/kernel/stringmap/stringmapSyscalls.c b/src/kernel/stringmap/stringmapSyscalls.c new file mode 100644 index 0000000..262a6f3 --- /dev/null +++ b/src/kernel/stringmap/stringmapSyscalls.c @@ -0,0 +1,21 @@ +#include +#include +#include + +void handleInsertStringSyscall(Syscall *call) { + Service *callService = call->service; + void *string = kernelMapPhysical(getPhysicalAddress( + callService->pagingInfo.pageDirectory, PTR(call->parameters[0]))); + uintptr_t size = call->parameters[1]; + char *savedString = malloc(size + 1); + memcpy(string, savedString, size); + savedString[size] = 0; + call->returnValue = insertString(savedString, size); + unmapPage(string); +} + +void handleReadStringLengthSyscall(Syscall *call) { + uintptr_t size, stringId = call->parameters[0]; + char *string = retrieveString(stringId, &size); + call->returnValue = size; +} diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/kernel/include/memory.h b/src/kernel/include/memory.h index 60d8c0e..8a679d7 100644 --- a/src/kernel/include/memory.h +++ b/src/kernel/include/memory.h @@ -3,6 +3,16 @@ #include +typedef struct AllocationBlock { + uint8_t data[3948]; + uint32_t allocatedFine[32]; + uint32_t allocatedCoarse; + uint32_t blockSize; + struct AllocationBlock *next; + struct AllocationBlock *previous; + uint32_t magic; +} AllocationBlock; + typedef struct { uint32_t present : 1; uint32_t writable : 1; diff --git a/src/kernel/include/stringmap.h b/src/kernel/include/stringmap.h new file mode 100644 index 0000000..9ab2af0 --- /dev/null +++ b/src/kernel/include/stringmap.h @@ -0,0 +1,10 @@ +#ifndef STRINGMAP_H +#define STRINGMAP_H + +#include "stdint.h" + +extern uintptr_t insertString(char *string, uintptr_t size); +extern char *retrieveString(uintptr_t stringId, uintptr_t *size); +extern void discardString(uintptr_t stringId); + +#endif diff --git a/src/kernel/include/util.h b/src/kernel/include/util.h index a5e3154..44ed622 100644 --- a/src/kernel/include/util.h +++ b/src/kernel/include/util.h @@ -12,6 +12,7 @@ #define MIN(x, y) (x < y ? x : y) #define PAGE_COUNT(x) (((x - 1) / 4096) + 1) +#define BITS(x) (sizeof(x) * 8) extern bool stringEquals(char *string1, char *string2); extern char *combineStrings(char *string1, char *string2); diff --git a/src/kernel/memory/malloc.h b/src/kernel/memory/malloc.h index 16e0c80..b9f010a 100644 --- a/src/kernel/memory/malloc.h +++ b/src/kernel/memory/malloc.h @@ -1,20 +1,11 @@ #ifndef ALLOC_H #define ALLOC_H +#include #include #define ALLOCATION_MAGIC 0x44BB33DD -typedef struct AllocationBlock { - uint8_t data[3948]; - uint32_t allocatedFine[32]; - uint32_t allocatedCoarse; - uint32_t blockSize; - struct AllocationBlock *next; - struct AllocationBlock *previous; - uint32_t magic; -} AllocationBlock; - typedef AllocationBlock *AllocationData[12]; #endif diff --git a/src/kernel/stringmap/stringmap.c b/src/kernel/stringmap/stringmap.c new file mode 100644 index 0000000..6e0cea1 --- /dev/null +++ b/src/kernel/stringmap/stringmap.c @@ -0,0 +1,59 @@ +#include +#include +#include + +typedef void **MapLayer; + +static void *rootLayer[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +uintptr_t hashString(char *string, uintptr_t size) { + uintptr_t hash = 0; + for (uintptr_t i = 0; i < size; i++) { + hash = 257 * hash + string[i]; + } + return hash; +} + +uintptr_t insertString(char *string, uintptr_t size) { + uintptr_t hash = hashString(string, size); + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(hash >> startBit) & 0xF]; + if (!nextLayer) { + nextLayer = malloc(sizeof(uintptr_t) * 16); + memset(nextLayer, 0, sizeof(uintptr_t) * 16); + currentLayer[(hash >> startBit) & 0xF] = nextLayer; + } + currentLayer = nextLayer; + } + currentLayer[hash >> (BITS(uintptr_t) - 4)] = string; + return hash; +} + +char *retrieveString(uintptr_t stringId, uintptr_t *size) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + *size = 0; + return NULL; + } + currentLayer = nextLayer; + } + char *result = currentLayer[stringId >> (BITS(uintptr_t) - 4)]; + *size = strlen(result); + return result; +} + +void discardString(uintptr_t stringId) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < sizeof(uintptr_t) - 4; + startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + return; + } + currentLayer = nextLayer; + } + currentLayer[stringId >> (sizeof(uintptr_t) - 4)] = NULL; +} diff --git a/src/kernel/stringmap/stringmapSyscalls.c b/src/kernel/stringmap/stringmapSyscalls.c new file mode 100644 index 0000000..262a6f3 --- /dev/null +++ b/src/kernel/stringmap/stringmapSyscalls.c @@ -0,0 +1,21 @@ +#include +#include +#include + +void handleInsertStringSyscall(Syscall *call) { + Service *callService = call->service; + void *string = kernelMapPhysical(getPhysicalAddress( + callService->pagingInfo.pageDirectory, PTR(call->parameters[0]))); + uintptr_t size = call->parameters[1]; + char *savedString = malloc(size + 1); + memcpy(string, savedString, size); + savedString[size] = 0; + call->returnValue = insertString(savedString, size); + unmapPage(string); +} + +void handleReadStringLengthSyscall(Syscall *call) { + uintptr_t size, stringId = call->parameters[0]; + char *string = retrieveString(stringId, &size); + call->returnValue = size; +} diff --git a/src/kernel/syscalls/syscall.c b/src/kernel/syscalls/syscall.c index 168c54b..e00c358 100644 --- a/src/kernel/syscalls/syscall.c +++ b/src/kernel/syscalls/syscall.c @@ -56,6 +56,7 @@ extern uintptr_t handleCreateEventSyscall, handleGetEventSyscall, handleFireEventSyscall, handleSubscribeEventSyscall; extern uintptr_t handleSubscribeInterruptSyscall; +extern uintptr_t handleInsertStringSyscall, handleReadStringLengthSyscall; void (*syscallHandlers[])(Syscall *) = { 0, @@ -72,6 +73,8 @@ (void *)&handleFireEventSyscall, (void *)&handleSubscribeEventSyscall, (void *)&handleGetServiceIdSyscall, + (void *)&handleInsertStringSyscall, + (void *)&handleReadStringLengthSyscall, }; void processSyscall(Syscall *call) { diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/kernel/include/memory.h b/src/kernel/include/memory.h index 60d8c0e..8a679d7 100644 --- a/src/kernel/include/memory.h +++ b/src/kernel/include/memory.h @@ -3,6 +3,16 @@ #include +typedef struct AllocationBlock { + uint8_t data[3948]; + uint32_t allocatedFine[32]; + uint32_t allocatedCoarse; + uint32_t blockSize; + struct AllocationBlock *next; + struct AllocationBlock *previous; + uint32_t magic; +} AllocationBlock; + typedef struct { uint32_t present : 1; uint32_t writable : 1; diff --git a/src/kernel/include/stringmap.h b/src/kernel/include/stringmap.h new file mode 100644 index 0000000..9ab2af0 --- /dev/null +++ b/src/kernel/include/stringmap.h @@ -0,0 +1,10 @@ +#ifndef STRINGMAP_H +#define STRINGMAP_H + +#include "stdint.h" + +extern uintptr_t insertString(char *string, uintptr_t size); +extern char *retrieveString(uintptr_t stringId, uintptr_t *size); +extern void discardString(uintptr_t stringId); + +#endif diff --git a/src/kernel/include/util.h b/src/kernel/include/util.h index a5e3154..44ed622 100644 --- a/src/kernel/include/util.h +++ b/src/kernel/include/util.h @@ -12,6 +12,7 @@ #define MIN(x, y) (x < y ? x : y) #define PAGE_COUNT(x) (((x - 1) / 4096) + 1) +#define BITS(x) (sizeof(x) * 8) extern bool stringEquals(char *string1, char *string2); extern char *combineStrings(char *string1, char *string2); diff --git a/src/kernel/memory/malloc.h b/src/kernel/memory/malloc.h index 16e0c80..b9f010a 100644 --- a/src/kernel/memory/malloc.h +++ b/src/kernel/memory/malloc.h @@ -1,20 +1,11 @@ #ifndef ALLOC_H #define ALLOC_H +#include #include #define ALLOCATION_MAGIC 0x44BB33DD -typedef struct AllocationBlock { - uint8_t data[3948]; - uint32_t allocatedFine[32]; - uint32_t allocatedCoarse; - uint32_t blockSize; - struct AllocationBlock *next; - struct AllocationBlock *previous; - uint32_t magic; -} AllocationBlock; - typedef AllocationBlock *AllocationData[12]; #endif diff --git a/src/kernel/stringmap/stringmap.c b/src/kernel/stringmap/stringmap.c new file mode 100644 index 0000000..6e0cea1 --- /dev/null +++ b/src/kernel/stringmap/stringmap.c @@ -0,0 +1,59 @@ +#include +#include +#include + +typedef void **MapLayer; + +static void *rootLayer[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +uintptr_t hashString(char *string, uintptr_t size) { + uintptr_t hash = 0; + for (uintptr_t i = 0; i < size; i++) { + hash = 257 * hash + string[i]; + } + return hash; +} + +uintptr_t insertString(char *string, uintptr_t size) { + uintptr_t hash = hashString(string, size); + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(hash >> startBit) & 0xF]; + if (!nextLayer) { + nextLayer = malloc(sizeof(uintptr_t) * 16); + memset(nextLayer, 0, sizeof(uintptr_t) * 16); + currentLayer[(hash >> startBit) & 0xF] = nextLayer; + } + currentLayer = nextLayer; + } + currentLayer[hash >> (BITS(uintptr_t) - 4)] = string; + return hash; +} + +char *retrieveString(uintptr_t stringId, uintptr_t *size) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + *size = 0; + return NULL; + } + currentLayer = nextLayer; + } + char *result = currentLayer[stringId >> (BITS(uintptr_t) - 4)]; + *size = strlen(result); + return result; +} + +void discardString(uintptr_t stringId) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < sizeof(uintptr_t) - 4; + startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + return; + } + currentLayer = nextLayer; + } + currentLayer[stringId >> (sizeof(uintptr_t) - 4)] = NULL; +} diff --git a/src/kernel/stringmap/stringmapSyscalls.c b/src/kernel/stringmap/stringmapSyscalls.c new file mode 100644 index 0000000..262a6f3 --- /dev/null +++ b/src/kernel/stringmap/stringmapSyscalls.c @@ -0,0 +1,21 @@ +#include +#include +#include + +void handleInsertStringSyscall(Syscall *call) { + Service *callService = call->service; + void *string = kernelMapPhysical(getPhysicalAddress( + callService->pagingInfo.pageDirectory, PTR(call->parameters[0]))); + uintptr_t size = call->parameters[1]; + char *savedString = malloc(size + 1); + memcpy(string, savedString, size); + savedString[size] = 0; + call->returnValue = insertString(savedString, size); + unmapPage(string); +} + +void handleReadStringLengthSyscall(Syscall *call) { + uintptr_t size, stringId = call->parameters[0]; + char *string = retrieveString(stringId, &size); + call->returnValue = size; +} diff --git a/src/kernel/syscalls/syscall.c b/src/kernel/syscalls/syscall.c index 168c54b..e00c358 100644 --- a/src/kernel/syscalls/syscall.c +++ b/src/kernel/syscalls/syscall.c @@ -56,6 +56,7 @@ extern uintptr_t handleCreateEventSyscall, handleGetEventSyscall, handleFireEventSyscall, handleSubscribeEventSyscall; extern uintptr_t handleSubscribeInterruptSyscall; +extern uintptr_t handleInsertStringSyscall, handleReadStringLengthSyscall; void (*syscallHandlers[])(Syscall *) = { 0, @@ -72,6 +73,8 @@ (void *)&handleFireEventSyscall, (void *)&handleSubscribeEventSyscall, (void *)&handleGetServiceIdSyscall, + (void *)&handleInsertStringSyscall, + (void *)&handleReadStringLengthSyscall, }; void processSyscall(Syscall *call) { diff --git a/src/userland/hlib/include/syscalls.h b/src/userland/hlib/include/syscalls.h index 8c27ac7..f2344c1 100644 --- a/src/userland/hlib/include/syscalls.h +++ b/src/userland/hlib/include/syscalls.h @@ -19,6 +19,8 @@ SYS_FIRE_EVENT = 11, SYS_SUBSCRIBE_EVENT = 12, SYS_GET_SERVICE_ID = 13, + SYS_INSERT_STRING = 14, + SYS_GET_STRING_LENGTH = 15, } SyscallIds; #endif diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/kernel/include/memory.h b/src/kernel/include/memory.h index 60d8c0e..8a679d7 100644 --- a/src/kernel/include/memory.h +++ b/src/kernel/include/memory.h @@ -3,6 +3,16 @@ #include +typedef struct AllocationBlock { + uint8_t data[3948]; + uint32_t allocatedFine[32]; + uint32_t allocatedCoarse; + uint32_t blockSize; + struct AllocationBlock *next; + struct AllocationBlock *previous; + uint32_t magic; +} AllocationBlock; + typedef struct { uint32_t present : 1; uint32_t writable : 1; diff --git a/src/kernel/include/stringmap.h b/src/kernel/include/stringmap.h new file mode 100644 index 0000000..9ab2af0 --- /dev/null +++ b/src/kernel/include/stringmap.h @@ -0,0 +1,10 @@ +#ifndef STRINGMAP_H +#define STRINGMAP_H + +#include "stdint.h" + +extern uintptr_t insertString(char *string, uintptr_t size); +extern char *retrieveString(uintptr_t stringId, uintptr_t *size); +extern void discardString(uintptr_t stringId); + +#endif diff --git a/src/kernel/include/util.h b/src/kernel/include/util.h index a5e3154..44ed622 100644 --- a/src/kernel/include/util.h +++ b/src/kernel/include/util.h @@ -12,6 +12,7 @@ #define MIN(x, y) (x < y ? x : y) #define PAGE_COUNT(x) (((x - 1) / 4096) + 1) +#define BITS(x) (sizeof(x) * 8) extern bool stringEquals(char *string1, char *string2); extern char *combineStrings(char *string1, char *string2); diff --git a/src/kernel/memory/malloc.h b/src/kernel/memory/malloc.h index 16e0c80..b9f010a 100644 --- a/src/kernel/memory/malloc.h +++ b/src/kernel/memory/malloc.h @@ -1,20 +1,11 @@ #ifndef ALLOC_H #define ALLOC_H +#include #include #define ALLOCATION_MAGIC 0x44BB33DD -typedef struct AllocationBlock { - uint8_t data[3948]; - uint32_t allocatedFine[32]; - uint32_t allocatedCoarse; - uint32_t blockSize; - struct AllocationBlock *next; - struct AllocationBlock *previous; - uint32_t magic; -} AllocationBlock; - typedef AllocationBlock *AllocationData[12]; #endif diff --git a/src/kernel/stringmap/stringmap.c b/src/kernel/stringmap/stringmap.c new file mode 100644 index 0000000..6e0cea1 --- /dev/null +++ b/src/kernel/stringmap/stringmap.c @@ -0,0 +1,59 @@ +#include +#include +#include + +typedef void **MapLayer; + +static void *rootLayer[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +uintptr_t hashString(char *string, uintptr_t size) { + uintptr_t hash = 0; + for (uintptr_t i = 0; i < size; i++) { + hash = 257 * hash + string[i]; + } + return hash; +} + +uintptr_t insertString(char *string, uintptr_t size) { + uintptr_t hash = hashString(string, size); + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(hash >> startBit) & 0xF]; + if (!nextLayer) { + nextLayer = malloc(sizeof(uintptr_t) * 16); + memset(nextLayer, 0, sizeof(uintptr_t) * 16); + currentLayer[(hash >> startBit) & 0xF] = nextLayer; + } + currentLayer = nextLayer; + } + currentLayer[hash >> (BITS(uintptr_t) - 4)] = string; + return hash; +} + +char *retrieveString(uintptr_t stringId, uintptr_t *size) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + *size = 0; + return NULL; + } + currentLayer = nextLayer; + } + char *result = currentLayer[stringId >> (BITS(uintptr_t) - 4)]; + *size = strlen(result); + return result; +} + +void discardString(uintptr_t stringId) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < sizeof(uintptr_t) - 4; + startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + return; + } + currentLayer = nextLayer; + } + currentLayer[stringId >> (sizeof(uintptr_t) - 4)] = NULL; +} diff --git a/src/kernel/stringmap/stringmapSyscalls.c b/src/kernel/stringmap/stringmapSyscalls.c new file mode 100644 index 0000000..262a6f3 --- /dev/null +++ b/src/kernel/stringmap/stringmapSyscalls.c @@ -0,0 +1,21 @@ +#include +#include +#include + +void handleInsertStringSyscall(Syscall *call) { + Service *callService = call->service; + void *string = kernelMapPhysical(getPhysicalAddress( + callService->pagingInfo.pageDirectory, PTR(call->parameters[0]))); + uintptr_t size = call->parameters[1]; + char *savedString = malloc(size + 1); + memcpy(string, savedString, size); + savedString[size] = 0; + call->returnValue = insertString(savedString, size); + unmapPage(string); +} + +void handleReadStringLengthSyscall(Syscall *call) { + uintptr_t size, stringId = call->parameters[0]; + char *string = retrieveString(stringId, &size); + call->returnValue = size; +} diff --git a/src/kernel/syscalls/syscall.c b/src/kernel/syscalls/syscall.c index 168c54b..e00c358 100644 --- a/src/kernel/syscalls/syscall.c +++ b/src/kernel/syscalls/syscall.c @@ -56,6 +56,7 @@ extern uintptr_t handleCreateEventSyscall, handleGetEventSyscall, handleFireEventSyscall, handleSubscribeEventSyscall; extern uintptr_t handleSubscribeInterruptSyscall; +extern uintptr_t handleInsertStringSyscall, handleReadStringLengthSyscall; void (*syscallHandlers[])(Syscall *) = { 0, @@ -72,6 +73,8 @@ (void *)&handleFireEventSyscall, (void *)&handleSubscribeEventSyscall, (void *)&handleGetServiceIdSyscall, + (void *)&handleInsertStringSyscall, + (void *)&handleReadStringLengthSyscall, }; void processSyscall(Syscall *call) { diff --git a/src/userland/hlib/include/syscalls.h b/src/userland/hlib/include/syscalls.h index 8c27ac7..f2344c1 100644 --- a/src/userland/hlib/include/syscalls.h +++ b/src/userland/hlib/include/syscalls.h @@ -19,6 +19,8 @@ SYS_FIRE_EVENT = 11, SYS_SUBSCRIBE_EVENT = 12, SYS_GET_SERVICE_ID = 13, + SYS_INSERT_STRING = 14, + SYS_GET_STRING_LENGTH = 15, } SyscallIds; #endif diff --git a/src/userland/hlib/main.c b/src/userland/hlib/main.c index f0b855a..6e9f93f 100644 --- a/src/userland/hlib/main.c +++ b/src/userland/hlib/main.c @@ -82,3 +82,11 @@ } uint32_t getServiceId() { return syscall(SYS_GET_SERVICE_ID, 0, 0, 0, 0); } + +uintptr_t insertString(char *string, uintptr_t size) { + return syscall(SYS_INSERT_STRING, U32(string), size, 0, 0); +} + +uintptr_t getStringLength(uintptr_t stringId) { + return syscall(SYS_GET_STRING_LENGTH, stringId, 0, 0, 0); +} diff --git a/src/include/hlib.h b/src/include/hlib.h index f517ea2..fed57d9 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -29,5 +29,7 @@ extern void request(uint32_t service, uint32_t provider, void *data, uint32_t size); extern uint32_t getServiceId(); +extern uintptr_t insertString(char *string, uintptr_t size); +extern uintptr_t getStringLength(uintptr_t stringId); #endif diff --git a/src/kernel/include/memory.h b/src/kernel/include/memory.h index 60d8c0e..8a679d7 100644 --- a/src/kernel/include/memory.h +++ b/src/kernel/include/memory.h @@ -3,6 +3,16 @@ #include +typedef struct AllocationBlock { + uint8_t data[3948]; + uint32_t allocatedFine[32]; + uint32_t allocatedCoarse; + uint32_t blockSize; + struct AllocationBlock *next; + struct AllocationBlock *previous; + uint32_t magic; +} AllocationBlock; + typedef struct { uint32_t present : 1; uint32_t writable : 1; diff --git a/src/kernel/include/stringmap.h b/src/kernel/include/stringmap.h new file mode 100644 index 0000000..9ab2af0 --- /dev/null +++ b/src/kernel/include/stringmap.h @@ -0,0 +1,10 @@ +#ifndef STRINGMAP_H +#define STRINGMAP_H + +#include "stdint.h" + +extern uintptr_t insertString(char *string, uintptr_t size); +extern char *retrieveString(uintptr_t stringId, uintptr_t *size); +extern void discardString(uintptr_t stringId); + +#endif diff --git a/src/kernel/include/util.h b/src/kernel/include/util.h index a5e3154..44ed622 100644 --- a/src/kernel/include/util.h +++ b/src/kernel/include/util.h @@ -12,6 +12,7 @@ #define MIN(x, y) (x < y ? x : y) #define PAGE_COUNT(x) (((x - 1) / 4096) + 1) +#define BITS(x) (sizeof(x) * 8) extern bool stringEquals(char *string1, char *string2); extern char *combineStrings(char *string1, char *string2); diff --git a/src/kernel/memory/malloc.h b/src/kernel/memory/malloc.h index 16e0c80..b9f010a 100644 --- a/src/kernel/memory/malloc.h +++ b/src/kernel/memory/malloc.h @@ -1,20 +1,11 @@ #ifndef ALLOC_H #define ALLOC_H +#include #include #define ALLOCATION_MAGIC 0x44BB33DD -typedef struct AllocationBlock { - uint8_t data[3948]; - uint32_t allocatedFine[32]; - uint32_t allocatedCoarse; - uint32_t blockSize; - struct AllocationBlock *next; - struct AllocationBlock *previous; - uint32_t magic; -} AllocationBlock; - typedef AllocationBlock *AllocationData[12]; #endif diff --git a/src/kernel/stringmap/stringmap.c b/src/kernel/stringmap/stringmap.c new file mode 100644 index 0000000..6e0cea1 --- /dev/null +++ b/src/kernel/stringmap/stringmap.c @@ -0,0 +1,59 @@ +#include +#include +#include + +typedef void **MapLayer; + +static void *rootLayer[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +uintptr_t hashString(char *string, uintptr_t size) { + uintptr_t hash = 0; + for (uintptr_t i = 0; i < size; i++) { + hash = 257 * hash + string[i]; + } + return hash; +} + +uintptr_t insertString(char *string, uintptr_t size) { + uintptr_t hash = hashString(string, size); + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(hash >> startBit) & 0xF]; + if (!nextLayer) { + nextLayer = malloc(sizeof(uintptr_t) * 16); + memset(nextLayer, 0, sizeof(uintptr_t) * 16); + currentLayer[(hash >> startBit) & 0xF] = nextLayer; + } + currentLayer = nextLayer; + } + currentLayer[hash >> (BITS(uintptr_t) - 4)] = string; + return hash; +} + +char *retrieveString(uintptr_t stringId, uintptr_t *size) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < BITS(uintptr_t) - 4; startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + *size = 0; + return NULL; + } + currentLayer = nextLayer; + } + char *result = currentLayer[stringId >> (BITS(uintptr_t) - 4)]; + *size = strlen(result); + return result; +} + +void discardString(uintptr_t stringId) { + MapLayer currentLayer = rootLayer; + for (uint32_t startBit = 0; startBit < sizeof(uintptr_t) - 4; + startBit += 4) { + void *nextLayer = currentLayer[(stringId >> startBit) & 0xF]; + if (!nextLayer) { + return; + } + currentLayer = nextLayer; + } + currentLayer[stringId >> (sizeof(uintptr_t) - 4)] = NULL; +} diff --git a/src/kernel/stringmap/stringmapSyscalls.c b/src/kernel/stringmap/stringmapSyscalls.c new file mode 100644 index 0000000..262a6f3 --- /dev/null +++ b/src/kernel/stringmap/stringmapSyscalls.c @@ -0,0 +1,21 @@ +#include +#include +#include + +void handleInsertStringSyscall(Syscall *call) { + Service *callService = call->service; + void *string = kernelMapPhysical(getPhysicalAddress( + callService->pagingInfo.pageDirectory, PTR(call->parameters[0]))); + uintptr_t size = call->parameters[1]; + char *savedString = malloc(size + 1); + memcpy(string, savedString, size); + savedString[size] = 0; + call->returnValue = insertString(savedString, size); + unmapPage(string); +} + +void handleReadStringLengthSyscall(Syscall *call) { + uintptr_t size, stringId = call->parameters[0]; + char *string = retrieveString(stringId, &size); + call->returnValue = size; +} diff --git a/src/kernel/syscalls/syscall.c b/src/kernel/syscalls/syscall.c index 168c54b..e00c358 100644 --- a/src/kernel/syscalls/syscall.c +++ b/src/kernel/syscalls/syscall.c @@ -56,6 +56,7 @@ extern uintptr_t handleCreateEventSyscall, handleGetEventSyscall, handleFireEventSyscall, handleSubscribeEventSyscall; extern uintptr_t handleSubscribeInterruptSyscall; +extern uintptr_t handleInsertStringSyscall, handleReadStringLengthSyscall; void (*syscallHandlers[])(Syscall *) = { 0, @@ -72,6 +73,8 @@ (void *)&handleFireEventSyscall, (void *)&handleSubscribeEventSyscall, (void *)&handleGetServiceIdSyscall, + (void *)&handleInsertStringSyscall, + (void *)&handleReadStringLengthSyscall, }; void processSyscall(Syscall *call) { diff --git a/src/userland/hlib/include/syscalls.h b/src/userland/hlib/include/syscalls.h index 8c27ac7..f2344c1 100644 --- a/src/userland/hlib/include/syscalls.h +++ b/src/userland/hlib/include/syscalls.h @@ -19,6 +19,8 @@ SYS_FIRE_EVENT = 11, SYS_SUBSCRIBE_EVENT = 12, SYS_GET_SERVICE_ID = 13, + SYS_INSERT_STRING = 14, + SYS_GET_STRING_LENGTH = 15, } SyscallIds; #endif diff --git a/src/userland/hlib/main.c b/src/userland/hlib/main.c index f0b855a..6e9f93f 100644 --- a/src/userland/hlib/main.c +++ b/src/userland/hlib/main.c @@ -82,3 +82,11 @@ } uint32_t getServiceId() { return syscall(SYS_GET_SERVICE_ID, 0, 0, 0, 0); } + +uintptr_t insertString(char *string, uintptr_t size) { + return syscall(SYS_INSERT_STRING, U32(string), size, 0, 0); +} + +uintptr_t getStringLength(uintptr_t stringId) { + return syscall(SYS_GET_STRING_LENGTH, stringId, 0, 0, 0); +} diff --git a/src/userland/loader/main.c b/src/userland/loader/main.c index 5569b1f..075f44e 100644 --- a/src/userland/loader/main.c +++ b/src/userland/loader/main.c @@ -1,6 +1,9 @@ #include #include +char *testString = "hello world"; +char *lengthString = "0"; + int32_t main() { loadFromInitrd("log"); loadFromInitrd("parallel"); @@ -8,5 +11,10 @@ log("honey os is alive :)"); loadFromInitrd("pic"); loadFromInitrd("keyboard"); + log(testString); + uintptr_t id = insertString(testString, strlen(testString)); + uintptr_t length = getStringLength(id); + lengthString[0] += length; + log(lengthString); return 0; }