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:
(xz -d -k harddiskuefi.img.xz)
(dd if=harddiskuefi.img of=harddiskuefi.img.part1 skip=13672 bs=512)
(dd if=harddiskuefi.img of=harddiskuefi.img.before count=13672 bs=512;sync)
(mkdir ./mnt -p)
$(COMPRESS) -d -k harddiskuefi.img.xz
$(DISKCOPY) if=harddiskuefi.img of=harddiskuefi.img.part1 skip=13672 bs=512
$(DISKCOPY) if=harddiskuefi.img of=harddiskuefi.img.before count=13672 bs=512
$(SYNC)
$(CREATEDIR) ./mnt -p
harddiskuefi.img.final: harddiskuefi.img.before
(mount.fuse-ext2 -o rw+ harddiskuefi.img.part1 ./mnt)
(cp ../system/system.sys ./mnt/boot/;sync)
(fusermount ./mnt -u)
(cat harddiskuefi.img.before > harddiskuefi.img.final)
(cat harddiskuefi.img.part1 >> harddiskuefi.img.final;sync)
mount.fuse-ext2 -o rw+ harddiskuefi.img.part1 ./mnt
$(COPY) ../system/system.sys ./mnt/boot/
$(SYNC)
fusermount ./mnt -u
cat harddiskuefi.img.before > harddiskuefi.img.final
cat harddiskuefi.img.part1 >> harddiskuefi.img.final
$(SYNC)
harddisk.img.before:
(xz -d -k harddisk.img.xz)
(dd if=harddisk.img of=harddisk.img.part1 skip=63 bs=512)
(dd if=harddisk.img of=harddisk.img.before count=63 bs=512;sync)
(mkdir ./mnt -p)
$(COMPRESS) -d -k harddisk.img.xz
$(DISKCOPY) if=harddisk.img of=harddisk.img.part1 skip=63 bs=512
$(DISKCOPY) if=harddisk.img of=harddisk.img.before count=63 bs=512
$(SYNC)
$(CREATEDIR) ./mnt -p
harddisk.img.final: harddisk.img.before
(mount.fuse-ext2 -o rw+ harddisk.img.part1 ./mnt)
(cp ../system/system.sys ./mnt/boot/;sync)
(fusermount ./mnt -u)
(cat harddisk.img.before > harddisk.img.final)
(cat harddisk.img.part1 >> harddisk.img.final;sync)
floppy.img.final:
(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)
mount.fuse-ext2 -o rw+ harddisk.img.part1 ./mnt
$(COPY) ../system/system.sys ./mnt/boot/
$(SYNC)
fusermount ./mnt -u
cat harddisk.img.before > harddisk.img.final
cat harddisk.img.part1 >> harddisk.img.final
$(SYNC)
littleclean:
rm -f *.final
$(REMOVE) *.final
togit: clean
clean:
rm -f *.before
rm -f *.part1
rm -f *.img
rm -f *.final
$(REMOVE) *.before
$(REMOVE) *.part1
$(REMOVE) *.img
$(REMOVE) *.final

View File

