intrlock.src

来自「WinCE5.0部分核心源码」· SRC 代码 · 共 74 行

SRC
74
字号
;
; Copyright (c) Microsoft Corporation.  All rights reserved.
;
;
; This source code is licensed under Microsoft Shared Source License
; Version 1.0 for Windows CE.
; For a copy of the license visit http://go.microsoft.com/fwlink/?LinkId=3223.
;
    .HEADING "Interlock memory operations"
    .FORM LINES=55
;++
;
;
; Module Name:
;
;    intrlock.src
;
; Abstract:
;
;    This module implements the InterlockedIncrement, I...Decrement,
; I...Exchange and I...TestExchange APIs.
;
;    WARNING: This module jumps to well known code in the kernel data page to
; perform the interlocked operations.  The kernel exception handlers know the
; locations of those routines so that it can perform any necessary restarts in
; case of an interrupt or an exception.
;
; Environment:
;
;    Kernel mode or User mode.
;
; Revision History:
;
;--
    .include "ksshx.h"

    LEAF_ENTRY InterlockAPIs
    ALTERNATE_ENTRY _InterlockedExchange
    mov #USER_KPAGE+h'3c0, r0
    jmp @r0
    nop

    ALTERNATE_ENTRY _InterlockedTestExchange
    mov	r5, r0		;\ 
    mov	r6, r5		; > swap 2nd & 3rd arguments
    mov	r0, r6		;/
    ALTERNATE_ENTRY _InterlockedCompareExchange
    mov #USER_KPAGE+h'3d0, r0
    jmp @r0
    nop

    ALTERNATE_ENTRY _InterlockedIncrement
    mov #USER_KPAGE+h'3e0, r0
    jmp @r0
    nop

    ALTERNATE_ENTRY _InterlockedExchangeAdd
    mov #USER_KPAGE+h'3f0, r0
    jmp @r0
    nop
    .endf

    NESTED_ENTRY _InterlockedDecrement
    mov #USER_KPAGE+h'3f0, r0
    sts PR, r3          ; save return address
    PROLOG_END
    jsr @r0             ; InterlockedExchangeAdd(addend, -1)
    mov	#-1, r5
    jmp @r3             ; return to original caller
    add	#-1, r0         ; adjust for correct return value
    .endf

    .end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?