build: Correction des makefiles et ajout du disque dur UEFI

This commit is contained in:
Nicolas Hordé 2020-09-16 22:32:13 +02:00
parent 4f7aae792e
commit 349451ba33
10 changed files with 2097 additions and 413 deletions

File diff suppressed because it is too large Load Diff

BIN
final/harddiskuefi.img.xz Normal file

Binary file not shown.

View File

@ -1,48 +1,53 @@
all: harddisk.img.final floppy.img.final harddiskuefi.img.final REMOVE=rm -f
INSTALL=sudo apt-get install
COPY=cp
DISKCOPY=dd
COMPRESS=xz
SYNC=sync
CREATEDIR=mkdir
CAT=cat
all: harddisk.img.final harddiskuefi.img.final
harddiskuefi.img.before: harddiskuefi.img.before:
(xz -d -k harddiskuefi.img.xz) $(COMPRESS) -d -k harddiskuefi.img.xz
(dd if=harddiskuefi.img of=harddiskuefi.img.part1 skip=13672 bs=512) $(DISKCOPY) if=harddiskuefi.img of=harddiskuefi.img.part1 skip=13672 bs=512
(dd if=harddiskuefi.img of=harddiskuefi.img.before count=13672 bs=512;sync) $(DISKCOPY) if=harddiskuefi.img of=harddiskuefi.img.before count=13672 bs=512
(mkdir ./mnt -p) $(SYNC)
$(CREATEDIR) ./mnt -p
harddiskuefi.img.final: harddiskuefi.img.before harddiskuefi.img.final: harddiskuefi.img.before
(mount.fuse-ext2 -o rw+ harddiskuefi.img.part1 ./mnt) mount.fuse-ext2 -o rw+ harddiskuefi.img.part1 ./mnt
(cp ../system/system.sys ./mnt/boot/;sync) $(COPY) ../system/system.sys ./mnt/boot/
(fusermount ./mnt -u) $(SYNC)
(cat harddiskuefi.img.before > harddiskuefi.img.final) fusermount ./mnt -u
(cat harddiskuefi.img.part1 >> harddiskuefi.img.final;sync) cat harddiskuefi.img.before > harddiskuefi.img.final
cat harddiskuefi.img.part1 >> harddiskuefi.img.final
$(SYNC)
harddisk.img.before: harddisk.img.before:
(xz -d -k harddisk.img.xz) $(COMPRESS) -d -k harddisk.img.xz
(dd if=harddisk.img of=harddisk.img.part1 skip=63 bs=512) $(DISKCOPY) if=harddisk.img of=harddisk.img.part1 skip=63 bs=512
(dd if=harddisk.img of=harddisk.img.before count=63 bs=512;sync) $(DISKCOPY) if=harddisk.img of=harddisk.img.before count=63 bs=512
(mkdir ./mnt -p) $(SYNC)
$(CREATEDIR) ./mnt -p
harddisk.img.final: harddisk.img.before harddisk.img.final: harddisk.img.before
(mount.fuse-ext2 -o rw+ harddisk.img.part1 ./mnt) mount.fuse-ext2 -o rw+ harddisk.img.part1 ./mnt
(cp ../system/system.sys ./mnt/boot/;sync) $(COPY) ../system/system.sys ./mnt/boot/
(fusermount ./mnt -u) $(SYNC)
(cat harddisk.img.before > harddisk.img.final) fusermount ./mnt -u
(cat harddisk.img.part1 >> harddisk.img.final;sync) cat harddisk.img.before > harddisk.img.final
cat harddisk.img.part1 >> harddisk.img.final
floppy.img.final: $(SYNC)
(dd if=/dev/zero of=floppy.img.final count=2880 bs=512)
(mkfs.msdos -F 12 -n "COS2000" floppy.img.final)
(mkdir ./mnt -p)
(fusefat floppy.img.final ./mnt -o rw+)
(cp ../boot/loader.sys ./mnt/)
(cp ../system/system.sys ./mnt/;sync)
(fusermount ./mnt -u)
(dd if=../boot/boot12.bin of=floppy.img.final seek=0 count=1 conv=notrunc;sync)
littleclean: littleclean:
rm -f *.final $(REMOVE) *.final
togit: clean togit: clean
clean: clean:
rm -f *.before $(REMOVE) *.before
rm -f *.part1 $(REMOVE) *.part1
rm -f *.img $(REMOVE) *.img
rm -f *.final $(REMOVE) *.final

View File

