diff options
author | Francis Rowe <info@gluglug.org.uk> | 2015-01-11 05:08:24 +0000 |
---|---|---|
committer | Francis Rowe <info@gluglug.org.uk> | 2015-01-12 06:38:40 +0000 |
commit | c44ef19d49c16064bed8964557f102fb58a336e7 (patch) | |
tree | d856eb4b90173a5599ef2027ab0fbe4ed16507c2 | |
parent | 715fe3c8d106e396562abff64977d5e33a043720 (diff) | |
download | librebootfr-c44ef19d49c16064bed8964557f102fb58a336e7.tar.gz librebootfr-c44ef19d49c16064bed8964557f102fb58a336e7.zip |
ich9deblob/ich9gen: replace endianness checking function
-rw-r--r-- | resources/utilities/ich9deblob/src/common/x86compatibility.c | 18 | ||||
-rw-r--r-- | resources/utilities/ich9deblob/src/common/x86compatibility.h | 4 |
2 files changed, 7 insertions, 15 deletions
diff --git a/resources/utilities/ich9deblob/src/common/x86compatibility.c b/resources/utilities/ich9deblob/src/common/x86compatibility.c index aaf31733..f172d9a4 100644 --- a/resources/utilities/ich9deblob/src/common/x86compatibility.c +++ b/resources/utilities/ich9deblob/src/common/x86compatibility.c @@ -48,19 +48,6 @@ int structSizesIncorrect(struct DESCRIPTORREGIONRECORD descriptorDummy, struct G return 0; } -/* endianness check. big endian forced to fail */ -int systemIsBigEndian() -{ - uint16_t steak = 0xBEEF; - uint8_t *grill = (uint8_t*)&steak; - - if (*grill!=0xEF) { - printf("\nunsigned short 0xBEEF: first byte should be EF, but it's BE. Your system is big endian, and unsupported (only little endian is tested)\n"); - return 1; - } - return 0; /* you got the good half of the steak */ -} - /* fail if members are presented in the wrong order */ int structMembersWrongOrder() { @@ -164,7 +151,10 @@ int structBitfieldWrongOrder() int systemOrCompilerIncompatible(struct DESCRIPTORREGIONRECORD descriptorStruct, struct GBEREGIONRECORD_8K gbeStruct8k) { if (structSizesIncorrect(descriptorStruct, gbeStruct8k)) return 1; - if (systemIsBigEndian()) return 1; + if (IS_BIG_ENDIAN) { + printf("big endian not supported\n"); + return 1; + } if (structBitfieldWrongOrder()) return 1; if (structMembersWrongOrder()) return 1; return 0; diff --git a/resources/utilities/ich9deblob/src/common/x86compatibility.h b/resources/utilities/ich9deblob/src/common/x86compatibility.h index e5f02bee..9460b289 100644 --- a/resources/utilities/ich9deblob/src/common/x86compatibility.h +++ b/resources/utilities/ich9deblob/src/common/x86compatibility.h @@ -28,11 +28,13 @@ #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 systemIsBigEndian(); int structMembersWrongOrder(); int structBitfieldWrongOrder(); int systemOrCompilerIncompatible(struct DESCRIPTORREGIONRECORD descriptorStruct, struct GBEREGIONRECORD_8K gbeStruct8k); |