Skip to content
This repository was archived by the owner on Jan 12, 2025. It is now read-only.

Commit 3802d06

Browse files
authored
Merge pull request #26 from lvntky/dev
Dev to Master V0.2.2-ALPHA
2 parents 7407f9c + bf2a2d3 commit 3802d06

File tree

15 files changed

+135
-382
lines changed

15 files changed

+135
-382
lines changed

Makefile

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,46 @@
1-
FILES = ./build/kernel.asm.o ./build/kernel.o ./build/tty.o ./build/stdio.o ./build/string.o ./build/idt.asm.o ./build/idt.o ./build/cpu_info.o ./build/io_port.o ./build/vga_driver.o
2-
INCLUDES = -I./src
3-
FLAGS = -g -ffreestanding -falign-jumps -falign-functions -falign-labels -falign-loops -fstrength-reduce -fomit-frame-pointer -finline-functions -Wno-unused-function -fno-builtin -Werror -Wno-unused-label -Wno-cpp -Wno-unused-parameter -nostdlib -nostartfiles -nodefaultlibs -Wall -O0 -Iinc
1+
CFLAGS = -m32 -ffreestanding -falign-jumps -falign-functions -falign-labels -falign-loops -fstrength-reduce -fomit-frame-pointer -finline-functions -Wno-unused-function -fno-builtin -Werror -Wno-unused-label -Wno-cpp -Wno-unused-parameter -nostdlib -nostartfiles -nodefaultlibs -Wall -O0 -Iinc
2+
ASPARAMS = --32
3+
LDPARAMS = -melf_i386
44

5-
all: ./bin/boot.bin ./bin/kernel.bin
6-
rm -rf ./bin/artilleryos.bin
7-
dd if=./bin/boot.bin >> ./bin/artilleryos.bin
8-
dd if=./bin/kernel.bin >> ./bin/artilleryos.bin
9-
dd if=/dev/zero bs=512 count=100 >> ./bin/artilleryos.bin
5+
objects = build/loader.o build/kernel.o build/tty.o build/stdio.o build/cpu_info.o build/string.o build/io_port.o ./build/vga_driver.o
106

11-
./bin/kernel.bin: $(FILES)
12-
i686-elf-ld -g -relocatable $(FILES) -o ./build/kernel_bootloader_combined.o
13-
i686-elf-gcc $(FLAGS) -T ./kernel/linker.ld -o ./bin/kernel.bin -ffreestanding -O0 -nostdlib ./build/kernel_bootloader_combined.o
147

15-
./bin/boot.bin: ./boot/boot.asm
16-
nasm -f bin ./boot/boot.asm -o ./bin/boot.bin
178

18-
./build/kernel.asm.o: ./boot/kernel_entry.asm
19-
nasm -f elf -g ./boot/kernel_entry.asm -o ./build/kernel.asm.o
9+
build/%.o: kernel/src/%.c
10+
i686-elf-gcc $(CFLAGS) -c -o $@ $<
2011

21-
./build/kernel.o: ./kernel/src/kernel.c
22-
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./kernel/src/kernel.c -o ./build/kernel.o
12+
build/%.o: kernel/libc/%.c
13+
i686-elf-gcc $(CFLAGS) -c -o $@ $<
2314

24-
./build/tty.o: ./kernel/src/tty.c
25-
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./kernel/src/tty.c -o ./build/tty.o
15+
build/%.o: kernel/driver/%.c
16+
i686-elf-gcc $(CFLAGS) -c -o $@ $<
2617

27-
./build/stdio.o: ./kernel/libc/stdio.c
28-
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./kernel/libc/stdio.c -o ./build/stdio.o
18+
build/%.o: boot/%.s
19+
i686-elf-as $(ASPARAMS) -o $@ $<
2920

30-
./build/string.o: ./kernel/libc/string.c
31-
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./kernel/libc/string.c -o ./build/string.o
21+
kernel.bin: linker.ld $(objects)
22+
i686-elf-ld $(LDPARAMS) -T $< -o $@ $(objects)
3223

