Port-i386 archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
mbr gpt crc32 calculation
dave0 in #NetBSD on Freenode suggested the attached replacement for
the crc32 subroutine in src/sys/arch/i386/stand/mbr/gpt.S, to save a
bit of space where speed is unimportant.
I don't have the capacity to test it and make sure it's the right
thing here, but it looks plausible. Could someone who is more
i386-wizardly than I am take a look at it?
/* I hereby place this file into the public domain. */
/* ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/i386/stand/mbr/gpt.S */
/* /src/sys/arch/i386/stand/mbr/gpt.S */
/* replace lines 419-457 inclusive */
#ifndef NO_CRC_CHECK
/*
* The CRC32 calculation
*
* %si address of block to hash
* %di stop address
* %cx counter
* %ebx crc (returned)
*/
crc32:
orl $-1, %ebx /* init value */
1:
xorb (%si), %bl /* xoring next message byte with previous result */
inc %si
movb $8, %cl /* set bit counter */
2:
shrl $1, %ebx
jnc 3f
crc32_poly = . + 3 /* gross, but saves a few bytes */
xorl $0xedb88320, %ebx /* EFI CRC32 Polynomial */
3:
loop 2b /* loop over bits */
cmp %di, %si /* do we reached end of message? */
jne 1b
notl %ebx /* result correction */
ret
#endif
Home |
Main Index |
Thread Index |
Old Index