parent
fe90ab4f39
commit
b219c030cf
5 changed files with 28 additions and 47 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,5 @@
|
||||||
limine
|
limine
|
||||||
ovmf-X64
|
ovmf-x64
|
||||||
kernel/limine.h
|
kernel/limine.h
|
||||||
*.elf
|
*.elf
|
||||||
*.iso
|
*.iso
|
||||||
|
|
31
GNUmakefile
31
GNUmakefile
|
@ -1,12 +1,3 @@
|
||||||
ARCH ?= x86_64
|
|
||||||
|
|
||||||
# Check that the architecture is supported and set relevant variables.
|
|
||||||
ifeq ($(ARCH),x86_64)
|
|
||||||
override EFI_ARCH := X64
|
|
||||||
else
|
|
||||||
$(error Architecture $(ARCH) not supported)
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: barebones.iso
|
all: barebones.iso
|
||||||
|
|
||||||
|
@ -15,23 +6,23 @@ all-hdd: barebones.hdd
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: barebones.iso
|
run: barebones.iso
|
||||||
qemu-system-$(ARCH) -M q35 -m 2G -cdrom barebones.iso -boot d
|
qemu-system-x86_64 -M q35 -m 2G -cdrom barebones.iso -boot d
|
||||||
|
|
||||||
.PHONY: run-uefi
|
.PHONY: run-uefi
|
||||||
run-uefi: ovmf-$(EFI_ARCH) barebones.iso
|
run-uefi: ovmf-x64 barebones.iso
|
||||||
qemu-system-$(ARCH) -M q35 -m 2G -bios ovmf-$(EFI_ARCH)/OVMF.fd -cdrom barebones.iso -boot d
|
qemu-system-x86_64 -M q35 -m 2G -bios ovmf-x64/OVMF.fd -cdrom barebones.iso -boot d
|
||||||
|
|
||||||
.PHONY: run-hdd
|
.PHONY: run-hdd
|
||||||
run-hdd: barebones.hdd
|
run-hdd: barebones.hdd
|
||||||
qemu-system-$(ARCH) -M q35 -m 2G -hda barebones.hdd
|
qemu-system-x86_64 -M q35 -m 2G -hda barebones.hdd
|
||||||
|
|
||||||
.PHONY: run-hdd-uefi
|
.PHONY: run-hdd-uefi
|
||||||
run-hdd-uefi: ovmf-$(EFI_ARCH) barebones.hdd
|
run-hdd-uefi: ovmf-x64 barebones.hdd
|
||||||
qemu-system-$(ARCH) -M q35 -m 2G -bios ovmf-$(EFI_ARCH)/OVMF.fd -hda barebones.hdd
|
qemu-system-x86_64 -M q35 -m 2G -bios ovmf-x64/OVMF.fd -hda barebones.hdd
|
||||||
|
|
||||||
ovmf-$(EFI_ARCH):
|
ovmf-x64:
|
||||||
mkdir -p ovmf-$(EFI_ARCH)
|
mkdir -p ovmf-x64
|
||||||
cd ovmf-$(EFI_ARCH) && curl -o OVMF-$(EFI_ARCH).zip https://efi.akeo.ie/OVMF/OVMF-$(EFI_ARCH).zip && 7z x OVMF-$(EFI_ARCH).zip
|
cd ovmf-x64 && curl -o OVMF-X64.zip https://efi.akeo.ie/OVMF/OVMF-X64.zip && 7z x OVMF-X64.zip
|
||||||
|
|
||||||
limine:
|
limine:
|
||||||
git clone https://github.com/limine-bootloader/limine.git --branch=v3.0-branch-binary --depth=1
|
git clone https://github.com/limine-bootloader/limine.git --branch=v3.0-branch-binary --depth=1
|
||||||
|
@ -67,7 +58,7 @@ barebones.hdd: limine kernel
|
||||||
sudo mount `cat loopback_dev`p1 img_mount
|
sudo mount `cat loopback_dev`p1 img_mount
|
||||||
sudo mkdir -p img_mount/EFI/BOOT
|
sudo mkdir -p img_mount/EFI/BOOT
|
||||||
sudo cp -v kernel/kernel.elf limine.cfg limine/limine.sys img_mount/
|
sudo cp -v kernel/kernel.elf limine.cfg limine/limine.sys img_mount/
|
||||||
sudo cp -v limine/BOOT$(EFI_ARCH).EFI img_mount/EFI/BOOT/
|
sudo cp -v limine/BOOTX64.EFI img_mount/EFI/BOOT/
|
||||||
sync
|
sync
|
||||||
sudo umount img_mount
|
sudo umount img_mount
|
||||||
sudo losetup -d `cat loopback_dev`
|
sudo losetup -d `cat loopback_dev`
|
||||||
|
@ -80,5 +71,5 @@ clean:
|
||||||
|
|
||||||
.PHONY: distclean
|
.PHONY: distclean
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -rf limine ovmf-$(EFI_ARCH)
|
rm -rf limine ovmf-x64
|
||||||
$(MAKE) -C kernel distclean
|
$(MAKE) -C kernel distclean
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# Limine Bare Bones
|
# Limine Bare Bones
|
||||||
|
|
||||||
This repository will show you how to set up a simple 64-bit higher half kernel using Limine.
|
This repository will show you how to set up a simple 64-bit x86_64 Long Mode higher half kernel using Limine.
|
||||||
|
|
||||||
This project can be built using the host compiler on most Linux distros, but it's recommended you set up a [cross compiler](https://wiki.osdev.org/GCC_Cross-Compiler) for your target architecture.
|
This project can be built using the host compiler on most Linux distros on x86_64, but it's recommended you set up an x86_64-elf [cross compiler](https://wiki.osdev.org/GCC_Cross-Compiler).
|
||||||
|
|
||||||
It is also recommended to cross reference the contents of this repository with [the Limine Bare Bones](https://wiki.osdev.org/Limine_Bare_Bones) OSDev wiki page.
|
It is also recommended to cross reference the contents of this repository with [the Limine Bare Bones](https://wiki.osdev.org/Limine_Bare_Bones) OSDev wiki page.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
# Target processor architecture.
|
|
||||||
ARCH ?= x86_64
|
|
||||||
|
|
||||||
# This is the name that our final kernel executable will have.
|
# This is the name that our final kernel executable will have.
|
||||||
# Change as needed.
|
# Change as needed.
|
||||||
override KERNEL := kernel.elf
|
override KERNEL := kernel.elf
|
||||||
|
@ -35,6 +32,14 @@ override INTERNALCFLAGS := \
|
||||||
-fno-stack-check \
|
-fno-stack-check \
|
||||||
-fno-pie \
|
-fno-pie \
|
||||||
-fno-pic \
|
-fno-pic \
|
||||||
|
-mabi=sysv \
|
||||||
|
-mno-80387 \
|
||||||
|
-mno-mmx \
|
||||||
|
-mno-3dnow \
|
||||||
|
-mno-sse \
|
||||||
|
-mno-sse2 \
|
||||||
|
-mno-red-zone \
|
||||||
|
-mcmodel=kernel \
|
||||||
-MMD
|
-MMD
|
||||||
|
|
||||||
# Internal linker flags that should not be changed by the user.
|
# Internal linker flags that should not be changed by the user.
|
||||||
|
@ -44,25 +49,6 @@ override INTERNALLDFLAGS := \
|
||||||
-Wl,-z,max-page-size=0x1000 \
|
-Wl,-z,max-page-size=0x1000 \
|
||||||
-Wl,-T,linker.ld
|
-Wl,-T,linker.ld
|
||||||
|
|
||||||
# Set archtecture specific variables (and check that the architecture is supported).
|
|
||||||
ifeq ($(ARCH),x86_64)
|
|
||||||
override INTERNALCFLAGS += \
|
|
||||||
-m64 \
|
|
||||||
-march=x86-64 \
|
|
||||||
-mabi=sysv \
|
|
||||||
-mno-80387 \
|
|
||||||
-mno-mmx \
|
|
||||||
-mno-sse \
|
|
||||||
-mno-sse2 \
|
|
||||||
-mno-red-zone \
|
|
||||||
-mcmodel=kernel
|
|
||||||
override INTERNALLDFLAGS += \
|
|
||||||
-Wl,-m,elf_x86_64 \
|
|
||||||
-Wl,--oformat=elf64-x86-64
|
|
||||||
else
|
|
||||||
$(error Architecture $(ARCH) not supported)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Use find to glob all *.c files in the directory and extract the object names.
|
# Use find to glob all *.c files in the directory and extract the object names.
|
||||||
override CFILES := $(shell find ./ -type f -name '*.c')
|
override CFILES := $(shell find ./ -type f -name '*.c')
|
||||||
override OBJ := $(CFILES:.c=.o)
|
override OBJ := $(CFILES:.c=.o)
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
/* Tell the linker that we want an x86_64 ELF64 output file */
|
||||||
|
OUTPUT_FORMAT(elf64-x86-64)
|
||||||
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
|
|
||||||
/* We want the symbol _start to be our entry point */
|
/* We want the symbol _start to be our entry point */
|
||||||
ENTRY(_start)
|
ENTRY(_start)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue