Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8037
-gerrit
commit d81fe89a8368b39ab5d191f32b983cf4b356eee8
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Sat Jan 3 02:08:33 2015 +1100
util/gitconfig/pre-commit: Use clang-format to sanitise commits
Use the `git-format' tool to sanitise coreboot commits such that
they conform to coreboot's coding style.
This fancy piece of machinary allows one to have LibFormat from
Clang to automatically check your commit conforms to coreboot's
coding style, fix any issues automatically and provides you a
diff you may review and apply at your convenience.
Change-Id: If49017ea82f0707efd47cae5978a286a9af8f3b7
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
util/gitconfig/pre-commit | 140 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 140 insertions(+)
diff --git a/util/gitconfig/pre-commit b/util/gitconfig/pre-commit
index 8ab3e56..e414b05 100755
--- a/util/gitconfig/pre-commit
+++ b/util/gitconfig/pre-commit
@@ -1,2 +1,142 @@
#!/bin/sh
exec make lint-stable
+
+# git pre-commit hook that runs an clang-format stylecheck.
+# Features:
+# - abort commit when commit does not comply with the style guidelines
+# - create a patch of the proposed style changes
+
+# modifications for clang-format by rene.milk(a)wwu.de
+# This file is part of a set of unofficial pre-commit hooks available
+# at github.
+# Link: https://github.com/githubbrowser/Pre-commit-hooks
+# Contact: David Martin, david.martin.mailbox(a)googlemail.com
+
+
+##################################################################
+# SETTINGS
+# set path to clang-format binary
+CLANG_FORMAT="/usr/bin/clang-format"
+
+# remove any older patches from previous commits. Set to true or false.
+# DELETE_OLD_PATCHES=false
+DELETE_OLD_PATCHES=false
+
+# only parse files with the extensions in FILE_EXTS. Set to true or false.
+# if false every changed file in the commit will be parsed with clang-format.
+# if true only files matching one of the extensions are parsed with clang-format.
+# PARSE_EXTS=true
+PARSE_EXTS=true
+
+# file types to parse. Only effective when PARSE_EXTS is true.
+# FILE_EXTS=".c .h .cpp .hpp"
+FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx"
+
+##################################################################
+# There should be no need to change anything below this line.
+
+# Reference: http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gn…
+canonicalize_filename () {
+ local target_file=$1
+ local physical_directory=""
+ local result=""
+
+ # Need to restore the working directory after work.
+ pushd `pwd` > /dev/null
+
+ cd "$(dirname "$target_file")"
+ target_file=`basename $target_file`
+
+ # Iterate down a (possible) chain of symlinks
+ while [ -L "$target_file" ]
+ do
+ target_file=$(readlink "$target_file")
+ cd "$(dirname "$target_file")"
+ target_file=$(basename "$target_file")
+ done
+
+ # Compute the canonicalized name by finding the physical path
+ # for the directory we're in and appending the target file.
+ physical_directory=`pwd -P`
+ result="$physical_directory"/"$target_file"
+
+ # restore the working directory after work.
+ popd > /dev/null
+
+ echo "$result"
+}
+
+# exit on error
+set -e
+
+# check whether the given file matches any of the set extensions
+matches_extension() {
+ local filename=$(basename "$1")
+ local extension=".${filename##*.}"
+ local ext
+
+ for ext in $FILE_EXTS; do [[ "$ext" == "$extension" ]] && return 0; done
+
+ return 1
+}
+
+# necessary check for initial commit
+if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
+ against=HEAD
+else
+ # Initial commit: diff against an empty tree object
+ against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+fi
+
+if [ ! -x "$CLANG_FORMAT" ] ; then
+ printf "Error: clang-format executable not found.\n"
+ printf "Set the correct path in $(canonicalize_filename "$0").\n"
+ exit 1
+fi
+
+# create a random filename to store our generated patch
+prefix="pre-commit-clang-format"
+suffix="$(date +%s)"
+patch="/tmp/$prefix-$suffix.patch"
+
+# clean up any older clang-format patches
+$DELETE_OLD_PATCHES && rm -f /tmp/$prefix*.patch
+
+# create one patch containing all changes to the files
+git diff-index --cached --diff-filter=ACMR --name-only $against -- | while read file;
+do
+ # ignore file if we do check for file extensions and the file
+ # does not match any of the extensions specified in $FILE_EXTS
+ if $PARSE_EXTS && ! matches_extension "$file"; then
+ continue;
+ fi
+
+ # clang-format our sourcefile, create a patch with diff and append it to our $patch
+ # The sed call is necessary to transform the patch from
+ # --- $file timestamp
+ # +++ - timestamp
+ # to both lines working on the same file and having a a/ and b/ prefix.
+ # Else it can not be applied with 'git apply'.
+ "$CLANG_FORMAT" -style=file "$file" | \
+ diff -u "$file" - | \
+ sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch"
+done
+
+# if no patch has been generated all is ok, clean up the file stub and exit
+if [ ! -s "$patch" ] ; then
+ printf "Files in this commit comply with the clang-format rules.\n"
+ rm -f "$patch"
+ exit 0
+fi
+
+# a patch has been created, notify the user and exit
+printf "\nThe following differences were found between the code to commit "
+printf "and the clang-format rules:\n\n"
+cat "$patch"
+
+printf "\nYou can apply these changes with:\n git apply $patch\n"
+printf "(may need to be called from the root directory of your repository)\n"
+printf "Aborting commit. Apply changes and commit again or skip checking with"
+printf " --no-verify (not recommended).\n"
+
+exit 1
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8036
-gerrit
commit 907184f632283a6bdd3ccfdf15d0bd37132eb95b
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Sat Jan 3 01:55:22 2015 +1100
Provide coreboot coding style formalisation file for clang-format
The Clang project has a powerful code rewrite engine in the form
of LibFormat. A auxiliary tool is provided called `clang-format'
that can take a coding style formalisation file and rewrite your
code to conform to this style. Further, a wrapper script called
`git-clang-format' is also provided that can hook pre-commits
potentially replacing our slow and poor coverage regexp scripts
on pre-commits.
Herein we provide essentially the Linux Style Guide formalism.
Change-Id: Ica2207fdb8a4702793fa73eba6293b7b36ea9050
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
.clang-format | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..a3ef233
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,6 @@
+BasedOnStyle: LLVM
+IndentWidth: 8
+UseTab: Always
+BreakBeforeBraces: Linux
+AllowShortIfStatementsOnASingleLine: false
+IndentCaseLabels: false
Francis Rowe (info(a)gluglug.org.uk) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7786
-gerrit
commit 67504507ce9611eefbcc8a47ac50322308a98f0f
Author: Francis Rowe <info(a)gluglug.org.uk>
Date: Fri Dec 12 12:42:01 2014 +0000
northbridge/gm45/raminit.c: enable GS45 high-performance mode
X200S uses GS45 chipset, unlike X200 which uses GM45. These two
chipsets are mostly compatible except for raminit.
The datasheets for GS45 describe a high- and low-performance mode
for different CPUs. Coreboot currently disables GS45 altogether,
but forcing coreboot to treat high-performance GS45 as GM45 makes
the X200S boot if it has the right CPU type.
Hardcode-enable GS45 high-performance mode in coreboot, passing it
off as GM45. This is known to work with all CPUs except the SU
(low performance) models.
Patch courtesy of sgsit.
Change-Id: I57032bb6e1ebdaf4e2aa09548e73d253afb9b078
Signed-off-by: Francis Rowe <info(a)gluglug.org.uk>
Signed-off-by: Steve Shenton <sgsit(a)libreboot.org>
---
src/northbridge/intel/gm45/raminit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/northbridge/intel/gm45/raminit.c b/src/northbridge/intel/gm45/raminit.c
index 60b05bd..da38ef4 100644
--- a/src/northbridge/intel/gm45/raminit.c
+++ b/src/northbridge/intel/gm45/raminit.c
@@ -109,8 +109,8 @@ void get_gmch_info(sysinfo_t *sysinfo)
printk(BIOS_SPEW, "GMCH: GS40\n");
break;
case GMCH_GS45:
- printk(BIOS_SPEW, "GMCH: GS45, using low power mode by default\n");
- sysinfo->gs45_low_power_mode = 1;
+ printk(BIOS_SPEW, "GMCH: GS45, using high performance mode by default\n");
+ sysinfo->gs45_low_power_mode = 0;
break;
case GMCH_PM45:
printk(BIOS_SPEW, "GMCH: PM45\n");
@@ -1693,7 +1693,7 @@ void raminit(sysinfo_t *const sysinfo, const int s3resume)
{
const dimminfo_t *const dimms = sysinfo->dimms;
const timings_t *const timings = &sysinfo->selected_timings;
- const int sff = sysinfo->gfx_type == GMCH_GS45;
+ const int sff = (sysinfo->gfx_type == GMCH_GS45) && (sysinfo->gs45_low_power_mode == 1);
int ch;
u8 reg8;
Francis Rowe (info(a)gluglug.org.uk) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7786
-gerrit
commit 694d592d5ea081ade705f20cae56912866196a8f
Author: Francis Rowe <info(a)gluglug.org.uk>
Date: Fri Dec 12 12:42:01 2014 +0000
northbridge/gm45/raminit.c: enable GS45 high-performance mode
X200S uses GS45 chipset, unlike X200 which uses GM45. These two
chipsets are mostly compatible except for raminit.
The datasheets for GS45 describe a high- and low-performance mode
for different CPU's. Coreboot currently disables GS45 altogether,
but forcing coreboot to treat high-performance GS45 as GM45 makes
the X200S boot if it has the right CPU type.
Hardcode-enable GS45 high-performance mode in coreboot, passing it
off as GM45. This is known to work with all CPUs except the SU
(low performance) models.
Patch courtesy of sgsit.
Change-Id: I57032bb6e1ebdaf4e2aa09548e73d253afb9b078
Signed-off-by: Francis Rowe <info(a)gluglug.org.uk>
Signed-off-by: Steve Shenton <sgsit(a)libreboot.org>
---
src/northbridge/intel/gm45/raminit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/northbridge/intel/gm45/raminit.c b/src/northbridge/intel/gm45/raminit.c
index 60b05bd..da38ef4 100644
--- a/src/northbridge/intel/gm45/raminit.c
+++ b/src/northbridge/intel/gm45/raminit.c
@@ -109,8 +109,8 @@ void get_gmch_info(sysinfo_t *sysinfo)
printk(BIOS_SPEW, "GMCH: GS40\n");
break;
case GMCH_GS45:
- printk(BIOS_SPEW, "GMCH: GS45, using low power mode by default\n");
- sysinfo->gs45_low_power_mode = 1;
+ printk(BIOS_SPEW, "GMCH: GS45, using high performance mode by default\n");
+ sysinfo->gs45_low_power_mode = 0;
break;
case GMCH_PM45:
printk(BIOS_SPEW, "GMCH: PM45\n");
@@ -1693,7 +1693,7 @@ void raminit(sysinfo_t *const sysinfo, const int s3resume)
{
const dimminfo_t *const dimms = sysinfo->dimms;
const timings_t *const timings = &sysinfo->selected_timings;
- const int sff = sysinfo->gfx_type == GMCH_GS45;
+ const int sff = (sysinfo->gfx_type == GMCH_GS45) && (sysinfo->gs45_low_power_mode == 1);
int ch;
u8 reg8;
Francis Rowe (info(a)gluglug.org.uk) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7786
-gerrit
commit 6389b8d63d18dec264ff67eb674b953fff219175
Author: Francis Rowe <info(a)gluglug.org.uk>
Date: Fri Dec 12 12:42:01 2014 +0000
northbridge/gm45/raminit.c: enable GS45 high-perf
X200S uses GS45 chipset, unlike X200 which uses GM45. These two
chipsets are mostly compatible except for raminit.
The datasheets for GS45 describe a high- and low-performance mode
for different CPU's. Coreboot currently disables GS45 altogether,
but forcing coreboot to treat high-performance GS45 as GM45 makes
the X200S boot if it has the right CPU type.
Hardcode-enable GS45 high-performance mode in coreboot, passing it
off as GM45. This is known to work with all CPUs except the SU
(low performance) models.
Patch courtesy of sgsit.
Change-Id: I57032bb6e1ebdaf4e2aa09548e73d253afb9b078
Signed-off-by: Francis Rowe <info(a)gluglug.org.uk>
Signed-off-by: Steve Shenton <sgsit(a)libreboot.org>
---
src/northbridge/intel/gm45/raminit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/northbridge/intel/gm45/raminit.c b/src/northbridge/intel/gm45/raminit.c
index 60b05bd..da38ef4 100644
--- a/src/northbridge/intel/gm45/raminit.c
+++ b/src/northbridge/intel/gm45/raminit.c
@@ -109,8 +109,8 @@ void get_gmch_info(sysinfo_t *sysinfo)
printk(BIOS_SPEW, "GMCH: GS40\n");
break;
case GMCH_GS45:
- printk(BIOS_SPEW, "GMCH: GS45, using low power mode by default\n");
- sysinfo->gs45_low_power_mode = 1;
+ printk(BIOS_SPEW, "GMCH: GS45, using high performance mode by default\n");
+ sysinfo->gs45_low_power_mode = 0;
break;
case GMCH_PM45:
printk(BIOS_SPEW, "GMCH: PM45\n");
@@ -1693,7 +1693,7 @@ void raminit(sysinfo_t *const sysinfo, const int s3resume)
{
const dimminfo_t *const dimms = sysinfo->dimms;
const timings_t *const timings = &sysinfo->selected_timings;
- const int sff = sysinfo->gfx_type == GMCH_GS45;
+ const int sff = (sysinfo->gfx_type == GMCH_GS45) && (sysinfo->gs45_low_power_mode == 1);
int ch;
u8 reg8;
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8017
-gerrit
commit 741c86f2e40b8ae4674f758114521a25f9f80831
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Thu Jan 1 04:09:04 2015 +1100
northbridge/amd/agesa/family1{4,5}: Remove cruft from dimmSpd.c
Remove useless comment pretaining to abusing pragma's for old
GCC/GDB interaction issues.
Change-Id: Ic83a0285ac947a23699a81a82b89de08a47ab052
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/northbridge/amd/agesa/family14/dimmSpd.c | 3 ---
src/northbridge/amd/agesa/family15/dimmSpd.c | 3 ---
2 files changed, 6 deletions(-)
diff --git a/src/northbridge/amd/agesa/family14/dimmSpd.c b/src/northbridge/amd/agesa/family14/dimmSpd.c
index 6ca2ce1..bee2c7e 100644
--- a/src/northbridge/amd/agesa/family14/dimmSpd.c
+++ b/src/northbridge/amd/agesa/family14/dimmSpd.c
@@ -30,9 +30,6 @@
#include <northbridge/amd/agesa/dimmSpd.h>
-/* uncomment for source level debug - GDB gets really confused otherwise. */
-//#pragma optimize ("", off)
-
/**
* Gets the SMBus address for an SPD from the array in devicetree.cb
* then read the SPD into the supplied buffer.
diff --git a/src/northbridge/amd/agesa/family15/dimmSpd.c b/src/northbridge/amd/agesa/family15/dimmSpd.c
index bf8e59e..201f293 100644
--- a/src/northbridge/amd/agesa/family15/dimmSpd.c
+++ b/src/northbridge/amd/agesa/family15/dimmSpd.c
@@ -30,9 +30,6 @@
#include <northbridge/amd/agesa/dimmSpd.h>
-/* uncomment for source level debug - GDB gets really confused otherwise. */
-//#pragma optimize ("", off)
-
/**
* Gets the SMBus address for an SPD from the array in devicetree.cb
* then read the SPD into the supplied buffer.