Example #1
0
int apic(struct vmctl *v, uint64_t gpa, int destreg, uint64_t *regp, int store)
{
	uint32_t offset = gpa & 0xfffff;
	/* basic sanity tests. */
	// TODO: Should be minus the base but FIXME

	//fprintf(stderr, "WE SHOULD NEVER BE HERE: user/vmm/apic.c");
	//exit(1);

	offset = gpa & 0xfffff;
	if (offset & 0xf) {
		DPRINTF("bad register offset; low nibl is non-zero\n");
		return -1;
	}
	offset >>= 4;
	if (offset > APIC_CONFIG) {
		DPRINTF("Bad register offset: 0x%x and max is 0x%x\n", gpa, gpa + APIC_CONFIG);
		return -1;
	}

	if (store) {
		apic_write(offset, *regp);
		DPRINTF("Write: mov %s to %s @%p val %p\n", regname(destreg), apicregs[offset].name, gpa, *regp);
	} else {
		*regp = apic_read(offset);
		DPRINTF("Read: Set %s from %s @%p to %p\n", regname(destreg), apicregs[offset].name, gpa, *regp);
	}

}
Example #2
0
static void dump_register(uint32_t regbase, uint32_t dword, int level)
{
	init();

	if (!summary) {
		dump_register_val(regbase, dword, level);
	}

	if (type0_reg[regbase].fxn) {
		type0_reg[regbase].fxn(regname(regbase, 0), dword, level);
	} else if (reg_axxx[regbase].fxn) {
		reg_axxx[regbase].fxn(regname(regbase, 0), dword, level);
	}
}
Example #3
0
void io_i915_write32(unsigned long val, unsigned long addr)
{
	if (verbose & vio)printk(BIOS_SPEW, "%s: outl %08lx\n", regname(addr), val);
	outl(addr, addrport);
	outl(val, dataport);
	iowrite += 2;
}
Example #4
0
	static const char *parse_register_name(const char *source, const std::vector<std::string> &registers, size_t &index)
	{
		// Find end of the potential register name
		// That is, end of string or whitespace
		const char *end = source;
		while (*end && *end != ' ' && *end != '\t' && *end != '\n' && *end != '\r') end++;
		// Now end points to one past last character in name

		std::string regname(source, end-source);

		if (regname.size() == 0) return 0;

		// Check for supplied register name
		for (size_t i = 0; i < registers.size(); i++) {
			if (regname == registers[i]) {
				index = i;
				return end;
			}
		}

		// Check for temp register name
		if (regname[0] == 't' && regname.size() == 2) {
			if (regname[1] >= '0' && regname[1] <= '9') {
				index = registers.size() + regname[1] - '0';
				return end;
			}
		}

		// Nothing matches
		return 0;
	}