@ -12,14 +12,30 @@ mkfs.ext2 ${lo}p2
mount ${lo}p1 /mnt
mkdir /mnt/grub
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
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
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
mount ${lo}p2 /mnt
mkdir /mnt/boot/
umount /mnt
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
REMOVE=rm -f
CHANGEPERM=chmod 644
SYNC=sync
all: libs.o
sync
$(SYNC)
togit: clean indent
@ -41,7 +42,7 @@ clean:
$(REMOVE) */*.c~
$(REMOVE) ../include/*.h~
$(REMOVE) ./TEST/*.c
sync
$(SYNC)
indent:
$(CHANGEPERM) *.c
@ -56,4 +57,5 @@ indent:
$(CONVERT) ../include/*.h
$(INDENT) ../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
INSTALL=sudo apt-get install
COPY=cp
EMULATOR=bochs -f
OLDEMUX86=bochs -f
GIT=git status
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
sync
##### Construction
bits32: ARCH=bits32
bits32: lib/libs.o system/system.sys
sync
all: tools programs system32 system64 harddisk harddiskuefi
$(SYNC)
bits64: ARCH=bits64
bits64: lib/libs.o system/system.sys
sync
system32: ARCH=bits32
system32: lib/libs.o system/system.sys
$(SYNC)
system64: ARCH=bits64
system64: lib/libs.o system/system.sys
$(SYNC)
tools: tools/build
tools/build:
make -C tools
$(MAKE) tools
syscall: clean remakeapi all
@ -30,73 +48,79 @@ remakeapi:
programs: programs/test lib/TEST/test.c lib/TEST/test2.c
lib/TEST/test.c:
xxd -i programs/test lib/TEST/test.c
$(SOURCE) programs/test lib/TEST/test.c
lib/TEST/test2.c:
xxd -i programs/test2 lib/TEST/test2.c
$(SOURCE) programs/test2 lib/TEST/test2.c
programs/test:
make -C programs
$(MAKE) programs
harddisk: final/harddisk.img.final
uefi: final/harddiskuefi.img.final
harddiskuefi: final/harddiskuefi.img.final
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:
make -C system togit
make -C lib togit
make -C final togit
make -C programs togit
make -C tools togit
$(MAKE) system togit
$(MAKE) lib togit
$(MAKE) final togit
$(MAKE) programs togit
$(MAKE) tools togit
$(GIT)
sync
$(SYNC)
clean:
$(RM) -f .gdb_history
make -C system clean
make -C lib clean
make -C final clean
make -C programs clean
make -C tools clean
sync
$(REMOVE) .gdb_history
$(MAKE) system clean
$(MAKE) lib clean
$(MAKE) final clean
$(MAKE) programs clean
$(MAKE) tools clean
$(SYNC)
littleclean:
make -C system clean
make -C lib clean
make -C final littleclean
make -C programs clean
sync
$(MAKE) system clean
$(MAKE) lib clean
$(MAKE) final littleclean
$(MAKE) programs clean
$(SYNC)
indent:
make -C system indent
make -C lib indent
make -C programs indent
make -C tools indent
sync
$(MAKE) system indent
$(MAKE) lib indent
$(MAKE) programs indent
$(MAKE) tools indent
$(SYNC)
backup: clean
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
testbochs: tools programs bits32 harddisk bochs-debug
testbochs: tools programs system32 harddisk bochs-debug
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
@ -104,48 +128,56 @@ redebug64: littleclean debug-system64
kernel: debug-kernel
debug-boot: tools programs bits32 harddisk qemu-debug
sleep 2
$(DEBUG) ./debug/boot.txt
debug-boot: tools programs system32 harddisk qemu-debug32
$(WAIT2S)
$(GODEBUG) ./debug/boot.txt
debug-system: tools programs bits32 harddisk qemu-debug
sleep 2
$(DEBUG) ./debug/system.txt
debug-system32: tools programs system32 harddisk qemu-debug32
$(WAIT2S)
$(GODEBUG) ./debug/system.txt
debug-system64: tools programs bits64 uefi qemu-debug64
sleep 2
$(DEBUG) ./debug/system.txt
debug-system64: tools programs system32 harddiskuefi qemu-debug64
$(WAIT2S)
$(GODEBUG) ./debug/system.txt
bochs-debug: killer
$(EMULATOR) ./debug/config.bochs
$(OLDEMUX86) ./debug/config.bochs
killer:
killall bochs-debug || true
killall qemu-system-x86_64 || true
killall qemu-system-i386 || true
killall gnome-terminal-server || true
tmux kill-session -t debug || true
$(KILL) bochs-debug $(TRUE)
$(KILL) qemu-system-x86_64 $(TRUE)
$(KILL) qemu-system-i386 $(TRUE)
$(KILL) gnome-terminal-server $(TRUE)
$(TMUXKILL) debug $(TRUE)
qemu-debug: killer
qemu-system-i386 -monitor telnet:127.0.0.1:6666,server,nowait -m 1G -drive format=raw,file=./final/harddisk.img.final -s -S &
##### Emulation
qemu-debug32: killer
$(EMUX86) $(LEGACY) $(DEBUG) &
$(SPICE) &
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
qemu-system-i386 -m 1G -drive format=raw,file=./final/harddisk.img.final --enable-kvm -cpu host -s &
qemu32: killer
$(EMUX86) $(LEGACY) &
$(WAIT2S)
$(SPICE)
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:
make -C system
$(MAKE) system
final/harddisk.img.final:
make -C final harddisk.img.final
$(MAKE) final harddisk.img.final
final/harddiskuefi.img.final:
make -C final harddiskuefi.img.final
$(MAKE) final harddiskuefi.img.final
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
CHANGELF=elfedit --output-osabi FenixOS
CHANGEPERM=chmod 644
MAKE=make -C
SYNC=sync
all: lib/libs.a $(EXECS)
sync
$(SYNC)
togit: clean indent
lib/libs.a:
make -C lib
$(MAKE) lib
%: %.c
$(CC) $@.o $<
@ -23,16 +25,17 @@ lib/libs.a:
$(CHANGELF) $@
clean:
make -C lib clean
$(MAKE) lib clean
$(REMOVE) *.o
$(REMOVE) *.c~
find . -type f ! -perm /u=x -maxdepth 1 -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;
sync
find . -maxdepth 1 -type f ! -perm /u=x -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;
$(SYNC)
indent:
make -C lib indent
$(MAKE) lib indent
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.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
BUILD=../tools/build
MKPIGGY=../tools/mkpiggy
MAKE=make -C
SYNC=sync
all: system.sys
system.sys: piggy.o voffset.h zoffset.h realmode/setup.bin
$(BUILD) realmode/setup.bin system.bin zoffset.h system.sys
sync
$(SYNC)
allpiggy.o: 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) $^ > $@
realmode/setup.bin:
make -C realmode
$(MAKE) realmode
system.o: system.c
$(GCC) $@ $^
@ -58,7 +60,7 @@ system_asm.o: system_asm.S
$(ASM) $@ $^
clean:
make -C realmode clean
$(MAKE) realmode clean
$(REMOVE) system
$(REMOVE) piggy.S
$(REMOVE) *.o
@ -72,12 +74,13 @@ clean:
$(REMOVE) *.sys
$(REMOVE) *.s
$(REMOVE) *.c~
sync
$(SYNC)
indent:
make -C realmode indent
$(MAKE) realmode indent
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
sync
$(SYNC)

View File

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

View File

@ -17,7 +17,7 @@ togit: clean indent
clean:
$(REMOVE) *.o
$(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
indent: