-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start work on interrupt handlers and stuff
- Loading branch information
Showing
10 changed files
with
100 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
void heap_init(); | ||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
void* malloc(size_t size); | ||
void heap_init(); | ||
|
||
void free(void *ptr); | ||
void *kmalloc(size_t size); | ||
|
||
void kfree(void *ptr); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdlib.h> | ||
#include <kernel/heap.h> | ||
|
||
// TODO thats not how it works lol | ||
|
||
void *malloc(size_t size) | ||
{ | ||
return kmalloc(size); | ||
} | ||
|
||
void free(void *ptr) | ||
{ | ||
return kfree(ptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <stdlib.h> | ||
|
||
namespace nk | ||
{ | ||
|
||
template <typename T> | ||
class Vector | ||
{ | ||
private: | ||
T *data = nullptr; | ||
int index = 0; | ||
int capacity = 0; | ||
|
||
public: | ||
Vector() | ||
{ | ||
EnsureCapacity(5); | ||
} | ||
|
||
void Add(T obj) | ||
{ | ||
EnsureCapacity(index + 1); | ||
data[index] = T; | ||
index++; | ||
} | ||
|
||
private: | ||
void EnsureCapacity(int min) | ||
{ | ||
if (min > capacity) | ||
{ | ||
int newCapacity = min * 2; | ||
T *newData = malloc(sizeof(T) * newCapacity); | ||
if (this->data != nullptr) | ||
{ | ||
memcpy(newData, data, sizeof(T) * index); | ||
} | ||
this->data = newData; | ||
this->capacity = newCapacity; | ||
} | ||
} | ||
}; | ||
|
||
} // namespace nk |