示例#1
0
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	int cnum =0;
	while ((c = getopt (argc, argv, "c:")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
		}
	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}
	int32_t a, b = 4, v = 0, i;
	if (optind >= argc) {
		fprintf (stderr, "No address specified.\n");
		return 1;
	}
	sscanf (argv[optind], "%x", &a);
	if (optind + 1 < argc)
		sscanf (argv[optind + 1], "%x", &b);
	if (optind + 2 < argc)
		sscanf (argv[optind + 2], "%x", &v);
	for (i = 0; i < b; i += 4) {
		nva_wr32(cnum, a+i, v+i);
	}
	return 0;
}
示例#2
0
int main(int argc, char **argv) {
	struct pms_ucode _pms, *pms=&_pms;
	ptime_t exec_time;
	int i;

	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	int cnum =0;
	while ((c = getopt (argc, argv, "c:")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
		}
	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}

	timing_pms_waits(cnum);

	return 0;
}
示例#3
0
int main() {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int i;
	for (i = 0; i < nva_cardsnum; i++) {
		struct nva_card *card = nva_cards[i];
		printf ("%d: %04x:%02x:%02x.%x", i, 
			card->pci->domain, card->pci->bus, card->pci->dev, card->pci->func);
		switch (card->type) {
			case NVA_DEVICE_GPU:
				list_gpu(card);
				break;
			case NVA_DEVICE_SMU:
				list_smu(card);
				break;
			case NVA_DEVICE_APU:
				list_apu(card);
				break;
			default:
				abort();
		}
	}
	return 0;
}
示例#4
0
int main() {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int i;
	for (i = 0; i < nva_cardsnum; i++)
		printf ("%d: %04x:%02x:%02x.%x NV%02X%s %08x\n", i,
				nva_cards[i].pci->domain, nva_cards[i].pci->bus, nva_cards[i].pci->dev, nva_cards[i].pci->func,
				nva_cards[i].chipset, (nva_cards[i].is_nv03t?"T":""), nva_cards[i].boot0);
	return 0;
}
示例#5
0
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	int cnum =0;
	while ((c = getopt (argc, argv, "c:")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
		}
	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}

	uint32_t m, d, ctrl;
	if (optind + 3 > argc) {
		fprintf (stderr, "%s: <channel> <method> <data>\n", argv[0]);
		return 1;
	}
	sscanf (argv[optind + 0], "%d", &c);
	sscanf (argv[optind + 1], "%x", &m);
	sscanf (argv[optind + 2], "%x", &d);

	if (nva_cards[cnum].chipset >= 0xd0) {
		ctrl = nva_rd32(cnum, 0x610700 + (c * 8));
		nva_wr32(cnum, 0x610700 + (c * 8), ctrl | 1);
		nva_wr32(cnum, 0x610704 + (c * 8), d);
		nva_wr32(cnum, 0x610700 + (c * 8), 0x80000001 | m);
		while (nva_rd32(cnum, 0x610700 + (c * 8)) & 0x80000000);
		nva_wr32(cnum, 0x610700 + (c * 8), ctrl);
	} else
	if (nva_cards[cnum].chipset == 0x50 ||
	    nva_cards[cnum].chipset >= 0x84) {
		ctrl = nva_rd32(cnum, 0x610300 + (c * 8));
		nva_wr32(cnum, 0x610300 + (c * 8), ctrl | 1);
		nva_wr32(cnum, 0x610304 + (c * 8), d);
		nva_wr32(cnum, 0x610300 + (c * 8), 0x80000001 | m);
		while (nva_rd32(cnum, 0x610300 + (c * 8)) & 0x80000000);
		nva_wr32(cnum, 0x610300 + (c * 8), ctrl);
	} else {
		fprintf (stderr, "unsupported chipset\n");
		return 1;
	}

	return 0;
}
示例#6
0
int main(int argc, char **argv)
{
	int c, cnum = 0;

	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}

	/* Arguments parsing */
	while ((c = getopt (argc, argv, "c:")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
		}

	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}

	if (nva_cards[cnum].chipset < 0x10 ||
	    nva_cards[cnum].chipset >= 0xc0)
	{
		fprintf(stderr, "The chipset nv%x isn't currently supported\n",
			nva_cards[cnum].chipset);
		return 1;
	}

	/* Init */
	nva_wr32(cnum, 0x200, 0xffffffff);

	printf("Chipset nv%x:\n\n", nva_cards[cnum].chipset);

	poll_signals(cnum, signals_ref);
	find_counter_noise(cnum);
	find_ptimer_b12(cnum);
	find_host_mem_read_write(cnum);
	find_mmio_read_write(cnum, 0x200, "MMIO");
	find_mmio_read_write(cnum, 0x2210, "MMIO_PFIFO");
	find_mmio_read_write(cnum, 0x610384, "MMIO_PDISPLAY");
	find_mmio_read_write(cnum, 0x6666, "MMIO_INVALID");
	find_pgraphIdle_and_interrupt(cnum);
	find_ctxCtlFlags(cnum);

	return 0;
}
示例#7
0
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	int cnum =0;
	while ((c = getopt (argc, argv, "c:")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
		}
	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}
	int32_t a, b = 4, i;
	if (optind >= argc) {
		fprintf (stderr, "No address specified.\n");
		return 1;
	}
	sscanf (argv[optind], "%x", &a);
	if (optind + 1 < argc)
		sscanf (argv[optind + 1], "%x", &b);
	nva_wr32(cnum, 0x1700, 0x30);
	int ls = 1;
	while (b > 0) {
		uint32_t z[4];
		int s = 0;
		for (i = 0; i < 16 && i < b; i+=4)
			if ((z[i/4] = xt_rd32(cnum, a+i))) s = 1;
		if (s) {
			ls = 1;
			printf ("%08x:", a);
			for (i = 0; i < 16 && i < b; i+=4) {
				printf (" %08x", z[i/4]);
			}
			printf ("\n");
		} else  {
			if (ls) printf ("...\n"), ls = 0;
		}
		a+=16;
		b-=16;
	}
	return 0;
}
示例#8
0
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	int cnum =0;
	while ((c = getopt (argc, argv, "c:")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
		}
	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}
	uint32_t a, b;
	if (optind >= argc) {
		fprintf (stderr, "No address specified.\n");
		return 1;
	}
	if (optind + 1 >= argc) {
		fprintf (stderr, "No length specified.\n");
		return 1;
	}
	FILE *file = stdout;
	if (optind + 2 < argc) {
		file = fopen(argv[optind+2], "wb");
		if (!file) {
			perror("fopen");
			return 1;
		}
	}
	sscanf (argv[optind], "%x", &a);
	sscanf (argv[optind+1], "%x", &b);
	b += a;
	while (a != b) {
		nva_wr32(cnum, 0x1700, a >> 16);
		int c = nva_rd8(cnum, 0x700000 | (a&0xffff));
		putc(c, file);
		a++;
	}
	return 0;
}
示例#9
0
static int open_map(void)
{
	if (nva_init()) {
		fprintf(stderr, "NVA init failed\n");
		return 0;
	}
	if (!nva_cardsnum) {
		fprintf(stderr, "Cannot find any valid card!\n");
		return 0;
	}
	if (cnum > nva_cardsnum) {
		fprintf(stderr, "Only %u cards found, invalid card %u selected\n", nva_cardsnum, cnum);
		return 0;
	}
	return 1;
}
示例#10
0
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	int cnum =0;
	while ((c = getopt (argc, argv, "c:")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
		}
	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}
	int32_t a, b = 1;
	if (optind >= argc) {
		fprintf (stderr, "No address specified.\n");
		return 1;
	}
	sscanf (argv[optind], "%x", &a);
	if (optind + 1 < argc)
		sscanf (argv[optind + 1], "%x", &b);
	nva_wr32(cnum, 0x1700, 0x30);
	while (b > 0) {
		printf("%02x: ", a);
		uint32_t status;
		uint32_t val = xt_rsr(cnum, a, &status);
		if (status) {
			printf("EXC%02x\n", status & 0x3f);
		} else {
			printf("%08x\n", val);
		}
		a++;
		b--;
	}
	return 0;
}
示例#11
0
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	int wanttime = 0;
	while ((c = getopt (argc, argv, "tc:")) != -1)
		switch (c) {
			case 't':
				wanttime = 1;
				break;
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
		}
	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}
	if (optind >= argc) {
		fprintf (stderr, "No address specified.\n");
		return 1;
	}
	sscanf (argv[optind], "%x", &a);
	pthread_t thr;
	pthread_create(&thr, 0, wanttime ? twatchfun : watchfun, 0);
	uint32_t ptime = 0;
	while (1) {
		while (get == put)
			sched_yield();
		if (wanttime)
			printf("%08x[+%d]: %08x\n", tqueue[get], tqueue[get]-ptime, queue[get]);
		else
			printf("%08x\n", queue[get]);
		ptime = tqueue[get];
		get = (get + 1) % SZ;
	}
}
示例#12
0
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	struct nva_regspace rs = { 0 };
	while ((c = getopt (argc, argv, "c:i:b:t:")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &rs.cnum);
				break;
			case 'i':
				sscanf(optarg, "%d", &rs.idx);
				break;
			case 'b':
				sscanf(optarg, "%d", &rs.regsz);
				if (rs.regsz != 1 && rs.regsz != 2 && rs.regsz != 4 && rs.regsz != 8) {
					fprintf (stderr, "Invalid size.\n");
					return 1;
				}
				break;
			case 't':
				rs.type = nva_rstype(optarg);
				if (rs.type == -1) {
					fprintf (stderr, "Unknown register space.\n");
					return 1;
				}
				break;
		}
	if (rs.cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}
	rs.card = &nva_cards[rs.cnum];
	if (rs.regsz == 0)
		rs.regsz = nva_rsdefsz(&rs);
	uint32_t a, b = rs.regsz;
	uint64_t val, step = 0;
	if (optind >= argc) {
		fprintf (stderr, "No address specified.\n");
		return 1;
	}
	sscanf (argv[optind], "%x", &a);
	if (optind + 1 >= argc) {
		fprintf (stderr, "No value specified.\n");
		return 1;
	}
	if (optind + 2 >= argc) {
		sscanf (argv[optind + 1], "%"SCNx64, &val);
	} else {
		sscanf (argv[optind + 1], "%x", &b);
		sscanf (argv[optind + 2], "%"SCNx64, &val);
	}
	if (optind + 3 < argc)
		sscanf (argv[optind + 3], "%"SCNx64, &step);
	while (b > 0) {
		int e = nva_wr(&rs, a, val);
		if (e)
			printf("%08x: ERR %c\n", a, nva_rserrc(e));
		a += rs.regsz;
		b -= rs.regsz;
		val += step;
	}
	return 0;
}
示例#13
0
文件: hwtest.c 项目: jhol/envytools
int main(int argc, char **argv) {
	struct hwtest_ctx sctx;
	struct hwtest_ctx *ctx = &sctx;
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c, force = 0;
	ctx->cnum = 0;
	ctx->colors = 1;
	ctx->noslow = 0;
	ctx->indent = 0;
	ctx->rand48[0] = 0xdead;
	ctx->rand48[1] = 0xbeef;
	ctx->rand48[2] = 0xcafe;
	while ((c = getopt (argc, argv, "c:nsf")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &ctx->cnum);
				break;
			case 'n':
				ctx->colors = 0;
				break;
			case 's':
				ctx->noslow = 1;
				break;
			case 'f':
				force = 1;
				break;
		}
	if (ctx->cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}
	ctx->chipset = nva_cards[ctx->cnum]->chipset.chipset;
	ctx->card_type = nva_cards[ctx->cnum]->chipset.card_type;
	if (pci_device_has_kernel_driver(nva_cards[ctx->cnum]->pci)) {
		if (force) {
			fprintf(stderr, "WARNING: Kernel driver in use.\n");
		} else {
			fprintf(stderr, "ERROR: Kernel driver in use. If you know what you are doing, use -f option.\n");
			return 1;
		}
	}
	int worst = 0;
	if (optind == argc) {
		printf("Running all tests...\n");
		worst = hwtest_run_group(ctx, &hwtest_root_group, 0);
	} else while (optind < argc) {
		int res = hwtest_run_group(ctx, &hwtest_root_group, argv[optind++]);
		if (res > worst)
			worst = res;
	}
	if (worst == HWTEST_RES_PASS)
		return 0;
	else
		return worst + 1;
}
示例#14
0
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	int cnum =0;
	int base =0;
	int start = 1;
	while ((c = getopt (argc, argv, "c:bvu")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
			case 'b':
			    base = 0xabcd;
				break;
			case 'u':
			    start = 0;
		}

	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}

	if (!base) {
		fprintf (stderr, "No engine specified. Specify -b for PBSP, -v for PVP\n");
		return 1;
	}
	
	if (optind >= argc) {
	    fprintf(stderr, "At least specify payload file.\n");
	    return 1;
	}

	FILE *payload = fopen(argv[optind], "rb");
    
    if (payload == NULL) {
        fprintf(stderr, "Binary file %s could not be opened.\n", argv[optind]);
        return 1;
    } else {
        fprintf(stderr, "Uploading file %s.\n", argv[optind]);
    }
    
    int i;

    vuc_hold(cnum, 0);

	for (i = 0; ; i += 4) {
	    uint32_t word = 0;
	    int y;
	    int character = 0;
	    for (y = 0; y < 4; y++) {
    		character = fgetc(payload);
    		if (character == EOF) {
    		    break;
    		}
    		word |= ((unsigned char)character) << (y * 8);
    	}
    	if (y == 0) {
    	    break;
    	}
    	host_xt_wr32(cnum, XTENSA_VUC_CODE_ACCESS, word);
   		if (character == EOF) {
   		    break;
   		}
	}
	if (start) {
    	vuc_start(cnum, 0);
    }
	return 0;
}
示例#15
0
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	int cnum =0;
	uint32_t base = 0;
	while ((c = getopt (argc, argv, "c:bv")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
			case 'b':
				base = 0x103000;
				break;
			case 'v':
				base = 0xf000;
				break;
		}
	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}

	if (!base) {
		fprintf (stderr, "No engine specified. Specify -b for PBSP, -v for PVP\n");
		return 1;
	}
	
	if (optind >= argc) {
	    fprintf(stderr, "At least specify payload file.\n");
	    return 1;
	}

	FILE *payload = fopen(argv[optind], "rb");
    
    if (payload == NULL) {
        fprintf(stderr, "Binary file %s could not be opened.\n", argv[optind]);
        return 1;
    } else {
        fprintf(stderr, "Uploading file %s.\n", argv[optind]);
    }
    
    int32_t i;
	nva_wr32(cnum, 0x200, 0x40110011);
	nva_wr32(cnum, 0x200, 0xffffffff);
	usleep(1000);
	nva_wr32(cnum, 0x1700, 0x10);
	if (base == 0x103000) {
		nva_wr32(cnum, 0x701080, 0x00190000);
		nva_wr32(cnum, 0x701084, 0x003fffff);
		nva_wr32(cnum, 0x701088, 0x00300000);
		nva_wr32(cnum, 0x70108c, 0x00000000);
		nva_wr32(cnum, 0x701090, 0x00000000);
		nva_wr32(cnum, 0x701094, 0x00000000);
	} else {
		nva_wr32(cnum, 0x701040, 0x00190000);
		nva_wr32(cnum, 0x701044, 0x003fffff);
		nva_wr32(cnum, 0x701048, 0x00300000);
		nva_wr32(cnum, 0x70104c, 0x00000000);
		nva_wr32(cnum, 0x701050, 0x00000000);
		nva_wr32(cnum, 0x701054, 0x00000000);
	}
	nva_wr32(cnum, 0x1700, 0x30);
	nva_wr32(cnum, 0x700000, 0x00000000);
	nva_wr32(cnum, 0x1700, 0x20);
	for (i = 0; i < 0x100000; i+= 4)
		nva_wr32(cnum, 0x700000 + i, 0xffff06);
		
	for (i = 0; ; i += 4) {
	    uint32_t word = 0;
	    int y;
	    int character = 0;
	    for (y = 0; y < 4; y++) {
    		character = fgetc(payload);
    		if (character == EOF) {
    		    break;
    		}
    		word |= ((unsigned char)character) << (y * 8);
    	}
    	nva_wr32(cnum, 0x700000 + i, word);
   		if (character == EOF) {
   		    break;
   		}
	}
	
	nva_wr32(cnum, 0x70000, 1);
	while (nva_rd32(cnum, 0x70000));
	usleep(1000);
	nva_wr32(cnum, base+0xd10, 0x1fffffff);
	nva_wr32(cnum, base+0xd08, 0xfffffff);
	nva_wr32(cnum, base+0xd28, 0x90044);
	nva_wr32(cnum, base+0xcc0, 0x2000);
	nva_wr32(cnum, base+0xcc4, 0x1c);
	nva_wr32(cnum, base+0xcc8, 0x400);
	nva_wr32(cnum, base+0xce4, 0x0000);
	nva_wr32(cnum, base+0xce8, 0x0f);
	nva_wr32(cnum, base+0xcec, 0x404);
	nva_wr32(cnum, base+0xc20, 0x3f);
	nva_wr32(cnum, base+0xd84, 0x3f);
	nva_wr32(cnum, 0x1588, nva_rd32(cnum, 0x1588) & ~0xffff);
	nva_wr32(cnum, 0x2500, 1);
	nva_wr32(cnum, 0x3200, 1);
	nva_wr32(cnum, 0x3250, 1);
	nva_wr32(cnum, 0x1700, 0x10);
	nva_wr32(cnum, 0x700000+0xf00, 0);
	nva_wr32(cnum, 0x700000+0xf04, 0);
	nva_wr32(cnum, 0x700000+0xf08, 0);
	nva_wr32(cnum, 0x700000+0xf0c, 0);
	nva_wr32(cnum, 0x700000+0xf10, 0);
	nva_wr32(cnum, 0x700000+0xf14, 0);
	nva_wr32(cnum, 0x700000+0xf18, 0);
	nva_wr32(cnum, 0x700000+0xf1c, 0);
	nva_wr32(cnum, 0x700000+0xf20, 0);
	nva_wr32(cnum, 0x700000+0xf24, 0);
	nva_wr32(cnum, 0x700000+0xf28, 0);
	nva_wr32(cnum, 0x700000+0xf2c, 0);
	nva_wr32(cnum, 0x700000+0xf30, 0);
	nva_wr32(cnum, 0x700000+0xf34, 0);
	nva_wr32(cnum, 0x700000+0xf38, 0);
	nva_wr32(cnum, 0x700000+0xf3c, 0x403f6078);
	nva_wr32(cnum, 0x700000+0xf40, 0);
	nva_wr32(cnum, 0x700000+0xf44, 0x2101ffff);
	nva_wr32(cnum, 0x700000+0xf48, 0x10);
	nva_wr32(cnum, 0x700000+0xf4c, 0);
	nva_wr32(cnum, 0x700000+0xf50, 0x110000);
	nva_wr32(cnum, 0x700000+0xf54, 0x80000);
	nva_wr32(cnum, 0x700000+0xf58, 0);
	nva_wr32(cnum, 0x700000+0xf5c, 0);
	nva_wr32(cnum, 0x700000+0xf60, 0);
	nva_wr32(cnum, 0x700000+0xf64, 0);
	nva_wr32(cnum, 0x700000+0xf68, 0);
	nva_wr32(cnum, 0x700000+0xf6c, 0);
	nva_wr32(cnum, 0x700000+0xf70, 0);
	nva_wr32(cnum, 0x700000+0xf74, 0);
	nva_wr32(cnum, 0x700000+0xf78, 0);
	nva_wr32(cnum, 0x700000+0xf7c, 0x30000fff);
	nva_wr32(cnum, 0x700000+0xf80, 0x4000600);
	nva_wr32(cnum, 0x700000+0xf84, 0);
	nva_wr32(cnum, 0x700000+0xf88, 0x410);
	nva_wr32(cnum, 0x700000+0xf8c, 0);
	nva_wr32(cnum, 0x700000+0xf90, 0);
	nva_wr32(cnum, 0x700000+0xf94, 0);
	nva_wr32(cnum, 0x700000+0xf98, 0x101);

	nva_wr32(cnum, 0x700000+0xe00, 0);
	nva_wr32(cnum, 0x700000+0xe04, 0);
	nva_wr32(cnum, 0x700000+0xe08, 0);
	nva_wr32(cnum, 0x700000+0xe0c, 0);
	nva_wr32(cnum, 0x700000+0xe10, 0);
	nva_wr32(cnum, 0x700000+0xe14, 0);
	nva_wr32(cnum, 0x700000+0xe18, 0);
	nva_wr32(cnum, 0x700000+0xe1c, 0);
	nva_wr32(cnum, 0x700000+0xe20, 0);
	nva_wr32(cnum, 0x700000+0xe24, 0);
	nva_wr32(cnum, 0x700000+0xe28, 0);
	nva_wr32(cnum, 0x700000+0xe2c, 0);
	nva_wr32(cnum, 0x700000+0xe30, 0);
	nva_wr32(cnum, 0x700000+0xe34, 0);
	nva_wr32(cnum, 0x700000+0xe38, 0);
	nva_wr32(cnum, 0x700000+0xe3c, 0x403f6078);
	nva_wr32(cnum, 0x700000+0xe40, 0);
	nva_wr32(cnum, 0x700000+0xe44, 0x2101ffff);
	nva_wr32(cnum, 0x700000+0xe48, 0x10);
	nva_wr32(cnum, 0x700000+0xe4c, 0);
	nva_wr32(cnum, 0x700000+0xe50, 0x110000);
	nva_wr32(cnum, 0x700000+0xe54, 0x80000);
	nva_wr32(cnum, 0x700000+0xe58, 0);
	nva_wr32(cnum, 0x700000+0xe5c, 0);
	nva_wr32(cnum, 0x700000+0xe60, 0);
	nva_wr32(cnum, 0x700000+0xe64, 0);
	nva_wr32(cnum, 0x700000+0xe68, 0);
	nva_wr32(cnum, 0x700000+0xe6c, 0);
	nva_wr32(cnum, 0x700000+0xe70, 0);
	nva_wr32(cnum, 0x700000+0xe74, 0);
	nva_wr32(cnum, 0x700000+0xe78, 0);
	nva_wr32(cnum, 0x700000+0xe7c, 0x30000fff);
	nva_wr32(cnum, 0x700000+0xe80, 0x4000600);
	nva_wr32(cnum, 0x700000+0xe84, 0);
	nva_wr32(cnum, 0x700000+0xe88, 0x410);
	nva_wr32(cnum, 0x700000+0xe8c, 0);
	nva_wr32(cnum, 0x700000+0xe90, 0);
	nva_wr32(cnum, 0x700000+0xe94, 0);
	nva_wr32(cnum, 0x700000+0xe98, 0x101);
	for (i = 0; i <= 0x1000; i+= 4)
		nva_wr32(cnum, 0x700000+0x6000 + i, 0);
	nva_wr32(cnum, 0x700000+0x7008, 0x1);
	if (base == 0x103000)
		nva_wr32(cnum, 0x700000+0x700c, 0x00600004);
	else
		nva_wr32(cnum, 0x700000+0x700c, 0x00400004);
	nva_wr32(cnum, 0x700000+0x1100, 0x0019003d);
	nva_wr32(cnum, 0x700000+0x1104, 0xffffffff);
	nva_wr32(cnum, 0x700000+0x1108, 0);
	nva_wr32(cnum, 0x700000+0x110c, 0);
	nva_wr32(cnum, 0x700000+0x1110, 0);
	nva_wr32(cnum, 0x700000+0x1114, 0);
	nva_wr32(cnum, 0x700000+0x9000, 1);
	nva_wr32(cnum, 0x70000, 1);
	while (nva_rd32(cnum, 0x70000));
	nva_wr32(cnum, 0x2600, 0x8000100d);
	nva_wr32(cnum, 0x2604, 0xc000100f);
	nva_wr32(cnum, 0x27fc, 0x8000100e);
	nva_wr32(cnum, 0x32f4, 0x109);
	nva_wr32(cnum, 0x32ec, 0x1);
	nva_wr32(cnum, 0x2500, 0x101);
	nva_wr32(cnum, 0x700000+0x20000, 0x00040000);
	nva_wr32(cnum, 0x700000+0x20004, 0x00000001);
	nva_wr32(cnum, 0x700000+0x10000, 0x00120000);
	nva_wr32(cnum, 0x700000+0x10004, 0x00008000);
	nva_wr32(cnum, 0x70000, 1);
	while (nva_rd32(cnum, 0x70000));
	nva_wr32(cnum, 0xc0208c, 1);
	return 0;
}
示例#16
0
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	int cnum =0;
	int alias = 0;
	while ((c = getopt (argc, argv, "ac:")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
			case 'a':
				alias = 1;
				break;
		}
	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}
	int32_t a, b = 4, i;
	if (optind >= argc) {
		fprintf (stderr, "No address specified.\n");
		return 1;
	}
	sscanf (argv[optind], "%x", &a);
	if (optind + 1 < argc)
		sscanf (argv[optind + 1], "%x", &b);
	int ls = 1;
	for (i = 0; i < b; i+=4) {
		uint32_t x, y, z;
		x = nva_rd32(cnum, a+i);
		nva_wr32(cnum, a+i, -1);
		y = nva_rd32(cnum, a+i);
		nva_wr32(cnum, a+i, 0);
		z = nva_rd32(cnum, a+i);
		nva_wr32(cnum, a+i, x);
		if (x || y || z) {
			int cool = (x != y) || (y != z);
			int isalias = 0, areg;
			if (cool && alias) {
				int j;
				nva_wr32(cnum, a+i, -1);
				for (j = 0; j < i; j+=4) {
					uint32_t sv = nva_rd32(cnum, a+j);
					nva_wr32(cnum, a+j, 0);
					uint32_t ch = nva_rd32(cnum, a+i);
					nva_wr32(cnum, a+j, sv);
					if (ch == z) {
						areg = a + j;
						isalias = 1;
						break;
					}
				}
				nva_wr32(cnum, a+i, x);
			}
			printf ("%06x: %08x %08x %08x%s", a+i, x, y, z, cool?" *":"");
			if (isalias) {
				printf(" ALIASES %06x", areg);
			}
			printf("\n");
			ls = 1;
		} else {
			if (ls)
				printf("...\n");
			ls = 0;
		}
	}
	return 0;
}
示例#17
0
文件: nvascan.c 项目: plaes/envytools
int main(int argc, char **argv) {
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int alias = 0;
	int slow = 0;
	int c;
	struct nva_regspace rs = { 0 };
	while ((c = getopt (argc, argv, "asc:i:b:t:")) != -1)
		switch (c) {
			case 'a':
				alias = 1;
				break;
			case 's':
				slow = 1;
				break;
			case 'c':
				sscanf(optarg, "%d", &rs.cnum);
				break;
			case 'i':
				sscanf(optarg, "%d", &rs.idx);
				break;
			case 'b':
				sscanf(optarg, "%d", &rs.regsz);
				if (rs.regsz != 1 && rs.regsz != 2 && rs.regsz != 4 && rs.regsz != 8) {
					fprintf (stderr, "Invalid size.\n");
					return 1;
				}
				break;
			case 't':
				rs.type = nva_rstype(optarg);
				if (rs.type == NVA_REGSPACE_UNKNOWN) {
					fprintf (stderr, "Unknown register space.\n");
					return 1;
				}
				break;
		}
	if (rs.cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}
	rs.card = &nva_cards[rs.cnum];
	if (rs.regsz == 0)
		rs.regsz = nva_rsdefsz(&rs);
	int32_t a, b = rs.regsz, i;
	if (optind >= argc) {
		fprintf (stderr, "No address specified.\n");
		return 1;
	}
	sscanf (argv[optind], "%x", &a);
	if (optind + 1 < argc)
		sscanf (argv[optind + 1], "%x", &b);
	int ls = 1;
	for (i = 0; i < b; i+=rs.regsz) {
		uint64_t x, y, z;
		int ex = nva_rd(&rs, a+i, &x);
		int ew = 0, ey = 0, ev = 0, ez = 0, eb = 0;
		if (!ex) {
			ew = nva_wr(&rs, a+i, -1ll);
			ey = nva_rd(&rs, a+i, &y);
			ev = nva_wr(&rs, a+i, 0);
			ez = nva_rd(&rs, a+i, &z);
			eb = nva_wr(&rs, a+i, x);
		}
		if (ex || ey || ez || ey || ev || eb || x || y || z) {
			if (ex) {
				printf ("%06x: %c\n", a+i, nva_rserrc(ex));
			} else {
				int cool = (x != y) || (y != z);
				int isalias = 0, areg;
				if (cool && alias) {
					int j;
					nva_wr(&rs, a+i, -1ll);
					for (j = 0; j < i; j+=4) {
						uint64_t sv;
						uint64_t ch;
						int es = nva_rd(&rs, a+j, &sv);
						if (!es) {
							es |= nva_wr(&rs, a+j, 0);
							es |= nva_rd(&rs, a+i, &ch);
							es |= nva_wr(&rs, a+j, sv);
							if (ch == z && !es) {
								areg = a + j;
								isalias = 1;
								break;
							}
						}
					}
					nva_wr(&rs, a+i, x);
				}
				printf ("%06x:", a+i);
				nva_rsprint(&rs, ex, x);
				nva_rsprint(&rs, ey, y);
				nva_rsprint(&rs, ez, z);
				if (ew || ev || eb)
					printf(" WERR");
				if (cool)
					printf(" *");
				if (isalias) {
					printf(" ALIASES %06x", areg);
				}
				printf("\n");
			}
			ls = 1;
		} else {
			if (ls)
				printf("...\n");
			ls = 0;
		}
		if (slow) {
			int j;
			for (j = 0; j < 100; j++)
				nva_rd32(rs.cnum, 0);
			usleep(10000);
			for (j = 0; j < 100; j++)
				nva_rd32(rs.cnum, 0);
		}
	}
	return 0;
}
示例#18
0
int main(int argc, char **argv) {
    if (nva_init()) {
        fprintf (stderr, "PCI init failure!\n");
        return 1;
    }
    int c;
    int cnum =0;
    while ((c = getopt (argc, argv, "c:")) != -1)
        switch (c) {
        case 'c':
            sscanf(optarg, "%d", &cnum);
            break;
        }
    if (cnum >= nva_cardsnum) {
        if (nva_cardsnum)
            fprintf (stderr, "No such card.\n");
        else
            fprintf (stderr, "No cards found.\n");
        return 1;
    }
    /* ??? */
    dac_write(cnum, 5, 0xff);
    /* PMC.ENABLE */
    nva_wr32(cnum, 0x200, 0);
    nva_wr32(cnum, 0x200, 0x01011111);
    /* PFB scanout config */
    nva_wr32(cnum, 0x600200, 0x130);
    nva_wr32(cnum, 0x600400, 0x0);
    nva_wr32(cnum, 0x600500, 0x18);
    nva_wr32(cnum, 0x600510, 0x88);
    nva_wr32(cnum, 0x600520, 0xa0);
    nva_wr32(cnum, 0x600530, 0x400);
    nva_wr32(cnum, 0x600540, 0x3);
    nva_wr32(cnum, 0x600550, 0x6);
    nva_wr32(cnum, 0x600560, 0x1d);
    nva_wr32(cnum, 0x600570, 0x300);
    /* DAC scanout config */
    dac_write(cnum, 4, 0x39);
    dac_write(cnum, 5, 0x08);
    /* VPLL */
    dac_write(cnum, 0x18, 0x0a);
    dac_write(cnum, 0x19, 0x35);
    dac_write(cnum, 0x1a, 0x01);
    dac_write(cnum, 0x1b, 0x01);
    /* ??? */
    dac_write(cnum, 0x1c, 0x00);
    /* start it up */
    nva_wr32(cnum, 0x6000c0, 0x00330000);
    /* ??? */
    nva_wr32(cnum, 0x001400, 0x1000);
    nva_wr32(cnum, 0x001200, 0x1010);
    nva_wr32(cnum, 0x400084, 0x01110100);

    /* memory detection */
    nva_wr32(cnum, 0x600000, 0x2);
    nva_wr32(cnum, 0x1000000, 0xabcd0000);
    nva_wr32(cnum, 0x1000004, 0xabcd0001);
    nva_wr32(cnum, 0x100000c, 0xabcd0002);
    nva_wr32(cnum, 0x1000010, 0xabcd0010);
    nva_wr32(cnum, 0x1000014, 0xabcd0011);
    nva_wr32(cnum, 0x100001c, 0xabcd0012);
    if (nva_rd32(cnum, 0x100000c) == 0xabcd0002) {
        printf("POSTing 4MB card\n");
        nva_wr32(cnum, 0x600000, 0x10000202);
        nva_wr32(cnum, 0x600040, 0x00900011);
        nva_wr32(cnum, 0x600044, 0x00000003);
        nva_wr32(cnum, 0x600080, 0x00010000);
        dac_write(cnum, 4, 0x39);
    } else if (nva_rd32(cnum, 0x1000004) == 0xabcd0001) {
        printf("POSTing 2MB card\n");
        nva_wr32(cnum, 0x600000, 0x10001201);
        nva_wr32(cnum, 0x600040, 0x00400011);
        nva_wr32(cnum, 0x600044, 0x00000002);
        nva_wr32(cnum, 0x600080, 0x00010000);
        dac_write(cnum, 4, 0x39);
    } else if (nva_rd32(cnum, 0x1000000) == 0xabcd0000) {
        printf("POSTing 1MB card\n");
        nva_wr32(cnum, 0x600000, 0x10001100);
        nva_wr32(cnum, 0x600040, 0x00400011);
        nva_wr32(cnum, 0x600044, 0x00000002);
        nva_wr32(cnum, 0x600080, 0x00010000);
        dac_write(cnum, 4, 0x35);
    } else {
        printf("POST failure - memory didn't come up!\n");
        return 1;
    }
    /* MPLL */
    dac_write(cnum, 0x10, 0x0c);
    dac_write(cnum, 0x11, 0x60);
    dac_write(cnum, 0x12, 0x01);
    dac_write(cnum, 0x13, 0x01);
    /* AUDIO */
    nva_wr32(cnum, 0x3000c0, 0x111);
    /* ??? */
    nva_wr32(cnum, 0x6c1f20, 0x332);
    nva_wr32(cnum, 0x6c1f24, 0x3330333);
    nva_wr32(cnum, 0x6c1f00, 1);

    /* palette */
    nva_wr32(cnum, 0x609000, 0);
    int i;
    for (i = 0; i < 256; i++) {
        nva_wr32(cnum, 0x609004, ((i >> 5) & 7) * 255/7);
        nva_wr32(cnum, 0x609004, ((i >> 2) & 7) * 255/7);
        nva_wr32(cnum, 0x609004, ((i >> 0) & 3) * 255/3);
    }
    for (i = 0; i < 0x400000; i+=4)
        nva_wr32(cnum, 0x1000000 + i, 0xcccccccc);

    /* framebuffer*/
    for (i = 0; i < 0x300 * 0x400; i++) {
        int x = i & 0x3ff;
        int y = i >> 10;
        int col = 0;
        if (x+y <= 32)
            col = 3;
        if (x-y >= 0x400-32)
            col = 0x1c;
        if (x-y <= -0x300+32)
            col = 0xe0;
        if (x+y >= 0x700-32)
            col = 0xff;
        nva_wr8(cnum, 0x1000000 + i, col);
    }

    /* PGRAPH */
    nva_wr32(cnum, 0x4006a4, 0x07000111);
    nva_wr32(cnum, 0x400080, 0x11111111);
    nva_wr32(cnum, 0x400084, 0x11111000);
    nva_wr32(cnum, 0x400088, 0x11111111);
    nva_wr32(cnum, 0x40008c, 0x11111111);
    nva_wr32(cnum, 0x400100, 0xffffffff);
    nva_wr32(cnum, 0x400104, 0xffffffff);
    nva_wr32(cnum, 0x400140, 0xffffffff);
    nva_wr32(cnum, 0x400144, 0xffffffff);
    nva_wr32(cnum, 0x400180, 0x00000010);
    nva_wr32(cnum, 0x400190, 0x10010000);
    for (i = 0; i < 18; i++) {
        nva_wr32(cnum, 0x400400 + i * 4, 0);
        nva_wr32(cnum, 0x400480 + i * 4, 0);
    }
    nva_wr32(cnum, 0x400450, 0);
    nva_wr32(cnum, 0x400454, 0);
    nva_wr32(cnum, 0x400460, 0x10);
    nva_wr32(cnum, 0x400464, 0x3f0);
    nva_wr32(cnum, 0x400468, 0x10);
    nva_wr32(cnum, 0x40046c, 0x2f0);
    nva_wr32(cnum, 0x400600, 0);
    nva_wr32(cnum, 0x400604, 0);
    nva_wr32(cnum, 0x400608, 0);
    nva_wr32(cnum, 0x40060c, 0);
    nva_wr32(cnum, 0x400610, 0);
    nva_wr32(cnum, 0x400614, 0);
    nva_wr32(cnum, 0x400618, 0);
    nva_wr32(cnum, 0x40061c, 0);
    nva_wr32(cnum, 0x400620, 0);
    nva_wr32(cnum, 0x400624, 0);
    nva_wr32(cnum, 0x400628, 0);
    nva_wr32(cnum, 0x40062c, 0);
    nva_wr32(cnum, 0x400630, 0);
    nva_wr32(cnum, 0x400634, 0); /* XXX */
    nva_wr32(cnum, 0x400640, 0);
    nva_wr32(cnum, 0x400644, 0);
    nva_wr32(cnum, 0x400648, 0);
    nva_wr32(cnum, 0x40064c, 0);
    nva_wr32(cnum, 0x400650, 0);
    nva_wr32(cnum, 0x400654, 0);
    nva_wr32(cnum, 0x400658, 0);
    nva_wr32(cnum, 0x40065c, 0);
    nva_wr32(cnum, 0x400660, 0);
    nva_wr32(cnum, 0x400680, 0);
    nva_wr32(cnum, 0x400684, 0);
    nva_wr32(cnum, 0x400688, 0);
    nva_wr32(cnum, 0x40068c, 0x02ff03ff);
    nva_wr32(cnum, 0x400690, 0);
    nva_wr32(cnum, 0x400694, 0);
    nva_wr32(cnum, 0x400698, 0);
    nva_wr32(cnum, 0x40069c, 0);
    nva_wr32(cnum, 0x4006a0, 0);
    for (i = 0; i < 14; i++)
        nva_wr32(cnum, 0x400700 + i * 4, 0);
    return 0;
}
示例#19
0
int main(int argc, char **argv){
	if (nva_init()) {
		fprintf (stderr, "PCI init failure!\n");
		return 1;
	}
	int c;
	while ((c = getopt (argc, argv, "c:")) != -1)
		switch (c) {
			case 'c':
				sscanf(optarg, "%d", &cnum);
				break;
		}
	if (cnum >= nva_cardsnum) {
		if (nva_cardsnum)
			fprintf (stderr, "No such card.\n");
		else
			fprintf (stderr, "No cards found.\n");
		return 1;
	}
	nv50_graph_reset();
	nva_wr32(cnum, 0x1700, 0x400);
	nva_wr32(cnum, 0x700020, 0x190000);
	nva_wr32(cnum, 0x700024, 0x4000000 + 0x80000);
	nva_wr32(cnum, 0x700028, 0x4000000 + 0x10000);
	nva_wr32(cnum, 0x70002c, 0);
	nva_wr32(cnum, 0x700030, 0);
	nva_wr32(cnum, 0x700034, 0x10000);
	nva_wr32(cnum, 0x700200, 0x190000);
	nva_wr32(cnum, 0x700204, 0x4000000 + 0x80000);
	nva_wr32(cnum, 0x700208, 0x4000000 + 0x10000);
	nva_wr32(cnum, 0x70020c, 0);
	nva_wr32(cnum, 0x700210, 0);
	nva_wr32(cnum, 0x700214, 0x10000);

	int j;
	int k;

	for (j = 0; j < 16; j++) {
		printf ("Strand %d!\n", j);
		uint32_t tab[0x3000][6];
		kill(j);
		for (k = 0; k < 0x70000; k += 4)
			nva_wr32(cnum, 0x710000 + k, 0xdeafbeef);
		strread(j, 0);
		for (k = 4*(j&7); k < 0x3000*32; k += 4*8) {
			tab[k/32][0] = nva_rd32(cnum, 0x710000 + k);
		}

		for (k = 0; k < 0x70000; k += 4)
			nva_wr32(cnum, 0x710000 + k, 0);
		strwrite(j, 0);
		for (k = 0; k < 0x70000; k += 4)
			nva_wr32(cnum, 0x710000 + k, 0);
		strread(j, 0);
		for (k = 4*(j&7); k < 0x3000*32; k += 4*8) {
			tab[k/32][1] = nva_rd32(cnum, 0x710000 + k);
		}

		for (k = 0; k < 0x70000; k += 4)
			nva_wr32(cnum, 0x710000 + k, -1);
		strwrite(j, 0);
		for (k = 0; k < 0x70000; k += 4)
			nva_wr32(cnum, 0x710000 + k, 0);
		strread(j, 0);
		for (k = 4*(j&7); k < 0x3000*32; k += 4*8) {
			tab[k/32][2] = nva_rd32(cnum, 0x710000 + k);
		}

		for (k = 0; k < 0x70000; k += 4)
			nva_wr32(cnum, 0x710000 + k, 0);
		strwrite(j, 8);
		for (k = 0; k < 0x70000; k += 4)
			nva_wr32(cnum, 0x710000 + k, 0);
		strread(j, 8);
		for (k = 4*(j&7); k < 0x3000*32; k += 4*8) {
			tab[k/32][3] = nva_rd32(cnum, 0x710000 + k);
		}

		for (k = 0; k < 0x70000; k += 4)
			nva_wr32(cnum, 0x710000 + k, -1);
		strwrite(j, 8);
		for (k = 0; k < 0x70000; k += 4)
			nva_wr32(cnum, 0x710000 + k, 0);
		strread(j, 8);
		for (k = 4*(j&7); k < 0x3000*32; k += 4*8) {
			tab[k/32][4] = nva_rd32(cnum, 0x710000 + k);
			tab[k/32][5] = 0;
		}

		int z;
		for (z = 0; z < 32; z++) {
			for (k = 0; k < 0x70000; k += 4)
				nva_wr32(cnum, 0x710000 + k, -1);
			strwrite(j, 8);
			nva_wr32(cnum, 0x400040, 1 << z);
			nva_wr32(cnum, 0x400040, 0);
			strwait();
			for (k = 0; k < 0x70000; k += 4)
				nva_wr32(cnum, 0x710000 + k, 0);
			strread(j, 8);
			for (k = 4*(j&7); k < 0x3000*32; k += 4*8) {
				if (tab[k/32][4] != nva_rd32(cnum, 0x710000 + k))
					tab[k/32][5] |= 1 << z;
			}
		}

		for (k = 0; k < 0x3000; k++)
			if (tab[k][0] == 0xdeafbeef && !tab[k][4]) {
				slen[j] = k;
				break;
			}

		if (slen[j]) {
			printf ("Initial length: %04x\n", slen[j]);
			while (slen[j]) {
				for (k = 0; k < 0x70000; k += 4)
					nva_wr32(cnum, 0x710000 + k, 0);
				nva_wr32(cnum, 0x710000 + (j&7)*4 + (slen[j] - 1) * 32, 0xffffffff);
				strwrite(j, 8);
				for (k = 0; k < 0x70000; k += 4)
					nva_wr32(cnum, 0x710000 + k, 0);
				strread(j, 8);
				if (nva_rd32(cnum, 0x710000 + (j&7)*4 + (slen[j] - 1) * 32)) {
					break;
				} else {
					slen[j]--;
				}
			}
		}
		printf ("Length: %04x\n", slen[j]);

		int i;
		for (i = 0; i < 0x400; i++) {
			int pos = -1;
			int l;
			int ctr = 0;
//			int try;
			for (l = 1; l < 0x14; l++) {
//				try = 0;
//respin:
				for (k = 0; k < 0x70000; k += 4)
					nva_wr32(cnum, 0x710000 + k, 0);
				strwrite(j, 8);
				for (k = 0; k < l; k++)
					nva_wr32(cnum, 0x400420 + k * 4, 0xffffffff);
				nva_wr32(cnum, 0x400408, i << 16);
				nva_wr32(cnum, 0x400404, 0x30000 | (j & 7) << 8 | (j&8) << (12-3) | l);
				strwait();
				strread(j, 8);
				ctr = 0;
				pos = -1;
				for (k = 0; k < 0x70000; k += 4)
					if (nva_rd32(cnum, 0x710000 + k) && (k & 0x1c) == (j & 7) << 2) {
						if (pos == -1)
							pos = k / 32;
						ctr++;
//						printf ("%04x: %08x\n", k/32, nva_rd32(cnum, 0x710000 + k));
					}
				if (ctr <= l && ctr)
					break;
//				else
//					if (try++ < 4)
//						goto respin;
			}
			if (pos == -1) {
				seekcnt[j] = i;
				break;
			}
			assert(ctr == l);
			printf ("SEEK: %04x [%d/%d]...\n", pos, ctr, l);
			seekstart[j][i] = pos;
			seeksize[j][i] = l;
		}

		i = 0;
		for (k = 0; k < slen[j]; k++) {
			if (i < seekcnt[j] && k == seekstart[j][i]) {
				printf ("\nSEEK %03x [unit %x]\n", i, seeksize[j][i]);
				i++;
			} else if (i && seeksize[j][i-1] != 1 && !((k - seekstart[j][i-1])%seeksize[j][i-1]))
				printf ("\n");
			printf ("%04x: %08x %08x %08x %08x %08x %08x\n", k, tab[k][0], tab[k][1], tab[k][2], tab[k][3], tab[k][4], tab[k][5]);
		}
	}


	return 0;
}