summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/device/device.h32
-rw-r--r--src/include/device/resource.h2
-rw-r--r--src/include/stddef.h15
3 files changed, 29 insertions, 20 deletions
diff --git a/src/include/device/device.h b/src/include/device/device.h
index bb0d0ca8b8..7b4fce36ea 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -84,9 +84,9 @@ static inline void device_noop(struct device *dev) {}
struct bus {
- ROMSTAGE_CONST struct device *dev; /* This bridge device */
- ROMSTAGE_CONST struct device *children; /* devices behind this bridge */
- ROMSTAGE_CONST struct bus *next; /* The next bridge on this device */
+ DEVTREE_CONST struct device *dev; /* This bridge device */
+ DEVTREE_CONST struct device *children; /* devices behind this bridge */
+ DEVTREE_CONST struct bus *next; /* The next bridge on this device */
unsigned int bridge_ctrl; /* Bridge control register */
uint16_t bridge_cmd; /* Bridge command register */
unsigned char link_num; /* The index of this link */
@@ -113,12 +113,12 @@ struct pci_irq_info {
};
struct device {
- ROMSTAGE_CONST struct bus *bus; /* bus this device is on, for bridge
+ DEVTREE_CONST struct bus *bus; /* bus this device is on, for bridge
* devices, it is the up stream bus */
- ROMSTAGE_CONST struct device *sibling; /* next device on this bus */
+ DEVTREE_CONST struct device *sibling; /* next device on this bus */
- ROMSTAGE_CONST struct device *next; /* chain of all devices */
+ DEVTREE_CONST struct device *next; /* chain of all devices */
struct device_path path;
unsigned int vendor;
@@ -134,26 +134,26 @@ struct device {
u8 command;
/* Base registers for this device. I/O, MEM and Expansion ROM */
- ROMSTAGE_CONST struct resource *resource_list;
+ DEVTREE_CONST struct resource *resource_list;
/* links are (downstream) buses attached to the device, usually a leaf
* device with no children has 0 buses attached and a bridge has 1 bus
*/
- ROMSTAGE_CONST struct bus *link_list;
+ DEVTREE_CONST struct bus *link_list;
struct device_operations *ops;
-#ifndef __PRE_RAM__
+#if !DEVTREE_EARLY
struct chip_operations *chip_ops;
const char *name;
#endif
- ROMSTAGE_CONST void *chip_info;
+ DEVTREE_CONST void *chip_info;
};
/**
* This is the root of the device tree. The device tree is defined in the
* static.c file and is generated by the config tool at compile time.
*/
-extern ROMSTAGE_CONST struct device dev_root;
+extern DEVTREE_CONST struct device dev_root;
#ifndef __SIMPLE_DEVICE__
@@ -272,13 +272,13 @@ u32 find_pci_tolm(struct bus *bus);
#else /* vv __SIMPLE_DEVICE__ vv */
-ROMSTAGE_CONST struct device *dev_find_slot(unsigned int bus,
+DEVTREE_CONST struct device *dev_find_slot(unsigned int bus,
unsigned int devfn);
-ROMSTAGE_CONST struct device *dev_find_next_pci_device(
- ROMSTAGE_CONST struct device *previous_dev);
-ROMSTAGE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
+DEVTREE_CONST struct device *dev_find_next_pci_device(
+ DEVTREE_CONST struct device *previous_dev);
+DEVTREE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
unsigned int addr);
-ROMSTAGE_CONST struct device *dev_find_slot_pnp(u16 port, u16 device);
+DEVTREE_CONST struct device *dev_find_slot_pnp(u16 port, u16 device);
#endif
diff --git a/src/include/device/resource.h b/src/include/device/resource.h
index d794fb21e7..eefaf96e28 100644
--- a/src/include/device/resource.h
+++ b/src/include/device/resource.h
@@ -42,7 +42,7 @@ struct resource {
resource_t base; /* Base address of the resource */
resource_t size; /* Size of the resource */
resource_t limit; /* Largest valid value base + size -1 */
- ROMSTAGE_CONST struct resource *next; /* Next resource in the list */
+ DEVTREE_CONST struct resource *next; /* Next resource in the list */
unsigned long flags; /* Descriptions of the kind of resource */
unsigned long index; /* Bus specific per device resource id */
unsigned char align; /* Required alignment (log 2) of the resource */
diff --git a/src/include/stddef.h b/src/include/stddef.h
index d0308d2580..af63196697 100644
--- a/src/include/stddef.h
+++ b/src/include/stddef.h
@@ -2,6 +2,7 @@
#define STDDEF_H
#include <commonlib/helpers.h>
+#include <rules.h>
typedef long ptrdiff_t;
#ifndef __SIZE_TYPE__
@@ -21,10 +22,18 @@ typedef unsigned int wint_t;
#define NULL ((void *)0)
-#ifdef __PRE_RAM__
-#define ROMSTAGE_CONST const
+/* The devicetree data structures are only mutable in ramstage. All other
+ stages have a constant devicetree. */
+#if !ENV_RAMSTAGE
+#define DEVTREE_EARLY 1
#else
-#define ROMSTAGE_CONST
+#define DEVTREE_EARLY 0
+#endif
+
+#if DEVTREE_EARLY
+#define DEVTREE_CONST const
+#else
+#define DEVTREE_CONST
#endif
/* Work around non-writable data segment in execute-in-place romstage on x86. */