2012-12-08 02:24:06 +01:00
|
|
|
#ifndef STDDEF_H
|
|
|
|
#define STDDEF_H
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
typedef long ptrdiff_t;
|
2012-05-14 22:21:08 +02:00
|
|
|
#ifndef __SIZE_TYPE__
|
|
|
|
#define __SIZE_TYPE__ unsigned long
|
|
|
|
#endif
|
|
|
|
typedef __SIZE_TYPE__ size_t;
|
2013-05-02 23:02:28 +02:00
|
|
|
/* There is a GCC macro for a size_t type, but not
|
|
|
|
* for a ssize_t type. Below construct tricks GCC
|
|
|
|
* into making __SIZE_TYPE__ signed.
|
|
|
|
*/
|
|
|
|
#define unsigned signed
|
|
|
|
typedef __SIZE_TYPE__ ssize_t;
|
|
|
|
#undef unsigned
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
typedef int wchar_t;
|
|
|
|
typedef unsigned int wint_t;
|
|
|
|
|
2004-10-14 22:54:17 +02:00
|
|
|
#define NULL ((void *)0)
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2013-03-16 04:17:26 +01:00
|
|
|
/* Standard units. */
|
|
|
|
#define KiB (1<<10)
|
|
|
|
#define MiB (1<<20)
|
|
|
|
#define GiB (1<<30)
|
|
|
|
/* Could we ever run into this one? I hope we get this much memory! */
|
|
|
|
#define TiB (1<<40)
|
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
|
|
|
|
2013-12-10 02:46:22 +01:00
|
|
|
#define check_member(structure, member, offset) _Static_assert( \
|
|
|
|
offsetof(struct structure, member) == offset, \
|
|
|
|
"`struct " #structure "` offset for `" #member "` is not " #offset )
|
|
|
|
|
2015-01-05 20:09:11 +01:00
|
|
|
/**
|
|
|
|
* container_of - cast a member of a structure out to the containing structure
|
|
|
|
* @param ptr: the pointer to the member.
|
|
|
|
* @param type: the type of the container struct this is embedded in.
|
|
|
|
* @param member: the name of the member within the struct.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define container_of(ptr, type, member) ({ \
|
|
|
|
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
|
|
|
(type *)( (char *)__mptr - offsetof(type,member) );})
|
|
|
|
|
Make the device tree available in the rom stage
We thought about two ways to do this change. The way we decided to try
was to
1. drop all ops from devices in romstage
2. constify all devices in romstage (make them read-only) so we can
compile static.c into romstage
3. the device tree "devices" can be used to read configuration from
the device tree (and nothing else, really)
4. the device tree devices are accessed through struct device * in
romstage only. device_t stays the typedef to int in romstage
5. Use the same static.c file in ramstage and romstage
We declare structs as follows:
ROMSTAGE_CONST struct bus dev_root_links[];
ROMSTAGE_CONST is const in romstage and empty in ramstage; This
forces all of the device tree into the text area.
So a struct looks like this:
static ROMSTAGE_CONST struct device _dev21 = {
#ifndef __PRE_RAM__
.ops = 0,
#endif
.bus = &_dev7_links[0],
.path = {.type=DEVICE_PATH_PCI,{.pci={ .devfn = PCI_DEVFN(0x1c,3)}}},
.enabled = 0,
.on_mainboard = 1,
.subsystem_vendor = 0x1ae0,
.subsystem_device = 0xc000,
.link_list = NULL,
.sibling = &_dev22,
#ifndef __PRE_RAM__
.chip_ops = &southbridge_intel_bd82x6x_ops,
#endif
.chip_info = &southbridge_intel_bd82x6x_info_10,
.next=&_dev22
};
Change-Id: I722454d8d3c40baf7df989f5a6891f6ba7db5727
Signed-off-by: Ronald G. Minnich <rminnich@chromium.org>
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/1398
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-08-01 01:47:25 +02:00
|
|
|
#ifdef __PRE_RAM__
|
|
|
|
#define ROMSTAGE_CONST const
|
|
|
|
#else
|
|
|
|
#define ROMSTAGE_CONST
|
|
|
|
#endif
|
|
|
|
|
2014-06-07 01:10:56 +02:00
|
|
|
/* Work around non-writable data segment in execute-in-place romstage on x86. */
|
|
|
|
#if defined(__PRE_RAM__) && CONFIG_ARCH_X86
|
|
|
|
#define MAYBE_STATIC
|
|
|
|
#else
|
|
|
|
#define MAYBE_STATIC static
|
|
|
|
#endif
|
|
|
|
|
2012-12-08 02:24:06 +01:00
|
|
|
#endif /* STDDEF_H */
|