summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@openbios.org>2005-11-14 23:04:55 +0000
committerStefan Reinauer <stepan@openbios.org>2005-11-14 23:04:55 +0000
commit0d304c18e2cf1451a45c69aac61198d896da1e4d (patch)
tree3e0e47da22601967fb4c5b9c5c4ee31befe818fc
parent8af7998bacc11c66381836c28b099a4407da955c (diff)
comment and unify lb_uint64 handling as discussed on the mailinglist
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2086 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--src/arch/i386/boot/linuxbios_table.c16
-rw-r--r--src/arch/ppc/boot/linuxbios_table.c16
-rw-r--r--src/include/boot/linuxbios_tables.h38
-rw-r--r--util/lbtdump/lbtdump.c8
4 files changed, 34 insertions, 44 deletions
diff --git a/src/arch/i386/boot/linuxbios_table.c b/src/arch/i386/boot/linuxbios_table.c
index 414addff49..10d3b0ce9d 100644
--- a/src/arch/i386/boot/linuxbios_table.c
+++ b/src/arch/i386/boot/linuxbios_table.c
@@ -7,22 +7,6 @@
#include <device/device.h>
#include <stdlib.h>
-static inline uint64_t unpack_lb64(struct lb_uint64 value)
-{
- uint64_t result;
- result = value.hi;
- result = (result << 32) + value.lo;
- return result;
-}
-
-static inline struct lb_uint64 pack_lb64(uint64_t value)
-{
- struct lb_uint64 result;
- result.lo = (value >> 0) & 0xffffffff;
- result.hi = (value >> 32) & 0xffffffff;
- return result;
-}
-
struct lb_header *lb_table_init(unsigned long addr)
{
struct lb_header *header;
diff --git a/src/arch/ppc/boot/linuxbios_table.c b/src/arch/ppc/boot/linuxbios_table.c
index 414addff49..10d3b0ce9d 100644
--- a/src/arch/ppc/boot/linuxbios_table.c
+++ b/src/arch/ppc/boot/linuxbios_table.c
@@ -7,22 +7,6 @@
#include <device/device.h>
#include <stdlib.h>
-static inline uint64_t unpack_lb64(struct lb_uint64 value)
-{
- uint64_t result;
- result = value.hi;
- result = (result << 32) + value.lo;
- return result;
-}
-
-static inline struct lb_uint64 pack_lb64(uint64_t value)
-{
- struct lb_uint64 result;
- result.lo = (value >> 0) & 0xffffffff;
- result.hi = (value >> 32) & 0xffffffff;
- return result;
-}
-
struct lb_header *lb_table_init(unsigned long addr)
{
struct lb_header *header;
diff --git a/src/include/boot/linuxbios_tables.h b/src/include/boot/linuxbios_tables.h
index 9288d3b23c..527c44d5fc 100644
--- a/src/include/boot/linuxbios_tables.h
+++ b/src/include/boot/linuxbios_tables.h
@@ -31,6 +31,40 @@
* table entries and be backwards compatible, but it is not required.
*/
+/* Since LinuxBIOS is usually compiled 32bit, gcc will align 64bit
+ * types to 32bit boundaries. If the LinuxBIOS table is dumped on a
+ * 64bit system, a uint64_t would be aligned to 64bit boundaries,
+ * breaking the table format.
+ *
+ * lb_uint64 will keep 64bit LinuxBIOS table values aligned to 32bit
+ * to ensure compatibility. They can be accessed with the two functions
+ * below: unpack_lb64() and pack_lb64()
+ *
+ * See also: util/lbtdump/lbtdump.c
+ */
+
+struct lb_uint64 {
+ uint32_t lo;
+ uint32_t hi;
+};
+
+static inline uint64_t unpack_lb64(struct lb_uint64 value)
+{
+ uint64_t result;
+ result = value.hi;
+ result = (result << 32) + value.lo;
+ return result;
+}
+
+static inline struct lb_uint64 pack_lb64(uint64_t value)
+{
+ struct lb_uint64 result;
+ result.lo = (value >> 0) & 0xffffffff;
+ result.hi = (value >> 32) & 0xffffffff;
+ return result;
+}
+
+
struct lb_header
{
@@ -57,10 +91,6 @@ struct lb_record {
#define LB_TAG_MEMORY 0x0001
-struct lb_uint64 {
- uint32_t lo;
- uint32_t hi;
-};
struct lb_memory_range {
struct lb_uint64 start;
struct lb_uint64 size;
diff --git a/util/lbtdump/lbtdump.c b/util/lbtdump/lbtdump.c
index 4b5d9dfa65..e799e8d0c3 100644
--- a/util/lbtdump/lbtdump.c
+++ b/util/lbtdump/lbtdump.c
@@ -9,14 +9,6 @@
#include <sys/mman.h>
#include "../../src/include/boot/linuxbios_tables.h"
-static inline uint64_t unpack_lb64(struct lb_uint64 value)
-{
- uint64_t result;
- result = value.hi;
- result = (result << 32) + value.lo;
- return result;
-}
-
void print_lb_records(struct lb_record *rec, struct lb_record *last, unsigned long addr);
unsigned long compute_checksum(void *addr, unsigned long length)