Make osdev example more uniform with the hello world
This commit is contained in:
@@ -7,9 +7,10 @@ Hello world programs that run without an operating system.
|
||||
1. [min](min.S)
|
||||
1. [No ld script](no-ld-script/)
|
||||
1. [NASM](nasm/)
|
||||
1. [bios_one_char](bios_one_char.S)
|
||||
1. [bios_hello_world](bios_hello_world.S)
|
||||
1. [shutdown_apm](shutdown_apm.S)
|
||||
1. [BIOS one char](bios_one_char.S)
|
||||
1. [BIOS hello world](bios_hello_world.S)
|
||||
1. [APM shutdown](apm_shutdown.S)
|
||||
1. [APM shutdown 2](apm_shutdown2.S)
|
||||
1. [Multiboot](multiboot/)
|
||||
1. TODO not working
|
||||
1. [UEFI](uefi/)
|
||||
@@ -38,7 +39,7 @@ To run on real hardware, insert an USB, determine its device (`/dev/sdX`) with:
|
||||
sudo lsblk
|
||||
sudo fdisk -l
|
||||
|
||||
Run:
|
||||
Pick the `.img` file that you wan to run and:
|
||||
|
||||
sudo dd if=bios_hello_world.img of=/dev/sdX
|
||||
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
.POSIX:
|
||||
|
||||
BIN := isodir/boot/main.bin
|
||||
MAIN := main.iso
|
||||
ISODIR := iso
|
||||
MULTIBOOT := $(ISODIR)/boot/main.elf
|
||||
MAIN := main.img
|
||||
|
||||
.PHONY: clean run
|
||||
|
||||
$(MAIN):
|
||||
as -32 boot.S -o boot.o
|
||||
gcc -c kernel.c -ffreestanding -m32 -o kernel.o -std=gnu99
|
||||
gcc -ffreestanding -m32 -nostdlib -o '$(BIN)' -T linker.ld boot.o kernel.o -lgcc
|
||||
grub-mkrescue -o main.iso isodir
|
||||
gcc -ffreestanding -m32 -nostdlib -o '$(MULTIBOOT)' -T linker.ld boot.o kernel.o -lgcc
|
||||
grub-mkrescue -o '$@' '$(ISODIR)'
|
||||
|
||||
clean:
|
||||
rm -f *.o '$(BIN)' '$(MAIN)'
|
||||
rm -f *.o '$(MULTIBOOT)' '$(MAIN)'
|
||||
|
||||
run: $(MAIN)
|
||||
qemu-system-i386 -cdrom '$(MAIN)'
|
||||
# Would also work.
|
||||
#qemu-system-i386 -hda '$(MAIN)'
|
||||
#qemu-system-i386 -kernel myos.bin
|
||||
#qemu-system-i386 -kernel '$(MULTIBOOT)'
|
||||
|
||||
5
multiboot/osdev/iso/boot/grub/grub.cfg
Normal file
5
multiboot/osdev/iso/boot/grub/grub.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
set timeout=0
|
||||
set default="0"
|
||||
menuentry "main" {
|
||||
multiboot /boot/main.elf
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
menuentry "main" {
|
||||
multiboot /boot/main.bin
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
BASENAME ?= bios_hello_world
|
||||
IN_EXT ?= .asm
|
||||
OUT_EXT ?= .bin
|
||||
OUT_EXT ?= .img
|
||||
|
||||
OUT := $(BASENAME)$(OUT_EXT)
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# No ld script
|
||||
|
||||
Hello world using the default `ld` script, no explicit one set with `-T`. Uses:
|
||||
|
||||
- `-tText`
|
||||
- `.org` inside each assembly file
|
||||
- `_start` must be present to avoid a warning, since the default linker script expects it
|
||||
|
||||
Less convenient, but a little less code if you are using a single file.
|
||||
9
no-linker-script/README.md
Normal file
9
no-linker-script/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# No linker script
|
||||
|
||||
Hello world using the default `ld` script, not an explicit one set with `-T`. Uses:
|
||||
|
||||
- `-tText`
|
||||
- `.org` inside each assembly file
|
||||
- `_start` must be present to avoid a warning, since the default linker script expects it
|
||||
|
||||
Less stable, but more convenient for quick and dirty tests.
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
Minimal boot sector example that does nothing, just halts immediately, generated with `printf` byte by byte.
|
||||
|
||||
You can get more minimal than this.
|
||||
You can't get more minimal than this.
|
||||
|
||||
Reference in New Issue
Block a user