From bf4556b97210201feb430cd16d3da6d54689a0df Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sat, 12 Sep 2015 11:37:30 +0200 Subject: [PATCH] Infinite loop, rm .elf output --- .gitignore | 1 + bios_one_char.S | 7 +++++-- infinite_loop.S | 11 +++++++++++ multiboot/README.md | 2 +- multiboot/hello-world/Makefile | 5 +++-- multiboot/hello-world/isodir/boot/grub/grub.cfg | 3 +++ multiboot/hello-world/main.elf | Bin 9638 -> 0 bytes template.S | 4 ++++ 8 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 infinite_loop.S create mode 100644 multiboot/hello-world/isodir/boot/grub/grub.cfg delete mode 100755 multiboot/hello-world/main.elf create mode 100644 template.S diff --git a/.gitignore b/.gitignore index 3c3aac9..04443a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.bin *.efi +*.elf *.img *.iso *.o diff --git a/bios_one_char.S b/bios_one_char.S index 084d864..617fbe8 100644 --- a/bios_one_char.S +++ b/bios_one_char.S @@ -1,5 +1,8 @@ -# Print a single `@` character with the BIOS. -# More minimal than the hello world. +/* +Print a single `@` character with the BIOS. +More minimal than the hello world. +*/ + #include "common.h" BEGIN mov $0x40, %al diff --git a/infinite_loop.S b/infinite_loop.S new file mode 100644 index 0000000..48cc960 --- /dev/null +++ b/infinite_loop.S @@ -0,0 +1,11 @@ +/* +This is a common alternative to `hlt`. + +It likely wastes more energy? But is less prone to being interrupted than `hlt`. +*/ + +#include "common.h" +BEGIN +loop: +jmp loop +END diff --git a/multiboot/README.md b/multiboot/README.md index fade8b9..223e62b 100644 --- a/multiboot/README.md +++ b/multiboot/README.md @@ -25,4 +25,4 @@ GRUB leaves the application into a well defined starting state. It seems that Linux does not implement Multiboot natively, but GRUB supports it as an exception: -Use `grub-mkrescue` to make a multiboot file into a bootable disk. +Use `grub-mkrescue` and `grub-mkdisk` to make a multiboot file into a bootable ISO or disk. diff --git a/multiboot/hello-world/Makefile b/multiboot/hello-world/Makefile index a9604eb..d7d9902 100644 --- a/multiboot/hello-world/Makefile +++ b/multiboot/hello-world/Makefile @@ -1,11 +1,12 @@ +# main.elf is the main output: the multiboot file. main.elf: entry.o main.o ld -m elf_i386 -nostdlib -T linker.ld -o '$@' $^ entry.o: entry.asm - nasm -f elf '$<' -o '$@' + nasm -f elf32 '$<' -o '$@' main.o: main.c - gcc -c -m32 -std=c99 -ffreestanding -fno-builtin -Os -Wall -Wextra -o '$@' '$<' + gcc -c -m32 -std=c99 -ffreestanding -fno-builtin -Os -o '$@' -Wall -Wextra '$<' clean: rm -f *.elf *.o diff --git a/multiboot/hello-world/isodir/boot/grub/grub.cfg b/multiboot/hello-world/isodir/boot/grub/grub.cfg new file mode 100644 index 0000000..436dd09 --- /dev/null +++ b/multiboot/hello-world/isodir/boot/grub/grub.cfg @@ -0,0 +1,3 @@ +menuentry "main" { + multiboot /boot/main.bin +} diff --git a/multiboot/hello-world/main.elf b/multiboot/hello-world/main.elf deleted file mode 100755 index 44383cd2233e5d1a03a97b29fec340583c249022..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9638 zcmeHNO>7%Q6n>5!;;061OQ1%fVkEb&r>7 zHq#oVGp(->|FyIIcXn+nypausHK*IIRCwb@$L>owwzihsnLgF}(s7)X zANm@}o$a63%|Fka6XRzZ?**r$e`KP+l=PXI=}e+^QSw$Er0w5ERvtcO-&;3#&YYVS z^b)mhp4J1~&&olRyWD`Ze{T%H{ z@WoaHZ(Za@6N%UKW7#=-$+GpB@rn_9>9{RW^!;ee7>o_bERj*aRIze%@K#Owq8C-> zie|20*2u8Ti@R~Y; zAvD)K-YhWBJLu+_H{izXymb#E=D9rE(us;5fM*^Xd#SO2H25shT_g_xK7q#TLIvz< z>6}l4@LwS3nKz$@J3Y_9<0Xr)lf-gmz8(_0N6fmz{I1%puf*NLvyKw;RhN26EOyw4 zoW#N1^JE;Lw!`POcdTvaF!0{_x1DEz_jGGJe1GvfKsZ?2;rqyY7s#0R07-?|`)HWm z5O-{CX9E2Z_xyOJ3@~3`X+89o8?oc#+Xn?ckHjR#55XV8coW_muVF_~3HVdg`I*D@ zWv-{?{9L~b%=#V`bw6E!*Z1*PfxYXYVSEF4|M<^<`A5a~!9nivJFZ~xZf zxuv%W50m^NRdNeUMxK^!t4?)(YUImit|p7K%T`SgxSXeQRXmVPX1%jeFst+rw6Z5= diff --git a/template.S b/template.S new file mode 100644 index 0000000..48c2e1d --- /dev/null +++ b/template.S @@ -0,0 +1,4 @@ +#include "common.h" +BEGIN +hlt +END