...
This commit is contained in:
7
.clangd
7
.clangd
@@ -5,6 +5,11 @@ CompileFlags:
|
||||
- "-ffreestanding"
|
||||
- "-fno-builtin"
|
||||
- "-fno-common"
|
||||
- "-Wall"
|
||||
- "-Wextra"
|
||||
- "-Wshadow"
|
||||
- "-fno-strict-aliasing"
|
||||
- "-nostdinc"
|
||||
- "-nostdlib"
|
||||
- "-Istdlib"
|
||||
- "-I"
|
||||
- "/home/oliste/repos/nub-os/src/stdlib"
|
||||
|
||||
7
makefile
7
makefile
@@ -2,13 +2,12 @@ CC = x86_64-elf-gcc
|
||||
LD = x86_64-elf-ld
|
||||
AS = nasm
|
||||
|
||||
TARGET_PATH = src/arch/x86_64
|
||||
CFLAGS = -m64 -ffreestanding -nostdlib -fno-builtin -Wall -Wextra -Wshadow -std=c11 -I src/stdlib -g
|
||||
CFLAGS = -m64 -ffreestanding -nostdinc -nostdlib -fno-builtin -Wall -Wextra -Wshadow -std=c11 -I src/stdlib -g
|
||||
LDFLAGS = -g
|
||||
ASFLAGS = -f elf64 -g -F dwarf
|
||||
|
||||
SRC_C := $(shell find src -name '*.c' )
|
||||
SRC_ASM := $(shell find src -name '*.asm' )
|
||||
SRC_C := $(shell find src -name '*.c')
|
||||
SRC_ASM := $(shell find src -name '*.asm')
|
||||
|
||||
OBJS := $(patsubst src/%.c, .build/%.o, $(SRC_C)) $(patsubst src/%.asm, .build/%.o, $(SRC_ASM))
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "stdint.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "interrupts.h"
|
||||
#include "../arch.h"
|
||||
#include "stdio.h"
|
||||
#include "util.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define PIC1_COMMAND 0x20
|
||||
#define PIC1_DATA 0x21
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "stdbool.h"
|
||||
#include "stdint.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// #include "keyboard.h"
|
||||
// #include "interrupts.h"
|
||||
// #include "util.h"
|
||||
// #include <stddef.h>
|
||||
// #include "stddef.h"
|
||||
|
||||
// #define SCANCODE_LEFT_SHIFT 42
|
||||
// #define SCANCODE_RIGHT_SHIFT 54
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// #pragma once
|
||||
|
||||
// #include <stdbool.h>
|
||||
// #include <stdint.h>
|
||||
// #include "stdbool.h"
|
||||
// #include "stdint.h"
|
||||
|
||||
// typedef struct
|
||||
// {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "mmap.h"
|
||||
#include "../mmap.h"
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include "stddef.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#define USABLE_REGION_SIZE 32
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "stdint.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "vga.h"
|
||||
#include <stddef.h>
|
||||
#include "stddef.h"
|
||||
|
||||
#define ROWS 25
|
||||
#define COLUMNS 80
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "stdint.h"
|
||||
|
||||
#define VGA_BLACK 0
|
||||
#define VGA_BLUE 1
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#include "interrupts.h"
|
||||
#include "mmap.h"
|
||||
#include "multiboot.h"
|
||||
#include "stddef.h"
|
||||
#include "stdio.h"
|
||||
#include "util.h"
|
||||
#include "vga.h"
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void entry(multiboot_info_t* mbd)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "kernel.h"
|
||||
#include "pmm.h"
|
||||
#include <stdio.h>
|
||||
#include "stdio.h"
|
||||
|
||||
void kmain()
|
||||
{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#include "pmm.h"
|
||||
#include "arch/mmap.h"
|
||||
#include <mem.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include "mem.h"
|
||||
#include "stddef.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#define BITMAP_SIZE 32768 // Supports up to 1GB of RAM
|
||||
#define USABLE_REGION_SIZE 32
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "stdint.h"
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "mem.h"
|
||||
#include <stdint.h>
|
||||
#include "stdint.h"
|
||||
|
||||
void memset(void* destination, uint8_t value, size_t length)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "stddef.h"
|
||||
#include "stdint.h"
|
||||
|
||||
void memset(void* destination, uint8_t value, size_t length);
|
||||
8
src/stdlib/stdarg.h
Normal file
8
src/stdlib/stdarg.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
typedef __builtin_va_list va_list;
|
||||
|
||||
#define va_start(ap, last) __builtin_va_start(ap, last)
|
||||
#define va_arg(ap, type) __builtin_va_arg(ap, type)
|
||||
#define va_end(ap) __builtin_va_end(ap)
|
||||
#define va_copy(dest, src) __builtin_va_copy(dest, src)
|
||||
7
src/stdlib/stdbool.h
Normal file
7
src/stdlib/stdbool.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#define __bool_true_false_are_defined 1
|
||||
12
src/stdlib/stddef.h
Normal file
12
src/stdlib/stddef.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void*)0)
|
||||
#endif
|
||||
|
||||
typedef unsigned long size_t;
|
||||
typedef long ptrdiff_t;
|
||||
typedef long intptr_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
|
||||
#define offsetof(type, member) __builtin_offsetof(type, member)
|
||||
50
src/stdlib/stdint.h
Normal file
50
src/stdlib/stdint.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef int8_t i8;
|
||||
typedef uint16_t u16;
|
||||
typedef int16_t i16;
|
||||
typedef uint32_t u32;
|
||||
typedef int32_t i32;
|
||||
typedef uint64_t u64;
|
||||
typedef int64_t i64;
|
||||
|
||||
#define INT8_MIN (-128)
|
||||
#define INT8_MAX 127
|
||||
#define UINT8_MAX 0xff
|
||||
|
||||
#define INT16_MIN (-32768)
|
||||
#define INT16_MAX 32767
|
||||
#define UINT16_MAX 0xffff
|
||||
|
||||
#define INT32_MIN (-2147483647 - 1)
|
||||
#define INT32_MAX 2147483647
|
||||
#define UINT32_MAX 0xffffffffU
|
||||
|
||||
#define INT64_MIN (-9223372036854775807LL - 1)
|
||||
#define INT64_MAX 9223372036854775807LL
|
||||
#define UINT64_MAX 0xffffffffffffffffULL
|
||||
|
||||
#define INT8_C(x) x
|
||||
#define UINT8_C(x) x##U
|
||||
|
||||
#define INT16_C(x) x
|
||||
#define UINT16_C(x) x##U
|
||||
|
||||
#define INT32_C(x) x
|
||||
#define UINT32_C(x) x##U
|
||||
|
||||
#define INT64_C(x) x##LL
|
||||
#define UINT64_C(x) x##ULL
|
||||
|
||||
#define INTMAX_C(x) x##LL
|
||||
#define UINTMAX_C(x) x##ULL
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "stdio.h"
|
||||
#include "../arch/arch.h"
|
||||
#include "stdarg.h"
|
||||
#include "stdbool.h"
|
||||
#include "stddef.h"
|
||||
#include "string.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
void printf(const char* fmt, ...)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user