Makefile done and kernel booting
This commit is contained in:
parent
32c01291ad
commit
a3e5157879
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build
|
||||
obj
|
41
Makefile
41
Makefile
@ -0,0 +1,41 @@
|
||||
AS := i386-elf-as
|
||||
ASFLAGS :=
|
||||
CC := i386-elf-gcc
|
||||
CCFLAGS := -std=gnu99 -ffreestanding -O2 -Wall -Wextra
|
||||
LD := $(CC)
|
||||
LDFLAGS := -T boot/linker.ld -ffreestanding -O2 -nostdlib
|
||||
LIBS := -lgcc
|
||||
|
||||
SSRC := $(wildcard src/*.s)
|
||||
CSRC := $(wildcard src/*.c)
|
||||
OBJ := $(patsubst src/%.c,obj/%.o,$(CSRC))\
|
||||
$(patsubst src/%.s,obj/%.o,$(SSRC))
|
||||
|
||||
NAME := bozOS
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
obj/%.o: src/%.s
|
||||
mkdir -p obj/
|
||||
$(AS) $(ASFLAGS) $< -o $@
|
||||
|
||||
obj/%.o: src/%.c
|
||||
mkdir -p obj/
|
||||
$(CC) $(CCFLAGS) -c $< -o $@
|
||||
|
||||
$(NAME): $(OBJ)
|
||||
mkdir -p build/
|
||||
$(LD) $(LDFLAGS) -o build/$(NAME).bin $(OBJ) $(LIBS)
|
||||
|
||||
run: $(NAME)
|
||||
qemu-system-i386 -kernel build/$(NAME).bin
|
||||
|
||||
clean:
|
||||
rm -rf obj/
|
||||
|
||||
fclean: clean
|
||||
rm -rf build/
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY: all clean fclean re run
|
28
boot/linker.ld
Normal file
28
boot/linker.ld
Normal file
@ -0,0 +1,28 @@
|
||||
ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 2M;
|
||||
|
||||
.text BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.multiboot)
|
||||
*(.text)
|
||||
}
|
||||
|
||||
.rodata BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.rodata)
|
||||
}
|
||||
|
||||
.data BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.data)
|
||||
}
|
||||
|
||||
.bss BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(COMMON)
|
||||
*(.bss)
|
||||
}
|
||||
}
|
@ -41,6 +41,13 @@ static inline uint16_t vga_entry(unsigned char uc, uint8_t color) {
|
||||
return (uint16_t)uc | (uint16_t)color << 8;
|
||||
}
|
||||
|
||||
size_t strlen(const char *str) {
|
||||
size_t len = 0;
|
||||
while (str[len])
|
||||
len++;
|
||||
return len;
|
||||
}
|
||||
|
||||
static const size_t VGA_WIDTH = 80;
|
||||
static const size_t VGA_HEIGHT = 25;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user