arch/loongarch/kernel/lbt.S

Source file repositories/reference/linux-study-clean/arch/loongarch/kernel/lbt.S

File Facts

System
Linux kernel
Corpus path
arch/loongarch/kernel/lbt.S
Extension
.S
Size
3189 bytes
Lines
163
Domain
Architecture Layer
Bucket
arch/loongarch
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration 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

#include <asm/asm.h>
#include <asm/asmmacro.h>
#include <asm/asm-extable.h>
#include <asm/asm-offsets.h>
#include <asm/errno.h>
#include <asm/regdef.h>
#include <asm/unwind_hints.h>

#define SCR_REG_WIDTH 8

	.macro	EX insn, reg, src, offs
.ex\@:	\insn	\reg, \src, \offs
	_asm_extable .ex\@, .L_lbt_fault
	.endm

/*
 * Save a thread's lbt context.
 */
SYM_FUNC_START(_save_lbt)
	movscr2gr	t1, $scr0		# save scr
	stptr.d		t1, a0, THREAD_SCR0
	movscr2gr	t1, $scr1
	stptr.d		t1, a0, THREAD_SCR1
	movscr2gr	t1, $scr2
	stptr.d		t1, a0, THREAD_SCR2
	movscr2gr	t1, $scr3
	stptr.d		t1, a0, THREAD_SCR3

	x86mfflag	t1, 0x3f		# save eflags
	stptr.d		t1, a0, THREAD_EFLAGS
	jr		ra
SYM_FUNC_END(_save_lbt)
EXPORT_SYMBOL(_save_lbt)

/*
 * Restore a thread's lbt context.
 */
SYM_FUNC_START(_restore_lbt)
	ldptr.d		t1, a0, THREAD_SCR0	# restore scr
	movgr2scr	$scr0, t1
	ldptr.d		t1, a0, THREAD_SCR1
	movgr2scr	$scr1, t1
	ldptr.d		t1, a0, THREAD_SCR2
	movgr2scr	$scr2, t1
	ldptr.d		t1, a0, THREAD_SCR3
	movgr2scr	$scr3, t1

	ldptr.d		t1, a0, THREAD_EFLAGS	# restore eflags
	x86mtflag	t1, 0x3f
	jr		ra
SYM_FUNC_END(_restore_lbt)
EXPORT_SYMBOL(_restore_lbt)

/*
 * Load scr/eflag with zero.
 */
SYM_FUNC_START(_init_lbt)
	movgr2scr	$scr0, zero
	movgr2scr	$scr1, zero
	movgr2scr	$scr2, zero
	movgr2scr	$scr3, zero

	x86mtflag	zero, 0x3f
	jr		ra
SYM_FUNC_END(_init_lbt)

/*
 * a0: scr
 * a1: eflag
 */

Annotation

Implementation Notes