code:
#!/bin/bash

#  helper script: downloads flashrom and patches it
#
#	Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
#
#    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
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# This script assumes that the working directory is the
# root of libreboot_src or libreboot git.

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

# Get flashrom at the last previously tested revision

# Remove the old version that may still exist:
# ------------------------------------------------------------------------------

printf "Downloading flashrom\n"

rm -Rf "flashrom/"

# Get flashrom
# ------------------------------------------------------------------------------

# download it using git
git clone https://github.com/stefanct/flashrom.git

(
cd "flashrom/"

# reset to known revision
git checkout 0.9.9
git reset --hard

# Apply patches
# ------------------------------------------------------------------------------

printf "Enabling whitelist for X200S, X200 Tablet, T400, T500 and R400\n"
git am "../resources/flashrom/patch/0001-New-laptops-whitelisted-ThinkPad-R400-and-ThinkPad-T.patch"

printf "Enabling whitelist for Libiquity Taurinus X200\n"
git am "../resources/flashrom/patch/0002-Add-whitelist-for-Taurinus-X200-laptop.patch"

# Remove redundant definitions for the flash chips that
# supported libreboot systems use. This removes the need
# for the user to run with the "-c" argument on these systems
printf "Patching flashchips.c to remove the redundant entries\n"
git am "../resources/flashrom/patch/0003-purged-chips.patch"
)

printf "\n\n"


code:
#!/bin/bash

#  helper script: Downloads GRUB and patches it.
#
#	Copyright (C) 2014, 2015, 2016 Leah Rowe <info@minifree.org>
#
#    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
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# This script assumes that the working directory is the
# root of libreboot_src or libreboot git.

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

# Remove the old version that may still exist
# ------------------------------------------------------------------------------

printf "Downloading GRUB\n"

rm -Rf "grub/"

# Get latest GRUB
# ------------------------------------------------------------------------------

# download it using git
git clone git://git.savannah.gnu.org/grub.git || git clone http://git.savannah.gnu.org/r/grub.git

# modifications are required
cd "grub/"

# reset to known revision
git reset --hard 7f2a856faec951b7ab816880bd26e1e10b17a596

# Apply patches
# ------------------------------------------------------------------------------

# Replace "GNU GRUB version" in GRUB screen with "FREE AS IN FREEDOM"
git am "../resources/grub/patch/0001-grub-core-normal-main.c-Display-FREE-AS-IN-FREEDOM-n.patch"

# GRUB enhancement patches from grub.johnlane.ie (rebased in libreboot's GRUB, unofficially, on 30 November 2015)
git am "../resources/grub/patch/grub.johnlane.ie/0001-Cryptomount-support-LUKS-detached-header.patch"
git am "../resources/grub/patch/grub.johnlane.ie/0002-Cryptomount-support-key-files.patch"
git am "../resources/grub/patch/grub.johnlane.ie/0003-Cryptomount-luks-allow-multiple-passphrase-attempts.patch"
git am "../resources/grub/patch/grub.johnlane.ie/0004-Cryptomount-support-plain-dm-crypt.patch"
git am "../resources/grub/patch/grub.johnlane.ie/0005-Cryptomount-support-for-hyphens-in-UUID.patch"
# hotfix from kl3 (merged from autoboot) (ditto)
git am "../resources/grub/patch/grub.johnlane.ie/0006-grub-core-disk-cryptodisk.c-Point-to-const-char.patch"

# Needed for reproducible builds in GRUB
git am "../resources/grub/patch/reproducible/0001-mkstandalone-add-argument-fixed-time-to-override-mti.patch"
git am "../resources/grub/patch/reproducible/0002-mkrescue-add-argument-fixed-time-to-get-reproducible.patch"
git am "../resources/grub/patch/reproducible/0003-Makefile-use-FIXED_TIMESTAMP-for-mkstandalone-if-set.patch"

cd "../"

# Also download SeaBIOS, which we use with GRUB, to implement SeaGRUB
./download seabios

printf "\n\n"

path: resources/scripts/helpers/download/grub

license: mit


code:
#!/bin/bash

#  helper script: Downloads MemTest86+ and patches it
#
#	Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
#	Copyright (C) 2015 Joseph Michael Thompson <jmt@josepht.me>
#	Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
#
#    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
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# This script assumes that the working directory is the
# root of libreboot_src or libreboot git.

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

# Get the last version of MemTest86+ used, apply patches, build it.

# Remove the old version that may exist
# ------------------------------------------------------------------------------

printf "Downloading MemTest86+\n"

rm -Rf "memtest86plus/"

# Get latest memtest86+:
# ------------------------------------------------------------------------------

# download it using wget
wget http://www.memtest.org/download/5.01/memtest86+-5.01.tar.gz

if [ "$(sha512sum memtest86+-5.01.tar.gz | cut -c1-128)" = "d872db35ef733ec8f49094251f2bf6b98cc80eb06d04044be3aecf28d534f24ba293a08b9979b112dbd07cf27368148939a33a32c7010fc9581a3a5b150c94d7" ]; then
	printf "Valid checksum for memtest86plus\n"
else
	rm -f "memtest86+-5.01.tar.gz"
	printf "Invalid checksum for memtest86plus\n"
	exit 1
fi

# extract it
tar -xzf "memtest86+-5.01.tar.gz"

# delete the tar file (no longer needed)
rm -f "memtest86+-5.01.tar.gz"

# make direcotory name consistent
mv "memtest86+-5.01/" "memtest86plus/"

# Apply necessary patches
# ------------------------------------------------------------------------------

