📄 vxalib.s
字号:
/* vxALib.s - i80x86 miscellaneous assembly routines *//* Copyright 1984-1993 Wind River Systems, Inc. */ .data .globl _copyright_wind_river .long _copyright_wind_river/*modification history --------------------01c,01jun93,hdn updated to 5.1. - fixed #else and #endif - changed VOID to void - changed ASMLANGUAGE to _ASMLANGUAGE - changed copyright notice01a,03mar92,hdn written based on TRON, 68k version.*//*DESCRIPTIONThis module contains miscellaneous VxWorks support routines for theI80x86 family of processors.SEE ALSO: vxLib*/#define _ASMLANGUAGE#include "vxWorks.h"#include "asm.h" /* internals */ .globl _vxMemProbeSup .globl _vxMemProbeTrap .globl _vxTas .text .align 4/********************************************************************************* vxMemProbeSup - vxMemProbe support routine** This routine is called to try to read byte, word, or long, as specified* by length, from the specified source to the specified destination.** NOMANUAL* STATUS vxMemProbeSup (length, src, dest)* int length; /* length of cell to test (1, 2, 4) ** char *src; /* address to read ** char *dest; /* address to write **/_vxMemProbeSup: pushl %ebp movl %esp,%ebp pushl %ebx /* save non-volatile registers */ pushl %esi pushl %edi movl ARG2(%ebp),%esi /* get source address */ movl ARG3(%ebp),%edi /* get destination address */ xorl %eax,%eax /* preset status = OK */ movl ARG1(%ebp),%edx /* get length */ cmpl $1,%edx jne vmp10 movb (%esi),%bl /* read byte */ movb %bl,(%edi) /* write byte */ jmp vmpRtn .align 4,0x90vmp10: cmp $2,%edx jne vmp20 movw (%esi),%bx /* read word */ movw %bx,(%edi) /* write word */ jmp vmpRtn .align 4,0x90vmp20: movl (%esi),%ebx /* read long */ movl %ebx,(%edi) /* write long */ /* NOTE: vmpRtn is known by vxMemProbTrap to stop retry */vmpRtn: popl %edi /* restore non-volatile registers */ popl %esi popl %ebx leave ret/********************************************************************************* vxMemProbeTrap - vxMemProbe support routine** This entry point is momentarily attached to the bus error exception vector.* It simply sets %eax to ERROR to indicate that* the general protection fault did occur, and returns from the interrupt.** NOTE:* The instruction that caused the general protection fault must not be run * again so we have to set some special bits in the exception stack frame.** NOMANUAL** void vxMemProbeTrap()*/ .align 4,0x90_vxMemProbeTrap: /* we get here via the general protection fault */ addl $8,%esp pushl $vmpRtn /* patch return address, EIP */ movl $-1,%eax /* set status to ERROR */ iret /* return to the subroutine *//******************************************************************************** * vxTas - C-callable atomic test-and-set primitive** This routine provides a C-callable interface to the test-and-set* instruction. The LOCK-BTS instruction is executed on the specified* address.** RETURNS:* TRUE if value had been not set, but is now,* FALSE if the value was set already.* BOOL vxTas (address)* char *address; /* address to be tested **/ .align 4,0x90_vxTas: xorl %eax,%eax /* set status to FALSE */ movl 4(%esp),%edx /* get address */ lock bts $0,(%edx) /* XXX set MSB with bus-lock */ jc vxT1 incl %eax /* set status to TRUE */vxT1: ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -