separating: there will be libk and libc
This commit is contained in:
@@ -59,7 +59,7 @@ void program_myprogram(int argc, char* argv[])
|
||||
```
|
||||
|
||||
Then, code your stuff freely. The entry point function will basically be the "main" function of your program, like in a regular C file. You can make your own header file too, for example `myprogram.h`.
|
||||
Keep in mind that the standard C library is not available here, so you'll have to use functions from the BlankOS C library, which is located in `src/libc`. Also feel free to look at the header files in `src/drivers` and `src/kernel`, there might be interesting functions in there too (managing input/output devices, the timer, etc..)
|
||||
Keep in mind that the standard C library is not available here, so you'll have to use functions from the BlankOS C library, which is located in `src/libk`. Also feel free to look at the header files in `src/drivers` and `src/kernel`, there might be interesting functions in there too (managing input/output devices, the timer, etc..)
|
||||
|
||||
### Step 2 - Registering the program
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "../kernel/io.h"
|
||||
#include "serial.h"
|
||||
#include "../libc/stdio.h"
|
||||
#include "../libk/stdio.h"
|
||||
|
||||
int init_serial()
|
||||
{
|
||||
@@ -4,7 +4,7 @@
|
||||
// https://github.com/xamidev/blankos
|
||||
|
||||
#include "../kernel/system.h"
|
||||
#include "../libc/stdio.h"
|
||||
#include "../libk/stdio.h"
|
||||
|
||||
volatile unsigned long global_ticks = 0;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// https://github.com/xamidev/blankos
|
||||
|
||||
#include "gdt.h"
|
||||
#include "../libc/stdio.h"
|
||||
#include "../libk/stdio.h"
|
||||
|
||||
struct gdt_entry gdt[3];
|
||||
struct gdt_ptr gp;
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "idt.h"
|
||||
#include "system.h"
|
||||
#include "../libc/stdio.h"
|
||||
#include "../libk/stdio.h"
|
||||
|
||||
struct idt_entry idt[256];
|
||||
struct idt_ptr idtp;
|
||||
@@ -3,9 +3,9 @@
|
||||
// Licensed under the Unlicense. See the repo below.
|
||||
// https://github.com/xamidev/blankos
|
||||
|
||||
#include "../libc/stdio.h"
|
||||
#include "../libk/stdio.h"
|
||||
#include <stdint.h>
|
||||
#include "../libc/string.h"
|
||||
#include "../libk/string.h"
|
||||
#include "initrd.h"
|
||||
#include "system.h"
|
||||
#include "kheap.h"
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "system.h"
|
||||
#include "io.h"
|
||||
#include "idt.h"
|
||||
#include "../libc/stdio.h"
|
||||
#include "../libk/stdio.h"
|
||||
|
||||
extern void irq0();
|
||||
extern void irq1();
|
||||
@@ -4,7 +4,7 @@
|
||||
// https://github.com/xamidev/blankos
|
||||
|
||||
#include "system.h"
|
||||
#include "../libc/stdio.h"
|
||||
#include "../libk/stdio.h"
|
||||
#include "idt.h"
|
||||
|
||||
extern void isr0();
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "kheap.h"
|
||||
#include <stdint.h>
|
||||
#include "system.h"
|
||||
#include "../libc/stdio.h"
|
||||
#include "../libk/stdio.h"
|
||||
|
||||
// Free list allocator
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Licensed under the Unlicense. See the repo below.
|
||||
// https://github.com/xamidev/blankos
|
||||
|
||||
#include "../libc/stdio.h"
|
||||
#include "../libk/stdio.h"
|
||||
#include "../drivers/serial.h"
|
||||
#include "gdt.h"
|
||||
#include "idt.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
// Ctype implementation for blankos/libc
|
||||
// Ctype implementation for blankos/libk
|
||||
// Author: xamidev
|
||||
// Licensed under the Unlicense. See the repo below.
|
||||
// https://github.com/xamidev/blankos
|
||||
@@ -1,4 +1,4 @@
|
||||
// Ctype implementation for blankos/libc header
|
||||
// Ctype implementation for blankos/libk header
|
||||
// Author: xamidev
|
||||
// Licensed under the Unlicense. See the repo below.
|
||||
// https://github.com/xamidev/blankos
|
||||
@@ -1,4 +1,4 @@
|
||||
// Standard input/output implementation for blankos/libc
|
||||
// Standard input/output implementation for blankos/libk
|
||||
// Author: xamidev
|
||||
// Licensed under the Unlicense. See the repo below.
|
||||
// https://github.com/xamidev/blankos
|
||||
@@ -1,4 +1,4 @@
|
||||
// Standard input/output implementation for blankos/libc header
|
||||
// Standard input/output implementation for blankos/libk header
|
||||
// Author: xamidev
|
||||
// Licensed under the Unlicense. See the repo below.
|
||||
// https://github.com/xamidev/blankos
|
||||
@@ -1,4 +1,4 @@
|
||||
// String operations implementation for blankos/libc
|
||||
// String operations implementation for blankos/libk
|
||||
// Author: xamidev
|
||||
// Licensed under the Unlicense. See the repo below.
|
||||
// https://github.com/xamidev/blankos
|
||||
@@ -1,4 +1,4 @@
|
||||
// String operations implementation for blankos/libc header
|
||||
// String operations implementation for blankos/libk header
|
||||
// Author: xamidev
|
||||
// Licensed under the Unlicense. See the repo below.
|
||||
// https://github.com/xamidev/blankos
|
||||
26
makefile
26
makefile
@@ -1,23 +1,22 @@
|
||||
CC = i386-elf-7.5.0-Linux-x86_64/bin/i386-elf-gcc
|
||||
CFLAGS = -ffreestanding -g -Wall -Wextra -mno-sse -mno-mmx -mno-avx -march=i386 -c -I src/
|
||||
CFLAGS = -ffreestanding -g -Wall -Wextra -mno-sse -mno-mmx -mno-avx -march=i386 -c -I .
|
||||
LD = ld
|
||||
LDFLAGS = -T link.ld -melf_i386
|
||||
AS = nasm
|
||||
ASFLAGS = -f elf
|
||||
AR = i386-elf-7.5.0-Linux-x86_64/bin/i386-elf-ar
|
||||
|
||||
SRC_DIR = src
|
||||
KERNEL_DIR = $(SRC_DIR)/kernel
|
||||
LIBC_DIR = $(SRC_DIR)/libc
|
||||
DRIVERS_DIR = $(SRC_DIR)/drivers
|
||||
KERNEL_DIR = kernel
|
||||
libk_DIR = libk
|
||||
DRIVERS_DIR = drivers
|
||||
INCLUDE_DIR = include
|
||||
FONTS_DIR = $(INCLUDE_DIR)/fonts
|
||||
OBJ_DIR = build
|
||||
|
||||
C_SOURCES = $(wildcard $(KERNEL_DIR)/*.c) $(wildcard $(LIBC_DIR)/*.c) $(wildcard $(DRIVERS_DIR)/*.c)
|
||||
ASM_SOURCES = $(wildcard $(KERNEL_DIR)/*.s) $(wildcard $(LIBC_DIR)/*.s) $(wildcard $(DRIVERS_DIR)/*.s)
|
||||
C_SOURCES = $(wildcard $(KERNEL_DIR)/*.c) $(wildcard $(libk_DIR)/*.c) $(wildcard $(DRIVERS_DIR)/*.c)
|
||||
ASM_SOURCES = $(wildcard $(KERNEL_DIR)/*.s) $(wildcard $(libk_DIR)/*.s) $(wildcard $(DRIVERS_DIR)/*.s)
|
||||
|
||||
OBJECTS = $(patsubst $(SRC_DIR)/%, $(OBJ_DIR)/%, $(C_SOURCES:.c=.o) $(ASM_SOURCES:.s=.o))
|
||||
OBJECTS = $(patsubst %, $(OBJ_DIR)/%, $(C_SOURCES:.c=.o) $(ASM_SOURCES:.s=.o))
|
||||
|
||||
TOOLCHAIN_SRC = https://newos.org/toolchains/i386-elf-7.5.0-Linux-x86_64.tar.xz
|
||||
TOOLCHAIN_FILE = i386-elf-7.5.0-Linux-x86_64.tar.xz
|
||||
@@ -29,15 +28,15 @@ all: $(OBJ_DIR) kernel.elf
|
||||
|
||||
$(OBJ_DIR):
|
||||
mkdir -p $(OBJ_DIR)
|
||||
mkdir -p $(OBJ_DIR)/kernel $(OBJ_DIR)/libc $(OBJ_DIR)/drivers $(OBJ_DIR)/fonts $(OBJ_DIR)/programs
|
||||
mkdir -p $(OBJ_DIR)/kernel $(OBJ_DIR)/libk $(OBJ_DIR)/drivers $(OBJ_DIR)/fonts $(OBJ_DIR)/programs
|
||||
|
||||
kernel.elf: $(OBJECTS) $(FONT_OBJ)
|
||||
$(LD) $(LDFLAGS) $(OBJECTS) $(FONT_OBJ) -o kernel.elf
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
$(OBJ_DIR)/%.o: %.c
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.s
|
||||
$(OBJ_DIR)/%.o: %.s
|
||||
$(AS) $(ASFLAGS) $< -o $@
|
||||
|
||||
$(FONT_OBJ): $(FONT_SRC) | $(OBJ_DIR)/fonts
|
||||
@@ -57,7 +56,7 @@ iso: kernel.elf initrd
|
||||
|
||||
initrd:
|
||||
mkdir -p iso/boot/grub
|
||||
tar -cf $(OBJ_DIR)/initrd.tar -C $(SRC_DIR)/initrd .
|
||||
tar -cf $(OBJ_DIR)/initrd.tar -C initrd .
|
||||
cp $(OBJ_DIR)/initrd.tar iso/boot
|
||||
|
||||
run: iso
|
||||
@@ -67,5 +66,4 @@ debug:
|
||||
./debug.sh
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR) kernel.elf blankos.iso $(TOOLCHAIN_FILE) $(SRC_DIR)/initrd/*.bin
|
||||
|
||||
rm -rf $(OBJ_DIR) kernel.elf blankos.iso $(TOOLCHAIN_FILE) initrd/*.bin
|
||||
|
||||
Reference in New Issue
Block a user