(
cd "memtest86plus/"
for patch in ../resources/memtest86plus/patch/*; do
	patch < "${patch}"
done
)

printf "\n\n"


code:
#!/bin/bash
#
#   Copyright (C) 2015, 2016 Leah Rowe <info@minifree.org>
#
#    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
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# This script assumes that the working directory is the
# root of libreboot_src or libreboot git.

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

# Get SeaBIOS, revert to commit last used and apply patches.

# Remove the old version that may still exist
# ------------------------------------------------------------------------------

printf "Downloading SeaBIOS\n"

rm -rf "seabios/"

# Get latest SeaBIOS
# ------------------------------------------------------------------------------

# download it using git
git clone git://git.seabios.org/seabios.git seabios

(
# modifications are required
cd "seabios/"

# Reset to the last commit that was tested (we use stable releases for seabios)
# ------------------------------------------------------------------------------

git reset --hard rel-1.9.1
)


code:
#!/usr/bin/env guile
-*- scheme -*-
!#
;;; check-trailing-newline -- Find files lacking a trailing newline
;;; Use guile 2 (not 1.8)
;;; Copyright (C) 2015  Mark H Weaver <mhw@netris.org>
;;;
;;; 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
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

(use-modules (ice-9 match)
             (rnrs io ports))

(define (check-file file-name)
  (let ((contents (call-with-input-file file-name get-string-all)))
    (unless (string-suffix? "\n" contents)
      (format (current-error-port)
              "~a: lacks trailing newline\n"
              file-name))))

(match (command-line)
  ((_ file-names ...)
   (for-each check-file file-names)))


code:
#! /bin/sh
################################################################################
#   Copyright (C) 2016 Namine Ritsu <ritsu73@ecantorix.moe>                    #
#                                                                              #
#   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       #
#   the Free Software Foundation, either version 3 of the License, or          #
#   (at your option) any later version.                                        #
#                                                                              #
#   This program is distributed in the hope that it will be useful,            #
#   but WITHOUT ANY WARRANTY; without even the implied warranty of             #
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
#   GNU General Public License for more details.                               #
#                                                                              #
#   You should have received a copy of the GNU General Public License          #
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.      #
#                                                                              #
################################################################################

### BEGIN INIT INFO
# Provides:		libreboot_usb_bugfix
# Required-Start:	$remote_fs $syslog
# Required-Stop:	$remote_fs $syslog
# Default-Start:	2 3 4 5
# Default-Stop:
# Short-Description:	Disable USB wakeup on libreboot machines
### END INIT INFO

case "$1" in
  start)
	EHC1=$(cat /proc/acpi/wakeup | grep EHC1 | grep enabled | wc -l)
	EHC2=$(cat /proc/acpi/wakeup | grep EHC2 | grep enabled | wc -l)
	if [ "$EHC1" -gt 0 ]
	then
		echo EHC1 > /proc/acpi/wakeup
	fi
	if [ "$EHC2" -gt 0 ]
	then
		echo EHC2 > /proc/acpi/wakeup
	fi
	;;
  status)
	cat /proc/acpi/wakeup | grep EHC
	;;
  *)
	echo "Usage: /etc/init.d/libreboot_usb_bugfix {start|status}"
	exit 1
esac

exit 0


code:
#!/bin/bash

#  powertop.trisquel7: automatically sets up powertop --auto-tune on startup in trisquel 7
#
#	Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
#
#    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
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

if [ $EUID -ne 0 ]; then
   printf "This script must be run as root\n"
   exit 1
fi

# For Trisquel 7 users.

apt-get -y install powertop

# Remove startup symlink if it exists
update-rc.d powertop remove
# Remove previous file if it exists
rm -Rf "/etc/init.d/powertop"

# write the correct commands there:
printf "#!/bin/sh\n" > "/etc/init.d/powertop"
printf "/usr/sbin/powertop --auto-tune\n" >> "/etc/init.d/powertop"

# make it executable:
chmod +x "/etc/init.d/powertop"

# Add the service to make it run automatically at boot time:
update-rc.d powertop defaults

# Run powertop now and tell the user
powertop --auto-tune
printf "Done. Run 'powertop --auto-tune' now. This will also run automatically at boot time. Run it again at any time, if needed. This has also been done for you just now.\n"


code:
#
# Automatically generated file; DO NOT EDIT.
# SeaBIOS Configuration
#

#
# General Features
#
CONFIG_COREBOOT=y
# CONFIG_QEMU is not set
# CONFIG_CSM is not set
# CONFIG_QEMU_HARDWARE is not set
CONFIG_THREADS=y
CONFIG_RELOCATE_INIT=y
CONFIG_BOOTMENU=y
CONFIG_BOOTSPLASH=y
CONFIG_BOOTORDER=y
CONFIG_COREBOOT_FLASH=y
CONFIG_LZMA=y
CONFIG_CBFS_LOCATION=0
CONFIG_MULTIBOOT=y
CONFIG_ENTRY_EXTRASTACK=y
CONFIG_MALLOC_UPPERMEMORY=y
CONFIG_ROM_SIZE=0

#
# Hardware support
#
CONFIG_ATA=y
# CONFIG_ATA_DMA is not set
# CONFIG_ATA_PIO32 is not set
CONFIG_AHCI=y
CONFIG_SDCARD=y
CONFIG_MEGASAS=y
CONFIG_FLOPPY=y
CONFIG_FLASH_FLOPPY=y
CONFIG_PS2PORT=y
CONFIG_USB=y
CONFIG_USB_UHCI=y
CONFIG_USB_OHCI=y
CONFIG_USB_EHCI=y
CONFIG_USB_XHCI=y
CONFIG_USB_MSC=y
CONFIG_USB_UAS=y
CONFIG_USB_HUB=y
CONFIG_USB_KEYBOARD=y
CONFIG_USB_MOUSE=y
CONFIG_SERIAL=y
CONFIG_LPT=y
CONFIG_RTC_TIMER=y
CONFIG_HARDWARE_IRQ=y
CONFIG_PMTIMER=y
CONFIG_TSC_TIMER=y

#
# BIOS interfaces
#
CONFIG_DRIVES=y
CONFIG_CDROM_BOOT=y
CONFIG_CDROM_EMU=y
CONFIG_PCIBIOS=y
CONFIG_APMBIOS=y
CONFIG_PNPBIOS=y
CONFIG_OPTIONROMS=y
CONFIG_PMM=y
CONFIG_BOOT=y
CONFIG_KEYBOARD=y
CONFIG_KBD_CALL_INT15_4F=y
CONFIG_MOUSE=y
CONFIG_S3_RESUME=y
CONFIG_VGAHOOKS=y
# CONFIG_DISABLE_A20 is not set
CONFIG_TCGBIOS=y

#
# VGA ROM
#
CONFIG_NO_VGABIOS=y
# CONFIG_VGA_GEODEGX2 is not set
# CONFIG_VGA_GEODELX is not set
# CONFIG_VGA_COREBOOT is not set
# CONFIG_BUILD_VGABIOS is not set
CONFIG_VGA_EXTRA_STACK_SIZE=512

#
# Debugging
#
CONFIG_DEBUG_LEVEL=1
# CONFIG_DEBUG_SERIAL is not set
CONFIG_DEBUG_COREBOOT=y

path: resources/seabios/config/config


code:
#
# Automatically generated file; DO NOT EDIT.
# SeaBIOS Configuration
#

#
# General Features
#
CONFIG_COREBOOT=y
# CONFIG_QEMU is not set
# CONFIG_CSM is not set
# CONFIG_QEMU_HARDWARE is not set
CONFIG_THREADS=y
CONFIG_RELOCATE_INIT=y
CONFIG_BOOTMENU=y
CONFIG_BOOTSPLASH=y
CONFIG_BOOTORDER=y
CONFIG_COREBOOT_FLASH=y
CONFIG_LZMA=y
CONFIG_CBFS_LOCATION=0
CONFIG_MULTIBOOT=y
CONFIG_ENTRY_EXTRASTACK=y
CONFIG_MALLOC_UPPERMEMORY=y
CONFIG_ROM_SIZE=0

#
# Hardware support
#
CONFIG_ATA=y
# CONFIG_ATA_DMA is not set
# CONFIG_ATA_PIO32 is not set
CONFIG_AHCI=y
CONFIG_SDCARD=y
CONFIG_MEGASAS=y
CONFIG_FLOPPY=y
CONFIG_FLASH_FLOPPY=y
CONFIG_PS2PORT=y
CONFIG_USB=y
CONFIG_USB_UHCI=y
CONFIG_USB_OHCI=y
CONFIG_USB_EHCI=y
CONFIG_USB_XHCI=y
CONFIG_USB_MSC=y
CONFIG_USB_UAS=y
CONFIG_USB_HUB=y
CONFIG_USB_KEYBOARD=y
CONFIG_USB_MOUSE=y
CONFIG_SERIAL=y
CONFIG_LPT=y
CONFIG_RTC_TIMER=y
CONFIG_HARDWARE_IRQ=y
CONFIG_PMTIMER=y
CONFIG_TSC_TIMER=y

#
# BIOS interfaces
#
CONFIG_DRIVES=y
CONFIG_CDROM_BOOT=y
CONFIG_CDROM_EMU=y
CONFIG_PCIBIOS=y
CONFIG_APMBIOS=y
CONFIG_PNPBIOS=y
CONFIG_OPTIONROMS=y
CONFIG_PMM=y
CONFIG_BOOT=y
CONFIG_KEYBOARD=y
CONFIG_KBD_CALL_INT15_4F=y
CONFIG_MOUSE=y
CONFIG_S3_RESUME=y
CONFIG_VGAHOOKS=y
# CONFIG_DISABLE_A20 is not set
CONFIG_TCGBIOS=y

#
# VGA ROM
#
# CONFIG_NO_VGABIOS is not set
# CONFIG_VGA_GEODEGX2 is not set
# CONFIG_VGA_GEODELX is not set
CONFIG_VGA_COREBOOT=y
CONFIG_BUILD_VGABIOS=y
CONFIG_VGA_EMULATE_TEXT=y
CONFIG_VGA_FIXUP_ASM=y
CONFIG_VGA_ALLOCATE_EXTRA_STACK=y
CONFIG_VGA_EXTRA_STACK_SIZE=512
CONFIG_VGA_VBE=y

#
# Debugging
#
CONFIG_DEBUG_LEVEL=1
# CONFIG_DEBUG_SERIAL is not set
CONFIG_DEBUG_COREBOOT=y


code:
git clone git://git.mtjm.eu/i945-pwm.git
^ is where i945-pwm came from.

The usual git commands apply.


code:
payloads/libpayload/curses/PDCurses-3.4/demos/worm.c
payloads/libpayload/curses/PDCurses-3.4/sdl1/deffont.h
payloads/libpayload/curses/PDCurses-3.4/sdl1/deficon.h
payloads/libpayload/curses/PDCurses-3.4/win32/pdckbd.c
payloads/libpayload/curses/PDCurses-3.4/x11/big_icon.xbm
payloads/libpayload/curses/PDCurses-3.4/x11/little_icon.xbm
payloads/libpayload/curses/pdcurses-backend/pdcdisp.c
payloads/libpayload/curses/tinycurses.c
payloads/libpayload/drivers/keyboard.c
payloads/libpayload/drivers/usb/usbmsc.c
payloads/libpayload/tests/cbfs-x86-test.c
payloads/nvramcui/payload.sh
src/cpu/allwinner/a10/raminit.c
src/cpu/amd/geode_gx2/Kconfig
src/cpu/amd/geode_lx/cpureginit.c
src/cpu/amd/geode_lx/Kconfig
src/cpu/amd/model_10xxx/init_cpus.c
src/cpu/amd/model_10xxx/processor_name.c
src/cpu/amd/model_fxx/model_fxx_update_microcode.c
src/cpu/amd/model_fxx/powernow_acpi.c
src/cpu/intel/haswell/acpi.c
src/cpu/intel/microcode/microcode.c
src/cpu/intel/model_2065x/acpi.c
src/cpu/intel/model_206ax/acpi.c
src/cpu/Kconfig
src/cpu/samsung/exynos5250/update-bl1.sh
src/cpu/via/nano/update_ucode.c
src/device/dram/spd_cache.c
src/device/Kconfig
src/device/oprom/yabel/interrupt.c
src/drivers/pc80/mc146818rtc.c
src/drivers/pc80/vga/vga_palette.c
src/Kconfig
src/lib/coreboot_table.c
src/lib/jpeg.c
src/mainboard/advansus/a785e-i/mptable.c
src/mainboard/amd/bimini_fam10/mptable.c
src/mainboard/amd/dinar/buildOpts.c
src/mainboard/amd/dinar/Kconfig
src/mainboard/amd/inagua/Kconfig
src/mainboard/amd/olivehill/mptable.c
src/mainboard/amd/olivehillplus/mptable.c
src/mainboard/amd/parmer/mptable.c
src/mainboard/amd/persimmon/Kconfig
src/mainboard/amd/serengeti_cheetah_fam10/get_bus_conf.c
src/mainboard/amd/south_station/Kconfig
src/mainboard/amd/south_station/mptable.c
src/mainboard/amd/thatcher/mptable.c
src/mainboard/amd/torpedo/Kconfig
src/mainboard/amd/torpedo/mptable.c
src/mainboard/amd/union_station/Kconfig
src/mainboard/amd/union_station/mptable.c
src/mainboard/asrock/e350m1/mptable.c
src/mainboard/asrock/imb-a180/mptable.c
src/mainboard/asus/f2a85-m/mptable.c
src/mainboard/asus/m5a88-v/mptable.c
src/mainboard/avalue/eax-785e/mptable.c
src/mainboard/digitallogic/adl855pc/irq_tables.c
src/mainboard/gigabyte/ga-b75m-d3h/romstage.c
src/mainboard/gizmosphere/gizmo2/Micron_MT41J128M16JT.spd.hex
src/mainboard/gizmosphere/gizmo/mptable.c
src/mainboard/google/bolt/romstage.c
src/mainboard/google/butterfly/hda_verb.c
src/mainboard/google/butterfly/mainboard.c
src/mainboard/google/falco/romstage.c
src/mainboard/google/link/hda_verb.c
src/mainboard/google/link/i915.c
src/mainboard/google/link/romstage.c
src/mainboard/google/panther/lan.c
src/mainboard/google/peach_pit/mainboard.c
src/mainboard/google/peppy/romstage.c
src/mainboard/google/rambi/romstage.c
src/mainboard/google/samus/romstage.c
src/mainboard/google/slippy/romstage.c
src/mainboard/hp/dl165_g6_fam10/get_bus_conf.c
src/mainboard/hp/pavilion_m6_1035dx/mptable.c
src/mainboard/ibase/mb899/cmos.layout
src/mainboard/ibase/mb899/superio_hwm.c
src/mainboard/intel/minnowmax/Kconfig
src/mainboard/intel/wtm2/i915.c
src/mainboard/jetway/nf81-t56n-lf/Kconfig
src/mainboard/kontron/986lcd-m/cmos.layout
src/mainboard/kontron/986lcd-m/mainboard.c
src/mainboard/lenovo/g505s/mptable.c
src/mainboard/lippert/frontrunner-af/Kconfig
src/mainboard/lippert/frontrunner-af/mptable.c
src/mainboard/lippert/toucan-af/Kconfig
src/mainboard/lippert/toucan-af/mptable.c
src/mainboard/msi/ms9652_fam10/get_bus_conf.c
src/mainboard/packardbell/ms2290/mainboard.c
src/mainboard/samsung/lumpy/romstage.c
src/mainboard/siemens/sitemp_g1p1/cmos.layout
src/mainboard/supermicro/h8dmr_fam10/get_bus_conf.c
src/mainboard/supermicro/h8qgi/buildOpts.c
src/mainboard/supermicro/h8qme_fam10/get_bus_conf.c
src/mainboard/supermicro/h8scm/buildOpts.c
src/mainboard/tyan/s2912_fam10/get_bus_conf.c
src/mainboard/tyan/s4880/irq_tables.c
src/mainboard/tyan/s4882/irq_tables.c
src/mainboard/tyan/s8226/buildOpts.c
src/northbridge/amd/agesa/common/common.c
src/northbridge/amd/amdk8/acpi.c
src/northbridge/amd/amdk8/coherent_ht.c
src/northbridge/amd/amdk8/raminit_test.c
src/northbridge/amd/amdmct/mct_ddr3/mcttmrl.c
src/northbridge/amd/amdmct/mct/mctardk3.c
src/northbridge/amd/amdmct/mct/mctardk4.c
src/northbridge/amd/amdmct/mct/mcttmrl.c
src/northbridge/amd/gx2/pll_reset.c
src/northbridge/amd/pi/00730F01/Kconfig
src/northbridge/intel/gm45/raminit_rcomp_calibration.c
src/northbridge/intel/gm45/raminit_read_write_training.c
src/northbridge/intel/haswell/Kconfig
src/northbridge/intel/haswell/raminit.c
src/northbridge/intel/i82830/vga.c
src/northbridge/intel/i945/raminit.c
src/northbridge/intel/nehalem/gma.c
src/northbridge/intel/nehalem/raminit.c
src/northbridge/intel/sandybridge/gma.c
src/northbridge/intel/sandybridge/Kconfig
src/northbridge/intel/sandybridge/raminit.c
src/northbridge/via/cx700/raminit.c
src/northbridge/via/vx800/ide.c
src/northbridge/via/vx800/uma_ram_setting.c
src/northbridge/via/vx900/sata.c
src/soc/intel/baytrail/acpi.c
src/soc/intel/baytrail/Kconfig
src/soc/intel/baytrail/romstage/raminit.c
src/soc/intel/broadwell/acpi.c
src/soc/intel/broadwell/Kconfig
src/soc/intel/broadwell/romstage/raminit.c
src/soc/intel/fsp_baytrail/acpi.c
src/soc/intel/fsp_baytrail/fsp/Kconfig
src/soc/intel/fsp_baytrail/Kconfig
src/soc/qualcomm/ipq806x/Kconfig
src/soc/samsung/exynos5250/clock.c
src/soc/samsung/exynos5420/clock.c
src/southbridge/amd/agesa/hudson/Kconfig
src/southbridge/amd/cimx/sb800/Kconfig
src/southbridge/intel/bd82x6x/Kconfig
src/southbridge/intel/i82801ix/dmi_setup.c
src/southbridge/intel/ibexpeak/Kconfig
src/southbridge/intel/lynxpoint/Kconfig
src/southbridge/intel/sch/Kconfig
src/southbridge/sis/sis966/early_smbus.c
src/southbridge/sis/sis966/ide.c
src/southbridge/sis/sis966/sata.c
src/southbridge/sis/sis966/usb2.c
src/southbridge/sis/sis966/usb.c
src/superio/via/vt1211/vt1211.c
src/vendorcode/amd/agesa/f10/Proc/CPU/Family/0x10/cpuF10Dmi.c
src/vendorcode/amd/agesa/f10/Proc/CPU/Family/0x10/cpuF10WheaInitDataTables.c
src/vendorcode/amd/agesa/f10/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f12/Proc/CPU/Family/0x10/cpuF10Dmi.c
src/vendorcode/amd/agesa/f12/Proc/CPU/Family/0x10/cpuF10WheaInitDataTables.c
src/vendorcode/amd/agesa/f12/Proc/CPU/Family/0x12/cpuF12Dmi.c
src/vendorcode/amd/agesa/f12/Proc/CPU/Family/0x12/cpuF12WheaInitDataTables.c
src/vendorcode/amd/agesa/f12/Proc/Fch/Hwm/Family/Hudson2/Hudson2HwmLateService.c
src/vendorcode/amd/agesa/f12/Proc/GNB/Gfx/Family/LN/F12GfxServices.c
src/vendorcode/amd/agesa/f12/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f14/Proc/CPU/Family/0x10/cpuF10Dmi.c
src/vendorcode/amd/agesa/f14/Proc/CPU/Family/0x10/cpuF10WheaInitDataTables.c
src/vendorcode/amd/agesa/f14/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f15/Proc/CPU/Family/0x10/cpuF10Dmi.c
src/vendorcode/amd/agesa/f15/Proc/CPU/Family/0x10/cpuF10WheaInitDataTables.c
src/vendorcode/amd/agesa/f15/Proc/CPU/Family/0x15/cpuF15WheaInitDataTables.c
src/vendorcode/amd/agesa/f15/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f15/Proc/Mem/Ps/OR/mpor3.c
src/vendorcode/amd/agesa/f15/Proc/Mem/Tech/DDR3/mtlrdimm3.c
src/vendorcode/amd/agesa/f15tn/Proc/CPU/Family/0x15/cpuF15WheaInitDataTables.c
src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbInitTN/GfxIntegratedInfoTableTN.c
src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbInitTN/GfxLibTN.c
src/vendorcode/amd/agesa/f15tn/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f15tn/Proc/Mem/Ps/TN/mptn3.c
src/vendorcode/amd/agesa/f15tn/Proc/Mem/Tech/DDR3/mtlrdimm3.c
src/vendorcode/amd/agesa/f16kb/Proc/CPU/Family/0x16/cpuF16WheaInitDataTables.c
src/vendorcode/amd/agesa/f16kb/Proc/GNB/Modules/GnbGfxIntTableV3/GfxLibV3.c
src/vendorcode/amd/agesa/f16kb/Proc/GNB/Modules/GnbInitKB/GnbF1TableKB.c
src/vendorcode/amd/agesa/f16kb/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f16kb/Proc/Mem/Ps/KB/mpkb3.c
src/vendorcode/amd/cimx/sb800/SATA.c
src/vendorcode/google/chromeos/build-snow
util/amdtools/example_input/lspci-cb-48G-667MHz-18.2-20090909e
util/amdtools/example_input/lspci-prop-48G-667MHz-18.2
util/cbfstool/linux_trampoline.c
util/ifdtool/ifdtool.c
util/kconfig/zconf.hash.c_shipped
util/kconfig/zconf.lex.c_shipped
util/kconfig/zconf.tab.c_shipped
util/nvramtool/accessors/layout-bin.c
util/romcc/do_tests.sh
util/romcc/tests/include/linux_console.h
util/romcc/tests/linux_console.h
util/romcc/tests/linux_test5.c
util/romcc/tests/raminit_test6.c
util/romcc/tests/raminit_test7.c
util/romcc/tests/simple_test14.c
util/romcc/tests/simple_test30.c
util/romcc/tests/simple_test38.c
util/romcc/tests/simple_test39.c
util/romcc/tests/simple_test54.c
util/romcc/tests/simple_test59.c
util/romcc/tests/simple_test72.c
util/romcc/tests/simple_test73.c
util/sconfig/lex.yy.c_shipped
util/sconfig/sconfig.tab.c_shipped
util/superiotool/fintek.c
util/superiotool/ite.c
util/superiotool/smsc.c
util/superiotool/winbond.c
src/mainboard/google/slippy/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/falco/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/peppy/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/link/micron_4Gb_1600_1.35v_x16.spd.hex
src/mainboard/google/rambi/spd/micron_1GiB_dimm_MT41K128M16JT-125.spd.hex
src/mainboard/google/rambi/spd/micron_2GiB_dimm_MT41K256M16HA-125.spd.hex
src/mainboard/google/bolt/micron_4Gb_1600_1.35v_x16.spd.hex
src/mainboard/google/link/samsung_4Gb_1600_1.35v_x16.spd.hex
src/mainboard/google/link/elpida_4Gb_1600_x16.spd.hex
src/mainboard/google/slippy/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/falco/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/falco/Elpida_EDJ4216EFBG.spd.hex
src/mainboard/google/rambi/spd/hynix_1GiB_dimm_H5TC2G63FFR-PBA.spd.hex
src/mainboard/google/rambi/spd/hynix_2GiB_dimm_H5TC4G63AFR-PBA.spd.hex
src/mainboard/google/bolt/samsung_4Gb_1600_1.35v_x16.spd.hex
src/mainboard/google/bolt/elpida_4Gb_1600_x16.spd.hex
src/mainboard/google/peppy/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/peppy/Elpida_EDJ4216EFBG.spd.hex
src/mainboard/google/falco/Samsung_M471B5674QH0.spd.hex
src/mainboard/google/samus/spd/empty.spd.hex
src/mainboard/google/samus/spd/elpida_4.spd.hex
src/mainboard/google/samus/spd/hynix_4.spd.hex
src/mainboard/google/samus/spd/elpida_16.spd.hex
src/mainboard/google/samus/spd/hynix_8.spd.hex
src/mainboard/google/samus/spd/hynix_16.spd.hex
src/mainboard/google/samus/spd/samsung_8.spd.hex
src/mainboard/google/samus/spd/elpida_8.spd.hex
src/mainboard/google/samus/spd/samsung_4.spd.hex
src/mainboard/google/auron/spd/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/auron/spd/Elpida_EDJ4216EFBG.spd.hex
src/mainboard/google/auron/spd/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/glados/spd/samsung_dimm_K4E6E304EE-EGCF.spd.hex
src/mainboard/google/auron/spd/empty.spd.hex
src/mainboard/google/cyan/spd/hynix_2GiB_dimm_HMT425S6CFR6A_H5TC4G63CFR.spd.hex
src/mainboard/google/cyan/spd/samsung_2GiB_dimm_K4B4G1646Q-HYK0.spd.hex
src/mainboard/google/cyan/spd/hynix_2GiB_dimm_H5TC4G63AFR-PBA.spd.hex
src/mainboard/google/glados/spd/hynix_dimm_H9CCNNNBLTALAR.spd.hex
src/mainboard/google/glados/spd/empty.spd.hex
src/mainboard/google/glados/spd/hynix_dimm_H9CCNNN8JTBLAR.spd.hex
src/mainboard/intel/sklrvp/spd/empty.spd.hex
src/mainboard/intel/sklrvp/spd/rvp3.spd.hex
src/mainboard/intel/kunimitsu/spd/empty.spd.hex
src/mainboard/intel/kunimitsu/spd/samsung_dimm_K4E8E304EE-EGCE.spd.hex
src/mainboard/intel/strago/spd/hynix_2GiB_dimm_HMT425S6CFR6A_H5TC4G63CFR.spd.hex
src/mainboard/intel/strago/spd/samsung_2GiB_dimm_K4B4G1646Q-HYK0.spd.hex
src/mainboard/intel/strago/spd/hynix_2GiB_dimm_H5TC4G63AFR-PBA.spd.hex
src/mainboard/intel/kunimitsu/spd/hynix_dimm_H9CCNNNBLTALAR-NUD-2G-1866.spd.hex
src/mainboard/intel/kunimitsu/spd/samsung_dimm_K4E8E304EE-EGCF-1G-1866.spd.hex
src/mainboard/intel/kunimitsu/spd/samsung_dimm_K4E6E304EE-EGCF-2G-1866.spd.hex
src/mainboard/intel/kunimitsu/spd/hynix_dimm_H9CCNNN8JTALAR-NUD-1G-1866.spd.hex
src/mainboard/bap/ode_e20XX/BAP_Q7.spd.hex
src/northbridge/intel/nehalem/raminit_tables.c
src/northbridge/intel/sandybridge/raminit_patterns.h
src/southbridge/nvidia/mcp55/early_setup_ss.h
src/southbridge/nvidia/ck804/early_setup_ss.h
src/southbridge/sis/sis966/early_setup_ss.h
util/crossgcc/patches/binutils-2.25_riscv.patch
src/southbridge/amd/pi/hudson/Kconfig
src/drivers/xgi/common/vb_setmode.c
src/drivers/xgi/common/vb_table.h
src/drivers/xgi/common/XGI_main.h
src/mainboard/siemens/mc_tcu3/romstage.c
src/mainboard/siemens/mc_tcu3/lcd_panel.c
src/mainboard/siemens/mc_tcu3/modhwinfo.c
src/mainboard/pcengines/apu1/Kconfig
src/mainboard/asus/kfsn4-dre/get_bus_conf.c
src/mainboard/google/samus/spd/spd.c
src/mainboard/hp/abm/mptable.c
src/northbridge/amd/pi/00630F01/Kconfig
src/cpu/amd/microcode/microcode.c
src/lib/tlcl_structures.h
util/rockchip/make_idb.py
util/autoport/readme.md
util/bimgtool/bimgtool.c
util/cbfstool/fmd_parser.c_shipped
util/cbfstool/fmd_scanner.c_shipped
Documentation/CorebootBuildingGuide.tex
Documentation/hypertransport.svg
Documentation/codeflow.svg
src/soc/broadcom/cygnus/ddr_init.c
src/soc/broadcom/cygnus/ddr_init_table.c
src/soc/qualcomm/ipq806x/lcc.c
src/soc/intel/braswell/acpi.c
src/soc/intel/braswell/Kconfig
src/vendorcode/amd/pi/Kconfig
src/drivers/intel/fsp1_1/Kconfig
src/drivers/intel/fsp1_1/fsp_gop.c
src/drivers/i2c/ww_ring/ww_ring_programs.c
src/mainboard/google/auron/spd/spd.c
src/mainboard/google/jecht/lan.c
src/mainboard/gigabyte/ga-b75m-d3v/romstage.c
src/mainboard/amd/lamar/Kconfig
payloads/external/GRUB2/Kconfig
payloads/external/FILO/Kconfig
payloads/external/SeaBIOS/Kconfig
src/soc/intel/common/fsp_ramstage.c
src/soc/intel/skylake/Kconfig
src/soc/intel/braswell/gpio.c
src/soc/nvidia/tegra210/Kconfig
src/soc/nvidia/tegra210/mtc.c
src/southbridge/intel/common/firmware/Kconfig
src/mainboard/google/cyan/spd/spd.c
src/mainboard/google/cyan/Kconfig
src/mainboard/google/glados/spd/spd.c
src/mainboard/intel/sklrvp/spd/spd.c
src/mainboard/intel/kunimitsu/spd/spd.c
src/mainboard/intel/strago/spd/spd.c
src/mainboard/intel/strago/Kconfig
src/mainboard/amd/bettong/mptable.c
src/northbridge/amd/pi/00660F01/Kconfig
util/crossgcc/patches/gcc-5.2.0_riscv.patch
util/xcompile/xcompile
src/northbridge/intel/sandybridge/raminit_mrc.c
src/northbridge/intel/fsp_rangeley/fsp/Kconfig
src/drivers/intel/fsp1_1/car.c
src/mainboard/intel/mohonpeak/Kconfig
src/mainboard/apple/macbookair4_2/early_southbridge.c
src/cpu/intel/fsp_model_406dx/acpi.c
src/northbridge/intel/fsp_sandybridge/fsp/Kconfig
src/drivers/aspeed/common/ast_dram_tables.h
src/drivers/aspeed/common/ast_tables.h
src/mainboard/intel/cougar_canyon2/Kconfig
src/cpu/amd/family_10h-family_15h/processor_name.c
src/cpu/amd/family_10h-family_15h/init_cpus.c
src/cpu/intel/fsp_model_206ax/acpi.c


code:
.spd.hex files - serial presence detect. These are not blobs
see JEDEC standard or https://en.wikipedia.org/wiki/Serial_presence_detect
These are added to the nonblobs file

src/northbridge/intel/nehalem/raminit_tables.c"
src/northbridge/intel/sandybridge/raminit_patterns.h
These are used by native raminit for the relevant platforms, and are not blobs

"src/southbridge/nvidia/mcp55/early_setup_ss.h" \
"src/southbridge/nvidia/ck804/early_setup_ss.h" \
"src/southbridge/sis/sis966/early_setup_ss.h"
not blobs

The text in this file is CC-BY-SA 4.0 or higher. All contributions to it must
be made under the same license.


code:
./3rdparty/vboot/tests/testcases/padding_test_vectors.inc
It's not a blob, see tests/rsa_padding_test.h for explanation.

The text in this file is CC-BY-SA 4.0 or higher. All contributions to it must
be made under the same license.


code:
#!/bin/bash

#  DEBLOB script: deblobs the version of coreboot used for this release.
#
#	Copyright (C) 2014, 2015, 2016 Leah Rowe <info@minifree.org>
#
#    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
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# This script assumes that the current working directory is the root
# of the libreboot_src/ or git clone.

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

printf "Deleting blobs in coreboot\n"

for payloads in resources/libreboot/config/*; do

	if [ ! -d "${payloads}/" ]; then
		continue
	fi

	payload="${payloads##*/}"

	for boards in "${payloads}/"*; do

		if [ ! -d "${boards}/" ]; then
			continue
		fi

		board="${boards##*/}"
		cbrevision="$(cat "resources/libreboot/config/${payload}/${board}/cbrevision")"
        vbrevision="$(cat "resources/libreboot/config/${payload}/${board}/vbootrevision")"
		boardpath="coreboot/${cbrevision}/${cbrevision}"

		# deblob coreboot
		for blob in $(cat "resources/utilities/coreboot-libre/blobs/coreboot/${cbrevision}/blobs.list"); do
			rm -f "${boardpath}/${blob}"
		done

		# deblob 3rdparty
		# only non-crossgcc archives have 3rdparty (vboot) present.
		if [ "${payload}" != "crossgcc" ]; then
			vbootrevision="$(cat "resources/libreboot/config/${payload}/${board}/vbootrevision")"
			# deblob 3rdparty
			for blob in $(cat "resources/utilities/coreboot-libre/blobs/vboot/${vbootrevision}/blobs.list"); do
				rm -f "${boardpath}/${blob}"
			done
		fi

	done
