Coder Social home page Coder Social logo

limine-bootloader / limine-c-template Goto Github PK

View Code? Open in Web Editor NEW
117.0 3.0 8.0 53 KB

A simple template for building a Limine-compliant kernel in C.

License: BSD Zero Clause License

Makefile 63.79% C 36.21%
c limine template c-language limine-bootloader x86-64 bare-bones barebones amd64 kernel

limine-c-template's Introduction

Limine C Template

This repository will demonstrate how to set up a basic x86-64 kernel in C using Limine.

It is recommended to cross reference the contents of this repository with the Limine Bare Bones OSDev wiki page.

How to use this?

Dependencies

Any make command depends on GNU make (gmake) and is expected to be run using it. This usually means using make on most GNU/Linux distros, or gmake on other non-GNU systems.

All make all* targets depend on a GNU-compatible C toolchain capable of generating x86-64 ELF objects. Usually gcc/binutils or clang/llvm/lld provided by any x86-64 UNIX like (including Linux) distribution will suffice.

Additionally, building an ISO with make all requires xorriso, and building a HDD/USB image with make all-hdd requires sgdisk (usually from gdisk or gptfdisk packages) and mtools.

Makefile targets

Running make all will compile the kernel (from the kernel/ directory) and then generate a bootable ISO image.

Running make all-hdd will compile the kernel and then generate a raw image suitable to be flashed onto a USB stick or hard drive/SSD.

Running make run will build the kernel and a bootable ISO (equivalent to make all) and then run it using qemu (if installed).

Running make run-hdd will build the kernel and a raw HDD image (equivalent to make all-hdd) and then run it using qemu (if installed).

The run-uefi and run-hdd-uefi targets are equivalent to their non -uefi counterparts except that they boot qemu using a UEFI-compatible firmware.

limine-c-template's People

Contributors

dbstream avatar mintsuki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

limine-c-template's Issues

change make dep

The makefile (./kernel/GNUmakefile) should have itself and the linker.ld as dependencies for all object files, as changes in cflags/linker flags can lead to subtle breakage of the kernel if object files are compiled with different flags.

How to compile for 32 bits?

Probably silly question, how can I compile for 32 bits? Currently my GTD/IDT/ISRs are for 32 bits so a 64 bit build doesn't work properly.
When I run QEMU (yes it's a qemu-system-i386 the screen says:
image

Code:

  • Full code can be found here
  • limine.cfg found here
  • linker.ld found here

Anything else can be found in the many Makefiles.

The link the makefile uses to obtain OVMF appears to be broken

curl -Lo OVMF-X64.zip https://efi.akeo.ie/OVMF/OVMF-X64.zip

This part of the topmost makefile seems not to work as of writing this because it appears that the link is broken. I am unsure if this issue only exists for me or if that link really is broken and the makefile needs to be fixed so that it obtains the OVMF from somewhere else.

Input?

Is their any way of getting input.

Building under Cygwin gives the error cc1: error: code model kernel does not support PIC mode

Running the make command on cygwin i get the following output

username@ARK /cygdrive/c/Users/username/OSDev
$ make
git clone https://github.com/limine-bootloader/limine.git --branch=v3.0-branch-binary --depth=1
Cloning into 'limine'...
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 17 (delta 3), reused 7 (delta 1), pack-reused 0
Receiving objects: 100% (17/17), 410.04 KiB | 3.15 MiB/s, done.
Resolving deltas: 100% (3/3), done.
make -C limine
make[1]: Entering directory '/cygdrive/c/Users/username/OSDev/limine'
cc -g -O2 -pipe -Wall -Wextra  -std=c99 -D__USE_MINGW_ANSI_STDIO limine-version.c -o limine-version
make[1]: Leaving directory '/cygdrive/c/Users/username/OSDev/limine'
make -C kernel
make[1]: Entering directory '/cygdrive/c/Users/username/OSDev/kernel'
curl https://raw.githubusercontent.com/limine-bootloader/limine/trunk/limine.h -o limine.h
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9993  100  9993    0     0  44571      0 --:--:-- --:--:-- --:--:-- 44811
cc  -O2 -g -Wall -Wextra -Wpedantic -pipe -I. -std=c11 -ffreestanding -fno-stack-protector -fno-stack-check -fno-pie -fno-pic -m64 -march=x86-64 -mabi=sysv -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone -mcmodel=kernel -MMD -c kernel.c -o kernel.o
cc1: error: code model kernel does not support PIC mode
make[1]: *** [GNUmakefile:89: kernel.o] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/username/OSDev/kernel'
make: *** [GNUmakefile:33: kernel] Error 2

I would provide more information but I'm not really sure what else to include

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.