#include <machine/specialreg.h>
ENTRY(mdrandom)
+ pushal
+
// See if we have CPU identification.
pushfl
popl %eax
movl $0, %ecx
cpuid
- movl 4(%esp), %ebx
- movl 8(%esp), %edx
+ movl 36(%esp), %ebx
+ movl 40(%esp), %edx
shrl $2, %edx
shll $2, %edx
xorl %edi, %edi
addl $4, %edi
cmpl %edi, %edx
jne userand
- ret
+ jmp done
usetsc:
rdtsc // Populates edx:eax.
addl $4, %edi
cmpl %edi, %ecx
jne usetsc
- ret
+ jmp done
done:
+ popal
ret
#include <machine/specialreg.h>
ENTRY(mdrandom)
+ pushal
+
// See if we have CPU identification.
pushfl
popl %eax
movl $0, %ecx
cpuid
- movl 4(%esp), %ebx
- movl 8(%esp), %edx
+ movl 36(%esp), %ebx
+ movl 40(%esp), %edx
shrl $2, %edx
shll $2, %edx
xorl %edi, %edi
addl $4, %edi
cmpl %edi, %edx
jne userand
- ret
+ jmp done
usetsc:
rdtsc // Populates edx:eax.
addl $4, %edi
cmpl %edi, %ecx
jne usetsc
- ret
+ jmp done
done:
+ popal
ret