コード例 #1
0
const char *nvrm_get_class_name(uint32_t cls)
{
	static struct rnnenum *rnndb_cls = NULL, *nvrm_cls = NULL;
	static uint32_t last_cls = 0;
	static const char *last_cls_name = NULL;

	if (!cls || !nvrm_describe_classes)
		return NULL;

	if (cls == last_cls)
		return last_cls_name;

	if (!rnndb_cls)
		rnndb_cls = rnn_findenum(rnndb, "obj-class");

	struct rnnvalue *v = NULL;
	FINDARRAY(rnndb_cls->vals, v, v->value == cls);
	if (v)
	{
		last_cls = cls;
		last_cls_name = v->name;
		return last_cls_name;
	}

	if (!nvrm_cls)
		nvrm_cls = rnn_findenum(rnndb_nvrm_object, "obj-class");

	v = NULL;
	FINDARRAY(nvrm_cls->vals, v, v->value == cls);
	if (v)
	{
		last_cls = cls;
		last_cls_name = v->name;
		return last_cls_name;
	}

	return NULL;
}
コード例 #2
0
ファイル: object_state.c プロジェクト: karolherbst/envytools
struct rnndeccontext *create_g80_texture_ctx(struct gpu_object *obj)
{
    struct rnndeccontext *texture_ctx = rnndec_newcontext(rnndb_g80_texture);
    texture_ctx->colors = colors;

    struct rnnvalue *v = NULL;
    struct rnnenum *chs = rnn_findenum(rnndb, "chipset");
    FINDARRAY(chs->vals, v, v->value == (uint64_t)nvrm_get_chipset(obj));
    rnndec_varadd(texture_ctx, "chipset", v ? v->name : "NV1");
    rnndec_varadd(texture_ctx, "gk20a_extended_components", "NO");
    rnndec_varadd(texture_ctx, "gm200_tic_header_version", "ONE_D_BUFFER");

