From 96ca7ee67a36605a33de8d57eb8e8d3998bc6427 Mon Sep 17 00:00:00 2001
From: Michał Masłowski <mtjm@mtjm.eu>
Date: Wed, 03 Sep 2014 14:30:21 -0400
Subject: Merge libreboot-6b6.

Conflicts:
	buildrom-withgrub
---
(limited to 'buildrom-withgrub')

diff --git a/buildrom-withgrub b/buildrom-withgrub
index faa785d..6ff7e2d 100755
--- a/buildrom-withgrub
+++ b/buildrom-withgrub
@@ -3,7 +3,7 @@
 #  buildrom-withgrub script: this generically builds the ROM images.
 #  The ROM images built by this script will use the GRUB payload.
 #
-#	Copyright (C) 2014 Francis Rowe
+#	Copyright (C) 2014 Francis Rowe <info@gluglug.org.uk>
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -22,9 +22,6 @@
 # DO NOT RUN THIS DIRECTLY!
 # Use "build"
 
-# base ROM's: coreboot_usqwerty.rom and coreboot_serial_usqwerty.rom
-# All other ROM's will be based on one of these.
-
 if (( $# != 1 )); then
 	echo "Usage: ./buildrom-withgrub boardname"
 	echo "Example: ./buildrom-withgrub x60"
@@ -42,82 +39,95 @@ rm -rf .config
 [[ -f cbfstool ]] || mv util/cbfstool/cbfstool .
 
 # prepare libreboot configuration and build it
+# it is assumed that these configs use coreboot text-mode
+# instead of coreboot framebuffer, by default
 cp ../resources/libreboot/config/$1/config .config
-
 # coreboot.rom will appear under ./coreboot/build
 make
-
 # move it out (we'll be cleaning the build)
-# also rename it to libreboot_usqwerty.rom
-mv build/coreboot.rom libreboot_usqwerty.rom
-
+mv build/coreboot.rom libreboot_txtmode.rom
 # clean the build
 make clean
-rm -rf .config
 
-# Insert files/configurations and perform operations that are common on all ROM images
-# ---------------------------------------------------------------------------------------------------------------
+# Now prepare ROM images that use coreboot vesa framebuffer instead of text mode.
+mv .config config_txtmode
+# create .config for vesa framebuffer (instead of text mode)
+sed 's/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/' < config_txtmode > .config
+# build new ROM
+make
+mv build/coreboot.rom libreboot_vesafb.rom
+# clean coreboot (again)
+make clean
 
-# Add background image and font
-./cbfstool libreboot_usqwerty.rom add -f ../resources/grub/background/background.jpg -n background.jpg -t raw
-./cbfstool libreboot_usqwerty.rom add -f ../resources/grub/background/gnulove.jpg -n gnulove.jpg -t raw
-./cbfstool libreboot_usqwerty.rom add -f ../resources/grub/font/dejavusansmono.pf2 -n dejavusansmono.pf2 -t raw
+# copies no longer needed
+rm -rf .config config_txtmode
 
-# Insert files/configurations and perform operations that are common on *serial* ROM images
+# Insert files/configurations and perform operations that are common on all images
 # ---------------------------------------------------------------------------------------------------------------
 
-# ROM's based on this will have MemTest86+ included inside.
-cp libreboot_usqwerty.rom libreboot_serial_usqwerty.rom
-
-# Add memtest86+ to libreboot_serial_usqwerty.rom
-./cbfstool libreboot_serial_usqwerty.rom add -f ../memtest86+-5.01/memtest -n memtest -t raw
+for rom in libreboot_vesafb.rom libreboot_txtmode.rom
+do
+	# Add SeaBIOS and SeaVGABIOS
+	./cbfstool $rom add -f ../seabios/out/vgabios.bin -n vgaroms/vgabios.bin -t raw
+	./cbfstool $rom add -f ../seabios/out/bios.bin.elf -n bios.bin.elf -t raw
+done
 
-# Prepare ROM's (based on libreboot_usqwerty.rom and libreboot_serial_usqwerty.rom) with
-# alternative keyboard layout configurations inside GRUB
+# Insert files/configurations and perform operations that are common on libreboot_vesafb.rom (coreboot framebuffer configuration)
 # ---------------------------------------------------------------------------------------------------------------
 
-# The for loops MUST be separate. Do NOT re-factor them!
+# Add background image and font
+./cbfstool libreboot_vesafb.rom add -f ../resources/grub/background/background.jpg -n background.jpg -t raw
+# ./cbfstool libreboot_vesafb.rom add -f ../resources/grub/background/gnulove.jpg -n gnulove.jpg -t raw
+./cbfstool libreboot_vesafb.rom add -f ../resources/grub/font/dejavusansmono.pf2 -n dejavusansmono.pf2 -t raw
 
-# default configs
-cp ../resources/grub/config/$1/grub_usqwerty.cfg .
-cp ../resources/grub/config/$1/grub_serial_usqwerty.cfg .
+# Insert files/configurations and perform operations that are common on libreboot_txtmode.rom (coreboot text mode)
+# ---------------------------------------------------------------------------------------------------------------
 
-for keymap in $(ls ../resources/grub/keymap/original)
-do
-    if [[ "$keymap" != usqwerty ]]; then
-	# copy the ROM based on the keymap
-	cp libreboot_usqwerty.rom libreboot_"$keymap".rom
-	cp libreboot_serial_usqwerty.rom libreboot_serial_"$keymap".rom
-    fi
-done
+# Add memtest86+
+./cbfstool libreboot_txtmode.rom add -f ../memtest86+-5.01/memtest -n memtest -t raw
 
-for keymap in $(ls ../resources/grub/keymap/original)
-do
-    if [[ "$keymap" != usqwerty ]]; then
-	# copy the config based on the keymap:
-	cp grub_usqwerty.cfg grub_"$keymap".cfg
-	cp grub_serial_usqwerty.cfg grub_serial_"$keymap".cfg
-    fi
-done
+# Add GRUB Invaders
+./cbfstool libreboot_txtmode.rom add -f ../grubinvaders/invaders -n invaders -t raw
+./cbfstool libreboot_txtmode.rom add -f ../grubinvaders/invaders.exec -n invaders.exec -t raw
 
-for keymap in $(ls ../resources/grub/keymap/original)
-do
-	# Insert GRUB keymap instructions into the config
-	echo "keymap $keymap" >> grub_"$keymap".cfg
-	echo "keymap $keymap" >> grub_serial_"$keymap".cfg
-done
+# Generate the GRUB configurations and add them to each ROM image as grub.cfg and grubtest.cfg
+# ---------------------------------------------------------------------------------------------------------------
 
-for keymap in $(ls ../resources/grub/keymap/original)
+for keymap in $(ls ../resources/utilities/grub-assemble/keymap/original)
 do
-	# Set the GRUB keymap for the given ROM image
-	./cbfstool libreboot_"$keymap".rom add -f grub_"$keymap".cfg -n grub.cfg -t raw
-	./cbfstool libreboot_serial_"$keymap".rom add -f grub_serial_"$keymap".cfg -n grub.cfg -t raw
+	for romtype in txtmode vesafb
+	do
+		# copy the images based on the keymap
+		cp libreboot_"$romtype".rom libreboot_"$keymap"_"$romtype".rom
+
+		# generate the correct grub config
+		touch grub_"$keymap"_"$romtype".cfg
+		# generate contents:
+		cat ../resources/grub/config/extra/common.cfg >> grub_"$keymap"_"$romtype".cfg
+		cat ../resources/grub/config/extra/"$romtype".cfg >> grub_"$keymap"_"$romtype".cfg
+		echo "keymap $keymap" >> grub_"$keymap"_"$romtype".cfg
+		cat ../resources/grub/config/menuentries/common.cfg >> grub_"$keymap"_"$romtype".cfg
+		cat ../resources/grub/config/menuentries/"$romtype".cfg >> grub_"$keymap"_"$romtype".cfg
+
+		# Insert grub config into the image
+		./cbfstool libreboot_"$keymap"_"$romtype".rom add -f grub_"$keymap"_"$romtype".cfg -n grub.cfg -t raw
+
+		# grubtest.cfg should be able to switch back to grub.cfg
+		sed 's/grubtest.cfg/grub.cfg/' < grub_"$keymap"_"$romtype".cfg > grub_"$keymap"_"$romtype"_test.cfg
+
+		# Insert grub test config into the image (for the user to test modifications to before modifying the main one)
+		./cbfstool libreboot_"$keymap"_"$romtype".rom add -f grub_"$keymap"_"$romtype"_test.cfg -n grubtest.cfg -t raw
+	done
 done
 
-# we don't need the grub.cfg's anymore
+# we don't need the generic rom images anymore
+rm -rf libreboot_txtmode.rom
+rm -rf libreboot_vesafb.rom
+
+# we don't need the grub configs anymore
 rm -rf grub*cfg
 
-# Now we clean up and prepare the binary archive ready for release.
+# Now we clean up and prepare the bin directory containing all the images
 # ----------------------------------------------------------------------------------------------------------------------------
 
 # prepare directory for new ROM images
--
cgit v0.9.1