Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/stand/prekern Add cpuid and rdseed.



details:   https://anonhg.NetBSD.org/src/rev/d0fe3ca974e5
branches:  trunk
changeset: 357427:d0fe3ca974e5
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri Nov 10 08:05:38 2017 +0000

description:
Add cpuid and rdseed.

diffstat:

 sys/arch/amd64/stand/prekern/locore.S  |  31 +++++++++++++++++++++++++++++--
 sys/arch/amd64/stand/prekern/prekern.h |   4 +++-
 2 files changed, 32 insertions(+), 3 deletions(-)

diffs (77 lines):

diff -r f25d14b480df -r d0fe3ca974e5 sys/arch/amd64/stand/prekern/locore.S
--- a/sys/arch/amd64/stand/prekern/locore.S     Fri Nov 10 07:25:39 2017 +0000
+++ b/sys/arch/amd64/stand/prekern/locore.S     Fri Nov 10 08:05:38 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.3 2017/10/29 11:28:30 maxv Exp $  */
+/*     $NetBSD: locore.S,v 1.4 2017/11/10 08:05:38 maxv Exp $  */
 
 /*
  * Copyright (c) 1998, 2000, 2007, 2008, 2016, 2017 The NetBSD Foundation, Inc.
@@ -583,9 +583,24 @@
 
 /* -------------------------------------------------------------------------- */
 
+ENTRY(cpuid)
+       movq    %rbx,%r8
+       movq    %rdi,%rax
+       movq    %rsi,%rcx
+       movq    %rdx,%rsi
+       cpuid
+       movl    %eax,0(%rsi)
+       movl    %ebx,4(%rsi)
+       movl    %ecx,8(%rsi)
+       movl    %edx,12(%rsi)
+       movq    %r8,%rbx
+       ret
+END(cpuid)
+
 ENTRY(lidt)
        lidt    (%rdi)
        ret
+END(lidt)
 
 ENTRY(rdtsc)
        xorq    %rax,%rax
@@ -593,9 +608,21 @@
        shlq    $32,%rdx
        orq     %rdx,%rax
        ret
+END(rdtsc)
+
+ENTRY(rdseed)
+       rdseed  %rax
+       jc      .Lsuccess
+       movq    $(-1),%rax
+       ret
+.Lsuccess:
+       movq    %rax,(%rdi)
+       xorq    %rax,%rax
+       ret
+END(rdseed)
 
 ENTRY(jump_kernel)
        movq    _C_LABEL(stkva),%rsp
        movq    $exec_kernel,%rax
        jmpq    *%rax
-
+END(jump_kernel)
diff -r f25d14b480df -r d0fe3ca974e5 sys/arch/amd64/stand/prekern/prekern.h
--- a/sys/arch/amd64/stand/prekern/prekern.h    Fri Nov 10 07:25:39 2017 +0000
+++ b/sys/arch/amd64/stand/prekern/prekern.h    Fri Nov 10 08:05:38 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: prekern.h,v 1.6 2017/11/09 15:56:56 maxv Exp $ */
+/*     $NetBSD: prekern.h,v 1.7 2017/11/10 08:05:38 maxv Exp $ */
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -144,8 +144,10 @@
 vaddr_t elf_kernel_reloc();
 
 /* locore.S */
+void cpuid(uint32_t, uint32_t, uint32_t *);
 void lidt(void *);
 uint64_t rdtsc();
+int rdseed(uint64_t *);
 void jump_kernel();
 
 /* mm.c */



Home | Main Index | Thread Index | Old Index