    return texture_ctx;
}
コード例 #3
0
ファイル: object_state.c プロジェクト: karolherbst/envytools
void decode_tic(struct rnndeccontext *texture_ctx, struct rnndomain *domain,
                uint32_t tic, uint32_t *data)
{
    int idx;

    if (domain == tic_domain)
        rnndec_varmod(texture_ctx, "gk20a_extended_components",
                      data[0] & 0x80000000 ? "YES" : "NO");
    if (domain == tic2_domain) {
        int version = (data[2] >> 21) & 0x7;
        struct rnnvalue *v = NULL;
        struct rnnenum *hdr = rnn_findenum(rnndb_g80_texture, "gm200_tic_header_version");
        FINDARRAY(hdr->vals, v, v->value == (uint64_t)version);
        rnndec_varmod(texture_ctx, "gm200_tic_header_version",
                      v ? v->name : "ONE_D_BUFFER");
    }
コード例 #4
0
ファイル: rnndec.c プロジェクト: CSRedRat/etna_viv
int rnndec_varadd(struct rnndeccontext *ctx, char *varset, char *variant) {
	struct rnnenum *en = rnn_findenum(ctx->db, varset);
	if (!en) {
		fprintf (stderr, "Enum %s doesn't exist in database!\n", varset);
		return 0;
	}
	int i;
	for (i = 0; i < en->valsnum; i++)
		if (!strcasecmp(en->vals[i]->name, variant)) {
			struct rnndecvariant *ci = calloc (sizeof *ci, 1);
			ci->en = en;
			ci->variant = i;
			ADDARRAY(ctx->vars, ci);
			return 1;
		}
	fprintf (stderr, "Variant %s doesn't exist in enum %s!\n", variant, varset);
	return 0;
}
コード例 #5
0
ファイル: lookup.c プロジェクト: polachok/envytools
int main(int argc, char **argv) {
	char *file = "nv_mmio.xml";
	char *name = "NV_MMIO";
	char *variant = NULL;
	char c, mode = 'd';
	uint64_t reg, colors=1, val = 0;
	struct rnndeccontext *vc;

	rnn_init();
	if (argc < 2) {
		usage();
	}
	struct rnndb *db = rnn_newdb();

	/* Arguments parsing */
	while ((c = getopt (argc, argv, "f:a:d:e:b:c")) != -1) {
		switch (c) {
			case 'f':
				file = strdup(optarg);
				break;
			case 'e':
				mode = 'e';
				name = strdup(optarg);
				break;
			case 'b':
				mode = 'b';
				name = strdup(optarg);
				break;
			case 'd':
				mode = 'd';
				name = strdup(optarg);
				break;
			case 'a':
				if (!strncasecmp(optarg, "NV", 2))
					variant = strdup(optarg);
				else
					asprintf(&variant, "NV%s", optarg);
				break;
			case 'c':
				colors = 0;
				break;
			default: usage();
		}
	}

	rnn_parsefile (db, file);
	rnn_prepdb (db);
	vc = rnndec_newcontext(db);
	if(colors)
		vc->colors = &rnndec_colorsterm;

	if (variant)
		rnndec_varadd(vc, "chipset", variant);

	/* Parse extra arguments */
	while (!strcmp (argv[optind], "-v")) {
		rnndec_varadd(vc, argv[optind+1], argv[optind+2]);
		optind+=3;
	}

	if (optind >= argc) {
		fprintf (stderr, "No address specified.\n");
		return 1;
	}

	reg = strtoull(argv[optind], 0, 16);
	if (optind + 1 < argc)
		val = strtoull(argv[optind + 1], 0, 16);

	if (mode == 'e') {
		struct rnnenum *en = rnn_findenum (db, name);
		if (en) {
			int i;
			int dec = 0;
			for (i = 0; i < en->valsnum; i++)
				if (en->vals[i]->valvalid && en->vals[i]->value == reg) {
					printf ("%s\n", en->vals[i]->name);
					dec = 1;
					break;
				}
			if (!dec)
				printf ("%#"PRIx64"\n", reg);

			return 0;
		} else {
			fprintf(stderr, "Not an enum: '%s'\n", name);
			return 1;
		}
	} else if (mode == 'b') {
		struct rnnbitset *bs = rnn_findbitset (db, name);

		if (bs) {
			printf("TODO\n");
			return 0;
		} else {
			fprintf(stderr, "Not a bitset: '%s'\n", name);
			return 1;
		}

	} else if (mode == 'd') {
		struct rnndomain *dom = rnn_finddomain (db, name);

		if (dom) {
			struct rnndecaddrinfo *info = rnndec_decodeaddr(vc, dom, reg, 0);
			if (info && info->typeinfo)
				printf ("%s => %s\n", info->name, rnndec_decodeval(vc, info->typeinfo, val, info->width));
			else if (info)
				printf ("%s\n", info->name);
			else
				return 1;
			return 0;
		} else {
			fprintf(stderr, "Not a domain: '%s'\n", name);
			return 1;
		}
	} else {
		return 1;
	}
}
コード例 #6
0
ファイル: rnn.c プロジェクト: AlbertJP/envytools
static void prepvarinfo (struct rnndb *db, char *what, struct rnnvarinfo *vi, struct rnnvarinfo *parent) {
	if (parent)
		vi->prefenum = parent->prefenum;
	if (vi->prefixstr) {
		if (!strcmp(vi->prefixstr, "none"))
			vi->prefenum = 0;
		else
			vi->prefenum = rnn_findenum(db, vi->prefixstr); // XXX
	}
	int i;
	if (parent)
		for (i = 0; i < parent->varsetsnum; i++)
			ADDARRAY(vi->varsets, copyvarset(parent->varsets[i]));
	struct rnnenum *varset = vi->prefenum;
	if (!varset && !vi->varsetstr && parent)
		vi->varsetstr = parent->varsetstr;
	if (vi->varsetstr)
		varset = rnn_findenum(db, vi->varsetstr);
	if (vi->variantsstr) {
		char *vars = vi->variantsstr;
		if (!varset) {
			fprintf (stderr, "%s: tried to use variants without active varset!\n", what);
			db->estatus = 1;
			return;
		}
		struct rnnvarset *vs = 0;
		int nvars = varset->valsnum;
		for (i = 0; i < vi->varsetsnum; i++)
			if (vi->varsets[i]->venum == varset) {
				vs = vi->varsets[i];
				break;
			}
		if (!vs) {
			vs = calloc (sizeof *vs, 1);
			vs->venum = varset;
			vs->variants = calloc(sizeof *vs->variants, nvars);
			for (i = 0; i < nvars; i++)
				vs->variants[i] = 1;
			ADDARRAY(vi->varsets, vs);
		}
		while (1) {
			while (*vars == ' ') vars++;
			if (*vars == 0)
				break;
			char *split = vars;
			while (*split != ':' && *split != '-' && *split != ' '  && *split != 0)
				split++;
			char *first = 0;
			if (split != vars)
				first = strndup(vars, split-vars);
			if (*split == ' ' || *split == 0) {
				int idx = findvidx(db, varset, first);
				if (idx != -1)
					vs->variants[idx] |= 2;
				vars = split;
			} else {
				char *end = split+1;
				while (*end != ' '  && *end != 0)
					end++;
				char *second = 0;
				if (end != split+1)
					second = strndup(split+1, end-split-1);
				int idx1 = 0;
				if (first)
					idx1 = findvidx(db, varset, first);
				int idx2 = nvars;
				if (second) {
					idx2 = findvidx(db, varset, second);
					if (*split == '-')
						idx2++;
				}
				if (idx1 != -1 && idx2 != -1)
					for (i = idx1; i < idx2; i++)
						vs->variants[i] |= 2;
				vars = end;
				free(second);
			}
			free(first);
		}
		vi->dead = 1;
		for (i = 0; i < nvars; i++) {
			vs->variants[i] = (vs->variants[i] == 3);
			if (vs->variants[i])
				vi->dead = 0;
		}
	}
	if (vi->dead)
		return;
	if (vi->prefenum) {
		struct rnnvarset *vs = 0;
		for (i = 0; i < vi->varsetsnum; i++)
			if (vi->varsets[i]->venum == vi->prefenum) {
				vs = vi->varsets[i];
				break;
			}
		if (vs) {
			for (i = 0; i < vi->prefenum->valsnum; i++)
				if (vs->variants[i]) {
					vi->prefix = vi->prefenum->vals[i]->name;
					return;
				}
		} else {
			vi->prefix = vi->prefenum->vals[0]->name;
		}
	}
}
コード例 #7
0
ファイル: rnn.c プロジェクト: AlbertJP/envytools
static void preptypeinfo(struct rnndb *db, struct rnntypeinfo *ti, char *prefix, struct rnnvarinfo *vi, int width, char *file) {
	int i;
	if (ti->name) {
		struct rnnenum *en = rnn_findenum (db, ti->name);
		struct rnnbitset *bs = rnn_findbitset (db, ti->name);
		struct rnnspectype *st = rnn_findspectype (db, ti->name);
		if (en) {
			if (en->isinline) {
				ti->type = RNN_TTYPE_INLINE_ENUM;
				int j;
				for (j = 0; j < en->valsnum; j++)
					ADDARRAY(ti->vals, copyvalue(en->vals[j], file));
			} else {
				ti->type = RNN_TTYPE_ENUM;
				ti->eenum = en;
			}
		} else if (bs) {
			if (bs->isinline) {
				ti->type = RNN_TTYPE_INLINE_BITSET;
				int j;
				for (j = 0; j < bs->bitfieldsnum; j++)
					ADDARRAY(ti->bitfields, copybitfield(bs->bitfields[j], file));
			} else {
				ti->type = RNN_TTYPE_BITSET;
				ti->ebitset = bs;
			}
		} else if (st) {
			ti->type = RNN_TTYPE_SPECTYPE;
			ti->spectype = st;
		} else if (!strcmp(ti->name, "hex")) {
			ti->type = RNN_TTYPE_HEX;
		} else if (!strcmp(ti->name, "float")) {
			ti->type = RNN_TTYPE_FLOAT;
		} else if (!strcmp(ti->name, "uint")) {
			ti->type = RNN_TTYPE_UINT;
		} else if (!strcmp(ti->name, "int")) {
			ti->type = RNN_TTYPE_INT;
		} else if (!strcmp(ti->name, "boolean")) {
			ti->type = RNN_TTYPE_BOOLEAN;
		} else if (!strcmp(ti->name, "bitfield")) {
			ti->type = RNN_TTYPE_INLINE_BITSET;
		} else if (!strcmp(ti->name, "enum")) {
			ti->type = RNN_TTYPE_INLINE_ENUM;
		} else if (!strcmp(ti->name, "fixed")) {
			ti->type = RNN_TTYPE_FIXED;
		} else if (!strcmp(ti->name, "ufixed")) {
			ti->type = RNN_TTYPE_UFIXED;
		} else {
			ti->type = RNN_TTYPE_HEX;
			fprintf (stderr, "%s: unknown type %s\n", prefix, ti->name);
			db->estatus = 1;
		}
	} else if (ti->bitfieldsnum) {
		ti->name = "bitfield";
		ti->type = RNN_TTYPE_INLINE_BITSET;
	} else if (ti->valsnum) {
		ti->name = "enum";
		ti->type = RNN_TTYPE_INLINE_ENUM;
	} else if (width == 1) {
		ti->name = "boolean";
		ti->type = RNN_TTYPE_BOOLEAN;
	} else {
		ti->name = "hex";
		ti->type = RNN_TTYPE_HEX;
	}
	for (i = 0; i < ti->bitfieldsnum; i++)
		prepbitfield(db,  ti->bitfields[i], prefix, vi);
	for (i = 0; i < ti->valsnum; i++)
		prepvalue(db, ti->vals[i], prefix, vi);
}
コード例 #8
0
ファイル: dedma.c プロジェクト: dayweek/envytools
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#include "dedma.h"
#include "util.h"

void
add_object(struct state *s, uint32_t handle, uint32_t class)
{
	struct rnnenum *chs = rnn_findenum(s->db, "chipset");
	struct rnnenum *cls = rnn_findenum(s->db, "obj-class");
	struct rnnvalue *v;
	struct obj *obj;
	int i;

	if (!cls || !chs) {
		fprintf(stderr, "No obj-class/chipset enum found\n");
		abort();
	}

	for (i = 0; obj = &s->objects[i], i < MAX_OBJECTS; i++) {
		if (!obj->handle) {
			obj->handle = handle;
			obj->class = class;
			obj->ctx = rnndec_newcontext(s->db);