From c95ea1903edac9851a976a2bb0e35037b66020a5 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 4 Jan 2011 16:52:47 +0100 Subject: 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 --- vm.c | 91 +++----------------------------------------------------------------- 1 file changed, 4 insertions(+), 87 deletions(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index b370002..b321a91 100644 --- a/vm.c +++ b/vm.c @@ -6,23 +6,7 @@ #include #include -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; -- cgit v1.2.3