aboutsummaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2011-01-04 16:52:47 +0100
committerArnd Bergmann <arnd@arndb.de>2011-01-04 16:52:47 +0100
commitc95ea1903edac9851a976a2bb0e35037b66020a5 (patch)
tree331e691135a6ff27d94ca83bd06ceb805ecb3cbb /vm.c
parent5acb726787452d09e8fc562c563e4ec02e8f340c (diff)
flashbench: make code more modular
This makes it possible to call programs from outside of vm.c, and moves all device access to dev.c, as a step towards integrating the flashbench front-end with the vm. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c91
1 files changed, 4 insertions, 87 deletions
diff --git a/vm.c b/vm.c
index b370002..b321a91 100644
--- a/vm.c
+++ b/vm.c
@@ -6,23 +6,7 @@
#include <sys/types.h>
#include <stdlib.h>
-struct device;
-
-typedef union result res_t;
-
-enum resulttype {
- R_NONE,
- R_ARRAY,
- R_NS,
- R_BYTE,
- R_STRING,
-};
-
-union result {
- res_t *_p;
- long long l;
- char s[8];
-} __attribute__((aligned(8)));
+#include "vm.h"
static inline res_t *res_ptr(res_t r)
{
@@ -41,72 +25,6 @@ static inline res_t to_res(res_t *_p, enum resulttype t)
static const res_t res_null = { };
-struct operation {
- enum opcode {
- /* end of program marker */
- O_END = 0,
-
- /* basic operations */
- O_READ,
- O_WRITE_ZERO,
- O_WRITE_ONE,
- O_WRITE_RAND,
- O_ERASE,
-
- /* output */
- O_PRINT,
- O_PRINTF,
- O_FORMAT,
- O_NEWLINE,
-
- /* group */
- O_SEQUENCE,
- O_REPEAT,
-
- /* series */
- O_OFF_FIXED,
- O_OFF_POW2,
- O_OFF_LIN,
- O_OFF_RAND,
- O_LEN_POW2,
- O_MAX_POW2,
- O_MAX_LIN,
-
- /* reduce dimension */
- O_REDUCE,
-
- /* ignore result */
- O_DROP,
-
- /* end of list */
- O_MAX = O_DROP,
- } code;
-
- /* number of indirect results, if any */
- unsigned int num;
-
- /* command code specific value */
- long long val;
-
- /* output string for O_PRINT */
- const char *string;
-
- /* aggregation of results from children */
- enum {
- A_MINIMUM,
- A_MAXIMUM,
- A_AVERAGE,
- A_TOTAL,
- A_IGNORE,
- } aggregate;
-
- /* dynamic result contents */
- res_t result;
- unsigned int size_x;
- unsigned int size_y;
- enum resulttype r_type;
-};
-
struct syntax {
enum opcode opcode;
const char *name;
@@ -122,11 +40,10 @@ struct syntax {
};
static struct syntax syntax[];
-static int verbose = 0;
-#define pr_debug(...) do { if (verbose) printf(__VA_ARGS__); } while(0)
-#define return_err(...) do { printf(__VA_ARGS__); return NULL; } while(0)
-static struct operation *call(struct operation *op, struct device *dev,
+int verbose = 0;
+
+struct operation *call(struct operation *op, struct device *dev,
off_t off, off_t max, size_t len)
{
struct operation *next;