done

# Now also do the same for crossgcc coreboot
for blob in $(cat "resources/utilities/coreboot-libre/blobs/coreboot/crossgcc/blobs.list"); do
    rm -f "crossgcc/${blob}"
done
for blob in $(cat "resources/utilities/coreboot-libre/blobs/vboot/crossgcc/blobs.list"); do
    rm -f "crossgcc/${blob}"
done

printf "\n\n"


code:
#!/bin/bash

#  find blobs in coreboot
#
#	Copyright (C) 2014, 2015, 2016 Leah Rowe <info@minifree.org>
#
#    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
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -e -u

# This is used when updating the version of
# coreboot that libreboot uses, to know what
# new blobs have landed in coreboot

# full deblob scripts based on linux-libre
# will replace this script later on. For now,
# this will have to do.

printf "Searching for blobs in coreboot\n"
cp "deblob-check" "../../../coreboot/coreboot/"
cd "../../../coreboot/coreboot/"

chmod +x "deblob-check"
find -type f | xargs ./deblob-check > "tocheck"
rm -f "deblob-check"

rm -f "../../resources/utilities/coreboot-libre/tocheck"
mv "tocheck" "../../resources/utilities/coreboot-libre/"

cd "../../resources/utilities/coreboot-libre/"

printf "Done! open resources/utilities/coreboot-libre/tocheck in an editor\n"
printf "This will contain the names of the files that you must decide whether they are blobs or not\n\n"