Example #5
0
unsigned long io_i915_read32(unsigned long addr)
{
	unsigned long val;
	outl(addr, addrport);
	val = inl(dataport);
	ioread += 2;
	if (verbose & vio)printk(BIOS_SPEW, "%s: Got %08lx\n", regname(addr), val);
	return val;
}
Example #6
0
static const char* compute_reg_list (unsigned list) {
        int i, idx = 1, mark = 0;
	const char *name;
        tmpbuf[0] = '{';
        for (i = 0; i<16; i++) {
                if (list & (1<<i)) {
                        if (mark) {
                                tmpbuf[idx++] = ',';
                                tmpbuf[idx++] = ' ';
                        } else mark = 1;
                        name = regname(i);
                        tmpbuf[idx++] = name[0];
                        tmpbuf[idx++] = name[1];
                }
        }
        tmpbuf[idx++] = '}';
        tmpbuf[idx++] = '\0';
        return tmpbuf;
}
Example #7
0
static void dump_registers(uint32_t regbase,
		uint32_t *dwords, uint32_t sizedwords, int level)
{
	while (sizedwords--) {
		int last_summary = summary;

		/* access to non-banked registers needs a WFI:
		 * TODO banked register range for a2xx??
		 */
		if (needs_wfi && !is_banked_reg(regbase))
			printf("NEEDS WFI: %s (%x)\n", regname(regbase, 1), regbase);

		type0_reg_vals[regbase] = *dwords;
		type0_reg_written[regbase/8] |= (1 << (regbase % 8));
		dump_register(regbase, *dwords, level);
		regbase++;
		dwords++;
		summary = last_summary;
	}
}
Example #8
0
int i915lightup(unsigned int pphysbase,
	unsigned int piobase,
	unsigned int pmmio,
	unsigned int pgfx)
{
	int i, prev = 0;
	struct iodef *id, *lastidread = 0;
	unsigned long u, t;
	static unsigned long times[4096];
	mmio = (void *)pmmio;
	addrport = piobase;
	dataport = addrport + 4;
	physbase = pphysbase;
	graphics = pgfx;
	printk(BIOS_SPEW,
		"i915lightup: graphics %p mmio %p"
		"addrport %04x physbase %08x\n",
			(void *)graphics, mmio, addrport, physbase);
	globalstart = rdtscll();

	/* state machine! */
	for(i = 0, id = iodefs; i < ARRAY_SIZE(iodefs); i++, id++){
		switch(id->op){
		case M:
			if (verbose & vmsg) printk(BIOS_SPEW, "%ld: %s\n",
				globalmicroseconds(), id->msg);
			break;
		case R:
			u = READ32(id->addr);
			if (verbose & vio)printk(BIOS_SPEW, "%s: Got %08lx, expect %08lx\n",
				regname(id->addr), u, id->data);
			/* we're looking for something. */
			if (lastidread->addr == id->addr){
				/* they're going to be polling.
				 * just do it 1000 times
				 */
				for(t = 0; t < 1000 && id->data != u; t++){
					u = READ32(id->addr);
				}
				if (verbose & vspin) printk(BIOS_SPEW,
						"%s: # loops %ld got %08lx want %08lx\n",
						regname(id->addr),
						t, u, id->data);
			}
			lastidread = id;
			break;
		case W:
			if (verbose & vio)printk(BIOS_SPEW, "%s: outl %08lx\n", regname(id->addr),
									id->data);
			WRITE32(id->data, id->addr);
			if (id->addr == PCH_PP_CONTROL){
				switch(id->data & 0xf){
					case 8: break;
					case 7: break;
					default: udelay(100000);
				}
			}
			break;
		case V:
			if (id->count < 8){
				prev = verbose;
				verbose = id->count;
			} else {
				verbose = prev;
			}
			break;
		case I:
			break;
		default:
			printk(BIOS_SPEW, "BAD TABLE, opcode %d @ %d\n", id->op, i);
			return -1;
		}
		if (id->udelay)
			udelay(id->udelay);
		times[i] = globalmicroseconds();
	}
	/* optional, we don't even want to take timestamp overhead
	 * if we can avoid it. */
	if (0)
	for(i = 0, id = iodefs; i < ARRAY_SIZE(iodefs); i++, id++){
		switch(id->op){
		case R:
			printk(BIOS_SPEW, "%ld: R %08lx\n", times[i], id->addr);
			break;
		case W:
			printk(BIOS_SPEW, "%ld: W %08lx %08lx\n", times[i],
				id->addr, id->data);
			break;
		}
	}

	setgtt(0, 4520, physbase, 4096);
	printk(BIOS_SPEW, "memset %p to 0 for %d bytes\n",
				(void *)graphics, 4520*4096);
	memset((void *)graphics, 0, 4520*4096);
	printk(BIOS_SPEW, "%ld microseconds\n", globalmicroseconds());
	i915_init_done = 1;
	oprom_is_loaded = 1;
	return 0;
}
Example #9
0
int
command(char *buf, int defcom)
{
	char	*reg;
	char	savc;
	char	*savlp=lp;
	char	savlc = lastc;
	char	savpc = peekc;
	static char lastcom = '=', savecom = '=';

	if (defcom == 0)
		defcom = lastcom;
	if (buf) {
		if (*buf==EOR)
			return(FALSE);
		clrinp();
		lp=buf;
	}
	do {
		adrflg=expr(0);		/* first address */
		if (adrflg){
			dot=expv;
			ditto=expv;
		}
		adrval=dot;

		if (rdc()==',' && expr(0)) {	/* count */
			cntflg=TRUE;
			cntval=expv;
		} else {
			cntflg=FALSE;
			cntval=1;
			reread();
		}

		if (!eol(rdc()))
			lastcom=lastc;		/* command */
		else {
			if (adrflg==0)
				dot=inkdot(dotinc);
			reread();
			lastcom=defcom;
		}
		switch(lastcom) {
		case '/':
		case '=':
		case '?':
			savecom = lastcom;
			acommand(lastcom);
			break;

		case '>':
			lastcom = savecom; 
			savc=rdc();
			if (reg=regname(savc))
				rput(correg, reg, dot);
			else	
				error("bad variable");
			break;

		case '!':
			lastcom=savecom;
			shell(); 
			break;

		case '$':
			lastcom=savecom;
			printdollar(nextchar()); 
			break;

		case ':':
			if (!executing) { 
				executing=TRUE;
				subpcs(nextchar());
				executing=FALSE;
				lastcom=savecom;
			}
			break;

		case 0:
			prints(DBNAME);
			break;

		default: 
			error("bad command");
		}
		flushbuf();
	} while (rdc()==';');
	if (buf == 0)
		reread();
	else {
		clrinp();
		lp=savlp;
		lastc = savlc;
		peekc = savpc;
	}

	if(adrflg)
		return dot;
	return 1;
}
Example #10
0
const char* expected_str(Reg8 r)  { return regname(r); }
Example #11
0
item(int a)
{	/* name [ . local ] | number | . | ^  | <register | 'x | | */
	char	*base;
	char	savc;
	uvlong e;
	Symbol s;
	char gsym[MAXSYM], lsym[MAXSYM];

	readchar();
	if (isfileref()) {
		readfname(gsym);
		rdc();			/* skip white space */
		if (lastc == ':') {	/* it better be */
			rdc();		/* skip white space */
			if (!getnum(readchar))
				error("bad number");
			if (expv == 0)
				expv = 1;	/* file begins at line 1 */
			expv = file2pc(gsym, expv);
			if (expv == -1)
				error("%r");
			return 1;
		}
		error("bad file location");
	} else if (symchar(0)) {	
		readsym(gsym);
		if (lastc=='.') {
			readchar();	/* ugh */
			if (lastc == '.') {
				lsym[0] = '.';
				readchar();
				readsym(lsym+1);
			} else if (symchar(0)) {
				readsym(lsym);
			} else
				lsym[0] = 0;
			if (localaddr(cormap, gsym, lsym, &e, rget) < 0)
				error("%r");
			expv = e;
		}
		else {
			if (lookup(0, gsym, &s) == 0)
				error("symbol not found");
			expv = s.value;
		}
		reread();
	} else if (getnum(readchar)) {
		;
	} else if (lastc=='.') {	
		readchar();
		if (!symchar(0) && lastc != '.') {
			expv = dot;
		} else {
			if (findsym(rget(cormap, mach->pc), CTEXT, &s) == 0)
				error("no current function");
			if (lastc == '.') {
				lsym[0] = '.';
				readchar();
				readsym(lsym+1);
			} else
				readsym(lsym);
			if (localaddr(cormap, s.name, lsym, &e, rget) < 0)
				error("%r");
			expv = e;
		}	
		reread();
	} else if (lastc=='"') {
		expv=ditto;
	} else if (lastc=='+') {
		expv=inkdot(dotinc);
	} else if (lastc=='^') {
		expv=inkdot(-dotinc);
	} else if (lastc=='<') {
		savc=rdc();
		base = regname(savc);
		expv = rget(cormap, base);
	}
	else if (lastc=='\'')
		expv = ascval();
	else if (a)
		error("address expected");
	else {	
		reread();
		return(0);
	}
	return(1);
}
Example #12
0
static void ignore_access(const char *kind, target_phys_addr_t addr)
{
    fprintf(stderr, "%s to %s (0x" TARGET_FMT_plx ") ignored\n",
	    kind, regname(addr), addr);
}
Example #13
0
static int run(int index)
{
	int i, prev = 0;
	struct iodef *id, *lastidread = 0;
	unsigned long u, t;
	if (index >= niodefs)
		return index;
	/* state machine! */
	for (i = index, id = &iodefs[i]; id->op; i++, id++) {
		switch (id->op) {
		case M:
			if (verbose & vmsg)
				printk(BIOS_SPEW, "%ld: %s\n",
						globalmicroseconds(), id->msg);
			break;
		case P:
			palette();
			break;
		case R:
			u = READ32(id->addr);
			if (verbose & vio)
				printk(BIOS_SPEW, "\texpect %08lx\n", id->data);
			/* we're looking for something. */
			if (lastidread->addr == id->addr) {
				/* they're going to be polling.
				 * just do it 1000 times
				 */
				for (t = 0; t < 1000 && id->data != u; t++)
					u = READ32(id->addr);

				if (verbose & vspin)
					printk(BIOS_SPEW,
					       "%s: # loops %ld got %08lx want %08lx\n",
						regname(id->addr),
						t, u, id->data);
			}
			lastidread = id;
			break;
		case W:
			WRITE32(id->data, id->addr);
			if (id->addr == PCH_PP_CONTROL) {
				if (verbose & vio)
					printk(BIOS_SPEW, "PCH_PP_CONTROL\n");
				switch (id->data & 0xf) {
				case 8:
					break;
				case 7:
					break;
				default:
					udelay(100000);
					if (verbose & vio)
						printk(BIOS_SPEW, "U %d\n",
						       100000);
				}
			}
			break;
		case V:
			if (id->count < 8) {
				prev = verbose;
				verbose = id->count;
			} else {
				verbose = prev;
			}
			printk(BIOS_SPEW, "Change verbosity to %d\n", verbose);
			break;
		case I:
			printk(BIOS_SPEW, "run: return %d\n", i+1);
			return i+1;
			break;
		default:
			printk(BIOS_SPEW, "BAD TABLE, opcode %d @ %d\n",
			       id->op, i);
			return -1;
		}
		if (id->udelay)
			udelay(id->udelay);
		if (i < ARRAY_SIZE(times))
			times[i] = globalmicroseconds();
	}
	printk(BIOS_SPEW, "run: return %d\n", i);
	return i+1;
}
Example #14
0
offs_t mcs96_device::disasm_generic(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options, const disasm_entry *entries)
{
    bool prefix_fe = false;
    int off = 0;
    if(oprom[0] == 0xfe && entries[oprom[1]].opcode_fe) {
        prefix_fe = true;
        pc++;
        off++;
        oprom++;
    }
    const disasm_entry &e = entries[oprom[0]];
    UINT32 flags = e.flags | DASMFLAG_SUPPORTED;
    buffer += sprintf(buffer, "%s", prefix_fe ? e.opcode_fe : e.opcode);

    switch(e.mode) {
    case DASM_none:
        flags |= 1;
        break;

    case DASM_nop_2:
        sprintf(buffer, " %02x", oprom[1]);
        flags |= 2;
        break;

    case DASM_rel8: {
        int delta = oprom[1];
        if(delta & 0x80)
            delta -= 0x100;
        sprintf(buffer, " %04x", (pc+2+delta) & 0xffff);
        flags |= 2;
        break;
    }

    case DASM_rel11: {
        int delta = ((oprom[0] << 8) | oprom[1]) & 0x7ff;
        if(delta & 0x400)
            delta -= 0x800;
        sprintf(buffer, " %04x", (pc+2+delta) & 0xffff);
        flags |= 2;
        break;
    }

    case DASM_rel16: {
        int delta = oprom[1] | (oprom[2] << 8);
        sprintf(buffer, " %04x", (pc+3+delta) & 0xffff);
        flags |= 3;
        break;
    }

    case DASM_rrel8: {
        int delta = oprom[2];
        if(delta & 0x80)
            delta -= 0x100;
        sprintf(buffer, " %s, %04x", regname(oprom[1]).c_str(), (pc+3+delta) & 0xffff);
        flags |= 3;
        break;
    }

    case DASM_brrel8: {
        int delta = oprom[2];
        if(delta & 0x80)
            delta -= 0x100;
        sprintf(buffer, " %d, %s, %04x", oprom[0] & 7, regname(oprom[1]).c_str(), (pc+3+delta) & 0xffff);
        flags |= 3;
        break;
    }

    case DASM_direct_1:
        sprintf(buffer, " %s", regname(oprom[1]).c_str());
        flags |= 2;
        break;

    case DASM_direct_2:
        sprintf(buffer, " %s, %s", regname(oprom[2]).c_str(), regname(oprom[1]).c_str());
        flags |= 3;
        break;

    case DASM_direct_3:
        sprintf(buffer, " %s, %s, %s", regname(oprom[3]).c_str(), regname(oprom[2]).c_str(), regname(oprom[1]).c_str());
        flags |= 4;
        break;

    case DASM_immed_1b:
        sprintf(buffer, " #%02x", oprom[1]);
        flags |= 2;
        break;

    case DASM_immed_2b:
        sprintf(buffer, " %s, #%02x", regname(oprom[2]).c_str(), oprom[1]);
        flags |= 3;
        break;

    case DASM_immed_or_reg_2b:
        if(oprom[1] >= 0x10)
            sprintf(buffer, " %s, %s", regname(oprom[2]).c_str(), regname(oprom[1]).c_str());
        else
            sprintf(buffer, " %s, #%02x", regname(oprom[2]).c_str(), oprom[1]);
        flags |= 3;
        break;

    case DASM_immed_3b:
        sprintf(buffer, " %s, %s, #%02x", regname(oprom[3]).c_str(), regname(oprom[2]).c_str(), oprom[1]);
        flags |= 4;
        break;

    case DASM_immed_1w:
        sprintf(buffer, " #%02x%02x", oprom[2], oprom[1]);
        flags |= 3;
        break;

    case DASM_immed_2w:
        sprintf(buffer, " %s, #%02x%02x", regname(oprom[3]).c_str(), oprom[2], oprom[1]);
        flags |= 4;
        break;

    case DASM_immed_3w:
        sprintf(buffer, " %s, %s, #%02x%02x", regname(oprom[4]).c_str(), regname(oprom[3]).c_str(), oprom[2], oprom[1]);
        flags |= 5;
        break;

    case DASM_indirect_1n:
        sprintf(buffer, " [%s]", regname(oprom[1]).c_str());
        flags |= 2;
        break;

    case DASM_indirect_1:
        if(oprom[1] & 0x01) {
            sprintf(buffer, " [%s]+", regname(oprom[1]-1).c_str());
            flags |= 2;
        } else {
            sprintf(buffer, " [%s]", regname(oprom[1]).c_str());
            flags |= 2;
        }
        break;

    case DASM_indirect_2:
        if(oprom[1] & 0x01) {
            sprintf(buffer, " %s, [%s]+", regname(oprom[2]).c_str(), regname(oprom[1]-1).c_str());
            flags |= 3;
        } else {
            sprintf(buffer, " %s, [%s]", regname(oprom[2]).c_str(), regname(oprom[1]).c_str());
            flags |= 3;
        }
        break;

    case DASM_indirect_3:
        if(oprom[1] & 0x01) {
            sprintf(buffer, " %s, %s, [%s]+", regname(oprom[3]).c_str(), regname(oprom[2]).c_str(), regname(oprom[1]-1).c_str());
            flags |= 4;
        } else {
            sprintf(buffer, " %s, %s, [%s]", regname(oprom[3]).c_str(), regname(oprom[2]).c_str(), regname(oprom[1]).c_str());
            flags |= 4;
        }
        break;

    case DASM_indexed_1:
        if(oprom[1] & 0x01) {
            if(oprom[1] == 0x01)
                sprintf(buffer, " %02x%02x", oprom[3], oprom[2]);
            else
                sprintf(buffer, " %02x%02x[%s]", oprom[3], oprom[2], regname(oprom[1]-1).c_str());
            flags |= 4;
        } else {
            int delta = oprom[2];
            if(delta & 0x80)
                delta -= 0x100;
            if(oprom[1] == 0x00) {
                if(delta < 0)
                    sprintf(buffer, " %04x", delta & 0xffff);
                else
                    sprintf(buffer, " %02x", delta);
            } else {
                if(delta < 0)
                    sprintf(buffer, " -%02x[%s]", -delta, regname(oprom[1]).c_str());
                else
                    sprintf(buffer, " %02x[%s]", delta, regname(oprom[1]).c_str());
            }
            flags |= 3;
        }
        break;

    case DASM_indexed_2:
        if(oprom[1] & 0x01) {
            if(oprom[1] == 0x01)
                sprintf(buffer, " %s, %02x%02x", regname(oprom[4]).c_str(), oprom[3], oprom[2]);
            else
                sprintf(buffer, " %s, %02x%02x[%s]", regname(oprom[4]).c_str(), oprom[3], oprom[2], regname(oprom[1]-1).c_str());
            flags |= 5;
        } else {
            int delta = oprom[2];
            if(delta & 0x80)
                delta -= 0x100;
            if(oprom[1] == 0x00) {
                if(delta < 0)
                    sprintf(buffer, " %s, %04x", regname(oprom[3]).c_str(), delta & 0xffff);
                else
                    sprintf(buffer, " %s, %02x", regname(oprom[3]).c_str(), delta);
            } else {
                if(delta < 0)
                    sprintf(buffer, " %s, -%02x[%s]", regname(oprom[3]).c_str(), -delta, regname(oprom[1]).c_str());
                else
                    sprintf(buffer, " %s, %02x[%s]", regname(oprom[3]).c_str(), delta, regname(oprom[1]).c_str());
            }
            flags |= 4;
        }
        break;

    case DASM_indexed_3:
        if(oprom[1] & 0x01) {
            if(oprom[1] == 0x01)
                sprintf(buffer, " %s, %s, %02x%02x", regname(oprom[5]).c_str(),  regname(oprom[4]).c_str(), oprom[3], oprom[2]);
            else
                sprintf(buffer, " %s, %s, %02x%02x[%s]", regname(oprom[5]).c_str(), regname(oprom[4]).c_str(), oprom[3], oprom[2], regname(oprom[1]-1).c_str());
            flags |= 6;
        } else {
            int delta = oprom[2];
            if(delta & 0x80)
                delta -= 0x100;
            if(oprom[1] == 0x00) {
                if(delta < 0)
                    sprintf(buffer, " %s, %s, %04x", regname(oprom[4]).c_str(), regname(oprom[3]).c_str(), delta & 0xffff);
                else
                    sprintf(buffer, " %s, %s, %02x", regname(oprom[4]).c_str(), regname(oprom[3]).c_str(), delta);
            } else {
                if(delta < 0)
                    sprintf(buffer, " %s, %s, -%02x[%s]", regname(oprom[4]).c_str(), regname(oprom[3]).c_str(), -delta, regname(oprom[1]).c_str());
                else
                    sprintf(buffer, " %s, %s, %02x[%s]", regname(oprom[4]).c_str(), regname(oprom[3]).c_str(), delta, regname(oprom[1]).c_str());
            }
            flags |= 5;
        }
        break;

    default:
        fprintf(stderr, "Unhandled dasm mode %d\n", e.mode);
        abort();
    };

    return flags+off;
}
Example #15
0
File: sh7750.c Project: 8tab/qemu
static void error_access(const char *kind, hwaddr addr)
{
    fprintf(stderr, "%s to %s (0x" TARGET_FMT_plx ") not supported\n",
	    kind, regname(addr), addr);
}