@ -12,14 +12,30 @@ mkfs.ext2 ${lo}p2
mount ${lo}p1 /mnt mount ${lo}p1 /mnt
mkdir /mnt/grub mkdir /mnt/grub
echo -en "(hd0) ${lo}\n(hd0,1) ${lo}p1\n(hd0,2) ${lo}p2" > /mnt/grub/device.map echo -en "(hd0) ${lo}\n(hd0,1) ${lo}p1\n(hd0,2) ${lo}p2" > /mnt/grub/device.map
grub-install --no-floppy --boot-directory=/mnt/ --efi-directory=/mnt/ ${lo} --install-modules="part_gpt ext2 configfile normal multiboot2 video video_colors video_cirrus video_fb videotest all_video" --locales=fr --target=x86_64-efi --no-nvram #LS MINICMD pour avoir vision paritions
grub-install --no-floppy --boot-directory=/mnt/ --efi-directory=/mnt/ ${lo} --install-modules="part_gpt ext2 configfile normal linux16 video video_colors video_cirrus video_fb videotest all_video" --locales=fr --target=x86_64-efi --no-nvram
mkdir /mnt/EFI/BOOT mkdir /mnt/EFI/BOOT
cp /mnt/EFI/ubuntu/grubx64.efi /mnt/EFI/BOOT/bootx64.efi cp /mnt/EFI/ubuntu/grubx64.efi /mnt/EFI/BOOT/bootx64.efi
#grub-mkimage -d /usr/lib/grub/x86_64-efi -o /mnt/EFI/BOOT/bootx64.efi -c /mnt/EFI/ubuntu/grub.cfg -p "(hd0,1)/grub/" -O x86_64-efi part_gpt ext2 configfile normal multiboot2 video video_color video_cirrus video_fb videotest all_video #grub-mkimage -d /usr/lib/grub/x86_64-efi -o /mnt/EFI/BOOT/bootx64.efi -c /mnt/EFI/ubuntu/grub.cfg -p "(hd0,1)/grub/" -O x86_64-efi part_gpt ext2 configfile normal multiboot2 video video_color video_cirrus video_fb videotest all_video
echo -en "set timeout=4\nset default=0\n\nmenuentry "cos2000" {\nmultiboot2 (hd0,2)/boot/system.sys\nboot\n}" > /mnt/grub/grub.cfg echo -en "\
insmod ext2
insmod biosdisk
insmod part_msdos
insmod linux
insmod vbe
insmod gfxterm
insmod png
insmod font
set timeout=4\n\
set default=0\n\
menuentry "cos2000" {\n\
set root=(hd0,gpt2)\n\
linux16 /boot/system.sys root=hd0,gpt2\n
boot\n\
}" > /mnt/grub/grub.cfg
umount /mnt umount /mnt
mount ${lo}p2 /mnt mount ${lo}p2 /mnt
mkdir /mnt/boot/ mkdir /mnt/boot/
umount /mnt umount /mnt
losetup -d ${lo} losetup -d ${lo}
#xz -c harddiskuefi.img > harddiskuefi.img.xzcl xz -c harddiskuefi.img > harddiskuefi.img.xz

View File