code:
#!/bin/bash

#  grub-assemble gen.sh: generate GRUB ELF files (coreboot payloads)
#
#	Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
#
#    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
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

if [ $# != 1 ]; then
	printf "Usage: ./gen.sh mode\n"
	printf "Example: ./gen.sh vesafb\n"
	printf "Example: ./gen.sh txtmode\n"
	printf "You need to specify exactly 1 argument\n"
	exit 1
fi

if [ -f "../../../versiondate" ]; then
	# _src release archive is being used
	versiondate="$(cat ../../../versiondate)"
else
	# git repo is being used
	versiondate="$(git show -s --format=%ct)"
fi

# This is where GRUB is expected to be (outside of the grub-assemble, instead in main checkout)
grubdir="../../../grub"

source "modules.conf"

list_keymaps () {
	for keylayout in keymap/original/*; do
		keymap="${keylayout##*/}"
		printf "/boot/grub/layouts/%s.gkb=keymap/%s.gkb " "${keymap}" "${keymap}"
	done
}
keymaps=$(list_keymaps)

printf "Creating GRUB ELF executable for configuration '%s'\n" "${1}"
if [ "${1}" = "vesafb" ]; then
	# Generate the grub.elf (vesafb)
	$grubdir/grub-mkstandalone \
	  --grub-mkimage="${grubdir}/grub-mkimage" \
	  -O i386-coreboot \
	  -o "grub_vesafb.elf" \
	  -d "${grubdir}/grub-core/" \
	  --fonts= --themes= --locales=  \
	  --fixed-time ${versiondate} \
	  --modules="${grub_modules}" \
	  --install-modules="${grub_install_modules}" \
	  /boot/grub/grub.cfg="../../../resources/grub/config/grub_memdisk.cfg" \
	  /dejavusansmono.pf2="../../../resources/grub/font/dejavusansmono.pf2" \
	  ${keymaps}
