summaryrefslogtreecommitdiffstats
path: root/platform-intel.h
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2008-12-08 16:59:18 -0700
committerDan Williams <dan.j.williams@intel.com>2008-12-08 16:59:18 -0700
commit88c32bb1ec5d0c12eb557c4f46832fa4e1076784 (patch)
tree937a3f618adcb035b81e9a69e64bd0056f466679 /platform-intel.h
parent25921536da17d72dccc9aed736ce5f26ba08b4cb (diff)
downloadmdadm-88c32bb1ec5d0c12eb557c4f46832fa4e1076784.tar.gz
mdadm-88c32bb1ec5d0c12eb557c4f46832fa4e1076784.tar.xz
mdadm-88c32bb1ec5d0c12eb557c4f46832fa4e1076784.zip
imsm: validate arrays being created against firmware capabilities
These checks are only enabled when platform support for imsm is found, i.e. ahci driver is loaded and talking to an Intel(R) controller, and the option rom header is located. They can be turned off by setting the environment variable IMSM_NO_PLATFORM to 1. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'platform-intel.h')
-rw-r--r--platform-intel.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/platform-intel.h b/platform-intel.h
index c126482..bbdc9f9 100644
--- a/platform-intel.h
+++ b/platform-intel.h
@@ -17,6 +17,7 @@
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <asm/types.h>
+#include <strings.h>
/* The IMSM OROM Version Table definition */
struct imsm_orom {
@@ -78,6 +79,42 @@ struct imsm_orom {
__u32 reserved2;
} __attribute__((packed));
+static inline int imsm_orom_has_raid0(const struct imsm_orom *orom)
+{
+ return !!(orom->rlc & IMSM_OROM_RLC_RAID0);
+}
+static inline int imsm_orom_has_raid1(const struct imsm_orom *orom)
+{
+ return !!(orom->rlc & IMSM_OROM_RLC_RAID1);
+}
+static inline int imsm_orom_has_raid1e(const struct imsm_orom *orom)
+{
+ return !!(orom->rlc & IMSM_OROM_RLC_RAID1E);
+}
+static inline int imsm_orom_has_raid10(const struct imsm_orom *orom)
+{
+ return !!(orom->rlc & IMSM_OROM_RLC_RAID10);
+}
+static inline int imsm_orom_has_raid5(const struct imsm_orom *orom)
+{
+ return !!(orom->rlc & IMSM_OROM_RLC_RAID5);
+}
+
+/**
+ * imsm_orom_has_chunk - check if the orom supports the given chunk size
+ * @orom: orom pointer from find_imsm_orom
+ * @chunk: chunk size in kibibytes
+ */
+static inline int imsm_orom_has_chunk(const struct imsm_orom *orom, int chunk)
+{
+ int fs = ffs(chunk);
+
+ if (!fs)
+ return 0;
+ fs--; /* bit num to bit index */
+ return !!(orom->sss & (1 << (fs - 1)));
+}
+
struct sys_dev {
char *path;
struct sys_dev *next;