Skip to content

LandStander27/zig-efi-lib

Repository files navigation

Zig EFI

A simple library for creating EFI applications/operating systems in Zig.

Installation

NOTE: Only Zig version 0.14.0-dev.2577+271452d22 is supported as of the latest commit. (Although you will not need zig to compile, as it uses docker by default).

  1. In your project containing your build.zig file:
zig fetch --save git+https://codeberg.org/Land/zig-efi-lib
  1. Copy these files into your project:
  1. Done!

Building an EFI Application

  1. Install Docker
  2. Run:
make docker name="name of OS"

Highlighted features

  • Never have to call EFI functions manually
  • Heap management
  • Optional panic handler that enables partial debugging (depending on how far along the OS setup is)
  • Graphics
    • Text rendering
    • 2D graphics (can make games)
  • EFI Filesystem
    • Read-only filesystem
    • Files and directories
  • Input/Output
    • Experimental mouse input
  • Hardware RNG
    • Fallbacks to software RNG if hardware RNG fails

API Reference

Automatically generated API Reference for the project can be found at https://landstander27.github.io/zig-efi-lib. Note that Zig autodoc is in beta; the website may be broken or incomplete.

Examples (Ordered by least-most difficult)

To run these examples, excluding the last one, run make example example="dir" run, with dir being a directory in examples.

  • Hello World: Quick "Hello World" example.
  • Heap: Simple heap example.
  • Panic: Showcases how to use the optional panic handler.
  • Graphics: Text and 2D graphics.
  • Advanced: Skeleton for an "advanced" project.
  • Snake: A snake game. Showcases how to draw to screen with a framebuffer.
  • AeroOS: Simple OS I created that originally gave me the idea for this project. Most of the code of this library is taken from here.

FAQ

  • When building with docker, why are the error messages not "pretty"?:
    • Instead of running make docker, run make docker dockerflags="-it".

About

A simple library for creating EFI applications/operating systems in Zig.

Resources

License

Stars

Watchers

Forks

Contributors