elif [ "${1}" = "txtmode" ]
then
	# Generate the grub.elf (txtmode)
	"${grubdir}/grub-mkstandalone" \
	  --grub-mkimage="${grubdir}/grub-mkimage" \
	  -O i386-coreboot \
	  -o "grub_txtmode.elf" \
	  -d "${grubdir}/grub-core/" \
	  --fonts= --themes= --locales=  \
	  --fixed-time ${versiondate} \
	  --modules="${grub_modules}" \
	  --install-modules="${grub_install_modules}" \
	  /boot/grub/grub.cfg="../../../resources/grub/config/grub_memdisk.cfg" \
	  /memtest.bin="../../../memtest86plus/memtest.bin" \
	  ${keymaps}
else
	printf "grub-assemble gen.sh: invalid mode '%s'\n" "${1}"
	exit 1
fi
printf "\n\n"


code:
# Install modules (installed, but not automatically loaded)
grub_install_modules=" \
adler32 \
all_video \
archelp \
ata \
backtrace \
bitmap \
bitmap_scale \
cmp \
cpio_be \
cpio \
cpuid \
crc64 \
cs5536 \
div_test \
efiemu \
elf \
eval \
exfat \
extcmd \
file \
fshelp \
gettext \
gfxmenu \
gptsync \
gzio \
hashsum \
hexdump \
http \
linux16 \
loadenv \
lzopio \
mda_text \
mmap \
mpi \
msdospart \
multiboot2 \
multiboot \
nativedisk \
net \
newc \
ntfscomp \
ntfs \
odc \
offsetio \
parttool \
priority_queue \
procfs \
progress \
read \
relocator \
scsi \
search_fs_file \
search_fs_uuid \
search_label \
search \
setjmp \
setpci \
sleep \
squash4 \
tar \
terminfo \
testload \
testspeed \
tftp \
time \
trig \
tr \
true \
udf \
ufs1_be \
ufs1 \
ufs2 \
usbserial_common \
usbserial_ftdi \
usbserial_pl2303 \
usbserial_usbdebug \
usbtest \
video_colors \
videotest_checksum \
xzio \
"

# Modules (and always loaded)
grub_modules=" \
acpi \
ahci \
at_keyboard \
boot \
cat \
cbfs \
cbls \
cbtime \
chain \
cmosdump \
cmostest \
cbmemc \
crypto \
cryptodisk \
configfile \
datehook \
date \
datetime \
diskfilter \
disk \
echo \
ext2 \
ehci \
fat \
halt \
help \
iorw \
iso9660 \
keystatus \
linux \
loopback \
ls \
lsacpi \
lsmmap \
lspci \
luks \
lvm \
mdraid09_be \
mdraid09 \
mdraid1x \
raid5rec \
raid6rec \
memdisk \
minicmd \
memrw \
morse \
normal \
ohci \
part_gpt \
part_msdos \
password \
password_pbkdf2 \
pbkdf2 \
pcidump \
pci \
play \
probe \
reboot \
serial \
terminal \
test \
usb_keyboard \
usbms \
uhci \
gcry_arcfour \
gcry_blowfish \
gcry_camellia \
gcry_cast5 \
gcry_crc \
gcry_des \
gcry_dsa \
gcry_idea \
gcry_md4 \
gcry_md5 \
gcry_rfc2268 \
gcry_rijndael \
gcry_rmd160 \
gcry_rsa \
gcry_seed \
gcry_serpent \
gcry_sha1 \
gcry_sha256 \
gcry_sha512 \
gcry_tiger \
gcry_twofish \
gcry_whirlpool \
hdparm \
regexp \
spkmodem \
syslinuxcfg \
usb \
verify \
videoinfo \
videotest \
xfs \
btrfs \
zfs \
sfs \
romfs \
reiserfs \
nilfs2 \
minix_be \
minix3_be \
minix3 \
minix2_be \
minix2 \
minix \
jfs \
hfsplus \
hfs \
bfs \
afs \
affs \
gfxmenu \
gfxterm_background \
gfxterm_menu \
jpeg \
png \
tga \
pata \
bsd \
part_bsd \
"


code:
CFLAGS ?= -O2 -Wall -W -ggdb

i945-pwm: i945-pwm.c
	$(CC) -std=gnu99 $(CFLAGS) $(LDFLAGS) -o $@ $< -lpci -lz

clean:
	rm -f i945-pwm


code:
/*
  Copyright (C) 2014  Michał Masłowski  <mtjm@mtjm.eu>

  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
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/* Try several backlight PWM frequencies and duty cycles to see which
   expose the noise on X60 with coreboot.
*/

#include <assert.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pci/pci.h>

static struct pci_access *pacc;
static uint32_t *map;
static int fd;

#define REGISTER 0x61254

