Cleanup access to vendor/part # info
[coreboot.git] / payloads / libpayload / include / coreboot_tables.h
index 04b8cef4c1351824089130d15803a3750255a5ab..c68ccc9c2fb872b392202d7e3fe52ef6f816695f 100644 (file)
@@ -60,9 +60,13 @@ struct cb_memory_range {
        u32 type;
 };
 
-#define CB_MEM_RAM      1
-#define CB_MEM_RESERVED 2
-#define CB_MEM_TABLE    16
+#define CB_MEM_RAM          1
+#define CB_MEM_RESERVED     2
+#define CB_MEM_ACPI         3
+#define CB_MEM_NVS          4
+#define CB_MEM_UNUSABLE     5
+#define CB_MEM_VENDOR_RSVD  6
+#define CB_MEM_TABLE       16
 
 struct cb_memory {
        u32 tag;
@@ -110,7 +114,11 @@ struct cb_string {
 struct cb_serial {
        u32 tag;
        u32 size;
-       u16 ioport;
+#define CB_SERIAL_TYPE_IO_MAPPED     1
+#define CB_SERIAL_TYPE_MEMORY_MAPPED 2
+       u32 type;
+       u32 baseaddr;
+       u32 baud;
 };
 
 #define CB_TAG_CONSOLE       0x00010
@@ -122,10 +130,10 @@ struct cb_console {
 };
 
 #define CB_TAG_CONSOLE_SERIAL8250 0
-#define CB_TAG_CONSOLE_VGA        1
-#define CB_TAG_CONSOLE_BTEXT      2
+#define CB_TAG_CONSOLE_VGA        1 // OBSOLETE
+#define CB_TAG_CONSOLE_BTEXT      2 // OBSOLETE
 #define CB_TAG_CONSOLE_LOGBUF     3
-#define CB_TAG_CONSOLE_SROM       4
+#define CB_TAG_CONSOLE_SROM       4 // OBSOLETE
 #define CB_TAG_CONSOLE_EHCI       5
 
 #define CB_TAG_FORWARD       0x00011
@@ -208,22 +216,35 @@ struct    cb_cmos_checksum {
        u32 type;
 };
 
+/* Helpful inlines */
+
+static inline u64 cb_unpack64(struct cbuint64 val)
+{
+       return (((u64) val.hi) << 32) | val.lo;
+}
+
+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) \
        (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
 
 #define MEM_RANGE_PTR(_rec, _idx) \
-       (((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)
-
-#define UNPACK_CB64(_in) \
-       ( (((u64) _in.hi) << 32) | _in.lo )
+       (void *)(((u8 *) (_rec)) + sizeof(*(_rec)) \
+               + (sizeof((_rec)->map[0]) * (_idx)))
 
 #endif