Cleanup access to vendor/part # info
authorPhilip Prindeville <philipp@redfish-solutions.com>
Sun, 25 Dec 2011 05:12:37 +0000 (22:12 -0700)
committerPatrick Georgi <patrick@georgi-clan.de>
Sat, 7 Jan 2012 10:49:57 +0000 (11:49 +0100)
Instead of macros to access MAINBOARD record, use convenience functions.

Store pointers to MAINBOARD and HEADER for use outside of CB code.

Change-Id: I074e3a0df7d25726cbd942538bfdc5a63dd17e12
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Reviewed-on: http://review.coreboot.org/502
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
payloads/coreinfo/coreboot_module.c
payloads/libpayload/arch/i386/coreboot.c
payloads/libpayload/include/coreboot_tables.h
payloads/libpayload/include/sysinfo.h

index 7289366f8b5ded61902e9be7fc93cb70a14afb58..d33ea9ee60219ab5c02d0c5b2c54e0684cbab635 100644 (file)
@@ -142,8 +142,8 @@ static void parse_mainboard(unsigned char *ptr)
 {
        struct cb_mainboard *mb = (struct cb_mainboard *)ptr;
 
-       strncpy(cb_info.vendor, (const char *)MB_VENDOR_STRING(mb), 31);
-       strncpy(cb_info.part, (const char *)MB_PART_STRING(mb), 31);
+       strncpy(cb_info.vendor, cb_mb_vendor_part(mb), 31);
+       strncpy(cb_info.part, cb_mb_part_string(mb), 31);
 }
 
 static void parse_strings(unsigned char *ptr)
index 709f8ae00fc6ac2d274d41835ecf4fbd660fc90e..06acc17b1d244d0bd4713515bc173a61fc1edd62 100644 (file)
@@ -137,6 +137,8 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
                     header->table_bytes) != header->table_checksum)
                return -1;
 
+       info->header = header;
+
        /* Now, walk the tables. */
        ptr += header->header_bytes;
 
@@ -173,6 +175,9 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
                        cb_parse_framebuffer(ptr, info);
                        break;
 #endif
+               case CB_TAG_MAINBOARD:
+                       info->mainboard = (struct cb_mainboard *)ptr;
+                       break;
                }
 
                ptr += rec->size;
index e362d064808a84ae75943d35c1923b497945b4f0..c68ccc9c2fb872b392202d7e3fe52ef6f816695f 100644 (file)
@@ -228,6 +228,16 @@ static inline u16 cb_checksum(const void *ptr, unsigned len)
        return ipchksum(ptr, len);
 }
 
+static inline const char *cb_mb_vendor_string(const struct cb_mainboard *cbm)
+{
+       return (char *)(cbm->strings + cbm->vendor_idx);
+}
+
+static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm)
+{
+       return (char *)(cbm->strings + cbm->part_number_idx);
+}
+
 /* Helpful macros */
 
 #define MEM_RANGE_COUNT(_rec) \
@@ -237,10 +247,4 @@ static inline u16 cb_checksum(const void *ptr, unsigned len)
        (void *)(((u8 *) (_rec)) + sizeof(*(_rec)) \
                + (sizeof((_rec)->map[0]) * (_idx)))
 
-#define MB_VENDOR_STRING(_mb) \
-       (((unsigned char *) ((_mb)->strings)) + (_mb)->vendor_idx)
-
-#define MB_PART_STRING(_mb) \
-       (((unsigned char *) ((_mb)->strings)) + (_mb)->part_number_idx)
-
 #endif
index c1d2002279906b1cb9cadb98fdd81327e75cf591..778dfe9414a96e47987541f045a9b91d1e7bf90c 100644 (file)
@@ -56,6 +56,9 @@ struct sysinfo_t {
        struct cb_framebuffer *framebuffer;
 
        unsigned long *mbtable; /** Pointer to the multiboot table */
+
+       struct cb_header *header;
+       struct cb_mainboard *mainboard;
 };
 
 extern struct sysinfo_t lib_sysinfo;