@ -9,9 +9,10 @@ CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
REMOVE=rm -f REMOVE=rm -f
CHANGEPERM=chmod 644 CHANGEPERM=chmod 644
SYNC=sync
all: libs.o all: libs.o
sync $(SYNC)
togit: clean indent togit: clean indent
@ -41,7 +42,7 @@ clean:
$(REMOVE) */*.c~ $(REMOVE) */*.c~
$(REMOVE) ../include/*.h~ $(REMOVE) ../include/*.h~
$(REMOVE) ./TEST/*.c $(REMOVE) ./TEST/*.c
sync $(SYNC)
indent: indent:
$(CHANGEPERM) *.c $(CHANGEPERM) *.c
@ -56,4 +57,5 @@ indent:
$(CONVERT) ../include/*.h $(CONVERT) ../include/*.h
$(INDENT) ../include/*.h $(INDENT) ../include/*.h
$(REMOVE) ../include/*.h~ $(REMOVE) ../include/*.h~
sync $(SYNC)

176
makefile
View File

@ -1,26 +1,44 @@
DEBUG=exec gnome-terminal --geometry=120x55+1+1 -x ./debug/debug.sh ##### Variables
GODEBUG=exec gnome-terminal --geometry=120x55+1+1 -x ./debug/debug.sh
REMOVE=rm -f REMOVE=rm -f
INSTALL=sudo apt-get install INSTALL=sudo apt-get install
COPY=cp COPY=cp
EMULATOR=bochs -f OLDEMUX86=bochs -f
GIT=git status GIT=git status
MAKECALL=python makesyscall.py MAKECALL=python makesyscall.py
MAKE=make -C
SYNC=sync
KILL=killall
TAR=tar cf - Source\ C | gzip -f - > backup.tar.gz
HEXDUMP=hexdump -C ./final/harddisk.img.final|head -c10000
TMUXKILL=tmux kill-session -t
TRUE=|| true
SPICE=spicy --uri=spice://127.0.0.1?port=5900
SOURCE=xxd -i
EMUX86=qemu-system-i386
EMUX64=qemu-system-x86_64
LEGACY=-m 1G -drive format=raw,file=./final/harddisk.img.final --enable-kvm -cpu host -s -vga qxl -spice port=5900,addr=127.0.0.1,disable-ticketing
UEFI=-m 5G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd --enable-kvm -cpu host -s -vga qxl -spice port=5900,addr=127.0.0.1,disable-ticketing
DEBUG=-S -monitor telnet:127.0.0.1:6666,server,nowait
WAIT2S=sleep 2
all: tools programs bits32 bits64 harddisk uefi ##### Construction
sync
bits32: ARCH=bits32 all: tools programs system32 system64 harddisk harddiskuefi
bits32: lib/libs.o system/system.sys $(SYNC)
sync
bits64: ARCH=bits64 system32: ARCH=bits32
bits64: lib/libs.o system/system.sys system32: lib/libs.o system/system.sys
sync $(SYNC)
system64: ARCH=bits64
system64: lib/libs.o system/system.sys
$(SYNC)
tools: tools/build tools: tools/build
tools/build: tools/build:
make -C tools $(MAKE) tools
syscall: clean remakeapi all syscall: clean remakeapi all
@ -30,73 +48,79 @@ remakeapi:
programs: programs/test lib/TEST/test.c lib/TEST/test2.c programs: programs/test lib/TEST/test.c lib/TEST/test2.c
lib/TEST/test.c: lib/TEST/test.c:
xxd -i programs/test lib/TEST/test.c $(SOURCE) programs/test lib/TEST/test.c
lib/TEST/test2.c: lib/TEST/test2.c:
xxd -i programs/test2 lib/TEST/test2.c $(SOURCE) programs/test2 lib/TEST/test2.c
programs/test: programs/test:
make -C programs $(MAKE) programs
harddisk: final/harddisk.img.final harddisk: final/harddisk.img.final
uefi: final/harddiskuefi.img.final harddiskuefi: final/harddiskuefi.img.final
install: install:
$(INSTALL) gcc qemu fusefat fuseext2 gdb ovmf bsdmainutils tar bsdmainutils indent binutils bochs bochs-x bochsbios dos2unix gnome-terminal $(INSTALL) gcc qemu fusefat fuseext2 gdb ovmf bsdmainutils tar bsdmainutils indent binutils bochs bochs-x bochsbios dos2unix gnome-terminal spice-client-gtk python2
togit: togit:
make -C system togit $(MAKE) system togit
make -C lib togit $(MAKE) lib togit
make -C final togit $(MAKE) final togit
make -C programs togit $(MAKE) programs togit
make -C tools togit $(MAKE) tools togit
$(GIT) $(GIT)
sync $(SYNC)
clean: clean:
$(RM) -f .gdb_history $(REMOVE) .gdb_history
make -C system clean $(MAKE) system clean
make -C lib clean $(MAKE) lib clean
make -C final clean $(MAKE) final clean
make -C programs clean $(MAKE) programs clean
make -C tools clean $(MAKE) tools clean
sync $(SYNC)
littleclean: littleclean:
make -C system clean $(MAKE) system clean
make -C lib clean $(MAKE) lib clean
make -C final littleclean $(MAKE) final littleclean
make -C programs clean $(MAKE) programs clean
sync $(SYNC)
indent: indent:
make -C system indent $(MAKE) system indent
make -C lib indent $(MAKE) lib indent
make -C programs indent $(MAKE) programs indent
make -C tools indent $(MAKE) tools indent
sync $(SYNC)
backup: clean backup: clean
cd .. cd ..
tar cf - Source\ C | gzip -f - > backup.tar.gz $(TAR)
test: tools programs bits32 harddisk qemu test: test32
test64: tools programs bits64 uefi qemu64 retest: retest32
retest: littleclean test test32: tools programs system32 harddisk qemu32
test64: tools programs system64 harddiskuefi qemu64
retest32: littleclean test32
retest64: littleclean test64 retest64: littleclean test64
testbochs: tools programs bits32 harddisk bochs-debug testbochs: tools programs system32 harddisk bochs-debug
view: view:
hexdump -C ./final/harddisk.img.final|head -c10000 $(HEXDUMP)
debug: debug-system ##### Debuguage
redebug: littleclean debug-system debug: debug-system32
redebug32: littleclean debug-system32
debug64: debug-system64 debug64: debug-system64
@ -104,48 +128,56 @@ redebug64: littleclean debug-system64
kernel: debug-kernel kernel: debug-kernel
debug-boot: tools programs bits32 harddisk qemu-debug debug-boot: tools programs system32 harddisk qemu-debug32
sleep 2 $(WAIT2S)
$(DEBUG) ./debug/boot.txt $(GODEBUG) ./debug/boot.txt
debug-system: tools programs bits32 harddisk qemu-debug debug-system32: tools programs system32 harddisk qemu-debug32
sleep 2 $(WAIT2S)
$(DEBUG) ./debug/system.txt $(GODEBUG) ./debug/system.txt
debug-system64: tools programs bits64 uefi qemu-debug64 debug-system64: tools programs system32 harddiskuefi qemu-debug64
sleep 2 $(WAIT2S)
$(DEBUG) ./debug/system.txt $(GODEBUG) ./debug/system.txt
bochs-debug: killer bochs-debug: killer
$(EMULATOR) ./debug/config.bochs $(OLDEMUX86) ./debug/config.bochs
killer: killer:
killall bochs-debug || true $(KILL) bochs-debug $(TRUE)
killall qemu-system-x86_64 || true $(KILL) qemu-system-x86_64 $(TRUE)
killall qemu-system-i386 || true $(KILL) qemu-system-i386 $(TRUE)
killall gnome-terminal-server || true $(KILL) gnome-terminal-server $(TRUE)
tmux kill-session -t debug || true $(TMUXKILL) debug $(TRUE)
qemu-debug: killer ##### Emulation
qemu-system-i386 -monitor telnet:127.0.0.1:6666,server,nowait -m 1G -drive format=raw,file=./final/harddisk.img.final -s -S &
qemu-debug32: killer
$(EMUX86) $(LEGACY) $(DEBUG) &
$(SPICE) &
qemu-debug64: killer qemu-debug64: killer
qemu-system-x86_64 -monitor telnet:127.0.0.1:6666,server,nowait -m 5G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd -s -S & $(EMUX64) $(UEFI) $(DEBUG) &
$(SPICE) &
qemu: killer qemu32: killer
qemu-system-i386 -m 1G -drive format=raw,file=./final/harddisk.img.final --enable-kvm -cpu host -s & $(EMUX86) $(LEGACY) &
$(WAIT2S)
$(SPICE)
qemu64: killer qemu64: killer
qemu-system-x86_64 -m 5G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd --enable-kvm -cpu host -s & $(EMUX64) $(UEFI) &
$(WAIT2S)
$(SPICE)
system/system.sys: system/system.sys:
make -C system $(MAKE) system
final/harddisk.img.final: final/harddisk.img.final:
make -C final harddisk.img.final $(MAKE) final harddisk.img.final
final/harddiskuefi.img.final: final/harddiskuefi.img.final:
make -C final harddiskuefi.img.final $(MAKE) final harddiskuefi.img.final
lib/libs.o: lib/libs.o:
make -C lib $(MAKE) lib

View File

@ -7,14 +7,16 @@ INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bl
REMOVE=rm -f REMOVE=rm -f
CHANGELF=elfedit --output-osabi FenixOS CHANGELF=elfedit --output-osabi FenixOS
CHANGEPERM=chmod 644 CHANGEPERM=chmod 644
MAKE=make -C
SYNC=sync
all: lib/libs.a $(EXECS) all: lib/libs.a $(EXECS)
sync $(SYNC)
togit: clean indent togit: clean indent
lib/libs.a: lib/libs.a:
make -C lib $(MAKE) lib
%: %.c %: %.c
$(CC) $@.o $< $(CC) $@.o $<
@ -23,16 +25,17 @@ lib/libs.a:
$(CHANGELF) $@ $(CHANGELF) $@
clean: clean:
make -C lib clean $(MAKE) lib clean
$(REMOVE) *.o $(REMOVE) *.o
$(REMOVE) *.c~ $(REMOVE) *.c~
find . -type f ! -perm /u=x -maxdepth 1 -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \; find . -maxdepth 1 -type f ! -perm /u=x -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;
sync $(SYNC)
indent: indent:
make -C lib indent $(MAKE) lib indent
$(CHANGEPERM) *.c $(CHANGEPERM) *.c
$(CONVERT) *.c $(CONVERT) *.c
$(INDENT) *.c $(INDENT) *.c
$(REMOVE) *.c~ $(REMOVE) *.c~
sync $(SYNC)

View File

@ -13,12 +13,14 @@ VOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|__bss_start\|_end\)
COMP=gzip -9 -f COMP=gzip -9 -f
BUILD=../tools/build BUILD=../tools/build
MKPIGGY=../tools/mkpiggy MKPIGGY=../tools/mkpiggy
MAKE=make -C
SYNC=sync
all: system.sys all: system.sys
system.sys: piggy.o voffset.h zoffset.h realmode/setup.bin system.sys: piggy.o voffset.h zoffset.h realmode/setup.bin
$(BUILD) realmode/setup.bin system.bin zoffset.h system.sys $(BUILD) realmode/setup.bin system.bin zoffset.h system.sys
sync $(SYNC)
allpiggy.o: piggy.o decompress.o header.o allpiggy.o: piggy.o decompress.o header.o
$(LINK) -T allpiggy piggy.o decompress.o header.o $(LINK) -T allpiggy piggy.o decompress.o header.o
@ -49,7 +51,7 @@ piggy.S: system.bin.gz
$(MKPIGGY) $^ > $@ $(MKPIGGY) $^ > $@
realmode/setup.bin: realmode/setup.bin:
make -C realmode $(MAKE) realmode
system.o: system.c system.o: system.c
$(GCC) $@ $^ $(GCC) $@ $^
@ -58,7 +60,7 @@ system_asm.o: system_asm.S
$(ASM) $@ $^ $(ASM) $@ $^
clean: clean:
make -C realmode clean $(MAKE) realmode clean
$(REMOVE) system $(REMOVE) system
$(REMOVE) piggy.S $(REMOVE) piggy.S
$(REMOVE) *.o $(REMOVE) *.o
@ -72,12 +74,13 @@ clean:
$(REMOVE) *.sys $(REMOVE) *.sys
$(REMOVE) *.s $(REMOVE) *.s
$(REMOVE) *.c~ $(REMOVE) *.c~
sync $(SYNC)
indent: indent:
make -C realmode indent $(MAKE) realmode indent
$(CHANGEPERM) *.c $(CHANGEPERM) *.c
$(CONVERT) *.c $(CONVERT) *.c
$(INDENT) *.c $(INDENT) *.c
$(REMOVE) *.c~ $(REMOVE) *.c~
sync $(SYNC)

View File

@ -9,9 +9,10 @@ NM=nm
OBJCOPY=objcopy -O binary -R .note -R .comment -S OBJCOPY=objcopy -O binary -R .note -R .comment -S
OBJDEBUG=objcopy --only-keep-debug OBJDEBUG=objcopy --only-keep-debug
$(eval VERSION=$(shell git describe --tags)) $(eval VERSION=$(shell git describe --tags))
SYNC=sync
all: setup.bin all: setup.bin
sync $(SYNC)
setup: setupc.o setup.o setup32.o setup: setupc.o setup.o setup32.o
$(LINK) -T setup.ld setupc.o setup.o setup32.o $(LINK) -T setup.ld setupc.o setup.o setup32.o
@ -40,11 +41,12 @@ clean:
$(REMOVE) *.sys $(REMOVE) *.sys
$(REMOVE) *.s $(REMOVE) *.s
$(REMOVE) *.c~ $(REMOVE) *.c~
sync $(SYNC)
indent: indent:
$(CHANGEPERM) *.c $(CHANGEPERM) *.c
$(CONVERT) *.c $(CONVERT) *.c
$(INDENT) *.c $(INDENT) *.c
$(REMOVE) *.c~ $(REMOVE) *.c~
sync $(SYNC)

View File

@ -17,7 +17,7 @@ togit: clean indent
clean: clean:
$(REMOVE) *.o $(REMOVE) *.o
$(REMOVE) *.c~ $(REMOVE) *.c~
find . -type f ! -name makefile -perm /u=x -maxdepth 1 -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \; find . -maxdepth 1 -type f ! -name makefile -perm /u=x -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;
sync sync
indent: indent: