2012-12-08 02:24:06 +01:00
|
|
|
#ifndef STDDEF_H
|
|
|
|
#define STDDEF_H
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2015-09-08 20:34:43 +02:00
|
|
|
#include <commonlib/helpers.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
|
|
|
|
2017-04-17 05:05:36 +02:00
|
|
|
/* The devicetree data structures are only mutable in ramstage. All other
|
|
|
|
stages have a constant devicetree. */
|
2019-05-15 16:57:04 +02:00
|
|
|
#if !ENV_PAYLOAD_LOADER
|
2017-04-17 05:05:36 +02:00
|
|
|
#define DEVTREE_EARLY 1
|
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
|
|
|
#else
|
2017-04-17 05:05:36 +02:00
|
|
|
#define DEVTREE_EARLY 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEVTREE_EARLY
|
|
|
|
#define DEVTREE_CONST const
|
|
|
|
#else
|
|
|
|
#define DEVTREE_CONST
|
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
|
|
|
#endif
|
|
|
|
|
2019-08-20 05:01:57 +02:00
|
|
|
#if ENV_STAGE_HAS_DATA_SECTION
|
|
|
|
#define MAYBE_STATIC_NONZERO static
|
2014-06-07 01:10:56 +02:00
|
|
|
#else
|
2019-08-20 05:01:57 +02:00
|
|
|
#define MAYBE_STATIC_NONZERO
|
|
|
|
#endif
|
|
|
|
|
2016-01-27 08:18:16 +01:00
|
|
|
/* Provide a pointer to address 0 that thwarts any "accessing this is
|
|
|
|
* undefined behaviour and do whatever" trickery in compilers.
|
|
|
|
* Use when you _really_ need to read32(zeroptr) (ie. read address 0).
|
|
|
|
*/
|
2016-04-13 18:51:12 +02:00
|
|
|
extern char zeroptr[];
|
2016-01-27 08:18:16 +01:00
|
|
|
|
2012-12-08 02:24:06 +01:00
|
|
|
#endif /* STDDEF_H */
|