mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
arch/intel64: format asm files, remove unused debug macros
use tab at the beginning of lines, remove C++ comments, fix some tabs to spaces Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
This commit is contained in:
committed by
Xiang Xiao
parent
1b7ddab317
commit
f76017ca8a
@@ -26,45 +26,13 @@
|
||||
#include <arch/irq.h>
|
||||
#include "x86_64_internal.h"
|
||||
|
||||
.file "intel64_fullcontextrestore.S"
|
||||
|
||||
/**************************************************************************
|
||||
* Pre-processor Definitions
|
||||
**************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* Public Data
|
||||
**************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Macros
|
||||
****************************************************************************/
|
||||
|
||||
/* Trace macros, use like trace 'i' to print char to serial port. */
|
||||
|
||||
.macro chout, addr, ch
|
||||
#ifdef CONFIG_DEBUG_FEATURES
|
||||
mov $\addr, %dx
|
||||
mov $\ch, %al
|
||||
out %al, %dx
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.macro trace, ch
|
||||
#ifdef CONFIG_DEBUG_FEATURES
|
||||
push %eax
|
||||
push %edx
|
||||
chout 0x3f8, \ch
|
||||
pop %edx
|
||||
pop %eax
|
||||
#endif
|
||||
.endm
|
||||
.file "intel64_fullcontextrestore.S"
|
||||
|
||||
/**************************************************************************
|
||||
* Public Functions
|
||||
**************************************************************************/
|
||||
|
||||
.text
|
||||
.text
|
||||
|
||||
/**************************************************************************
|
||||
* Name: x86_64_fullcontextrestore
|
||||
@@ -74,84 +42,85 @@
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
.globl x86_64_fullcontextrestore
|
||||
.type x86_64_fullcontextrestore, @function
|
||||
.globl x86_64_fullcontextrestore
|
||||
.type x86_64_fullcontextrestore, @function
|
||||
x86_64_fullcontextrestore:
|
||||
/* The pointer to the register save array in RDI. */
|
||||
/* The pointer to the register save array in RDI. */
|
||||
|
||||
/* Disable interrupts now (the correct RFLAGS will be restored before we
|
||||
* return
|
||||
*/
|
||||
/* Disable interrupts now (the correct RFLAGS will be restored before we
|
||||
* return
|
||||
*/
|
||||
|
||||
cli
|
||||
cli
|
||||
|
||||
/* Create an interrupt stack frame for the final iret.
|
||||
*
|
||||
*
|
||||
* IRET STACK
|
||||
* ---------------
|
||||
* RSP Before ->
|
||||
* SS
|
||||
* RSP
|
||||
* RFLAGS
|
||||
* CS
|
||||
* RSP After -> RIP
|
||||
*
|
||||
*/
|
||||
/* Create an interrupt stack frame for the final iret.
|
||||
*
|
||||
*
|
||||
* IRET STACK
|
||||
* ---------------
|
||||
* RSP Before ->
|
||||
* SS
|
||||
* RSP
|
||||
* RFLAGS
|
||||
* CS
|
||||
* RSP After -> RIP
|
||||
*
|
||||
*/
|
||||
|
||||
movq (8*REG_SS)(%rdi), %rbx
|
||||
push %rbx
|
||||
movq (8*REG_RSP)(%rdi), %rbx
|
||||
push %rbx
|
||||
movq (8*REG_SS)(%rdi), %rbx
|
||||
push %rbx
|
||||
movq (8*REG_RSP)(%rdi), %rbx
|
||||
push %rbx
|
||||
|
||||
movq (8*REG_RFLAGS)(%rdi), %rbx
|
||||
push %rbx
|
||||
movq (8*REG_CS)(%rdi), %rbx
|
||||
push %rbx
|
||||
movq (8*REG_RIP)(%rdi), %rbx
|
||||
push %rbx
|
||||
movq (8*REG_RFLAGS)(%rdi), %rbx
|
||||
push %rbx
|
||||
movq (8*REG_CS)(%rdi), %rbx
|
||||
push %rbx
|
||||
movq (8*REG_RIP)(%rdi), %rbx
|
||||
push %rbx
|
||||
|
||||
/* Save the value of RDI on the stack too */
|
||||
/* Save the value of RDI on the stack too */
|
||||
|
||||
movq (8*REG_RDI)(%rdi), %rbx
|
||||
push %rbx
|
||||
movq (8*REG_RDI)(%rdi), %rbx
|
||||
push %rbx
|
||||
|
||||
/* Now restore the remaining registers */
|
||||
movq (8*REG_RSI)(%rdi), %rsi
|
||||
movq (8*REG_RDX)(%rdi), %rdx
|
||||
movq (8*REG_RCX)(%rdi), %rcx
|
||||
movq (8*REG_R8 )(%rdi), %r8
|
||||
movq (8*REG_R9 )(%rdi), %r9
|
||||
/* Now restore the remaining registers */
|
||||
movq (8*REG_RSI)(%rdi), %rsi
|
||||
movq (8*REG_RDX)(%rdi), %rdx
|
||||
movq (8*REG_RCX)(%rdi), %rcx
|
||||
movq (8*REG_R8 )(%rdi), %r8
|
||||
movq (8*REG_R9 )(%rdi), %r9
|
||||
|
||||
movq (8*REG_R15)(%rdi), %r15
|
||||
movq (8*REG_R14)(%rdi), %r14
|
||||
movq (8*REG_R13)(%rdi), %r13
|
||||
movq (8*REG_R12)(%rdi), %r12
|
||||
movq (8*REG_R11)(%rdi), %r11
|
||||
movq (8*REG_R10)(%rdi), %r10
|
||||
movq (8*REG_RBP)(%rdi), %rbp
|
||||
movq (8*REG_RBX)(%rdi), %rbx
|
||||
movq (8*REG_RAX)(%rdi), %rax
|
||||
movq (8*REG_R15)(%rdi), %r15
|
||||
movq (8*REG_R14)(%rdi), %r14
|
||||
movq (8*REG_R13)(%rdi), %r13
|
||||
movq (8*REG_R12)(%rdi), %r12
|
||||
movq (8*REG_R11)(%rdi), %r11
|
||||
movq (8*REG_R10)(%rdi), %r10
|
||||
movq (8*REG_RBP)(%rdi), %rbp
|
||||
movq (8*REG_RBX)(%rdi), %rbx
|
||||
movq (8*REG_RAX)(%rdi), %rax
|
||||
|
||||
/* Restore the data segment register. I think there is an issue that will
|
||||
* need to be address here at some time: If the register save area is in
|
||||
* one data segment and the stack is in another, then the above would not
|
||||
* work (and, conversely, if they are in the same data segment, the
|
||||
* following is unnecessary and redundant).
|
||||
*/
|
||||
/* Restore the data segment register. I think there is an issue that will
|
||||
* need to be address here at some time: If the register save area is in
|
||||
* one data segment and the stack is in another, then the above would not
|
||||
* work (and, conversely, if they are in the same data segment, the
|
||||
* following is unnecessary and redundant).
|
||||
*/
|
||||
|
||||
mov (8*REG_DS)(%rdi), %ds
|
||||
// mov (8*REG_ES)(%rdi), %es // Not used in 64 bit
|
||||
// mov (8*REG_GS)(%rdi), %gs // Disabled, otherwise we will destroy MSR_GS_BASE
|
||||
// mov (8*REG_FS)(%rdi), %fs // Disabled, otherwise we will destroy MSR_FS_BASE
|
||||
// XXX: Should use wrgsbase and wrfsbase to restore the gs and fs register
|
||||
mov (8*REG_DS)(%rdi), %ds
|
||||
/* mov (8*REG_ES)(%rdi), %es // Not used in 64 bit
|
||||
* mov (8*REG_GS)(%rdi), %gs // Disabled, otherwise we will destroy MSR_GS_BASE
|
||||
* mov (8*REG_FS)(%rdi), %fs // Disabled, otherwise we will destroy MSR_FS_BASE
|
||||
* XXX: Should use wrgsbase and wrfsbase to restore the gs and fs register
|
||||
*/
|
||||
|
||||
/* restore xmm registers */
|
||||
fxrstorq (%rdi)
|
||||
/* restore xmm registers */
|
||||
fxrstorq (%rdi)
|
||||
|
||||
/* Restore the correct value of EAX and then return */
|
||||
/* Restore the correct value of EAX and then return */
|
||||
|
||||
popq %rdi
|
||||
iretq
|
||||
.size x86_64_fullcontextrestore, . - x86_64_fullcontextrestore
|
||||
.end
|
||||
popq %rdi
|
||||
iretq
|
||||
.size x86_64_fullcontextrestore, . - x86_64_fullcontextrestore
|
||||
.end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,42 +26,15 @@
|
||||
#include <arch/irq.h>
|
||||
#include "x86_64_internal.h"
|
||||
|
||||
.file "intel64_saveusercontext.S"
|
||||
|
||||
/**************************************************************************
|
||||
* Pre-processor Definitions
|
||||
**************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Macros
|
||||
****************************************************************************/
|
||||
|
||||
/* Trace macros, use like trace 'i' to print char to serial port. */
|
||||
|
||||
.macro chout, addr, ch
|
||||
#ifdef CONFIG_DEBUG_FEATURES
|
||||
mov $\addr, %dx
|
||||
mov $\ch, %al
|
||||
out %al, %dx
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.macro trace, ch
|
||||
#ifdef CONFIG_DEBUG_FEATURES
|
||||
push %eax
|
||||
push %edx
|
||||
chout 0x3f8, \ch
|
||||
pop %edx
|
||||
pop %eax
|
||||
#endif
|
||||
.endm
|
||||
.file "intel64_saveusercontext.S"
|
||||
|
||||
/**************************************************************************
|
||||
* .text
|
||||
**************************************************************************/
|
||||
|
||||
.text
|
||||
.code64
|
||||
.text
|
||||
.code64
|
||||
|
||||
/**************************************************************************
|
||||
* Name: up_saveusercontext
|
||||
*
|
||||
@@ -84,66 +57,66 @@
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
.globl up_saveusercontext
|
||||
.type up_saveusercontext, @function
|
||||
.globl up_saveusercontext
|
||||
.type up_saveusercontext, @function
|
||||
up_saveusercontext:
|
||||
|
||||
// callee saved regs
|
||||
movq %rbx, (8*REG_RBX)(%rdi)
|
||||
movq %r12, (8*REG_R12)(%rdi)
|
||||
movq %r13, (8*REG_R13)(%rdi)
|
||||
movq %r14, (8*REG_R14)(%rdi)
|
||||
movq %r15, (8*REG_R15)(%rdi)
|
||||
/* callee saved regs */
|
||||
movq %rbx, (8*REG_RBX)(%rdi)
|
||||
movq %r12, (8*REG_R12)(%rdi)
|
||||
movq %r13, (8*REG_R13)(%rdi)
|
||||
movq %r14, (8*REG_R14)(%rdi)
|
||||
movq %r15, (8*REG_R15)(%rdi)
|
||||
|
||||
// save xmm registers
|
||||
fxsaveq (%rdi)
|
||||
/* save xmm registers */
|
||||
fxsaveq (%rdi)
|
||||
|
||||
/* Save the value of SP as will be at the time of the IRET that will
|
||||
* appear to be the return from this function.
|
||||
*
|
||||
* CURRENT STACK IRET STACK
|
||||
* ------------------------------ -----------------
|
||||
* RIP
|
||||
* CS
|
||||
* RFLAGS
|
||||
* RSP
|
||||
* ESP->Return address SS
|
||||
* Argument Alignment (16bytes)
|
||||
*
|
||||
*/
|
||||
/* Save the value of SP as will be at the time of the IRET that will
|
||||
* appear to be the return from this function.
|
||||
*
|
||||
* CURRENT STACK IRET STACK
|
||||
* ------------------------------ -----------------
|
||||
* RIP
|
||||
* CS
|
||||
* RFLAGS
|
||||
* RSP
|
||||
* ESP->Return address SS
|
||||
* Argument Alignment (16bytes)
|
||||
*
|
||||
*/
|
||||
|
||||
leaq 8(%rsp), %rcx
|
||||
movq %rcx, (8*REG_RSP)(%rdi)
|
||||
leaq 8(%rsp), %rcx
|
||||
movq %rcx, (8*REG_RSP)(%rdi)
|
||||
|
||||
/* Fetch the PC from the stack and save it in the save block */
|
||||
/* Fetch the PC from the stack and save it in the save block */
|
||||
|
||||
movq 0(%rsp), %rcx
|
||||
movq %rcx, (8*REG_RIP)(%rdi)
|
||||
movq 0(%rsp), %rcx
|
||||
movq %rcx, (8*REG_RIP)(%rdi)
|
||||
|
||||
/* Save the framepointer */
|
||||
/* Save the framepointer */
|
||||
|
||||
movq %rbp, (8*REG_RBP)(%rdi)
|
||||
movq %rbp, (8*REG_RBP)(%rdi)
|
||||
|
||||
/* Save EAX=1. This will be the "apparent" return value from this
|
||||
* function when context is switch back to this thread. The non-zero
|
||||
* return value is the indication that we have been resumed.
|
||||
*/
|
||||
/* Save EAX=1. This will be the "apparent" return value from this
|
||||
* function when context is switch back to this thread. The non-zero
|
||||
* return value is the indication that we have been resumed.
|
||||
*/
|
||||
|
||||
movq $1, (8*REG_RAX)(%rdi)
|
||||
movq $1, (8*REG_RAX)(%rdi)
|
||||
|
||||
/* Get and save the interrupt state */
|
||||
/* Get and save the interrupt state */
|
||||
|
||||
pushf
|
||||
pop %rcx
|
||||
movq %rcx, (8*REG_RFLAGS)(%rdi)
|
||||
pushf
|
||||
pop %rcx
|
||||
movq %rcx, (8*REG_RFLAGS)(%rdi)
|
||||
|
||||
/* And return 0 -- The zero return value is the indication that that
|
||||
* this is the original, "true" return from the function.
|
||||
*
|
||||
* 'ret' will remove the RIP from the top of the stack.
|
||||
*/
|
||||
/* And return 0 -- The zero return value is the indication that that
|
||||
* this is the original, "true" return from the function.
|
||||
*
|
||||
* 'ret' will remove the RIP from the top of the stack.
|
||||
*/
|
||||
|
||||
xor %rax, %rax
|
||||
ret
|
||||
.size up_saveusercontext, . - up_saveusercontext
|
||||
.end
|
||||
xor %rax, %rax
|
||||
ret
|
||||
.size up_saveusercontext, . - up_saveusercontext
|
||||
.end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user