arch/sparc/kernel/kgdb_64.c

Source file repositories/reference/linux-study-clean/arch/sparc/kernel/kgdb_64.c

File Facts

System
Linux kernel
Corpus path
arch/sparc/kernel/kgdb_64.c
Extension
.c
Size
4618 bytes
Lines
202
Domain
Architecture Layer
Bucket
arch/sparc
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

if (kgdb_hex2long(&ptr, &addr)) {
			linux_regs->tpc = addr;
			linux_regs->tnpc = addr + 4;
		}
		fallthrough;

	case 'D':
	case 'k':
		if (linux_regs->tpc == (unsigned long) arch_kgdb_breakpoint) {
			linux_regs->tpc = linux_regs->tnpc;
			linux_regs->tnpc += 4;
		}
		return 0;
	}
	return -1;
}

asmlinkage void kgdb_trap(unsigned long trap_level, struct pt_regs *regs)
{
	enum ctx_state prev_state = exception_enter();
	unsigned long flags;

	if (user_mode(regs)) {
		bad_trap(regs, trap_level);
		goto out;
	}

	flushw_all();

	local_irq_save(flags);
	kgdb_handle_exception(0x172, SIGTRAP, 0, regs);
	local_irq_restore(flags);
out:
	exception_exit(prev_state);
}

int kgdb_arch_init(void)
{
	return 0;
}

void kgdb_arch_exit(void)
{
}

void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long ip)
{
	regs->tpc = ip;
	regs->tnpc = regs->tpc + 4;
}

const struct kgdb_arch arch_kgdb_ops = {
	/* Breakpoint instruction: ta 0x72 */
	.gdb_bpt_instr		= { 0x91, 0xd0, 0x20, 0x72 },
};

Annotation

Implementation Notes