Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: bios-build

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: make
run: make
- name: Upload bios.bin
uses: actions/upload-artifact@v1
with:
name: bios.bin
path: build/bios.bin
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
*.o
*.d
*.bin
*.elf
80 changes: 80 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
CC ?= $(CROSS)gcc
AS ?= $(CROSS)gcc
OBJCOPY ?= $(CROSS)objcopy
O ?= build

all: $O/bios.bin
ROMSIZE = 65536

$O: ; mkdir -p $@

CFLAGS = \
-W \
-Wall \
-m32 \
-march=i386 \
-mregparm=3 \
-fno-stack-protector \
-fno-delete-null-pointer-checks \
-ffreestanding \
-mstringop-strategy=rep_byte \
-minline-all-stringops \
-fno-pic \
-Iinclude \
-MT $@ \
-MMD -MP \
-MF $O/$*.d \

ASFLAGS = $(CFLAGS)

LDFLAGS = \
-nostdlib \
-m32 \
-Wl,--build-id=none \
-Wl,-Tflat.lds \

OBJS = \
code16.o \
code32seg.o \
cstart.o \
entry.o \
fw_cfg.o \
hwsetup.o \
linuxboot.o \
main.o \
malloc.o \
mptable.o \
pci.o \
printf.o \
string.o \
smbios.o \
tables.o \

$O/bios.elf: $(addprefix $O/,$(OBJS))
$(CC) $(LDFLAGS) -o $@ $^

$O/%.bin: $O/%.elf
$(OBJCOPY) \
-O binary \
-j .text \
-j .rodata \
-j .data \
-j .bss \
-j .init \
$< \
"[email protected]"
@if [ `stat -c '%s' "[email protected]"` != $(ROMSIZE) ]; then \
echo >&2 '$@ != $(ROMSIZE) bytes!' ; \
exit 1 ; \
fi
mv "[email protected]" "$@"

$O/%.o: %.c | $O
$(CC) $(CFLAGS) -c -o $@ $<
$O/%.o: %.S | $O
$(CC) $(ASFLAGS) -c -o $@ $<

clean:
$(RM) $O/*.o $O/bios.bin $O/bios.bin.elf $O/*.d

-include $O/*.d
12 changes: 8 additions & 4 deletions README → README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[![Build status](../../workflows/bios-build/badge.svg)](../../actions?query=workflow%3Abios-build)

A simple x86 firmware that can boot Linux.

Most of QEMU's startup time is spent:

* in the dynamic linker. This can be reduced by 150 ms simply by
compiling a stripped down QEMU:

```
./configure --disable-libssh2 --disable-tcmalloc --disable-glusterfs \
--disable-seccomp --disable-{bzip2,snappy,lzo} --disable-usb-redir \
--disable-libusb --disable-smartcard-nss --disable-libnfs \
Expand All @@ -14,13 +17,14 @@ Most of QEMU's startup time is spent:
--disable-fdt --disable-curl --disable-curses --disable-sdl \
--disable-gtk --disable-tpm --disable-vte --disable-vnc \
--disable-xen --disable-opengl --target-list=x86_64-softmmu
```

* in the BIOS. qboot saves another 150 ms.

* until QEMU 2.7+, in fw_cfg. qboot uses the DMA interface which is pretty
* until QEMU 2.7+, in `fw_cfg`. qboot uses the DMA interface which is pretty
much instantaneous.

Compile qboot
Compile `qboot`
=============

Clone the source:
Expand All @@ -30,9 +34,9 @@ Clone the source:
Compile the qboot firmware (you may need to install the relevant build
time dependancies):

$ meson build && ninja -C build
$ make

The result will be a 64K file named bios.bin under the build/ directory.
The result will be a 64K file named `build/bios.bin`.

Usage
=====
Expand Down
52 changes: 0 additions & 52 deletions meson.build

This file was deleted.