33-
./build/idt.asm.o: ./kernel/idt/idt.asm
34-
nasm -f elf -g ./kernel/idt/idt.asm -o ./build/idt.asm.o
24+
all: kernel.bin
25+
mkdir iso
26+
mkdir iso/boot
27+
mkdir iso/boot/grub
28+
cp kernel.bin iso/boot/kernel.bin
29+
echo 'set timeout=10' > iso/boot/grub/grub.cfg
30+
echo 'set default=0' >> iso/boot/grub/grub.cfg
31+
echo '' >> iso/boot/grub/grub.cfg
32+
echo 'menuentry "Artillery OS" {' >> iso/boot/grub/grub.cfg
33+
echo ' multiboot /boot/kernel.bin' >> iso/boot/grub/grub.cfg
34+
echo ' boot' >> iso/boot/grub/grub.cfg
35+
echo '}' >> iso/boot/grub/grub.cfg
36+
grub-mkrescue --output=artillery.iso iso
37+
rm -rf iso
3538

36-
./build/idt.o: ./kernel/idt/idt.c
37-
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./kernel/idt/idt.c -o ./build/idt.o
38-
39-
./build/cpu_info.o: ./kernel/src/cpu_info.c
40-
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./kernel/src/cpu_info.c -o ./build/cpu_info.o
41-
42-
./build/io_port.o: ./kernel/src/io_port.c
43-
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./kernel/src/io_port.c -o ./build/io_port.o
44-
45-
./build/vga_driver.o: ./kernel/driver/vga_driver.c
46-
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./kernel/driver/vga_driver.c -o ./build/vga_driver.o
39+
install: kernel.bin
40+
sudo cp $< /boot/mykernel.bin
4741

4842
clean:
49-
rm -rf ./bin/boot.bin
50-
rm -rf ./bin/kernel.bin
51-
rm -rf ./bin/artilleryos.bin
52-
rm -rf ${FILES}
53-
rm -rf ./build/kernel_bootloader_combined.o
43+
sudo rm -r ./build/*
44+
sudo rm -r kernel.bin
45+
sudo rm -r artillery.iso
46+

boot/boot.asm

Lines changed: 0 additions & 131 deletions
This file was deleted.

boot/kernel_entry.asm

Lines changed: 0 additions & 39 deletions
This file was deleted.

boot/loader.s

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.set MAGIC, 0x1badb002
2+
.set FLAGS, (1<<0 | 1<<1)
3+
.set CHECKSUM, -(MAGIC + FLAGS)
4+
5+
.section .multiboot
6+
.long MAGIC
7+
.long FLAGS
8+
.long CHECKSUM
9+
10+
11+
.section .text
12+
.extern kernel_main
13+
.extern call_constructors
14+
.global loader
15+
16+
17+
loader:
18+
mov $kernel_stack, %esp
19+
call call_constructors
20+
push %eax
21+
push %ebx
22+
call kernel_main
23+
24+
25+
_stop:
26+
cli
27+
hlt
28+
jmp _stop
29+
30+
31+
.section .bss
32+
.space 2*1024*1024; # 2 MiB
33+
kernel_stack:

kernel/driver/include/vga_driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ uint8_t get_color_index(uint8_t, uint8_t, uint8_t);
3434
void put_pixel_rgb(uint32_t, uint32_t, uint8_t, uint8_t, uint8_t);
3535
void clear_screen();
3636
void color_demo();
37+
void clear_screen_withcolor(uint8_t);
3738

3839
#endif

kernel/driver/vga_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void color_demo()
145145
if (i > 16) {
146146
i = i % 16;
147147
}
148-
for (size_t i = 0; i < 99999900; i++) {
148+
for (size_t i = 0; i < 99999; i++) {
149149
/* code */
150150
}
151151

kernel/idt/idt.asm

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)