This commit is contained in:
nub31
2025-09-03 13:44:44 +02:00
parent 204c747c43
commit 08bbe517c5
20 changed files with 44 additions and 48 deletions

View File

@@ -13,3 +13,6 @@ CompileFlags:
- "-nostdlib" - "-nostdlib"
- "-I" - "-I"
- "/home/oliste/repos/nub-os/src/stdlib" - "/home/oliste/repos/nub-os/src/stdlib"
Style:
AngledHeaders: "src/stdlib/.*"

View File

@@ -1,17 +1,18 @@
#pragma once #pragma once
#include "stdint.h" #include <stddef.h>
#include <stdint.h>
typedef struct typedef struct
{ {
uint64_t base_address; uint64_t base_address;
uint64_t length; size_t length;
} memory_region_t; } memory_region_t;
typedef struct typedef struct
{ {
uint64_t num_regions;
memory_region_t* regions; memory_region_t* regions;
size_t num_regions;
} memory_map_t; } memory_map_t;
extern memory_map_t memory_map; extern memory_map_t memory_map;

View File

@@ -1,7 +1,7 @@
#include "interrupts.h" #include "interrupts.h"
#include "../arch.h" #include "../arch.h"
#include "stdio.h"
#include "util.h" #include "util.h"
#include <stdio.h>
#define PIC1_COMMAND 0x20 #define PIC1_COMMAND 0x20
#define PIC1_DATA 0x21 #define PIC1_DATA 0x21

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include "stdbool.h" #include <stdbool.h>
#include "stdint.h" #include <stdint.h>
typedef struct typedef struct
{ {

View File

@@ -1,7 +1,7 @@
// #include "keyboard.h" // #include "keyboard.h"
// #include "interrupts.h" // #include "interrupts.h"
// #include "util.h" // #include "util.h"
// #include "stddef.h" // #include <stddef.h>
// #define SCANCODE_LEFT_SHIFT 42 // #define SCANCODE_LEFT_SHIFT 42
// #define SCANCODE_RIGHT_SHIFT 54 // #define SCANCODE_RIGHT_SHIFT 54

View File

@@ -1,7 +1,7 @@
// #pragma once // #pragma once
// #include "stdbool.h" // #include <stdbool.h>
// #include "stdint.h" // #include <stdint.h>
// typedef struct // typedef struct
// { // {

View File

@@ -1,7 +1,7 @@
#include "mmap.h" #include "mmap.h"
#include "../mmap.h" #include "../mmap.h"
#include "stddef.h" #include <stddef.h>
#include "stdio.h" #include <stdio.h>
#define USABLE_REGION_SIZE 32 #define USABLE_REGION_SIZE 32

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include "stdint.h" #include <stdint.h>
enum enum
{ {

View File

@@ -1,5 +1,5 @@
#include "vga.h" #include "vga.h"
#include "stddef.h" #include <stddef.h>
#define ROWS 25 #define ROWS 25
#define COLUMNS 80 #define COLUMNS 80

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include "stdint.h" #include <stdint.h>
#define VGA_BLACK 0 #define VGA_BLACK 0
#define VGA_BLUE 1 #define VGA_BLUE 1

View File

@@ -3,10 +3,9 @@
#include "interrupts.h" #include "interrupts.h"
#include "mmap.h" #include "mmap.h"
#include "multiboot.h" #include "multiboot.h"
#include "stddef.h"
#include "stdio.h"
#include "util.h" #include "util.h"
#include "vga.h" #include "vga.h"
#include <stdio.h>
void entry(multiboot_info_t* mbd) void entry(multiboot_info_t* mbd)
{ {
@@ -14,7 +13,7 @@ void entry(multiboot_info_t* mbd)
map_memory(mbd); map_memory(mbd);
remap_pic(); remap_pic();
enable_interrupts(); enable_interrupts();
kmain(); main();
} }
void arch_callback() void arch_callback()

View File

@@ -1,8 +1,8 @@
#include "kernel.h" #include "kernel.h"
#include "pmm.h" #include "pmm.h"
#include "stdio.h" #include <stdio.h>
void kmain() void main()
{ {
init_pmm(); init_pmm();
printf("Welcome to nub OS :)\n"); printf("Welcome to nub OS :)\n");

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
void kmain(); void main();

View File

@@ -1,8 +1,8 @@
#include "pmm.h" #include "pmm.h"
#include "arch/mmap.h" #include "arch/mmap.h"
#include "mem.h" #include <stddef.h>
#include "stddef.h" #include <stdio.h>
#include "stdio.h" #include <string.h>
#define BITMAP_SIZE 32768 // Supports up to 1GB of RAM #define BITMAP_SIZE 32768 // Supports up to 1GB of RAM
#define USABLE_REGION_SIZE 32 #define USABLE_REGION_SIZE 32

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include "stdint.h" #include <stdint.h>
#define PAGE_SIZE 4096 #define PAGE_SIZE 4096

View File

@@ -1,10 +0,0 @@
#include "mem.h"
#include "stdint.h"
void memset(void* destination, uint8_t value, size_t length)
{
for (size_t i = 0; i < length; i++)
{
((uint8_t*)destination)[i] = value;
}
}

View File

@@ -1,6 +0,0 @@
#pragma once
#include "stddef.h"
#include "stdint.h"
void memset(void* destination, uint8_t value, size_t length);

View File

@@ -1,9 +1,9 @@
#include "stdio.h"
#include "../arch/arch.h" #include "../arch/arch.h"
#include "stdarg.h" #include <stdarg.h>
#include "stdbool.h" #include <stdbool.h>
#include "stddef.h" #include <stddef.h>
#include "string.h" #include <stdio.h>
#include <string.h>
void printf(const char* fmt, ...) void printf(const char* fmt, ...)
{ {

View File

@@ -1,4 +1,12 @@
#include "string.h" #include <string.h>
void memset(void* destination, uint8_t value, size_t length)
{
for (size_t i = 0; i < length; i++)
{
((uint8_t*)destination)[i] = value;
}
}
int strcmp(const char* a, const char* b) int strcmp(const char* a, const char* b)
{ {

View File

@@ -1,8 +1,9 @@
#pragma once #pragma once
#include "stddef.h" #include <stddef.h>
#include "stdint.h" #include <stdint.h>
void memset(void* destination, uint8_t value, size_t length);
int strcmp(const char* a, const char* b); int strcmp(const char* a, const char* b);
void reverse(char* str, size_t length); void reverse(char* str, size_t length);
void uitoa64(uint64_t value, char* buffer); void uitoa64(uint64_t value, char* buffer);