Example #1
0
int protoss_write_debug_reg(uint32_t reg, uint32_t val) {
    //IOLog("%d %d\n", reg, val);
    begin_debug();
    read_debug(197);
    write_debug(reg, val);
    end_debug();
    return 0;
}
Example #2
0
uint32_t protoss_dump_debug_reg(uint32_t reg) {
    //IOLog("dbg_map = %p\n", dbg_map);
    uint32_t result;
    begin_debug();
    read_debug(197);
    result = read_debug(reg);
    end_debug();
    return result;
}
Example #3
0
void		debug_binary(\
			void)
{
	if (!IS(O_FILEDEBUG, OPT) && !IS(O_DEBUG, OPT))
		return ;
	start_debug("Binary");
	ft_dicdoinf(BINARY, putbinary);
	end_debug("Binary");
}
Example #4
0
void		debug_env(\
			void)
{
	int		i;

	if (!IS(O_FILEDEBUG, OPT) && !IS(O_DEBUG, OPT))
		return ;
	start_debug("Environ");
	i = 0;
	while (ENV[i])
		ft_fprintf(FDDEBUG, "\t%s\n", ENV[i++]);
	end_debug("Environ");
}
Example #5
0
void		debug_builtin(\
			void)
{
	int		i;

	if (!IS(O_FILEDEBUG, OPT) && !IS(O_DEBUG, OPT))
		return ;
	start_debug("Builtin");
	i = -1;
	while (++i < FT_SH_BUILTIN_SIZE)
		ft_fprintf(FDDEBUG, FMT_BUILTIN_DEBUG, BUILTIN[i].id, BUILTIN[i].built);
	end_debug("Builtin");
}
Example #6
0
void protoss_stop() {
    if(trace_going || watch_going) {
        begin_debug(); // interrupts disabled
        read_debug(197);
        uint32_t dbgdscr = read_debug(34);
        dbgdscr |= 0x8000; // turn on debug
        write_debug(34, dbgdscr);
        for(int i = 0; i < 16; i++) {
            // bcr and wcr
            write_debug(80 + i, 0);
            write_debug(112 + i, 0);
        }

        dbgdscr = read_debug(34);
        dbgdscr &= ~0x8000;
        write_debug(34, dbgdscr);
        end_debug();
    }

    if(trace_going) {
        trace_going = false;
    }
    
    watch_going = false;

#ifdef WATCH{OINTS
    if(ter_patched) {
        memset(debug_stuff, 0, sizeof(debug_stuff));
        old_ie = ml_set_interrupts_enabled(0);

        for(int i = 0; i < 4; i++) ter_patch_loc[i] = ter_orig[i];
    
        flush_cache(ter_patch_loc, sizeof(ter_orig));

        ter_patched = false;

        ml_set_interrupts_enabled(old_ie);
    }
#endif

    if(prefetch_saved) {
        vector_base()[3+8] = prefetch_saved;
        prefetch_saved = NULL;
    }

    if(data_saved) {
        vector_base()[4+8] = data_saved;
        data_saved = NULL;
    }
}
Example #7
0
void		debug_cmd(\
			t_cmd cmd)
{
	int		i;

	if (!IS(O_FILEDEBUG, OPT) && !IS(O_DEBUG, OPT))
		return ;
	start_debug("Command");
	i = -1;
	ft_fprintf(FDDEBUG, "Binary: [%s] -> [%s]\n", cmd.arg_v[0], cmd.pathbin);
	while (cmd.arg_v[++i])
		ft_fprintf(FDDEBUG, FMT_ARGV, i, cmd.arg_v[i]);
	end_debug("Command");
}
Example #8
0
int protoss_go() {
    if(trace_going || watch_going) {
        IOLog("protoss_go: already enabled\n");
        return -1;
    }
    
    if(vector_base()[3] != (void *) 0xe59ff018) {
        return -1;
    }
    
    trace_going = true;

    if(!trace_start) trace_start = IOMalloc(num_trace_entries * sizeof(struct trace_entry));
    memset(trace_start, 0, (num_trace_entries - 1) * sizeof(struct trace_entry));
    memset(&trace_start[num_trace_entries - 1], 0xff, sizeof(struct trace_entry));
    trace_ptr = &trace_start[1];

    // We can't ever branch to 80xxxxxx, so overwrite it here
    prefetch_saved = vector_base()[3+8];
    vector_base()[3+8] = (void *) trace_prefetch_handler;

    union dbgbcr dbgbcr5, dbgbcr4;
    dbgbcr5.val = dbgbcr4.val = 0;
    uint32_t dbgbvr5, dbgbvr4;

    dbgbcr5.z1 = 0;
    dbgbcr5.address_range_mask = 0;
    dbgbcr5.z2 = 0;
    dbgbcr5.dbgbvr_match_or_mismatch = 1; // mismatch
    dbgbcr5.dbgbvr_iva_or_context_id = 0; // IVA
    dbgbcr5.dbgbvr_unlinked_or_linked = 1; // linked
    dbgbcr5.linked_brp_num = 4;
    dbgbcr5.security_state_control = 0; // match in either security state
    dbgbcr5.byte_address_select = 0xf; // I don't understand why this exists.
    dbgbcr5.z4 = 0;
    dbgbcr5.privileged_mode_control = 0; // user, system, svc *but not* exception
    dbgbcr5.breakpoint_enable = 1; // woo
    
    dbgbvr5 = 0xdeadbeec; // asm will fill this in for single stepping
    
    dbgbcr4.z1 = 0;
    dbgbcr4.address_range_mask = 0; // exact (but it's step-two for thumb :()
    dbgbcr4.z2 = 0;
    dbgbcr4.dbgbvr_match_or_mismatch = 0; // match
    dbgbcr4.dbgbvr_iva_or_context_id = 1; // Context ID
    dbgbcr4.dbgbvr_unlinked_or_linked = 1;
    dbgbcr4.linked_brp_num = 5;
    dbgbcr4.security_state_control = 0;
    dbgbcr4.byte_address_select = 0xf;
    dbgbcr4.z4 = 0;
    dbgbcr4.privileged_mode_control = 0;
    dbgbcr4.breakpoint_enable = 1;

    IOLog("%08x %08x\n", dbgbcr5.val, dbgbcr4.val);

    // get current context ID
    asm("mrc p15, 0, %0, c13, c0, 1" :"=r"(dbgbvr4) :);
    
    begin_debug(); // interrupts disabled
    read_debug(197);
    uint32_t dbgdscr = read_debug(34);
    dbgdscr |= 0x8000; // turn on debug
    write_debug(34, dbgdscr);
    for(int i = 0; i < 16; i++) {
        write_debug(80 + i, 0);
        write_debug(112 + i, 0);
    }
    for(int i = 0; i < 16; i++) {
        uint32_t bvr = 0, bcr = 0;
        if(i == 4) {
            bvr = dbgbvr4;
            bcr = dbgbcr4.val;
        } else if(i == 5) {
            bvr = dbgbvr5;
            bcr = dbgbcr5.val;
        }
        write_debug(64 + i, bvr);
        write_debug(80 + i, bcr);
        write_debug(112 + i, read_debug(112 + i));
    }
    end_debug();
    
    return 0;
}