예제 #1
0
static int msetup_getone(char *prompt,char *envvar,char *defval,int flg)
{
    char buffer[100];
    char pbuf[100];
    char *curval;

    curval = carmel_getenv(envvar);
    if (!curval) curval = defval;

    sprintf(pbuf,"%s [%s]: ",prompt,curval);

    for (;;) {
	console_readline(pbuf,buffer,sizeof(buffer));
	if (buffer[0] == 0) break;		/* default */
	if (flg & (MSETUP_UCASE|MSETUP_YESNO)) strupr(buffer);
	if (flg & MSETUP_YESNO) {
	    if (strcmp(buffer,"YES") == 0) break;
	    if (strcmp(buffer,"NO") == 0) break;
	    printf("You must enter 'YES' or 'NO'.\n");
	    continue;
	    }
	break;
	}
	

    if (buffer[0] == 0) {
	carmel_setenv(envvar,defval,0);
	}
    else {
	carmel_setenv(envvar,buffer,0);
	}

    return 0;
    
}
void cfe_command_loop()
{
    char buffer[300];
    int status;
    char *prompt;

    SETLEDS("CFE ");

	for (;;) {
        if (recovery_button_status())
        {
            xprintf("recovery\n");
            recovery_op();
        }
	prompt = env_getenv("PROMPT");
#if CFG_RAMAPP
	SETLEDS("CFE*");
	if (!prompt) prompt = "CFE_RAM> ";
#else
	if (!prompt) prompt = "CFE> ";
#endif
	console_readline(prompt,buffer,sizeof(buffer));

	status = ui_docommands(buffer);

	if (status != CMD_ERR_BLANK) {
	    xprintf("*** command status = %d\n", status);
	    }
	}
}
예제 #3
0
static int ui_cmd_reset(ui_cmdline_t *cmd,int argc,char *argv[])
{
    uint64_t data;
    uint64_t olddata;
    int confirm = 1;
    char str[50];

    data = SBREADCSR(A_SCD_SYSTEM_CFG) & ~M_SYS_SB_SOFTRES;
    olddata = data;

    if (cmd_sw_isset(cmd,"-yes")) confirm = 0;

    if (cmd_sw_isset(cmd,"-softreset")) data |= M_SYS_SB_SOFTRES;

    if (cmd_sw_isset(cmd,"-unicpu0")) data |= M_SYS_UNICPU0;
    else if (cmd_sw_isset(cmd,"-unicpu1")) data |= M_SYS_UNICPU1;

    if (cmd_sw_isset(cmd,"-sysreset")) data |= M_SYS_SYSTEM_RESET;

    if (cmd_sw_isset(cmd,"-cpu")) data |= (M_SYS_CPU_RESET_0 | M_SYS_CPU_RESET_1);

    if (data == olddata) {		/* no changes to reset pins were specified */
	return ui_showusage(cmd);
	}

    if (confirm) {
	console_readline("Are you sure you want to reset? ",str,sizeof(str));
	if ((str[0] != 'Y') && (str[0] != 'y')) return -1;
	}

    SBWRITECSR(A_SCD_SYSTEM_CFG,data);

    /* should not return */

    return -1;
}
예제 #4
0
파일: debug.c 프로젝트: Noltari/cfe_bcm63xx
void x86emu_single_step (void)
{
    char s[1024];
    int ps[10];
    int ntok;
    int cmd;
    int done;
    int segment;
    int offset;
    static int breakpoint;
    static int noDecode = 1;
    
    char *p;

    if (DEBUG_BREAK()) {
	if (M.x86.saved_ip != breakpoint) {
	    return;
	    } 
	else {
	    M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F;
	    M.x86.debug |= DEBUG_TRACE_F;
	    M.x86.debug &= ~DEBUG_BREAK_F;
	    print_decoded_instruction ();
	    X86EMU_trace_regs();
	    }
	}
    done=0;
    offset = M.x86.saved_ip;
    while (!done) {
#ifdef _CFE_
	cmd = console_readline("-",s,1023);
	if (cmd) { s[cmd] = '\n'; s[cmd+1] = 0;}
	p = s;
#else
        printk("-");
        p = fgets(s, 1023, stdin);
#endif
        cmd = parse_line(s, ps, &ntok);
        switch(cmd) {
	    case 'u':
		if (ntok == 2) { offset = ps[1]; }
		offset = disassemble_forward(M.x86.saved_cs,(u16)offset,10);
		break;
	    case 'd':  
		if (ntok == 2) {
		    segment = M.x86.saved_cs;
		    offset = ps[1];
		    X86EMU_dump_memory(segment,(u16)offset,16);
		    offset += 16;
		    } else if (ntok == 3) {
			segment = ps[1];
			offset = ps[2];
			X86EMU_dump_memory(segment,(u16)offset,16);
			offset += 16;
			} else {
			    segment = M.x86.saved_cs;
			    X86EMU_dump_memory(segment,(u16)offset,16);
			    offset += 16;
			    }
		break;
	    case 'c':
		M.x86.debug ^= DEBUG_TRACECALL_F;
		break;
	    case 's':
		M.x86.debug ^= DEBUG_SVC_F | DEBUG_SYS_F | DEBUG_SYSINT_F;
		break;
	    case 'r':
		X86EMU_trace_regs();
		break;
	    case 'x':
		X86EMU_trace_xregs();
		break;
	    case 'g':
		if (ntok == 2) {
		    breakpoint = ps[1];
		    if (noDecode) {
			M.x86.debug |= DEBUG_DECODE_NOPRINT_F;
			} else {
			    M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F;
			    }
		    M.x86.debug &= ~DEBUG_TRACE_F;
		    M.x86.debug |= DEBUG_BREAK_F;
		    done = 1;
		    }
		break;
	    case 'q':
		M.x86.debug &= ~DEBUG_TRACE_F;
		M.x86.debug &= ~DEBUG_BREAK_F;
		M.x86.debug &= ~DEBUG_STEP_F;
		M.x86.debug &= ~DEBUG_DECODE_F;
		done = 1;
		break;
	    case 'P':
		noDecode = (noDecode)?0:1;
		printk("Toggled decoding to %s\n",(noDecode)?"FALSE":"TRUE");
		break;
	    case 't':
	    case 0:
		done = 1;
		break;
	    }   
	}
}
예제 #5
0
static int ui_cmd_memedit(ui_cmdline_t *cmd,int argc,char *argv[])
{
    uint8_t b;
    uint16_t h;
    uint32_t w;
    uint64_t q;

    long addr;
    char *vtext;
    int wlen;
    int count;
    int idx = 1;
    int stuffed = 0;
    int res = 0;

    getaddrargs(cmd,&prev_wtype,&prev_addr,NULL);

    wlen = prev_wtype & ATYPE_SIZE_MASK;

    vtext = cmd_getarg(cmd,idx++);

    addr = prev_addr;

    while (vtext) {
	count = stuffmem(addr,wlen,vtext);
	if (count < 0) {
	    ui_showerror(count,"Could not modify memory");
	    return count;			/* error */
	    }
	addr += count*wlen;
	prev_addr += count*wlen;
	stuffed += count;
	vtext = cmd_getarg(cmd,idx++);
	}

    if (stuffed == 0) {
	char line[256];
	char prompt[32];

	xprintf("Type '.' to exit, '-' to back up, '=' to dump memory.\n");
	for (;;) {

	    addr = prev_addr;
	    if ((prev_wtype & ATYPE_TYPE_MASK) == ATYPE_TYPE_PHYS) {
		addr = UNCADDR(addr);
		}

	    xprintf("%P%c ",prev_addr,(addr != prev_addr) ? '%' : ':');

	    switch (wlen) {
		default:
		case 1:
		    if ((res = mem_peek(&b, addr, MEM_BYTE))) {
			return res;
			}
		    xsprintf(prompt,"[%02X]: ", b);
		    break;
		case 2:
		    if ((res = mem_peek(&h, addr, MEM_HALFWORD))) {
			return res;
			}
		    xsprintf(prompt,"[%04X]: ",h);
		    break;
		case 4:
		    if ((res = mem_peek(&w, addr, MEM_WORD))) {
			return res;
			}
		    xsprintf(prompt,"[%08X]: ",w);
		    break;
		case 8:
		    if ((res = mem_peek(&q, addr, MEM_QUADWORD))) {
			return res;
			}
		    xsprintf(prompt,"[%016llX]: ",q);
		    break;
		}

	    console_readline(prompt,line,sizeof(line));
	    if (line[0] == '-') {
		prev_addr -= wlen;
		continue;
		}
	    if (line[0] == '=') {
		dumpmem(prev_addr,prev_addr,16,wlen);
		continue;
		}
	    if (line[0] == '.') {
		break;
		}
	    if (line[0] == '\0') {
		prev_addr += wlen;
		continue;
		}
	    count = stuffmem(addr,wlen,line);
	    if (count < 0) return count;
	    if (count == 0) break;
	    prev_addr += count*wlen;
	    }
	}

    return 0;
}