summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2008-08-10 13:55:20 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2008-08-10 13:55:20 +0000
commitc31485f39d2672744106d3bd06b2bf41d61b682c (patch)
treef59bde84a9d5a7f928460ee4d3590b67daa0fdbb /sys/arch
parent1c2a086fbf4b5c1c95f9bafcf39d9ecb4eec4018 (diff)
Add hypervisor calls for the sun4v random number generator interface.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc64/include/hypervisor.h18
-rw-r--r--sys/arch/sparc64/sparc64/hvcall.S46
2 files changed, 58 insertions, 6 deletions
diff --git a/sys/arch/sparc64/include/hypervisor.h b/sys/arch/sparc64/include/hypervisor.h
index 6ef58b8d3d7..4172f1ecce4 100644
--- a/sys/arch/sparc64/include/hypervisor.h
+++ b/sys/arch/sparc64/include/hypervisor.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hypervisor.h,v 1.2 2008/07/21 13:30:04 art Exp $ */
+/* $OpenBSD: hypervisor.h,v 1.3 2008/08/10 13:55:19 kettenis Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
@@ -41,6 +41,7 @@ int64_t hv_mach_set_soft_state(uint64_t software_state,
* CPU services
*/
+void hv_cpu_yield(void);
int64_t hv_cpu_qconf(uint64_t queue, uint64_t base, uint64_t nentries);
#define CPU_MONDO_QUEUE 0x3c
@@ -49,8 +50,6 @@ int64_t hv_cpu_qconf(uint64_t queue, uint64_t base, uint64_t nentries);
int64_t hv_cpu_mondo_send(uint64_t ncpus, paddr_t cpulist, paddr_t data);
int64_t hv_cpu_myid(uint64_t *cpuid);
-void hv_cpu_yield(void);
-
/*
* MMU services
*/
@@ -146,6 +145,19 @@ int64_t hv_pci_config_put(uint64_t devhandle, uint64_t pci_device,
#define PCI_MAP_ATTR_READ 0x01 /* From memory */
#define PCI_MAP_ATTR_WRITE 0x02 /* To memory */
+int64_t hv_rng_get_diag_control(void);
+int64_t hv_rng_ctl_read(paddr_t raddr, uint64_t *state, uint64_t *delta);
+int64_t hv_rng_ctl_write(paddr_t raddr, uint64_t state, uint64_t timeout,
+ uint64_t *delta);
+
+#define RNG_STATE_UNCONFIGURED 0
+#define RNG_STATE_CONFIGURED 1
+#define RNG_STATE_HEALTHCHECK 2
+#define RNG_STATE_ERROR 3
+
+int64_t hv_rng_data_read_diag(paddr_t raddr, uint64_t size, uint64_t *delta);
+int64_t hv_rng_data_read(paddr_t raddr, uint64_t *delta);
+
/*
* Error codes
*/
diff --git a/sys/arch/sparc64/sparc64/hvcall.S b/sys/arch/sparc64/sparc64/hvcall.S
index dd27ee8496f..07f43bf5969 100644
--- a/sys/arch/sparc64/sparc64/hvcall.S
+++ b/sys/arch/sparc64/sparc64/hvcall.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: hvcall.S,v 1.2 2008/07/21 13:30:05 art Exp $ */
+/* $OpenBSD: hvcall.S,v 1.3 2008/08/10 13:55:19 kettenis Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
@@ -80,6 +80,12 @@
#define PCI_CONFIG_GET 0xb4
#define PCI_CONFIG_PUT 0xb5
+#define RNG_GET_DIAG_CONTROL 0x130
+#define RNG_CTL_READ 0x131
+#define RNG_CTL_WRITE 0x132
+#define RNG_DATA_READ_DIAG 0x133
+#define RNG_DATA_READ 0x134
+
#define API_SET_VERSION 0x00
#define API_PUTCHAR 0x01
#define API_EXIT 0x02
@@ -107,6 +113,12 @@ ENTRY(hv_mach_set_soft_state)
retl
nop
+ENTRY(hv_cpu_yield)
+ mov CPU_YIELD, %o5
+ ta FAST_TRAP
+ retl
+ nop
+
ENTRY(hv_cpu_qconf)
mov CPU_QCONF, %o5
ta FAST_TRAP
@@ -321,8 +333,36 @@ ENTRY(hv_pci_config_put)
retl
stx %o1, [%g5]
-ENTRY(hv_cpu_yield)
- mov CPU_YIELD, %o5
+ENTRY(hv_rng_get_diag_control)
+ mov RNG_GET_DIAG_CONTROL, %o5
ta FAST_TRAP
retl
nop
+
+ENTRY(hv_rng_ctl_read)
+ mov %o2, %o4
+ mov %o1, %o3
+ mov RNG_CTL_READ, %o5
+ ta FAST_TRAP
+ stx %o1, [%o3]
+ retl
+ stx %o2, [%o4]
+
+ENTRY(hv_rng_ctl_write)
+ mov RNG_CTL_WRITE, %o5
+ ta FAST_TRAP
+ retl
+ stx %o1, [%o3]
+
+ENTRY(hv_rng_data_read_diag)
+ mov RNG_DATA_READ_DIAG, %o5
+ ta FAST_TRAP
+ retl
+ stx %o1, [%o2]
+
+ENTRY(hv_rng_data_read)
+ mov %o1, %o2
+ mov RNG_DATA_READ, %o5
+ ta FAST_TRAP
+ retl
+ stx %o1, [%o2]