git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix build error by adding -fno-stack-protector to CFLAGS in usr/LBuild (#63)
[lunaix-os.git]
/
lunaix-os
/
arch
/
x86
/
hal
/
rngx86.c
diff --git
a/lunaix-os/arch/x86/hal/rngx86.c
b/lunaix-os/arch/x86/hal/rngx86.c
index 0d48d440624bd4cc8ba6a5529ea9e86a08253b5e..2baf96c50b3edf57ca019dd5ad8f5ff76a954b9c 100644
(file)
--- a/
lunaix-os/arch/x86/hal/rngx86.c
+++ b/
lunaix-os/arch/x86/hal/rngx86.c
@@
-8,22
+8,24
@@
rng_fill(void* data, size_t len)
{
#ifdef CONFIG_ARCH_X86_64
asm volatile("1:\n"
{
#ifdef CONFIG_ARCH_X86_64
asm volatile("1:\n"
+ "subq $8, %1\n"
"rdrand %%rax\n"
"rdrand %%rax\n"
- "movq %%rax, (%0)\n"
+ "movq %%rax, (%0
, %1, 1
)\n"
"addq $8, %%rax\n"
"addq $8, %%rax\n"
- "
subq $8
, %1\n"
+ "
testq %1
, %1\n"
"jnz 1b"
::
"r"((ptr_t)data),
"r"((len & ~0x7))
:
"jnz 1b"
::
"r"((ptr_t)data),
"r"((len & ~0x7))
:
- "
%e
ax");
+ "
r
ax");
#else
asm volatile("1:\n"
#else
asm volatile("1:\n"
+ "subl $4, %1\n"
"rdrand %%eax\n"
"rdrand %%eax\n"
- "movl %%eax, (%0)\n"
+ "movl %%eax, (%0
, %1, 1
)\n"
"addl $4, %%eax\n"
"addl $4, %%eax\n"
- "
subl $4
, %1\n"
+ "
testl %1
, %1\n"
"jnz 1b"
::
"r"((ptr_t)data),
"jnz 1b"
::
"r"((ptr_t)data),
@@
-54,7
+56,7
@@
__rand_rd(struct device* dev, void* buf, size_t offset, size_t len)
}
int
}
int
-pdev_randdev_
init(struct device_def* devdef
)
+pdev_randdev_
create(struct device_def* devdef, morph_t* obj
)
{
// FIXME add check on cpuid for presence of rdrand
struct device* devrand = device_allocseq(NULL, NULL);
{
// FIXME add check on cpuid for presence of rdrand
struct device* devrand = device_allocseq(NULL, NULL);
@@
-67,7
+69,8
@@
pdev_randdev_init(struct device_def* devdef)
}
static struct device_def devrandx86_def = {
}
static struct device_def devrandx86_def = {
- .name = "x86 On-Chip RNG",
- .class = DEVCLASS(DEVIF_SOC, DEVFN_CHAR, DEV_RNG),
- .init = pdev_randdev_init};
+ def_device_class(INTEL, CHAR, RNG),
+ def_device_name("x86 On-Chip RNG"),
+ def_on_create(pdev_randdev_create)
+};
EXPORT_DEVICE(randdev, &devrandx86_def, load_onboot);
\ No newline at end of file
EXPORT_DEVICE(randdev, &devrandx86_def, load_onboot);
\ No newline at end of file