📄 xllp_checksum.s
字号:
;******************************************************************************
;
; COPYRIGHT (C) 2005 Intel Corporation.
;
; This software as well as the software described in it is furnished under
; license and may only be used or copied in accordance with the terms of the
; license. The information in this file is furnished for informational use
; only, is subject to change without notice, and should not be construed as
; a commitment by Intel Corporation. Intel Corporation assumes no
; responsibility or liability for any errors or inaccuracies that may appear
; in this document or any software that may be provided in association with
; this document.
;
; Except as permitted by such license, no part of this document may be
; reproduced, stored in a retrieval system, or transmitted in any form or by
; any means without the express written consent of Intel Corporation.
;
;******************************************************************************
; PURPOSE:
; Checksum routine(s) for use by assembler and C code
; It was created initially primarily to contain functions that may be needed
; by both boot and kernel code.
; If such routines exist in modules that make external references to other modules,
; unresolved references are prone to be reported by the linker.
; When the linker needs to pull in a module to resolve an external reference
; it needs to resolve all external references in that module as well.
; Functions in this file should therefore not make external references.
AREA |.text|, CODE, READONLY, ALIGN=5 ; Align =5 required for "ALIGN 32" to work
;
INCLUDE xllp_ARM_macros.inc ; for RETURN macro
; Functions made public by this file:
;
EXPORT Xllp_SimpleChecksum
; This function is linked into both the boot loaders and the kernel image.
; 1. in resume code that is linked into the boot loader(s)
; 2. in suspend code that is linked into the kernel image
; It does not assume existance of a stack.
; However, if the SP is not zero it is assumed to be valid and registers used are preserved on the stack.
Xllp_SimpleChecksum FUNCTION
; Args:
; r0 = buffer address
; r1 = number of words
; Reg Use:
; r0 = accumlating checksum (and checksum returned)
; r1 = words left
; r2 = pointer to next buffer word
; r3 = current buffer word value
;
; if SP is non-zero save the registers we'll use
cmp sp, #0
stmnedb sp!, {r1-r4, lr} ; Push entry mode state onto our stack
mov r2, r0 ; buffer pointer
ldr r0, =(0x5A72) ; Pick a non-zero seed.
2
ldr r3, [r2], #4 ; get value and increment pointer
add r0, r0, r3
mov r0, r0, ROR #31 ; Rotate left by one bit position
subs r1, r1, #1 ; decrement words left
bne %B2
; if SP is non-zero restore regs we saved
cmp sp, #0
ldmneia sp!, {r1-r4, lr} ; Restore regs we used
RETURN
ENDFUNC
;**************************************************************************************************
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -