 +    return "UNKOWN OPCODE";
 +}
 +
++static int validate_load_state(u32 cmd, u32 *data)
++{
++	unsigned int count, off;
++
++	count = VIV_FE_LOAD_STATE_HEADER_COUNT(cmd);
++	off = VIV_FE_LOAD_STATE_HEADER_OFFSET(cmd);
++
++	if (count == 0x0)
++		return -EINVAL;
++
++	/* TODO: validate offset */
++
++	return count + 1;
++}
++
 +bool etnaviv_cmd_validate(struct etnaviv_gpu *gpu,
 +	struct etnaviv_gem_object *obj, unsigned int size)
 +{

 drivers/staging/etnaviv/state.xml.h           |  348 ++++++++
 drivers/staging/etnaviv/state_hi.xml.h        |  405 +++++++++
 include/uapi/drm/etnaviv_drm.h                |  223 +++++
 26 files changed, 6332 insertions(+)
 create mode 100644 drivers/staging/etnaviv/Kconfig
 create mode 100644 drivers/staging/etnaviv/Makefile
 create mode 100644 drivers/staging/etnaviv/cmdstream.xml.h

+}
diff --git a/drivers/staging/etnaviv/etnaviv_cmd_parser.c b/drivers/staging/etnaviv/etnaviv_cmd_parser.c
new file mode 100644
index 0000000..548703c
--- /dev/null
+++ b/drivers/staging/etnaviv/etnaviv_cmd_parser.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2015 Etnaviv Project
+ * Author: Russell King <rmk+kernel@arm.linux.org.uk>
