Changeset View
Changeset View
Standalone View
Standalone View
sys/i386/include/asmacros.h
/* -*- mode: asm -*- */ | |||||
/*- | /*- | ||||
* SPDX-License-Identifier: BSD-3-Clause | * SPDX-License-Identifier: BSD-3-Clause | ||||
* | * | ||||
* Copyright (c) 1993 The Regents of the University of California. | * Copyright (c) 1993 The Regents of the University of California. | ||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | |||||
#define ENTRY(name) GEN_ENTRY(name) | #define ENTRY(name) GEN_ENTRY(name) | ||||
#define FAKE_MCOUNT(caller) | #define FAKE_MCOUNT(caller) | ||||
#define MCOUNT | #define MCOUNT | ||||
#define MCOUNT_LABEL(name) | #define MCOUNT_LABEL(name) | ||||
#define MEXITCOUNT | #define MEXITCOUNT | ||||
#endif /* GPROF */ | #endif /* GPROF */ | ||||
#ifdef LOCORE | #ifdef LOCORE | ||||
#define GSEL_KPL 0x0020 /* GSEL(GCODE_SEL, SEL_KPL) */ | |||||
#define SEL_RPL_MASK 0x0003 | |||||
/* | /* | ||||
* Convenience macro for declaring interrupt entry points. | * Convenience macro for declaring interrupt entry points. | ||||
*/ | */ | ||||
#define IDTVEC(name) ALIGN_TEXT; .globl __CONCAT(X,name); \ | #define IDTVEC(name) ALIGN_TEXT; .globl __CONCAT(X,name); \ | ||||
.type __CONCAT(X,name),@function; __CONCAT(X,name): | .type __CONCAT(X,name),@function; __CONCAT(X,name): | ||||
/* | /* | ||||
* Macros to create and destroy a trap frame. | * Macros to create and destroy a trap frame. | ||||
*/ | */ | ||||
#define PUSH_FRAME \ | .macro PUSH_FRAME2 | ||||
pushl $0 ; /* dummy error code */ \ | pushal | ||||
pushl $0 ; /* dummy trap type */ \ | pushl $0 | ||||
pushal ; /* 8 ints */ \ | movw %ds,(%esp) | ||||
pushl $0 ; /* save data and extra segments ... */ \ | pushl $0 | ||||
movw %ds,(%esp) ; \ | movw %es,(%esp) | ||||
pushl $0 ; \ | pushl $0 | ||||
movw %es,(%esp) ; \ | |||||
pushl $0 ; \ | |||||
movw %fs,(%esp) | movw %fs,(%esp) | ||||
.endm | |||||
.macro PUSH_FRAME | |||||
pushl $0 /* dummy error code */ | |||||
pushl $0 /* dummy trap type */ | |||||
PUSH_FRAME2 | |||||
.endm | |||||
/* | /* | ||||
* Access per-CPU data. | * Access per-CPU data. | ||||
*/ | */ | ||||
#define PCPU(member) %fs:PC_ ## member | #define PCPU(member) %fs:PC_ ## member | ||||
#define PCPU_ADDR(member, reg) \ | #define PCPU_ADDR(member, reg) \ | ||||
movl %fs:PC_PRVSPACE, reg ; \ | movl %fs:PC_PRVSPACE, reg ; \ | ||||
addl $PC_ ## member, reg | addl $PC_ ## member, reg | ||||
/* | /* | ||||
* Setup the kernel segment registers. | * Setup the kernel segment registers. | ||||
*/ | */ | ||||
#define SET_KERNEL_SREGS \ | .macro SET_KERNEL_SREGS | ||||
movl $KDSEL, %eax ; /* reload with kernel's data segment */ \ | movl $KDSEL, %eax /* reload with kernel's data segment */ | ||||
movl %eax, %ds ; \ | movl %eax, %ds | ||||
movl %eax, %es ; \ | movl %eax, %es | ||||
movl $KPSEL, %eax ; /* reload with per-CPU data segment */ \ | movl $KPSEL, %eax /* reload with per-CPU data segment */ | ||||
movl %eax, %fs | movl %eax, %fs | ||||
.endm | |||||
.macro NMOVE_STACKS | |||||
movl PCPU(KESP0), %edx | |||||
movl $TF_SZ, %ecx | |||||
subl %ecx, %edx | |||||
movl %edx, %edi | |||||
movl %esp, %esi | |||||
rep; movsb | |||||
movl %edx, %esp | |||||
.endm | |||||
.macro MOVE_STACKS | |||||
call 1000f | |||||
1000: popl %eax | |||||
movl (tramp_idleptd - 1000b)(%eax), %eax | |||||
movl %eax, %cr3 | |||||
NMOVE_STACKS | |||||
.endm | |||||
.macro KENTER | |||||
/* XXXKIB vm86 */ | |||||
testb $SEL_RPL_MASK, TF_CS(%esp) | |||||
jz 1f | |||||
MOVE_STACKS | |||||
1: | |||||
.endm | |||||
#endif /* LOCORE */ | #endif /* LOCORE */ | ||||
#ifdef __STDC__ | #ifdef __STDC__ | ||||
#define ELFNOTE(name, type, desctype, descdata...) \ | #define ELFNOTE(name, type, desctype, descdata...) \ | ||||
.pushsection .note.name ; \ | .pushsection .note.name ; \ | ||||
.align 4 ; \ | .align 4 ; \ | ||||
.long 2f - 1f /* namesz */ ; \ | .long 2f - 1f /* namesz */ ; \ | ||||
Show All 22 Lines |