static void
init (void)
{
  fd = -1;
  /* Find the device. */
  struct pci_dev *dev;
  pacc = pci_alloc ();
  pacc->writeable = 1;
  pci_init (pacc);
  pci_scan_bus (pacc);
  for (dev = pacc->devices; dev != NULL; dev = dev->next)
    {
      pci_fill_info (dev, PCI_FILL_IDENT | PCI_FILL_BASES);
      if (dev->vendor_id != 0x8086 || dev->device_id != 0x27a2)
        continue;
      break;
    }
  if (dev == NULL)
    {
      fprintf (stderr, "Device not found.\n");
      goto fail;
    }
  /* Map a part of its MMIO. */
  fd = open ("/dev/mem", O_RDWR);
  if (fd == -1)
    {
      fprintf (stderr, "Cannot open memory.  Are you root?\n");
      goto fail;
    }
  map = mmap (NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, dev->base_addr[0] + (REGISTER & (~4095)));
  if (map != MAP_FAILED)
    return;
  else
    perror ("mmap failed");
 fail:
  if (pacc != NULL)
    pci_cleanup (pacc);
  if (fd != -1)
    close (fd);
  exit (1);
}

static void
set_pwm (uint16_t freq, uint16_t duty)
{
  assert (duty <= freq);
  map[((REGISTER - 4) & 4095) >> 2] = 0x80000000;
  map[(REGISTER & 4095) >> 2] = ((freq | 1) << 16) | duty;
}

int
main (void)
{
  init ();
  int exponent = 8;
  int diff = 0;
  int divisor = 2;
  uint16_t freq = 0x61;
  uint16_t duties[] = {
#if 1
    // i945
    0xf,
    0x13,
    0x19,
    0x1f,
    0x23,
    0x29,
    0x2f,
    0x35,
    0x39,
    0x3f,
    0x45,
    0x4b,
    0x4f,
    0x55,
    0x5b,
    0x61
#else
    // gm45
    0x2,
    0x4,
    0x5,
    0x7,
    0x9,
    0xb,
    0xd,
    0x11,
    0x14,
    0x17,
    0x1c,
    0x20,
    0x27,
    0x31,
    0x41,
    0x61,
#endif
  };
#if 1
  for (unsigned int di = 0; di < sizeof (duties) / sizeof (duties[0]); di++)
    {
      uint16_t duty = duties[di];
#else
      for (uint16_t duty = 0; duty < 0x61; duty++)
        {
#endif
#if 0
        }
#endif
      uint16_t pwm_freq = (freq + diff) << exponent;
      pwm_freq += (pwm_freq >> divisor);
      //pwm_freq |= 0x33;
      uint16_t pwm_duty = (duty + diff) << exponent;
      pwm_duty += (pwm_duty >> divisor);
      //pwm_duty |= 0x32;
      set_pwm (pwm_freq, pwm_duty);
      sleep (1);
    }
  if (pacc != NULL)
    pci_cleanup (pacc);
  if (map != NULL)
    munmap (map, 4096);
  if (fd != -1)
    close (fd);
  return 0;
}


code:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright (C) 2014  Michał Masłowski  <mtjm@mtjm.eu>
#
# Licensed under copyleft-next version 0.3.0.  See
# https://gitorious.org/copyleft-next/copyleft-next/raw/master:Releases/copyleft-next-0.3.0
# for more information.

"""Get values of interesting i945 graphics parameters from a running system.

This script might show the values for GPU registers specified in
devicetree.cb on coreboot mainboard ports using i945 native VGA init
from <http://review.coreboot.org/#/c/5320/>.

Run as root.
"""

import mmap
import re
import struct
import subprocess

_MEMORY = re.compile(r"^\s+Memory\s+at\s+([0-9a-f]+)\s+\(32-bit, non-prefetchable\)\s+\[size=[0-9]+K\]$")

