Skip to content

Commit

Permalink
Source + readme + license
Browse files Browse the repository at this point in the history
  • Loading branch information
luthor112 committed Oct 9, 2022
1 parent 3a2d7c1 commit 5d48a58
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
13 changes: 13 additions & 0 deletions COPYING.WTFPL
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
5 changes: 5 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Copyright © 2022 luthor112

This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See the COPYING file for more details.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# qefi
Quick POSIX-UEFI environment and test script

Based on:
- [POSIX-UEFI on GitLab](https://gitlab.com/bztsrc/posix-uefi)
- [UEFI on OSDev](https://wiki.osdev.org/UEFI)
- [POSIX-UEFI on OSDev](https://wiki.osdev.org/POSIX-UEFI)

Commands:
- `qefi setup` installs needed dependencies
- `qefi new NAME` creates a new environment in the NAME directory
- `qefi build` runs `make`...
- `qefi image` builds a disk image containing the built binary
- `qefi run` runs QEMU and drops you into the EFI Shell
43 changes: 43 additions & 0 deletions qefi
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

case "$1" in
setup)
sudo apt-get -y update
sudo apt-get -y install build-essential make git qemu-system-x86-64 ovmf mtools
git clone https://gitlab.com/bztsrc/posix-uefi.git ~/posix-uefi
;;
new)
mkdir $2
ln -s ~/posix-uefi/uefi $2/uefi

echo "TARGET = $2.efi" > $2/Makefile
echo "include uefi/Makefile" >> $2/Makefile

echo '#include <uefi.h>' > $2/main.c
echo '' >> $2/main.c
echo 'int main (int argc, char **argv)' >> $2/main.c
echo '{' >> $2/main.c
echo ' printf("Hello, world!\n");' >> $2/main.c
echo ' return 0;' >> $2/main.c
echo '}' >> $2/main.c
;;
build)
make
;;
image)
dd if=/dev/zero of=uefi.img bs=512 count=93750
parted uefi.img -s -a minimal mklabel gpt
parted uefi.img -s -a minimal mkpart EFI FAT16 2048s 93716s
parted uefi.img -s -a minimal toggle 1 boot

dd if=/dev/zero of=part.img bs=512 count=91669
mformat -i part.img -h 32 -t 32 -n 64 -c 1
mcopy -i part.img *.efi ::

dd if=part.img of=uefi.img bs=512 count=91669 seek=2048 conv=notrunc
;;
run)
sudo qemu-system-x86_64 -cpu qemu64 -drive if=pflash,format=raw,unit=0,file=/usr/share/OVMF/OVMF_CODE.fd,readonly=on -drive if=pflash,format=raw,unit=1,file=/usr/share/OVMF/OVMF_VARS.fd -net none -nographic -drive file=uefi.img,if=ide
;;
esac
echo "Done."

0 comments on commit 5d48a58

Please sign in to comment.