- Update the device header files
[coreboot.git] / src / include / device / resource.h
index f90aba19f43bb9ca288786d8919ae856e76744e8..7ab8065c23b842224915dfcd1c1a24a7924efb31 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef RESOURCE_H
 #define RESOURCE_H
 
+#include <stdint.h>
 
 #define IORESOURCE_BITS                0x000000ff      /* Bus-specific bits */
 
@@ -18,9 +19,9 @@
 #define IORESOURCE_SUBTRACTIVE  0x00040000     /* This resource filters all of the unclaimed transactions
                                                 * to the bus below.
                                                 */
-
-#define IORESOURCE_SET         0x80000000      /* An IO resource that has been assigned a value */
-#define IORESOURCE_FIXED       0x40000000      /* An IO resource the allocator must not change */
+#define IORESOURCE_STORED      0x20000000      /* The IO resource assignment has been stored in the device */
+#define IORESOURCE_ASSIGNED    0x40000000      /* An IO resource that has been assigned a value */
+#define IORESOURCE_FIXED       0x80000000      /* An IO resource the allocator must not change */
 
 /* PCI specific resource bits */
 #define IORESOURCE_PCI64       (1<<0)  /* 64bit long pci resource */
 #define IORESOURCE_MEM_SHADOWABLE      (1<<5)  /* dup: IORESOURCE_SHADOWABLE */
 #define IORESOURCE_MEM_EXPANSIONROM    (1<<6)
 
+
+typedef uint64_t resource_t;
 struct resource {
-       unsigned long base;     /* Base address of the resource */
-       unsigned long size;     /* Size of the resource */
-       unsigned long limit;    /* Largest valid value base + size -1 */
+       resource_t base;        /* Base address of the resource */
+       resource_t size;        /* Size of the resource */
+       resource_t limit;       /* Largest valid value base + size -1 */
        unsigned long flags;    /* Descriptions of the kind of resource */
        unsigned long index;    /* Bus specific per device resource id */
-       unsigned char align;    /* Required alignment (base 2) of the resource */
-       unsigned char gran;     /* Granularity (base 2) of the resource */
+       unsigned char align;    /* Required alignment (log 2) of the resource */
+       unsigned char gran;     /* Granularity (log 2) of the resource */
        /* Alignment must be >= the granularity of the resource */
 };
 
+/* Macros to generate index values for subtractive resources */
+#define IOINDEX_SUBTRACTIVE(IDX,LINK) (0x10000000 + ((IDX) << 8) + LINK)
+#define IOINDEX_SUBTRACTIVE_LINK(IDX) (IDX & 0xff)
+
+/* Generic resource helper functions */
+struct device;
+extern void compact_resources(struct device * dev);
+extern struct resource *probe_resource(struct device *dev, unsigned index);
+extern struct resource *new_resource(struct device * dev, unsigned index);
+extern struct resource *find_resource(struct device * dev, unsigned index);
+extern resource_t resource_end(struct resource *resource);
+extern resource_t resource_max(struct resource *resource);
+extern void report_resource_stored(struct device * dev, struct resource *resource, const char *comment);
+
 #endif /* RESOURCE_H */