Add user/.

This commit is contained in:
Alexander Myltsev 2022-11-21 01:50:02 +03:00
parent c40e007d8a
commit f6bbebbee3
3 changed files with 16 additions and 2 deletions

View File

@ -27,15 +27,20 @@ debug: image.bin
-ex "break _start" \ -ex "break _start" \
-ex "continue" -ex "continue"
fs.img: kernel.bin tools/mkfs fs.img: kernel.bin tools/mkfs user/false
tools/mkfs $@ $< tools/mkfs $@ $<
LDFLAGS=-m elf_i386
user/%: user/%.o user/crt.o
$(LD) $(LDFLAGS) -o $@ -Ttext 0x101000 $^
image.bin: mbr.bin fs.img image.bin: mbr.bin fs.img
cat $^ >$@ cat $^ >$@
kernel.bin: kernel.o console.o drivers/vga.o drivers/keyboard.o \ kernel.bin: kernel.o console.o drivers/vga.o drivers/keyboard.o \
string.o drivers/ata.o cpu/vectors.o cpu/idt.o drivers/uart.o string.o drivers/ata.o cpu/vectors.o cpu/idt.o drivers/uart.o
$(LD) -m elf_i386 -o $@ -Ttext 0x1000 $^ $(LD) $(LDFLAGS) -o $@ -Ttext 0x1000 $^
%.o: %.c %.o: %.c
$(CC) -m32 -ffreestanding -Wall -Werror -c -g $< -o $@ $(CC) -m32 -ffreestanding -Wall -Werror -c -g $< -o $@

6
user/crt.c Normal file
View File

@ -0,0 +1,6 @@
int main();
void _start() {
int exit_status = main();
asm("int $0x84": :"a"(exit_status));
}

3
user/false.c Normal file
View File

@ -0,0 +1,3 @@
int main() {
return 1;
}