build: correction des makefiles et ajout du disque dur UEFI

This commit is contained in:
Nicolas Hordé 2020-09-17 09:52:56 +02:00
parent 5afa43629d
commit 7cd20f6c0b
10 changed files with 308 additions and 149 deletions

BIN
final/harddiskuefi.img.xz Normal file

Binary file not shown.

View File

@ -1,47 +1,57 @@
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
mkdir ./mnt -p
sync
REMOVE=rm -f
INSTALL=sudo apt-get install
COPY=cp
DISKCOPY=dd
COMPRESS=xz
SYNC=sync
CREATEDIR=mkdir
CAT=cat
MAKE=make -C
harddiskuefi.img.final: initram.img harddiskuefi.img.before
all: harddisk.img.final harddiskuefi.img.final
harddiskuefi.img.before:
$(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/
cp ./initram.img ./mnt/boot/
sync
$(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
$(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
mkdir ./mnt -p
sync
$(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: initram.img harddisk.img.before
harddisk.img.final: harddisk.img.before
mount.fuse-ext2 -o rw+ harddisk.img.part1 ./mnt
cp ../system/system.sys ./mnt/boot/
cp ./initram.img ./mnt/boot/
sync
$(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
$(SYNC)
initram.img:
make -C ../programs
$(MAKE) ../programs
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)

174
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
@ -28,67 +46,75 @@ remakeapi:
$(MAKECALL)
programs:
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 cramfsprogs 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
wget http://ftp.fr.debian.org/debian/pool/main/c/cramfs/cramfsprogs_1.1-6_amd64.deb -O /tmp/cramfsprogs_1.1-6_amd64.deb
dpkg -i /tmp/cramfsprogs_1.1-6_amd64.deb
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
@ -96,48 +122,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,9 +7,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.a
sync
$(SYNC)
togit: clean indent
@ -26,7 +27,7 @@ clean:
$(REMOVE) *.o
$(REMOVE) *.c~
$(REMOVE) *.a
sync
$(SYNC)
indent:
$(CHANGEPERM) *.c
@ -37,4 +38,5 @@ indent:
$(CONVERT) ../include/*.h
$(INDENT) ../include/*.h
$(REMOVE) ../include/*.h~
sync
$(SYNC)

View File

@ -8,9 +8,11 @@ REMOVE=rm -f
CHANGELF=elfedit --output-osabi FenixOS
CHANGEPERM=chmod 644
MOVE=mv
SYNC=sync
MAKE=make -C
all: lib/libs.a ../final/initram.img
sync
$(SYNC)
togit: clean indent
@ -19,7 +21,7 @@ togit: clean indent
mkcramfs ../final/cramfs/ ../final/initram.img
lib/libs.a:
make -C lib
$(MAKE) lib
%: %.c
$(CC) $@.o $<
@ -33,12 +35,13 @@ clean:
$(REMOVE) *.c~
(find ../final/cramfs/executables -type f ! -perm /u=x -maxdepth 1 -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;;true)
(find . -type f ! -perm /u=x -maxdepth 1 -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;;true)
sync
$(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,98 @@ 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)
GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -I ../include -m32 -fno-pie -no-pie -c -o
ASM=gcc -nostdinc -ffreestanding -fno-builtin -m32 -c -fno-pie -no-pie -I ../include -D__ASSEMBLY__ -c -o
LINK=ld -m elf_i386 -n
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
NM=nm
OBJCOPY=objcopy -O binary -R .note -R .comment -S
OBJDEBUG=objcopy --only-keep-debug
ZOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
VOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p'
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)
allpiggy.o: piggy.o decompress.o header.o
$(LINK) -T allpiggy piggy.o decompress.o header.o
voffset.h: system
$(NM) system|$(VOFFSET)>voffset.h
zoffset.h: piggy.o
$(NM) piggy.o|$(ZOFFSET)>zoffset.h
togit: clean indent
piggy.o: piggy.S
$(ASM) $@ $^
system: system.o system_asm.o ../lib/libs.o
$(LINK) -T system.ld system.o system_asm.o ../lib/libs.o
$(OBJDEBUG) system system.sym
$(NM) system > system.map
system.bin: system
$(OBJCOPY) $^ $@
system.bin.gz: system.bin
cat $^|$(COMP) > $@
piggy.S: system.bin.gz
$(MKPIGGY) $^ > $@
realmode/setup.bin:
$(MAKE) realmode
system.o: system.c
$(GCC) $@ $^
system_asm.o: system_asm.S
$(ASM) $@ $^
clean:
$(MAKE) realmode clean
$(REMOVE) system
$(REMOVE) piggy.S
$(REMOVE) *.o
$(REMOVE) *.tmp
$(REMOVE) *.sym
$(REMOVE) *.map
$(REMOVE) *.gz
$(REMOVE) *.h
$(REMOVE) *.out
$(REMOVE) *.bin
$(REMOVE) *.sys
$(REMOVE) *.s
$(REMOVE) *.c~
$(SYNC)
indent:
$(MAKE) realmode indent
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
$(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

@ -6,9 +6,10 @@ 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
SYNC=sync
all: $(EXECS)
sync
$(SYNC)
togit: clean indent
@ -17,12 +18,13 @@ togit: clean indent
clean:
$(REMOVE) *.o
$(REMOVE) *.c~
find . -type f ! -name makefile -perm /u=x -maxdepth 1 -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;
sync
find . -maxdepth 1 -type f ! -name makefile -perm /u=x -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;
$(SYNC)
indent:
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
sync
$(SYNC)