def get_pci_data():
    # lspci has a machine readable format, but it doesn't have the needed data.
    for devid in ("8086:27a2",):
        lspci = subprocess.Popen(("lspci", "-vn", "-d", devid),
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
        address = None
        memory = None
        for line in lspci.communicate()[0].split("\n"):
            if line and line[0] == "0":
                address = line.split()[0]
            match = _MEMORY.match(line)
            if match is not None:
                memory = int(match.group(1), 16)
                break
        yield (address, memory)

def config_byte(address, offset):
    """Return byte at specified offset in PCI config space of device
    identified by address."""
    with open("/sys/bus/pci/devices/0000:%s/config" % address, "rb") as f:
        f.seek(offset)
        return struct.unpack("=B", f.read(1))

addr0, func0 = list(get_pci_data())[0]

def read32(fo, base, offset):
    memory = mmap.mmap(fo.fileno(), offset + 4,
                       mmap.MAP_SHARED, mmap.ACCESS_READ,
                       offset=base)
    try:
        memory.seek(offset)
        val = memory.read(4)
        return struct.unpack("=I", val)[0]
    finally:
        memory.close()

# Some i915 register names.
PORT_HOTPLUG_EN = 0x61110
BLC_PWM_CTL = 0x61254
LVDS = 0x61180

# Bits in LVDS.
LVDS_CLOCK_B_POWERUP_ALL = 3 << 4
LVDS_CLOCK_BOTH_POWERUP_ALL = 3 << 2

# Expansion of DPLL(1).
DPLL1 = ((0x06014) + (1)*((0x06018)-(0x06014)))

# Bits there.
DPLL_INTEGRATED_CLOCK_VLV = (1<<13)
DPLL_INTEGRATED_CRI_CLK_VLV = (1<<14)

if __name__ == "__main__":
    with open("/dev/mem", "rb") as mem:
        print "gpu_hotplug = 0x%08x" % read32(mem, func0, PORT_HOTPLUG_EN)
        dpll = read32(mem, func0, DPLL1)
        spread_spectrum = dpll & (DPLL_INTEGRATED_CLOCK_VLV \
                                  | DPLL_INTEGRATED_CRI_CLK_VLV)
        if spread_spectrum != 0:
            spread_spectrum = 1
        print "gpu_lvds_use_spread_spectrum_clock = %d" % spread_spectrum
        lvds = read32(mem, func0, LVDS)
        dual_channel = lvds & (LVDS_CLOCK_B_POWERUP_ALL \
                               | LVDS_CLOCK_BOTH_POWERUP_ALL)
        if dual_channel != 0:
            dual_channel = 1
        print "gpu_lvds_is_dual_channel = %d" % dual_channel
        backlight = read32(mem, func0, BLC_PWM_CTL)
        print "gpu_backlight = 0x%08x" % backlight
        # Using display clock from i945_get_display_clock_speed in
        # drivers/gpu/drm/i915/intel_display.c.  Result multiplied by
        # two to match BIOS-reported PWM frequency on my X60t.
        mod_freq = 2 * 400000000 / ((backlight >> 16) * 128.0)
        print "backlight modulation frequency = %f Hz" % mod_freq
        print "duty cycle = %d%%" % (100.0 * (backlight & 0xffff)
                                     / (backlight >> 16))
        print "legacy backlight brightness = 0x%02x" % config_byte(addr0, 0xf4)


code:
#
# Makefile for ich9deblob utility from libreboot project
#
# Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
#
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

CC=gcc
FORCEC99=-std=c99
CFLAGS=-I. -Wall -Wextra -g $(FORCEC99)
NOLINKER=-c

all: ich9deblob ich9gen demefactory

ich9deblob: obj/ich9deblob.o obj/common/descriptor_gbe.o \
		obj/descriptor/descriptor.o obj/gbe/gbe.o obj/common/x86compatibility.o

	$(CC) $(CFLAGS) obj/ich9deblob.o obj/common/descriptor_gbe.o \
		obj/common/x86compatibility.o obj/descriptor/descriptor.o obj/gbe/gbe.o \
		 -o ich9deblob

ich9gen: obj/ich9gen.o obj/ich9gen/mkdescriptor.o obj/ich9gen/mkgbe.o \
		obj/common/descriptor_gbe.o \
		obj/descriptor/descriptor.o obj/gbe/gbe.o obj/common/x86compatibility.o

	$(CC) $(CFLAGS) obj/ich9gen.o obj/ich9gen/mkdescriptor.o obj/ich9gen/mkgbe.o \
	 obj/common/descriptor_gbe.o \
		obj/common/x86compatibility.o obj/descriptor/descriptor.o obj/gbe/gbe.o \
		 -o ich9gen

demefactory: obj/demefactory.o obj/common/descriptor_gbe.o \
		obj/descriptor/descriptor.o obj/gbe/gbe.o obj/common/x86compatibility.o

	$(CC) $(CFLAGS) obj/demefactory.o obj/common/descriptor_gbe.o \
		obj/common/x86compatibility.o obj/descriptor/descriptor.o obj/gbe/gbe.o \
		 -o demefactory

# for demefactory
# ----------------------------------------------------------------------

obj/demefactory.o:
	$(CC) $(CFLAGS) $(NOLINKER) src/demefactory.c -o obj/demefactory.o

# for ich9deblob
# ----------------------------------------------------------------------

obj/ich9deblob.o:
	$(CC) $(CFLAGS) $(NOLINKER) src/ich9deblob.c -o obj/ich9deblob.o

# for ich9gen
# ----------------------------------------------------------------------

obj/ich9gen.o:
	$(CC) $(CFLAGS) $(NOLINKER) src/ich9gen.c -o obj/ich9gen.o

obj/ich9gen/mkdescriptor.o:
	$(CC) $(CFLAGS) $(NOLINKER) src/ich9gen/mkdescriptor.c -o obj/ich9gen/mkdescriptor.o

obj/ich9gen/mkgbe.o:
	$(CC) $(CFLAGS) $(NOLINKER) src/ich9gen/mkgbe.c -o obj/ich9gen/mkgbe.o

# for demefactory, ich9deblob and ich9gen:
# ----------------------------------------------------------------------

obj/common/descriptor_gbe.o:
	$(CC) $(CFLAGS) $(NOLINKER) src/common/descriptor_gbe.c -o obj/common/descriptor_gbe.o

obj/common/x86compatibility.o:
	$(CC) $(CFLAGS) $(NOLINKER) src/common/x86compatibility.c -o obj/common/x86compatibility.o

obj/descriptor/descriptor.o:
	$(CC) $(CFLAGS) $(NOLINKER) src/descriptor/descriptor.c -o obj/descriptor/descriptor.o

obj/gbe/gbe.o:
	$(CC) $(CFLAGS) $(NOLINKER) src/gbe/gbe.c -o obj/gbe/gbe.o

# make clean
# ----------------------------------------------------------------------
clean:
	rm -Rf ich9deblob ich9gen demefactory obj/*.o obj/*/*.o


code:
/*
 *  descriptor_gbe.c
 *  This file is part of the ich9deblob utility from the libreboot project
 *
 * Purpose: common descriptor/gbe functions used by ich9deblob
 *
 *  Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
 *  Copyright (C) 2014 Steve Shenton <sgsit@libreboot.org>
 *
 *  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
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "descriptor_gbe.h"

/*
 * create 12KiB file with descriptor, and then gbe immediately after.
 */
int notCreatedDescriptorGbeFile(struct DESCRIPTORREGIONRECORD descriptorStruct, struct GBEREGIONRECORD_8K gbeStruct8k, char* fileName)
{
	FILE* fileStream = NULL;

	/* delete old file before continuing */
	remove(fileName);

	/* open new file for writing the descriptor+gbe */
	fileStream = fopen(fileName, "ab");

	/* write the descriptor region into the first part */
	if (DESCRIPTORREGIONSIZE != fwrite((uint8_t*)&descriptorStruct, 1, sizeof(descriptorStruct), fileStream))
	{
		printf("\nerror: writing descriptor region failed\n");
		return 1;
	}

	/* add gbe to the end of the file */
	if (GBEREGIONSIZE_8K != fwrite((uint8_t*)&gbeStruct8k, 1, sizeof(gbeStruct8k), fileStream))
	{
		printf("\nerror: writing GBe region failed\n");
		return 1;
	}

	fclose(fileStream);

	printf("descriptor and gbe successfully written to the file: %s\n", fileName);
	printf("Now do: dd if=%s of=libreboot.rom bs=1 count=12k conv=notrunc\n", fileName);
	printf("(in other words, add the modified descriptor+gbe to your ROM image)\n\n");

	return 0;
}

/*
 * create 4KiB file with descriptor
 */
int notCreated4kDescriptorFile(struct DESCRIPTORREGIONRECORD descriptorStruct, char* fileName)
{
	FILE* fileStream = NULL;

	/* delete old file before continuing */
	remove(fileName);

	/* open new file for writing the descriptor+gbe */
	fileStream = fopen(fileName, "ab");

	/* write the descriptor region into the first part */
	if (DESCRIPTORREGIONSIZE != fwrite((uint8_t*)&descriptorStruct, 1, sizeof(descriptorStruct), fileStream))
	{
		printf("\nerror: writing descriptor region failed\n");
		return 1;
	}

	fclose(fileStream);

	printf("descriptor successfully written to the file: %s\n", fileName);
	printf("Now do: dd if=%s of=yourrom.rom bs=1 count=4k conv=notrunc\n", fileName);
	printf("(in other words, add the modified descriptor to your ROM image)\n\n");

	return 0;
}


code:
/*
 *  gbe_descriptor.h
 *  This file is part of the ich9deblob utility from the libreboot project
 *
 * Purpose: header file for descriptor_gbe.c
 *
 *  Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
 *  Copyright (C) 2014 Steve Shenton <sgsit@libreboot.org>
 *
 *  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
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef COMMON_DESCRIPTOR_GBE_H
#define COMMON_DESCRIPTOR_GBE_H

#include <stdio.h>
#include <string.h>
#include <stdint.h>

#include "../descriptor/descriptor.h" /* structs describing what's in the descriptor region */
#include "../gbe/gbe.h"               /* structs describing what's in the gbe region */

int notCreatedDescriptorGbeFile(struct DESCRIPTORREGIONRECORD descriptorStruct, struct GBEREGIONRECORD_8K gbeStruct8k, char* fileName);
int notCreated4kDescriptorFile(struct DESCRIPTORREGIONRECORD descriptorStruct, char* fileName);

#endif


code:
/*
 *  x86compatibility.c
 *  This file is part of the ich9deblob utility from the libreboot project
 *
 * Purpose: compiler/cpu compatibility checks. ich9deblob is not portable, yet.
 *
 *  Copyright (C) 2014 Steve Shenton <sgsit@libreboot.org>
 *                     Leah Rowe <info@minifree.org>
 *
 *  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
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "x86compatibility.h"

/*
 * ---------------------------------------------------------------------
 * x86 compatibility checking:
 * ---------------------------------------------------------------------
 */

/* fail if struct size is incorrect */
int structSizesIncorrect(struct DESCRIPTORREGIONRECORD descriptorDummy, struct GBEREGIONRECORD_8K gbe8kDummy)
{
	unsigned int descriptorRegionStructSize = sizeof(descriptorDummy);
	unsigned int gbeRegion8kStructSize = sizeof(gbe8kDummy);

	/* check compiler bit-packs in a compatible way. basically, it is expected that this code will be used on x86 */
	if (DESCRIPTORREGIONSIZE != descriptorRegionStructSize){
		printf("\nerror: compiler incompatibility: descriptor struct length is %i bytes (should be %i)\n", descriptorRegionStructSize, DESCRIPTORREGIONSIZE);
		return 1;
	}
	if (GBEREGIONSIZE_8K != gbeRegion8kStructSize){
		printf("\nerror: compiler incompatibility: gbe struct length is %i bytes (should be %i)\n", gbeRegion8kStructSize, GBEREGIONSIZE_8K);
		return 1;
	}

	return 0;
}

/* fail if members are presented in the wrong order */
int structMembersWrongOrder()
{
	int i;
	struct DESCRIPTORREGIONRECORD descriptorDummy;
	uint8_t *meVsccTablePtr = (uint8_t*)&descriptorDummy.meVsccTable;

	/* These do not use bitfields.  */
	descriptorDummy.meVsccTable.jid0 = 0x01020304;  /* unsigned int 32-bit */
	descriptorDummy.meVsccTable.vscc0 = 0x10203040; /* unsigned int 32-bit */
	descriptorDummy.meVsccTable.jid1 = 0x11223344;  /* unsigned int 32-bit */
	descriptorDummy.meVsccTable.vscc1 = 0x05060708; /* unsigned int 32-bit */
	descriptorDummy.meVsccTable.jid2 = 0x50607080;  /* unsigned int 32-bit */
	descriptorDummy.meVsccTable.vscc2 = 0x55667788; /* unsigned int 32-bit */
	descriptorDummy.meVsccTable.padding[0] = 0xAA;  /* unsigned char 8-bit */
	descriptorDummy.meVsccTable.padding[1] = 0xBB;  /* unsigned char 8-bit */
	descriptorDummy.meVsccTable.padding[2] = 0xCC;  /* unsigned char 8-bit */
	descriptorDummy.meVsccTable.padding[3] = 0xDD;  /* unsigned char 8-bit */

	/*
	 * Look from the top down, and concatenate the unsigned ints but
	 * with each unsigned in little endian order.
	 * Then, concatenate the unsigned chars in big endian order. (in the padding array)
	 *
	 * combined, these should become:
	 * 01020304 10203040 11223344 05060708 50607080 55667788 AA BB CC DD (ignore this. big endian. just working it out manually:)
	 * 04030201 40302010 44332211 08070605 80706050 88776655 AA BB CC DD (ignore this. not byte-separated, just working it out:)
	 * 04 03 02 01 40 30 20 10 44 33 22 11 08 07 06 05 80 70 60 50 88 77 66 55 AA BB CC DD <-- it should match this
	 */

	if (
			!
			(
				*meVsccTablePtr      == 0x04 && *(meVsccTablePtr+1)  == 0x03 && *(meVsccTablePtr+2)  == 0x02 && *(meVsccTablePtr+3)  == 0x01
			&& *(meVsccTablePtr+4)  == 0x40 && *(meVsccTablePtr+5)  == 0x30 && *(meVsccTablePtr+6)  == 0x20 && *(meVsccTablePtr+7)  == 0x10
			&& *(meVsccTablePtr+8)  == 0x44 && *(meVsccTablePtr+9)  == 0x33 && *(meVsccTablePtr+10) == 0x22 && *(meVsccTablePtr+11) == 0x11
			&& *(meVsccTablePtr+12) == 0x08 && *(meVsccTablePtr+13) == 0x07 && *(meVsccTablePtr+14) == 0x06 && *(meVsccTablePtr+15) == 0x05
			&& *(meVsccTablePtr+16) == 0x80 && *(meVsccTablePtr+17) == 0x70 && *(meVsccTablePtr+18) == 0x60 && *(meVsccTablePtr+19) == 0x50
			&& *(meVsccTablePtr+20) == 0x88 && *(meVsccTablePtr+21) == 0x77 && *(meVsccTablePtr+22) == 0x66 && *(meVsccTablePtr+23) == 0x55
			&& *(meVsccTablePtr+24) == 0xAA && *(meVsccTablePtr+25) == 0xBB && *(meVsccTablePtr+26) == 0xCC && *(meVsccTablePtr+27) == 0xDD
	      )
	   ) {

		printf("\nStruct member order check (descriptorDummy.meVsccTable) with junk/dummy data:");
		printf("\nShould be: 04 03 02 01 40 30 20 10 44 33 22 11 08 07 06 05 80 70 60 50 88 77 66 55 aa bb cc dd ");
		printf("\nAnd it is: ");

		for (i = 0; i < 28; i++) {
			printf("%02x ", *(meVsccTablePtr + i));
		}
		printf("\nIncorrect order.\n");

		return 1;
	}

	return 0;
}

/* fail if bit fields are presented in the wrong order */
int structBitfieldWrongOrder()
{
	int i;
	struct DESCRIPTORREGIONRECORD descriptorDummy;
	uint8_t *flMap0Ptr = (uint8_t*)&descriptorDummy.flMaps.flMap0;

	descriptorDummy.flMaps.flMap0.FCBA = 0xA2;      /* :8 --> 10100010 */
	descriptorDummy.flMaps.flMap0.NC = 0x02;        /* :2 --> 10       */
	descriptorDummy.flMaps.flMap0.reserved1 = 0x38; /* :6 --> 111000   */
	descriptorDummy.flMaps.flMap0.FRBA = 0xD2;      /* :8 --> 11010010 */
	descriptorDummy.flMaps.flMap0.NR = 0x05;        /* :3 --> 101      */
	descriptorDummy.flMaps.flMap0.reserved2 = 0x1C; /* :5 --> 11100    */

	/*
	 * Look from the top bottom up, and concatenate the binary strings.
	 * Then, convert the 8-bit groups to hex and reverse the (8-bit)byte order
	 *
	 * combined, these should become (in memory), in binary:
	 * 10100010 11100010 11010010 11100101
	 * or in hex:
	 * A2 E2 D2 E5
	 */

	if (!(*flMap0Ptr == 0xA2 && *(flMap0Ptr+1) == 0xE2 && *(flMap0Ptr+2) == 0xD2 && *(flMap0Ptr+3) == 0xE5))
	{
		printf("\nBitfield order check (descriptorDummy.flMaps.flMaps0) with junk/dummy data:");
		printf("\nShould be: a2 e2 d2 e5 ");
		printf("\nAnd it is: ");

		for (i = 0; i < 4; i++) {
			printf("%02x ", *(flMap0Ptr + i));
		}
		printf("\nIncorrect order.\n");

		return 1;
	}

	return 0;
}

/* Compatibility checks. This version of ich9deblob is not yet porable. */
int systemOrCompilerIncompatible(struct DESCRIPTORREGIONRECORD descriptorStruct, struct GBEREGIONRECORD_8K gbeStruct8k)
{
	if (structSizesIncorrect(descriptorStruct, gbeStruct8k)) return 1;
	if (IS_BIG_ENDIAN) {
		printf("big endian not supported\n");
		return 1;
	}
	if (structBitfieldWrongOrder()) return 1;
	if (structMembersWrongOrder()) return 1;
	return 0;
}


code:
/*
 *  x86compatibility.h
 *  This file is part of the ich9deblob utility from the libreboot project
 *
 * Purpose: keep gcc/make happy. no actual code here, just function definitions.
 *
 *  Copyright (C) 2014 Steve Shenton <sgsit@libreboot.org>
 *                     Leah Rowe <info@minifree.org>
 *
 *  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
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef X86COMPATIBILITY_H
#define X86COMPATIBILITY_H

#include <stdio.h>
#include <string.h>
#include <stdint.h>

/* http://esr.ibiblio.org/?p=5095 */
#define IS_BIG_ENDIAN (*(uint16_t *)"\0\xff" < 0x100)

#include "../descriptor/descriptor.h" /* structs describing what's in the descriptor region */
#include "../gbe/gbe.h"               /* structs describing what's in the gbe region */

int structSizesIncorrect(struct DESCRIPTORREGIONRECORD descriptorDummy, struct GBEREGIONRECORD_8K gbe8kDummy);
int structMembersWrongOrder();
int structBitfieldWrongOrder();
int systemOrCompilerIncompatible(struct DESCRIPTORREGIONRECORD descriptorStruct, struct GBEREGIONRECORD_8K gbeStruct8k);

#endif


code:
/*
 *  demefactory.c
 *  This file is part of the demefactory utility from the libreboot project
 *
 * Purpose: disable ME on GM45 factory firmware, but leave region intact
 * 			enable read-write on all regions
 *
 *	 Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
 *  Copyright (C) 2014 Steve Shenton <sgsit@libreboot.org>
 *
 *  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
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * demfactory utility - main
 */

#include "demefactory.h"

int main()
{
	struct DESCRIPTORREGIONRECORD descriptorStruct;
	uint8_t* descriptorBuffer = (uint8_t*)&descriptorStruct;

	struct GBEREGIONRECORD_8K gbeStruct8k; /* not needed, except for compatibility checking */

	char* romFilename = "factory.rom";
	char* descriptorFilename = "demefactory_4kdescriptor.bin";

	unsigned int bufferLength;
	unsigned int romSize;

	/*
	 * ------------------------------------------------------------------
	 * Compatibility checks. This version of ich9deblob is not yet portable.
	 * ------------------------------------------------------------------
	 */

	if (systemOrCompilerIncompatible(descriptorStruct, gbeStruct8k)) return 1;
	/* If true, fail with error message */

	/*
	 * ------------------------------------------------------------------
	 * Extract the descriptor region from the factory.rom dump
	 * ------------------------------------------------------------------
	 */
	FILE* fp = NULL;
	fp = fopen(romFilename, "rb"); /* open factory.rom */
	if (NULL == fp)
	{
		printf("\nerror: could not open %s\n", romFilename);
		fclose(fp);
		return 1;
	}
	printf("\n%s opened successfully\n", romFilename);

	/*
	 * Get the descriptor region dump from the factory.rom
	 * (goes in factoryDescriptorBuffer variable)
	 */
	bufferLength = fread(descriptorBuffer, 1, DESCRIPTORREGIONSIZE, fp);
	if (DESCRIPTORREGIONSIZE != bufferLength) //
	{
		printf("\nerror: could not read descriptor from %s (%i) bytes read\n", romFilename, bufferLength);
		fclose(fp);
		return 1;
	}
	printf("\ndescriptor region read successfully\n");

	/* ------------------------------------------------- */

	fseek(fp, 0L, SEEK_END);
	romSize = ftell(fp);
	printf("\n%s size: [%i] bytes\n", romFilename, romSize);

	/* -------------------------------------------------- */

	fclose(fp);

	/* Debugging (before modification) */
	printDescriptorRegionLocations(descriptorStruct, "Original");

	/*
	 * ------------------------------------------------------------------
	 * Modify the descriptor region, ready to go in the modified factory.rom
	 * ------------------------------------------------------------------
	 */

	// Disable the ME/TPM:
	descriptorStruct = descriptorDisableMe(descriptorStruct);
	descriptorStruct = descriptorDisableTpm(descriptorStruct);

	/* Host/CPU is allowed to read/write all regions. */
	descriptorStruct = descriptorHostRegionsUnlocked(descriptorStruct);
	/* The ME is disallowed read-write access to all regions
	 * (this is probably redundant, since the ME is already removed from libreboot) */
	descriptorStruct = descriptorMeRegionsForbidden(descriptorStruct);

	/* Debugging (after modifying the descriptor region) */
	printDescriptorRegionLocations(descriptorStruct, "Modified");

	/*
	 * ------------------------------------------------------------------
	 * Create the file with the modified descriptor inside
	 * ------------------------------------------------------------------
	 */

	printf("\n");
	if (notCreated4kDescriptorFile(descriptorStruct, descriptorFilename)) {
		return 1;
	}

	/*
	 * ------------------------------------------------------------------
	 * Generate ich9gen data (C code that will recreate the deactivatedME descriptor from scratch)
	 * ------------------------------------------------------------------
	 */
	/* Code for generating the Descriptor struct */
	/* mkdescriptor.h */
	if (notCreatedHFileForDescriptorCFile("mkdescriptor.h", "mkdescriptor.c")) {
		return 1;
	} /* and now mkdescriptor.c */
	if (notCreatedCFileFromDescriptorStruct(descriptorStruct, "mkdescriptor.c", "mkdescriptor.h")) {
		return 1;
	}

	printf("The modified descriptor region has also been dumped as src files: mkdescriptor.c, mkdescriptor.h\n\n");

	return 0;
}


code:
/*
 *  Copyright (C) 2015 Leah Rowe <info@minifree.org>
 *
 *  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
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/* Header file for demefactory.c */

#ifndef DEMEFACTORY_H
#define DEMEFACTORY_H

#include <stdio.h>
#include <string.h>
#include <stdint.h>

#include "common/descriptor_gbe.h"   /* common descriptor/gbe functions used by ich9deblob */
#include "common/x86compatibility.h" /* system/compiler compatibility checks. This code is not portable. */
#include "descriptor/descriptor.h"   /* structs describing what's in the descriptor region */
#include "gbe/gbe.h"                 /* structs describing what's in the gbe region */

int main();

#endif