aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-08-29 20:54:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-08-29 20:54:56 +0000
commitda2d1e9d2582eece6aad948897489ca0b5d64d73 (patch)
treeb28b1be01c712abe9ba9a7939a56ddcefdcc9a8b /sys/dev
parent8ba00cf9b74dbe9648b9e328d92ca6f0fcb07564 (diff)
parent0fb707ecc9b14d8af8d189ced26a84be5a488687 (diff)
Notes
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/agp/agp.c4
-rw-r--r--sys/dev/agp/agp_amd.c10
-rw-r--r--sys/dev/agp/agp_ati.c10
-rw-r--r--sys/dev/agp/agp_i810.c2
-rw-r--r--sys/dev/al_eth/al_eth.c8
-rw-r--r--sys/dev/amd_ecc_inject/ecc_inject.c2
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/cm.c9
-rw-r--r--sys/dev/cxgbe/tom/t4_ddp.c2
-rw-r--r--sys/dev/drm/drm.h11
-rw-r--r--sys/dev/drm/drm_drv.c3
-rw-r--r--sys/dev/drm/drm_scatter.c2
-rw-r--r--sys/dev/drm2/drm_os_freebsd.c3
-rw-r--r--sys/dev/drm2/drm_os_freebsd.h14
-rw-r--r--sys/dev/drm2/drm_scatter.c2
-rw-r--r--sys/dev/glxsb/glxsb.c2
-rw-r--r--sys/dev/hifn/hifn7751.c2
-rw-r--r--sys/dev/hyperv/vmbus/hyperv.c3
-rw-r--r--sys/dev/liquidio/lio_network.h2
-rw-r--r--sys/dev/mmc/mmcbrvar.h15
-rwxr-xr-xsys/dev/random/build.sh16
-rw-r--r--sys/dev/random/fortuna.c5
-rw-r--r--sys/dev/random/other_algorithm.c34
-rw-r--r--sys/dev/random/other_algorithm.h7
-rw-r--r--sys/dev/random/random_harvestq.c21
-rw-r--r--sys/dev/random/random_harvestq.h3
-rw-r--r--sys/dev/random/randomdev.c3
-rw-r--r--sys/dev/random/unit_test.c6
-rw-r--r--sys/dev/random/unit_test.h5
-rw-r--r--sys/dev/random/yarrow.c395
-rw-r--r--sys/dev/random/yarrow.h47
-rw-r--r--sys/dev/rndtest/rndtest.c2
-rw-r--r--sys/dev/safe/safe.c2
-rw-r--r--sys/dev/sdhci/sdhci_fdt.c2
-rw-r--r--sys/dev/sdhci/sdhci_xenon.c5
-rw-r--r--sys/dev/syscons/scmouse.c2
-rw-r--r--sys/dev/syscons/syscons.c2
-rw-r--r--sys/dev/ubsec/ubsec.c2
-rw-r--r--sys/dev/virtio/random/virtio_random.c3
-rw-r--r--sys/dev/vt/hw/efifb/efifb.c1
-rw-r--r--sys/dev/vt/hw/fb/vt_early_fb.c1
-rw-r--r--sys/dev/vt/hw/fb/vt_fb.c35
-rw-r--r--sys/dev/vt/hw/fb/vt_fb.h1
-rw-r--r--sys/dev/vt/hw/vga/vt_vga.c37
-rw-r--r--sys/dev/vt/vt.h7
-rw-r--r--sys/dev/vt/vt_core.c23
-rw-r--r--sys/dev/vt/vt_sysmouse.c2
46 files changed, 254 insertions, 521 deletions
diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c
index fca63f9666ae..011c89afeb37 100644
--- a/sys/dev/agp/agp.c
+++ b/sys/dev/agp/agp.c
@@ -171,8 +171,8 @@ agp_alloc_gatt(device_t dev)
void
agp_free_gatt(struct agp_gatt *gatt)
{
- kmem_free(kernel_arena, (vm_offset_t)gatt->ag_virtual,
- gatt->ag_entries * sizeof(u_int32_t));
+ kmem_free((vm_offset_t)gatt->ag_virtual, gatt->ag_entries *
+ sizeof(u_int32_t));
free(gatt, M_AGP);
}
diff --git a/sys/dev/agp/agp_amd.c b/sys/dev/agp/agp_amd.c
index 1648f41ac4a0..8307d8d9d797 100644
--- a/sys/dev/agp/agp_amd.c
+++ b/sys/dev/agp/agp_amd.c
@@ -119,8 +119,8 @@ agp_amd_alloc_gatt(device_t dev)
if (bootverbose)
device_printf(dev,
"failed to allocate page directory\n");
- kmem_free(kernel_arena, (vm_offset_t)gatt->ag_virtual,
- entries * sizeof(u_int32_t));
+ kmem_free((vm_offset_t)gatt->ag_virtual, entries *
+ sizeof(u_int32_t));
free(gatt, M_AGP);
return 0;
}
@@ -168,9 +168,9 @@ agp_amd_alloc_gatt(device_t dev)
static void
agp_amd_free_gatt(struct agp_amd_gatt *gatt)
{
- kmem_free(kernel_arena, (vm_offset_t)gatt->ag_vdir, AGP_PAGE_SIZE);
- kmem_free(kernel_arena, (vm_offset_t)gatt->ag_virtual,
- gatt->ag_entries * sizeof(u_int32_t));
+ kmem_free((vm_offset_t)gatt->ag_vdir, AGP_PAGE_SIZE);
+ kmem_free((vm_offset_t)gatt->ag_virtual, gatt->ag_entries *
+ sizeof(u_int32_t));
free(gatt, M_AGP);
}
diff --git a/sys/dev/agp/agp_ati.c b/sys/dev/agp/agp_ati.c
index d6c10dc66349..6dc2746f144e 100644
--- a/sys/dev/agp/agp_ati.c
+++ b/sys/dev/agp/agp_ati.c
@@ -147,8 +147,8 @@ agp_ati_alloc_gatt(device_t dev)
if (sc->ag_vdir == NULL) {
if (bootverbose)
device_printf(dev, "pagedir allocation failed\n");
- kmem_free(kernel_arena, (vm_offset_t)sc->ag_virtual,
- entries * sizeof(u_int32_t));
+ kmem_free((vm_offset_t)sc->ag_virtual, entries *
+ sizeof(u_int32_t));
return ENOMEM;
}
sc->ag_pdir = vtophys((vm_offset_t)sc->ag_vdir);
@@ -265,9 +265,9 @@ agp_ati_detach(device_t dev)
temp = pci_read_config(dev, apsize_reg, 4);
pci_write_config(dev, apsize_reg, temp & ~1, 4);
- kmem_free(kernel_arena, (vm_offset_t)sc->ag_vdir, AGP_PAGE_SIZE);
- kmem_free(kernel_arena, (vm_offset_t)sc->ag_virtual,
- sc->ag_entries * sizeof(u_int32_t));
+ kmem_free((vm_offset_t)sc->ag_vdir, AGP_PAGE_SIZE);
+ kmem_free((vm_offset_t)sc->ag_virtual, sc->ag_entries *
+ sizeof(u_int32_t));
bus_release_resource(dev, SYS_RES_MEMORY, ATI_GART_MMADDR, sc->regs);
agp_free_res(dev);
diff --git a/sys/dev/agp/agp_i810.c b/sys/dev/agp/agp_i810.c
index 59028f0533d8..27d7f1114a08 100644
--- a/sys/dev/agp/agp_i810.c
+++ b/sys/dev/agp/agp_i810.c
@@ -1329,7 +1329,7 @@ agp_i810_deinstall_gatt(device_t dev)
sc = device_get_softc(dev);
bus_write_4(sc->sc_res[0], AGP_I810_PGTBL_CTL, 0);
- kmem_free(kernel_arena, (vm_offset_t)sc->gatt->ag_virtual, 64 * 1024);
+ kmem_free((vm_offset_t)sc->gatt->ag_virtual, 64 * 1024);
}
static void
diff --git a/sys/dev/al_eth/al_eth.c b/sys/dev/al_eth/al_eth.c
index e949191ccfc2..80e4a8e47444 100644
--- a/sys/dev/al_eth/al_eth.c
+++ b/sys/dev/al_eth/al_eth.c
@@ -1202,8 +1202,12 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
uint32_t mss = m->m_pkthdr.tso_segsz;
struct ether_vlan_header *eh;
uint16_t etype;
+#ifdef INET
struct ip *ip;
+#endif
+#ifdef INET6
struct ip6_hdr *ip6;
+#endif
struct tcphdr *th = NULL;
int ehdrlen, ip_hlen = 0;
uint8_t ipproto = 0;
@@ -1243,6 +1247,7 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
}
switch (etype) {
+#ifdef INET
case ETHERTYPE_IP:
ip = (struct ip *)(m->m_data + ehdrlen);
ip_hlen = ip->ip_hl << 2;
@@ -1256,6 +1261,8 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
else
hal_pkt->l4_proto_idx = AL_ETH_PROTO_ID_UDP;
break;
+#endif /* INET */
+#ifdef INET6
case ETHERTYPE_IPV6:
ip6 = (struct ip6_hdr *)(m->m_data + ehdrlen);
hal_pkt->l3_proto_idx = AL_ETH_PROTO_ID_IPv6;
@@ -1267,6 +1274,7 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
else
hal_pkt->l4_proto_idx = AL_ETH_PROTO_ID_UDP;
break;
+#endif /* INET6 */
default:
break;
}
diff --git a/sys/dev/amd_ecc_inject/ecc_inject.c b/sys/dev/amd_ecc_inject/ecc_inject.c
index a682115b08ae..7425320f8256 100644
--- a/sys/dev/amd_ecc_inject/ecc_inject.c
+++ b/sys/dev/amd_ecc_inject/ecc_inject.c
@@ -195,7 +195,7 @@ ecc_ei_inject(int count)
pause_sbt("ecc_ei_inject", delay_ms * SBT_1MS, 0, 0);
}
- kmem_free(kernel_arena, memory, PAGE_SIZE);
+ kmem_free(memory, PAGE_SIZE);
}
static int
diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c
index ce42a90ad59b..9eab1750bb11 100644
--- a/sys/dev/cxgbe/iw_cxgbe/cm.c
+++ b/sys/dev/cxgbe/iw_cxgbe/cm.c
@@ -76,6 +76,7 @@ struct cpl_set_tcb_rpl;
#include <linux/inetdevice.h>
#include <linux/if_vlan.h>
#include <net/netevent.h>
+#include <rdma/rdma_cm.h>
static spinlock_t req_lock;
static TAILQ_HEAD(c4iw_ep_list, c4iw_ep_common) req_list;
@@ -2523,6 +2524,8 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
struct c4iw_dev *dev = to_c4iw_dev(cm_id->device);
struct c4iw_ep *ep = NULL;
struct ifnet *nh_ifp; /* Logical egress interface */
+ struct rdma_cm_id *rdma_id = (struct rdma_cm_id*)cm_id->context;
+ struct vnet *vnet = rdma_id->route.addr.dev_addr.net;
CTR2(KTR_IW_CXGBE, "%s:ccB %p", __func__, cm_id);
@@ -2568,7 +2571,10 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
ref_qp(ep);
ep->com.thread = curthread;
+ CURVNET_SET(vnet);
err = get_ifnet_from_raddr(&cm_id->remote_addr, &nh_ifp);
+ CURVNET_RESTORE();
+
if (err) {
CTR2(KTR_IW_CXGBE, "%s:cc7 %p", __func__, ep);
@@ -2811,7 +2817,10 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
if (!ep->parent_ep)
ep->com.state = MORIBUND;
+
+ CURVNET_SET(ep->com.so->so_vnet);
sodisconnect(ep->com.so);
+ CURVNET_RESTORE();
}
}
diff --git a/sys/dev/cxgbe/tom/t4_ddp.c b/sys/dev/cxgbe/tom/t4_ddp.c
index cba39f0c83dc..02c906c47d22 100644
--- a/sys/dev/cxgbe/tom/t4_ddp.c
+++ b/sys/dev/cxgbe/tom/t4_ddp.c
@@ -1970,6 +1970,8 @@ t4_ddp_mod_unload(void)
taskqueue_drain(taskqueue_thread, &ddp_orphan_task);
MPASS(TAILQ_EMPTY(&ddp_orphan_pagesets));
mtx_destroy(&ddp_orphan_pagesets_lock);
+ t4_register_shared_cpl_handler(CPL_SET_TCB_RPL, NULL, CPL_COOKIE_DDP0);
+ t4_register_shared_cpl_handler(CPL_SET_TCB_RPL, NULL, CPL_COOKIE_DDP1);
t4_register_cpl_handler(CPL_RX_DATA_DDP, NULL);
t4_register_cpl_handler(CPL_RX_DDP_COMPLETE, NULL);
}
diff --git a/sys/dev/drm/drm.h b/sys/dev/drm/drm.h
index a2612049bb0d..026907f2026d 100644
--- a/sys/dev/drm/drm.h
+++ b/sys/dev/drm/drm.h
@@ -1145,4 +1145,15 @@ typedef struct drm_mm_init_arg drm_mm_init_arg_t;
typedef enum drm_bo_type drm_bo_type_t;
#endif
+#define DRM_PORT "graphics/drm-legacy-kmod"
+
+#define DRM_OBSOLETE(dev) \
+ do { \
+ device_printf(dev, "=======================================================\n"); \
+ device_printf(dev, "This code is obsolete abandonware. Install the " DRM_PORT " pkg\n"); \
+ device_printf(dev, "=======================================================\n"); \
+ gone_in_dev(dev, 13, "drm drivers"); \
+ } while (0)
+
+
#endif
diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c
index 6874d45d0335..20d7d973aed1 100644
--- a/sys/dev/drm/drm_drv.c
+++ b/sys/dev/drm/drm_drv.c
@@ -174,7 +174,8 @@ int drm_probe(device_t kdev, drm_pci_id_list_t *idlist)
DRM_DEBUG("desc : %s\n", device_get_desc(kdev));
device_set_desc(kdev, id_entry->name);
}
- return 0;
+ DRM_OBSOLETE(kdev);
+ return BUS_PROBE_GENERIC;
}
return ENXIO;
diff --git a/sys/dev/drm/drm_scatter.c b/sys/dev/drm/drm_scatter.c
index 163634878d93..9b02d1a69c55 100644
--- a/sys/dev/drm/drm_scatter.c
+++ b/sys/dev/drm/drm_scatter.c
@@ -99,7 +99,7 @@ drm_sg_cleanup(struct drm_sg_mem *entry)
return;
if (entry->vaddr != 0)
- kmem_free(kernel_arena, entry->vaddr, IDX_TO_OFF(entry->pages));
+ kmem_free(entry->vaddr, IDX_TO_OFF(entry->pages));
free(entry->busaddr, DRM_MEM_SGLISTS);
free(entry, DRM_MEM_DRIVER);
diff --git a/sys/dev/drm2/drm_os_freebsd.c b/sys/dev/drm2/drm_os_freebsd.c
index 4ce8081887ba..8489ca848027 100644
--- a/sys/dev/drm2/drm_os_freebsd.c
+++ b/sys/dev/drm2/drm_os_freebsd.c
@@ -126,7 +126,8 @@ drm_probe_helper(device_t kdev, const drm_pci_id_list_t *idlist)
device_get_nameunit(kdev), id_entry->name);
device_set_desc(kdev, id_entry->name);
}
- return (0);
+ DRM_OBSOLETE(kdev);
+ return (-BUS_PROBE_GENERIC);
}
return (-ENXIO);
diff --git a/sys/dev/drm2/drm_os_freebsd.h b/sys/dev/drm2/drm_os_freebsd.h
index 11c9feb9b4aa..b7e81c56b94c 100644
--- a/sys/dev/drm2/drm_os_freebsd.h
+++ b/sys/dev/drm2/drm_os_freebsd.h
@@ -154,6 +154,20 @@ typedef void irqreturn_t;
*(volatile u_int64_t *)(((vm_offset_t)(map)->handle) + \
(vm_offset_t)(offset)) = htole64(val)
+#ifdef __LP64__
+#define DRM_PORT "graphics/drm-stable-kmod"
+#else
+#define DRM_PORT "graphics/drm-legacy-kmod"
+#endif
+
+#define DRM_OBSOLETE(dev) \
+ do { \
+ device_printf(dev, "=======================================================\n"); \
+ device_printf(dev, "This code is obsolete abandonware. Install the " DRM_PORT " pkg\n"); \
+ device_printf(dev, "=======================================================\n"); \
+ gone_in_dev(dev, 13, "drm2 drivers"); \
+ } while (0)
+
/* DRM_READMEMORYBARRIER() prevents reordering of reads.
* DRM_WRITEMEMORYBARRIER() prevents reordering of writes.
* DRM_MEMORYBARRIER() prevents reordering of reads and writes.
diff --git a/sys/dev/drm2/drm_scatter.c b/sys/dev/drm2/drm_scatter.c
index 510fce4cd6a4..1ccc88a5f69c 100644
--- a/sys/dev/drm2/drm_scatter.c
+++ b/sys/dev/drm2/drm_scatter.c
@@ -47,7 +47,7 @@ void drm_sg_cleanup(struct drm_sg_mem * entry)
return;
if (entry->vaddr != 0)
- kmem_free(kernel_arena, entry->vaddr, IDX_TO_OFF(entry->pages));
+ kmem_free(entry->vaddr, IDX_TO_OFF(entry->pages));
free(entry->busaddr, DRM_MEM_SGLISTS);
free(entry, DRM_MEM_DRIVER);
diff --git a/sys/dev/glxsb/glxsb.c b/sys/dev/glxsb/glxsb.c
index 4916d95cc6b7..4d89e7d6756a 100644
--- a/sys/dev/glxsb/glxsb.c
+++ b/sys/dev/glxsb/glxsb.c
@@ -457,7 +457,7 @@ glxsb_rnd(void *v)
value = bus_read_4(sc->sc_sr, SB_RANDOM_NUM);
/* feed with one uint32 */
/* MarkM: FIX!! Check that this does not swamp the harvester! */
- random_harvest_queue(&value, sizeof(value), 32/2, RANDOM_PURE_GLXSB);
+ random_harvest_queue(&value, sizeof(value), RANDOM_PURE_GLXSB);
}
callout_reset(&sc->sc_rngco, sc->sc_rnghz, glxsb_rnd, sc);
diff --git a/sys/dev/hifn/hifn7751.c b/sys/dev/hifn/hifn7751.c
index e43dd7b12a6b..f1a7ea52c257 100644
--- a/sys/dev/hifn/hifn7751.c
+++ b/sys/dev/hifn/hifn7751.c
@@ -259,7 +259,7 @@ static void
default_harvest(struct rndtest_state *rsp, void *buf, u_int count)
{
/* MarkM: FIX!! Check that this does not swamp the harvester! */
- random_harvest_queue(buf, count, count*NBBY/2, RANDOM_PURE_HIFN);
+ random_harvest_queue(buf, count, RANDOM_PURE_HIFN);
}
static u_int
diff --git a/sys/dev/hyperv/vmbus/hyperv.c b/sys/dev/hyperv/vmbus/hyperv.c
index d2d252ded07c..5bb38fde8241 100644
--- a/sys/dev/hyperv/vmbus/hyperv.c
+++ b/sys/dev/hyperv/vmbus/hyperv.c
@@ -264,8 +264,7 @@ SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init,
static void
hypercall_memfree(void)
{
- kmem_free(kernel_arena, (vm_offset_t)hypercall_context.hc_addr,
- PAGE_SIZE);
+ kmem_free((vm_offset_t)hypercall_context.hc_addr, PAGE_SIZE);
hypercall_context.hc_addr = NULL;
}
diff --git a/sys/dev/liquidio/lio_network.h b/sys/dev/liquidio/lio_network.h
index b8cdcde76626..b1f4e1448fe9 100644
--- a/sys/dev/liquidio/lio_network.h
+++ b/sys/dev/liquidio/lio_network.h
@@ -212,7 +212,7 @@ static inline void
lio_dma_free(size_t size, void *cpu_addr)
{
- kmem_free(kmem_arena, (vm_offset_t)cpu_addr, size);
+ kmem_free((vm_offset_t)cpu_addr, size);
}
static inline uint64_t
diff --git a/sys/dev/mmc/mmcbrvar.h b/sys/dev/mmc/mmcbrvar.h
index a6285eb7e9d3..7b0bc4739863 100644
--- a/sys/dev/mmc/mmcbrvar.h
+++ b/sys/dev/mmc/mmcbrvar.h
@@ -97,7 +97,6 @@ MMCBR_ACCESSOR(host_ocr, HOST_OCR, int)
MMCBR_ACCESSOR(mode, MODE, int)
MMCBR_ACCESSOR(ocr, OCR, int)
MMCBR_ACCESSOR(power_mode, POWER_MODE, int)
-MMCBR_ACCESSOR(retune_req, RETUNE_REQ, int)
MMCBR_ACCESSOR(vdd, VDD, int)
MMCBR_ACCESSOR(vccq, VCCQ, int)
MMCBR_ACCESSOR(caps, CAPS, int)
@@ -106,6 +105,20 @@ MMCBR_ACCESSOR(max_data, MAX_DATA, int)
MMCBR_ACCESSOR(max_busy_timeout, MAX_BUSY_TIMEOUT, u_int)
static int __inline
+mmcbr_get_retune_req(device_t dev)
+{
+ uintptr_t v;
+
+ if (__predict_false(BUS_READ_IVAR(device_get_parent(dev), dev,
+ MMCBR_IVAR_RETUNE_REQ, &v) != 0))
+ return (retune_req_none);
+ return ((int)v);
+}
+
+/*
+ * Convenience wrappers for the mmcbr interface
+ */
+static int __inline
mmcbr_update_ios(device_t dev)
{
diff --git a/sys/dev/random/build.sh b/sys/dev/random/build.sh
index 326f8a6c12e4..08e033f844ba 100755
--- a/sys/dev/random/build.sh
+++ b/sys/dev/random/build.sh
@@ -28,23 +28,23 @@
#
# Basic script to build crude unit tests.
#
-# Diff-reduction checking between Yarrow and fortuna is done like so:
+# Diff-reduction checking between fortuna and the other algorithm is done like so:
#
-# $ diff -u -B <(sed -e 's/yarrow/wombat/g' \
-# -e 's/YARROW/WOMBAT/g' yarrow.c) \
-# <(sed -e 's/fortuna/wombat/g' \
-# -e 's/FORTUNA/WOMBAT/g' fortuna.c) | less
+# $ diff -u -B <(sed -e 's/random_other/random_wombat/g' \
+# -e 's/RANDOM_OTHER/RANDOM_WOMBAT/g' other_algorithm.c) \
+# <(sed -e 's/random_fortuna/random_wombat/g' \
+# -e 's/RANDOM_FORTUNA/RANDOM_WOMBAT/g' fortuna.c) | less
#
cc -g -O0 -pthread \
-I../.. -lstdthreads -Wall \
unit_test.c \
- yarrow.c \
+ other_algorithm.c \
hash.c \
../../crypto/rijndael/rijndael-api-fst.c \
../../crypto/rijndael/rijndael-alg-fst.c \
../../crypto/sha2/sha256c.c \
-lz \
- -o yunit_test
+ -o other_unit_test
cc -g -O0 -pthread \
-I../.. -lstdthreads -Wall \
unit_test.c \
@@ -54,4 +54,4 @@ cc -g -O0 -pthread \
../../crypto/rijndael/rijndael-alg-fst.c \
../../crypto/sha2/sha256c.c \
-lz \
- -o funit_test
+ -o fortuna_unit_test
diff --git a/sys/dev/random/fortuna.c b/sys/dev/random/fortuna.c
index 17ebbd833c9a..c20cea2f21ae 100644
--- a/sys/dev/random/fortuna.c
+++ b/sys/dev/random/fortuna.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <dev/random/uint128.h>
#include <dev/random/fortuna.h>
#else /* !_KERNEL */
+#include <sys/param.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
@@ -97,9 +98,11 @@ CTASSERT(RANDOM_BLOCKSIZE == sizeof(uint128_t));
CTASSERT(RANDOM_KEYSIZE == 2*RANDOM_BLOCKSIZE);
/* Probes for dtrace(1) */
+#ifdef _KERNEL
SDT_PROVIDER_DECLARE(random);
SDT_PROVIDER_DEFINE(random);
SDT_PROBE_DEFINE2(random, fortuna, event_processor, debug, "u_int", "struct fs_pool *");
+#endif /* _KERNEL */
/*
* This is the beastie that needs protecting. It contains all of the
@@ -398,7 +401,9 @@ random_fortuna_pre_read(void)
} else
break;
}
+#ifdef _KERNEL
SDT_PROBE2(random, fortuna, event_processor, debug, fortuna_state.fs_reseedcount, fortuna_state.fs_pool);
+#endif
/* FS&K */
random_fortuna_reseed_internal(s, i < RANDOM_FORTUNA_NPOOLS ? i + 1 : RANDOM_FORTUNA_NPOOLS);
/* Clean up and secure */
diff --git a/sys/dev/random/other_algorithm.c b/sys/dev/random/other_algorithm.c
index 0c73ef5421df..57679f53a7da 100644
--- a/sys/dev/random/other_algorithm.c
+++ b/sys/dev/random/other_algorithm.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2015 Mark R V Murray
+ * Copyright (c) 2015-2018 Mark R V Murray
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,19 +30,21 @@
* containing an alternative entropy-processing algorithm for random(4).
*
* The functions below should be completed with the appropriate code,
- * and the nearby yarrow.c and fortuna.c may be consulted for examples
- * of working code.
+ * and the nearby fortuna.c may be consulted for examples of working code.
*
* The author is willing to provide reasonable help to those wishing to
* write such a module for themselves. Please use the markm@ FreeBSD
* email address, and ensure that you are developing this on a suitably
- * supported branch (This is currently 11-CURRENT, and will be no
- * older than 11-STABLE in the future).
+ * supported branch (This is currently 12-CURRENT, and may be no
+ * older than 12-STABLE in the future).
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/limits.h>
+
+#ifdef _KERNEL
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/lock.h>
@@ -62,6 +64,24 @@ __FBSDID("$FreeBSD$");
#include <dev/random/random_harvestq.h>
#include <dev/random/uint128.h>
#include <dev/random/other_algorithm.h>
+#else /* !_KERNEL */
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <threads.h>
+
+#include "unit_test.h"
+
+#include <crypto/rijndael/rijndael-api-fst.h>
+#include <crypto/sha2/sha256.h>
+
+#include <dev/random/hash.h>
+#include <dev/random/randomdev.h>
+#include <dev/random/uint128.h>
+#include <dev/random/other_algorithm.h>
+#endif /* _KERNEL */
static void random_other_pre_read(void);
static void random_other_read(uint8_t *, u_int);
@@ -73,9 +93,7 @@ static void random_other_deinit_alg(void *);
/*
* RANDOM_OTHER_NPOOLS is used when reading hardware random
* number sources to ensure that each pool gets one read sample
- * per loop iteration. Yarrow has 2 such pools (FAST and SLOW),
- * and fortuna has 32 (0-31). The RNG used prior to Yarrow and
- * ported from Linux had just 1 pool.
+ * per loop iteration. Fortuna has 32 (0-31).
*/
#define RANDOM_OTHER_NPOOLS 1
diff --git a/sys/dev/random/other_algorithm.h b/sys/dev/random/other_algorithm.h
index 8ca2bb89b39e..8486401daca7 100644
--- a/sys/dev/random/other_algorithm.h
+++ b/sys/dev/random/other_algorithm.h
@@ -31,14 +31,13 @@
* containing an alternative entropy-processing algorithm for random(4).
*
* The functions below should be completed with the appropriate code,
- * and the nearby yarrow.c and fortuna.c may be consulted for examples
- * of working code.
+ * and the nearby fortuna.c may be consulted for examples of working code.
*
* The author is willing to provide reasonable help to those wishing to
* write such a module for themselves. Please use the markm@ FreeBSD
* email address, and ensure that you are developing this on a suitably
- * supported branch (This is currently 11-CURRENT, and will be no
- * older than 11-STABLE in the future).
+ * supported branch (This is currently 12-CURRENT, and may be no
+ * older than 12-STABLE in the future).
*/
#ifndef SYS_DEV_RANDOM_OTHER_H_INCLUDED
diff --git a/sys/dev/random/random_harvestq.c b/sys/dev/random/random_harvestq.c
index d8620c84f1d6..934464e185c1 100644
--- a/sys/dev/random/random_harvestq.c
+++ b/sys/dev/random/random_harvestq.c
@@ -140,7 +140,7 @@ static struct kproc_desc random_proc_kp = {
&harvest_context.hc_kthread_proc,
};
-/* Pass the given event straight through to Fortuna/Yarrow/Whatever. */
+/* Pass the given event straight through to Fortuna/Whatever. */
static __inline void
random_harvestq_fast_process_event(struct harvest_event *event)
{
@@ -178,7 +178,7 @@ random_kthread(void)
/* XXX: FIX!! Increase the high-performance data rate? Need some measurements first. */
for (i = 0; i < RANDOM_ACCUM_MAX; i++) {
if (harvest_context.hc_entropy_fast_accumulator.buf[i]) {
- random_harvest_direct(harvest_context.hc_entropy_fast_accumulator.buf + i, sizeof(harvest_context.hc_entropy_fast_accumulator.buf[0]), 4, RANDOM_UMA);
+ random_harvest_direct(harvest_context.hc_entropy_fast_accumulator.buf + i, sizeof(harvest_context.hc_entropy_fast_accumulator.buf[0]), RANDOM_UMA);
harvest_context.hc_entropy_fast_accumulator.buf[i] = 0;
}
}
@@ -197,8 +197,7 @@ SYSINIT(random_device_h_proc, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, kproc_start,
/*
* Run through all fast sources reading entropy for the given
* number of rounds, which should be a multiple of the number
- * of entropy accumulation pools in use; 2 for Yarrow and 32
- * for Fortuna.
+ * of entropy accumulation pools in use; it is 32 for Fortuna.
*/
static void
random_sources_feed(void)
@@ -234,7 +233,7 @@ random_sources_feed(void)
printf("%s: rs_read for hardware device '%s' returned no entropy.\n", __func__, rrs->rrs_source->rs_ident);
continue;
}
- random_harvest_direct(entropy, n, (n*8)/2, rrs->rrs_source->rs_source);
+ random_harvest_direct(entropy, n, rrs->rrs_source->rs_source);
}
}
explicit_bzero(entropy, sizeof(entropy));
@@ -380,7 +379,7 @@ SYSINIT(random_device_h_init, SI_SUB_RANDOM, SI_ORDER_SECOND, random_harvestq_in
/*
* This is used to prime the RNG by grabbing any early random stuff
* known to the kernel, and inserting it directly into the hashing
- * module, e.g. Fortuna or Yarrow.
+ * module, currently Fortuna.
*/
/* ARGSUSED */
static void
@@ -414,7 +413,6 @@ random_harvestq_prime(void *unused __unused)
count = sizeof(event.he_entropy);
event.he_somecounter = (uint32_t)get_cyclecount();
event.he_size = count;
- event.he_bits = count/4; /* Underestimate the size for Yarrow */
event.he_source = RANDOM_CACHED;
event.he_destination = harvest_context.hc_destination[0]++;
memcpy(event.he_entropy, data + i, sizeof(event.he_entropy));
@@ -459,8 +457,7 @@ SYSUNINIT(random_device_h_init, SI_SUB_RANDOM, SI_ORDER_SECOND, random_harvestq_
* read which can be quite expensive.
*/
void
-random_harvest_queue_(const void *entropy, u_int size, u_int bits,
- enum random_entropy_source origin)
+random_harvest_queue_(const void *entropy, u_int size, enum random_entropy_source origin)
{
struct harvest_event *event;
u_int ring_in;
@@ -474,7 +471,6 @@ random_harvest_queue_(const void *entropy, u_int size, u_int bits,
event->he_somecounter = (uint32_t)get_cyclecount();
event->he_source = origin;
event->he_destination = harvest_context.hc_destination[origin]++;
- event->he_bits = bits;
if (size <= sizeof(event->he_entropy)) {
event->he_size = size;
memcpy(event->he_entropy, entropy, size);
@@ -496,7 +492,7 @@ random_harvest_queue_(const void *entropy, u_int size, u_int bits,
* This is the right place for high-rate harvested data.
*/
void
-random_harvest_fast_(const void *entropy, u_int size, u_int bits)
+random_harvest_fast_(const void *entropy, u_int size)
{
u_int pos;
@@ -512,7 +508,7 @@ random_harvest_fast_(const void *entropy, u_int size, u_int bits)
* (e.g.) booting when initial entropy is being gathered.
*/
void
-random_harvest_direct_(const void *entropy, u_int size, u_int bits, enum random_entropy_source origin)
+random_harvest_direct_(const void *entropy, u_int size, enum random_entropy_source origin)
{
struct harvest_event event;
@@ -520,7 +516,6 @@ random_harvest_direct_(const void *entropy, u_int size, u_int bits, enum random_
size = MIN(size, sizeof(event.he_entropy));
event.he_somecounter = (uint32_t)get_cyclecount();
event.he_size = size;
- event.he_bits = bits;
event.he_source = origin;
event.he_destination = harvest_context.hc_destination[origin]++;
memcpy(event.he_entropy, entropy, size);
diff --git a/sys/dev/random/random_harvestq.h b/sys/dev/random/random_harvestq.h
index d58a4940bb73..c7005cde4f22 100644
--- a/sys/dev/random/random_harvestq.h
+++ b/sys/dev/random/random_harvestq.h
@@ -38,10 +38,9 @@ struct harvest_event {
uint32_t he_somecounter; /* fast counter for clock jitter */
uint32_t he_entropy[HARVESTSIZE];/* some harvested entropy */
uint8_t he_size; /* harvested entropy byte count */
- uint8_t he_bits; /* stats about the entropy */
uint8_t he_destination; /* destination pool of this entropy */
uint8_t he_source; /* origin of the entropy */
-} __packed;
+};
void read_rate_increment(u_int);
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c
index 51c25ba408a3..c7bb97c3a0fe 100644
--- a/sys/dev/random/randomdev.c
+++ b/sys/dev/random/randomdev.c
@@ -166,7 +166,7 @@ READ_RANDOM_UIO(struct uio *uio, bool nonblock)
* Belt-and-braces.
* Round up the read length to a crypto block size multiple,
* which is what the underlying generator is expecting.
- * See the random_buf size requirements in the Yarrow/Fortuna code.
+ * See the random_buf size requirements in the Fortuna code.
*/
read_len = roundup(read_len, RANDOM_BLOCKSIZE);
/* Work in chunks page-sized or less */
@@ -250,7 +250,6 @@ randomdev_accumulate(uint8_t *buf, u_int count)
for (i = 0; i < RANDOM_KEYSIZE_WORDS; i += sizeof(event.he_entropy)/sizeof(event.he_entropy[0])) {
event.he_somecounter = (uint32_t)get_cyclecount();
event.he_size = sizeof(event.he_entropy);
- event.he_bits = event.he_size/8;
event.he_source = RANDOM_CACHED;
event.he_destination = destination++; /* Harmless cheating */
memcpy(event.he_entropy, entropy_data + i, sizeof(event.he_entropy));
diff --git a/sys/dev/random/unit_test.c b/sys/dev/random/unit_test.c
index aec2f1d2837e..b93eb092b92b 100644
--- a/sys/dev/random/unit_test.c
+++ b/sys/dev/random/unit_test.c
@@ -31,7 +31,6 @@
cc -g -O0 -pthread -DRANDOM_<alg> -I../.. -lstdthreads -Wall \
unit_test.c \
- yarrow.c \
fortuna.c \
hash.c \
../../crypto/rijndael/rijndael-api-fst.c \
@@ -41,7 +40,9 @@ cc -g -O0 -pthread -DRANDOM_<alg> -I../.. -lstdthreads -Wall \
-o unit_test
./unit_test
-Where <alg> is YARROW or FORTUNA.
+Where <alg> is FORTUNA. The parameterisation is a leftover from
+when Yarrow was an option, and remains to enable the testing of
+possible future algorithms.
*/
#include <sys/types.h>
@@ -157,7 +158,6 @@ RunHarvester(void *arg __unused)
e.he_somecounter = i;
*((uint64_t *)e.he_entropy) = random();
e.he_size = 8;
- e.he_bits = random()%4;
e.he_destination = i;
e.he_source = (i + 3)%7;
e.he_next = NULL;
diff --git a/sys/dev/random/unit_test.h b/sys/dev/random/unit_test.h
index 3c05ad0bf0f6..adca19efeadd 100644
--- a/sys/dev/random/unit_test.h
+++ b/sys/dev/random/unit_test.h
@@ -74,9 +74,8 @@ enum random_entropy_source {
struct harvest_event {
uintmax_t he_somecounter; /* fast counter for clock jitter */
uint32_t he_entropy[HARVESTSIZE];/* some harvested entropy */
- u_int he_size; /* harvested entropy byte count */
- u_int he_bits; /* stats about the entropy */
- u_int he_destination; /* destination pool of this entropy */
+ uint8_t he_size; /* harvested entropy byte count */
+ uint8_t he_destination; /* destination pool of this entropy */
enum random_entropy_source he_source; /* origin of the entropy */
void * he_next; /* next item on the list */
};
diff --git a/sys/dev/random/yarrow.c b/sys/dev/random/yarrow.c
deleted file mode 100644
index 40fc6cd9162e..000000000000
--- a/sys/dev/random/yarrow.c
+++ /dev/null
@@ -1,395 +0,0 @@
-/*-
- * Copyright (c) 2000-2015 Mark R V Murray
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer
- * in this position and unchanged.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#ifdef _KERNEL
-#include <sys/param.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/mutex.h>
-#include <sys/random.h>
-#include <sys/sdt.h>
-#include <sys/sysctl.h>
-#include <sys/systm.h>
-
-#include <machine/cpu.h>
-
-#include <crypto/rijndael/rijndael-api-fst.h>
-#include <crypto/sha2/sha256.h>
-
-#include <dev/random/hash.h>
-#include <dev/random/randomdev.h>
-#include <dev/random/random_harvestq.h>
-#include <dev/random/uint128.h>
-#include <dev/random/yarrow.h>
-#else /* !_KERNEL */
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <threads.h>
-
-#include "unit_test.h"
-
-#include <crypto/rijndael/rijndael-api-fst.h>
-#include <crypto/sha2/sha256.h>
-
-#include <dev/random/hash.h>
-#include <dev/random/randomdev.h>
-#include <dev/random/uint128.h>
-#include <dev/random/yarrow.h>
-#endif /* _KERNEL */
-
-#define RANDOM_YARROW_TIMEBIN 16 /* max value for Pt/t */
-
-#define RANDOM_YARROW_FAST 0
-#define RANDOM_YARROW_SLOW 1
-#define RANDOM_YARROW_NPOOLS 2
-
-/* This algorithm (and code) presumes that RANDOM_KEYSIZE is twice as large as RANDOM_BLOCKSIZE */
-CTASSERT(RANDOM_BLOCKSIZE == sizeof(uint128_t));
-CTASSERT(RANDOM_KEYSIZE == 2*RANDOM_BLOCKSIZE);
-
-/* Probes for dtrace(1) */
-SDT_PROVIDER_DECLARE(random);
-SDT_PROVIDER_DEFINE(random);
-SDT_PROBE_DEFINE3(random, yarrow, event_processor, debug, "boolean", "u_int", "struct ys_pool *");
-
-/*
- * This is the beastie that needs protecting. It contains all of the
- * state that we are excited about. Exactly one is instantiated.
- */
-static struct yarrow_state {
- uint128_t ys_counter; /* C */
- struct randomdev_key ys_key; /* K */
- u_int ys_gengateinterval; /* Pg */
- u_int ys_bins; /* Pt/t */
- u_int ys_outputblocks; /* count output blocks for gates */
- u_int ys_slowoverthresh; /* slow pool overthreshhold reseed count */
- struct ys_pool {
- u_int ysp_source_bits[ENTROPYSOURCE]; /* estimated bits of entropy per source */
- u_int ysp_thresh; /* pool reseed threshold */
- struct randomdev_hash ysp_hash; /* accumulated entropy */
- } ys_pool[RANDOM_YARROW_NPOOLS];/* pool[0] is fast, pool[1] is slow */
- bool ys_seeded;
- /* Reseed lock */
- mtx_t ys_mtx;
-} yarrow_state;
-
-#ifdef _KERNEL
-static struct sysctl_ctx_list random_clist;
-RANDOM_CHECK_UINT(gengateinterval, 4, 64);
-RANDOM_CHECK_UINT(bins, RANDOM_YARROW_NPOOLS, 16);
-RANDOM_CHECK_UINT(fastthresh, (RANDOM_BLOCKSIZE*8)/4, (RANDOM_BLOCKSIZE*8)); /* Bit counts */
-RANDOM_CHECK_UINT(slowthresh, (RANDOM_BLOCKSIZE*8)/4, (RANDOM_BLOCKSIZE*8)); /* Bit counts */
-RANDOM_CHECK_UINT(slowoverthresh, 1, 5);
-#endif /* _KERNEL */
-
-static void random_yarrow_pre_read(void);
-static void random_yarrow_read(uint8_t *, u_int);
-static bool random_yarrow_seeded(void);
-static void random_yarrow_process_event(struct harvest_event *);
-static void random_yarrow_init_alg(void *);
-static void random_yarrow_deinit_alg(void *);
-
-static void random_yarrow_reseed_internal(u_int);
-
-struct random_algorithm random_alg_context = {
- .ra_ident = "Yarrow",
- .ra_init_alg = random_yarrow_init_alg,
- .ra_deinit_alg = random_yarrow_deinit_alg,
- .ra_pre_read = random_yarrow_pre_read,
- .ra_read = random_yarrow_read,
- .ra_seeded = random_yarrow_seeded,
- .ra_event_processor = random_yarrow_process_event,
- .ra_poolcount = RANDOM_YARROW_NPOOLS,
-};
-
-/* ARGSUSED */
-static void
-random_yarrow_init_alg(void *unused __unused)
-{
- int i, j;
-#ifdef _KERNEL
- struct sysctl_oid *random_yarrow_o;
-#endif
-
- RANDOM_RESEED_INIT_LOCK();
- /* Start unseeded, therefore blocked. */
- yarrow_state.ys_seeded = false;
-#ifdef _KERNEL
- /*
- * Yarrow parameters. Do not adjust these unless you have
- * have a very good clue about what they do!
- */
- random_yarrow_o = SYSCTL_ADD_NODE(&random_clist,
- SYSCTL_STATIC_CHILDREN(_kern_random),
- OID_AUTO, "yarrow", CTLFLAG_RW, 0,
- "Yarrow Parameters");
- SYSCTL_ADD_PROC(&random_clist,
- SYSCTL_CHILDREN(random_yarrow_o), OID_AUTO,
- "gengateinterval", CTLTYPE_UINT | CTLFLAG_RWTUN,
- &yarrow_state.ys_gengateinterval, 0,
- random_check_uint_gengateinterval, "UI",
- "Generation gate interval");
- SYSCTL_ADD_PROC(&random_clist,
- SYSCTL_CHILDREN(random_yarrow_o), OID_AUTO,
- "bins", CTLTYPE_UINT | CTLFLAG_RWTUN,
- &yarrow_state.ys_bins, 0,
- random_check_uint_bins, "UI",
- "Execution time tuner");
- SYSCTL_ADD_PROC(&random_clist,
- SYSCTL_CHILDREN(random_yarrow_o), OID_AUTO,
- "fastthresh", CTLTYPE_UINT | CTLFLAG_RWTUN,
- &yarrow_state.ys_pool[0].ysp_thresh, 0,
- random_check_uint_fastthresh, "UI",
- "Fast reseed threshold");
- SYSCTL_ADD_PROC(&random_clist,
- SYSCTL_CHILDREN(random_yarrow_o), OID_AUTO,
- "slowthresh", CTLTYPE_UINT | CTLFLAG_RWTUN,
- &yarrow_state.ys_pool[1].ysp_thresh, 0,
- random_check_uint_slowthresh, "UI",
- "Slow reseed threshold");
- SYSCTL_ADD_PROC(&random_clist,
- SYSCTL_CHILDREN(random_yarrow_o), OID_AUTO,
- "slowoverthresh", CTLTYPE_UINT | CTLFLAG_RWTUN,
- &yarrow_state.ys_slowoverthresh, 0,
- random_check_uint_slowoverthresh, "UI",
- "Slow over-threshold reseed");
-#endif /* _KERNEL */
- yarrow_state.ys_gengateinterval = 10;
- yarrow_state.ys_bins = 10;
- yarrow_state.ys_pool[RANDOM_YARROW_FAST].ysp_thresh = (3*(RANDOM_BLOCKSIZE*8))/4;
- yarrow_state.ys_pool[RANDOM_YARROW_SLOW].ysp_thresh = (RANDOM_BLOCKSIZE*8);
- yarrow_state.ys_slowoverthresh = 2;
- /* Ensure that the first time we read, we are gated. */
- yarrow_state.ys_outputblocks = yarrow_state.ys_gengateinterval;
- /* Initialise the fast and slow entropy pools */
- for (i = RANDOM_YARROW_FAST; i <= RANDOM_YARROW_SLOW; i++) {
- randomdev_hash_init(&yarrow_state.ys_pool[i].ysp_hash);
- for (j = RANDOM_START; j < ENTROPYSOURCE; j++)
- yarrow_state.ys_pool[i].ysp_source_bits[j] = 0;
- }
- /* Clear the counter */
- yarrow_state.ys_counter = UINT128_ZERO;
-}
-
-/* ARGSUSED */
-static void
-random_yarrow_deinit_alg(void *unused __unused)
-{
-
- RANDOM_RESEED_DEINIT_LOCK();
- explicit_bzero(&yarrow_state, sizeof(yarrow_state));
-#ifdef _KERNEL
- sysctl_ctx_free(&random_clist);
-#endif
-}
-
-/* Process a single stochastic event off the harvest queue */
-static void
-random_yarrow_process_event(struct harvest_event *event)
-{
- u_int pl, overthreshhold[RANDOM_YARROW_NPOOLS];
- enum random_entropy_source src;
-
- RANDOM_RESEED_LOCK();
- /*
- * Accumulate the event into the appropriate pool
- * where each event carries the destination information.
- * We lock against pool state modification which can happen
- * during accumulation/reseeding and reading/regating
- */
- pl = event->he_destination % RANDOM_YARROW_NPOOLS;
- randomdev_hash_iterate(&yarrow_state.ys_pool[pl].ysp_hash, event, sizeof(*event));
- yarrow_state.ys_pool[pl].ysp_source_bits[event->he_source] += event->he_bits;
- /* Count the over-threshold sources in each pool */
- for (pl = RANDOM_YARROW_FAST; pl <= RANDOM_YARROW_SLOW; pl++) {
- overthreshhold[pl] = 0;
- for (src = RANDOM_START; src < ENTROPYSOURCE; src++) {
- if (yarrow_state.ys_pool[pl].ysp_source_bits[src] > yarrow_state.ys_pool[pl].ysp_thresh)
- overthreshhold[pl]++;
- }
- }
- /*
- * If enough slow sources are over threshold, then slow reseed
- * else if any fast source over threshold, then fast reseed.
- */
- if (overthreshhold[RANDOM_YARROW_SLOW] >= yarrow_state.ys_slowoverthresh)
- random_yarrow_reseed_internal(RANDOM_YARROW_SLOW);
- else if (overthreshhold[RANDOM_YARROW_FAST] > 0 && yarrow_state.ys_seeded)
- random_yarrow_reseed_internal(RANDOM_YARROW_FAST);
- explicit_bzero(event, sizeof(*event));
- RANDOM_RESEED_UNLOCK();
-}
-
-static void
-random_yarrow_reseed_internal(u_int fastslow)
-{
- /*
- * Interrupt-context stack is a limited resource; make large
- * structures static.
- */
- static uint8_t v[RANDOM_YARROW_TIMEBIN][RANDOM_KEYSIZE]; /* v[i] */
- static uint128_t temp;
- static struct randomdev_hash context;
- u_int i;
- enum random_entropy_source j;
-
- KASSERT(yarrow_state.ys_pool[RANDOM_YARROW_FAST].ysp_thresh > 0, ("random: Yarrow fast threshold = 0"));
- KASSERT(yarrow_state.ys_pool[RANDOM_YARROW_SLOW].ysp_thresh > 0, ("random: Yarrow slow threshold = 0"));
- RANDOM_RESEED_ASSERT_LOCK_OWNED();
- SDT_PROBE3(random, yarrow, event_processor, debug, yarrow_state.ys_seeded, yarrow_state.ys_slowoverthresh, yarrow_state.ys_pool);
- /* 1. Hash the accumulated entropy into v[0] */
- randomdev_hash_init(&context);
- /* Feed the slow pool hash in if slow */
- if (fastslow == RANDOM_YARROW_SLOW) {
- randomdev_hash_finish(&yarrow_state.ys_pool[RANDOM_YARROW_SLOW].ysp_hash, &temp);
- randomdev_hash_iterate(&context, &temp, sizeof(temp));
- }
- randomdev_hash_finish(&yarrow_state.ys_pool[RANDOM_YARROW_FAST].ysp_hash, &temp);
- randomdev_hash_iterate(&context, &temp, sizeof(temp));
- randomdev_hash_finish(&context, v[0]);
- /*-
- * 2. Compute hash values for all v. _Supposed_ to be computationally
- * intensive.
- */
- if (yarrow_state.ys_bins > RANDOM_YARROW_TIMEBIN)
- yarrow_state.ys_bins = RANDOM_YARROW_TIMEBIN;
- for (i = 1; i < yarrow_state.ys_bins; i++) {
- randomdev_hash_init(&context);
- /* v[i] #= h(v[i - 1]) */
- randomdev_hash_iterate(&context, v[i - 1], RANDOM_KEYSIZE);
- /* v[i] #= h(v[0]) */
- randomdev_hash_iterate(&context, v[0], RANDOM_KEYSIZE);
- /* v[i] #= h(i) */
- randomdev_hash_iterate(&context, &i, sizeof(i));
- /* Return the hashval */
- randomdev_hash_finish(&context, v[i]);
- }
- /*-
- * 3. Compute a new key; h' is the identity function here;
- * it is not being ignored!
- */
- randomdev_hash_init(&context);
- randomdev_hash_iterate(&context, &yarrow_state.ys_key, RANDOM_KEYSIZE);
- for (i = 1; i < yarrow_state.ys_bins; i++)
- randomdev_hash_iterate(&context, v[i], RANDOM_KEYSIZE);
- randomdev_hash_finish(&context, &temp);
- randomdev_encrypt_init(&yarrow_state.ys_key, &temp);
- /* 4. Recompute the counter */
- yarrow_state.ys_counter = UINT128_ZERO;
- randomdev_encrypt(&yarrow_state.ys_key, &yarrow_state.ys_counter, &temp, RANDOM_BLOCKSIZE);
- yarrow_state.ys_counter = temp;
- /* 5. Reset entropy estimate accumulators to zero */
- for (i = 0; i <= fastslow; i++)
- for (j = RANDOM_START; j < ENTROPYSOURCE; j++)
- yarrow_state.ys_pool[i].ysp_source_bits[j] = 0;
- /* 6. Wipe memory of intermediate values */
- explicit_bzero(v, sizeof(v));
- explicit_bzero(&temp, sizeof(temp));
- explicit_bzero(&context, sizeof(context));
-/* Not defined so writes ain't gonna happen. Kept for documenting. */
-#ifdef RANDOM_RWFILE_WRITE_IS_OK
- /*-
- * 7. Dump to seed file.
- * This pseudo-code is documentation. Please leave it alone.
- */
- seed_file = "<some file>";
- error = randomdev_write_file(seed_file, <generated entropy>, PAGE_SIZE);
- if (error == 0)
- printf("random: entropy seed file '%s' successfully written\n", seed_file);
-#endif
- /* Unblock the device if it was blocked due to being unseeded */
- if (!yarrow_state.ys_seeded) {
- yarrow_state.ys_seeded = true;
- randomdev_unblock();
- }
-}
-
-static __inline void
-random_yarrow_generator_gate(void)
-{
- u_int i;
- uint8_t temp[RANDOM_KEYSIZE];
-
- RANDOM_RESEED_ASSERT_LOCK_OWNED();
- uint128_increment(&yarrow_state.ys_counter);
- for (i = 0; i < RANDOM_KEYSIZE; i += RANDOM_BLOCKSIZE)
- randomdev_encrypt(&yarrow_state.ys_key, &yarrow_state.ys_counter, temp + i, RANDOM_BLOCKSIZE);
- randomdev_encrypt_init(&yarrow_state.ys_key, temp);
- explicit_bzero(temp, sizeof(temp));
-}
-
-/*-
- * Used to return processed entropy from the PRNG. There is a pre_read
- * required to be present (but it can be a stub) in order to allow
- * specific actions at the begin of the read.
- * Yarrow does its reseeding in its own thread; _pre_read() is not used
- * by Yarrow but must be kept for completeness.
- */
-void
-random_yarrow_pre_read(void)
-{
-}
-
-/*-
- * Main read from Yarrow.
- * The supplied buf MUST be a multiple (>=0) of RANDOM_BLOCKSIZE in size.
- * Lots of code presumes this for efficiency, both here and in other
- * routines. You are NOT allowed to break this!
- */
-void
-random_yarrow_read(uint8_t *buf, u_int bytecount)
-{
- u_int blockcount, i;
-
- KASSERT((bytecount % RANDOM_BLOCKSIZE) == 0, ("%s(): bytecount (= %d) must be a multiple of %d", __func__, bytecount, RANDOM_BLOCKSIZE ));
- RANDOM_RESEED_LOCK();
- blockcount = howmany(bytecount, RANDOM_BLOCKSIZE);
- for (i = 0; i < blockcount; i++) {
- if (yarrow_state.ys_outputblocks++ >= yarrow_state.ys_gengateinterval) {
- random_yarrow_generator_gate();
- yarrow_state.ys_outputblocks = 0;
- }
- uint128_increment(&yarrow_state.ys_counter);
- randomdev_encrypt(&yarrow_state.ys_key, &yarrow_state.ys_counter, buf, RANDOM_BLOCKSIZE);
- buf += RANDOM_BLOCKSIZE;
- }
- RANDOM_RESEED_UNLOCK();
-}
-
-bool
-random_yarrow_seeded(void)
-{
-
- return (yarrow_state.ys_seeded);
-}
diff --git a/sys/dev/random/yarrow.h b/sys/dev/random/yarrow.h
deleted file mode 100644
index a08d1070e89b..000000000000
--- a/sys/dev/random/yarrow.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 2000-2015 Mark R V Murray
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer
- * in this position and unchanged.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef SYS_DEV_RANDOM_YARROW_H_INCLUDED
-#define SYS_DEV_RANDOM_YARROW_H_INCLUDED
-
-#ifdef _KERNEL
-typedef struct mtx mtx_t;
-#define RANDOM_RESEED_INIT_LOCK(x) mtx_init(&yarrow_state.ys_mtx, "reseed mutex", NULL, MTX_DEF)
-#define RANDOM_RESEED_DEINIT_LOCK(x) mtx_destroy(&yarrow_state.ys_mtx)
-#define RANDOM_RESEED_LOCK(x) mtx_lock(&yarrow_state.ys_mtx)
-#define RANDOM_RESEED_UNLOCK(x) mtx_unlock(&yarrow_state.ys_mtx)
-#define RANDOM_RESEED_ASSERT_LOCK_OWNED(x) mtx_assert(&yarrow_state.ys_mtx, MA_OWNED)
-#else
-#define RANDOM_RESEED_INIT_LOCK(x) mtx_init(&yarrow_state.ys_mtx, mtx_plain)
-#define RANDOM_RESEED_DEINIT_LOCK(x) mtx_destroy(&yarrow_state.ys_mtx)
-#define RANDOM_RESEED_LOCK(x) mtx_lock(&yarrow_state.ys_mtx)
-#define RANDOM_RESEED_UNLOCK(x) mtx_unlock(&yarrow_state.ys_mtx)
-#define RANDOM_RESEED_ASSERT_LOCK_OWNED(x)
-#endif
-
-#endif /* SYS_DEV_RANDOM_YARROW_H_INCLUDED */
diff --git a/sys/dev/rndtest/rndtest.c b/sys/dev/rndtest/rndtest.c
index 5d2490af11db..f33edbfa048d 100644
--- a/sys/dev/rndtest/rndtest.c
+++ b/sys/dev/rndtest/rndtest.c
@@ -149,7 +149,7 @@ rndtest_harvest(struct rndtest_state *rsp, void *buf, u_int len)
rndstats.rst_discard += len;
else
/* MarkM: FIX!! Check that this does not swamp the harvester! */
- random_harvest_queue(buf, len, len*NBBY/2, RANDOM_PURE_RNDTEST);
+ random_harvest_queue(buf, len, RANDOM_PURE_RNDTEST);
}
static void
diff --git a/sys/dev/safe/safe.c b/sys/dev/safe/safe.c
index a1673c9cd60f..0edaea85f5b6 100644
--- a/sys/dev/safe/safe.c
+++ b/sys/dev/safe/safe.c
@@ -212,7 +212,7 @@ static void
default_harvest(struct rndtest_state *rsp, void *buf, u_int count)
{
/* MarkM: FIX!! Check that this does not swamp the harvester! */
- random_harvest_queue(buf, count, count*NBBY/2, RANDOM_PURE_SAFE);
+ random_harvest_queue(buf, count, RANDOM_PURE_SAFE);
}
#endif /* SAFE_NO_RNG */
diff --git a/sys/dev/sdhci/sdhci_fdt.c b/sys/dev/sdhci/sdhci_fdt.c
index 488a91fd16eb..78c17363c35b 100644
--- a/sys/dev/sdhci/sdhci_fdt.c
+++ b/sys/dev/sdhci/sdhci_fdt.c
@@ -353,7 +353,7 @@ static devclass_t sdhci_fdt_devclass;
DRIVER_MODULE(sdhci_fdt, simplebus, sdhci_fdt_driver, sdhci_fdt_devclass,
NULL, NULL);
-#ifndef MMCCAM
MODULE_DEPEND(sdhci_fdt, sdhci, 1, 1, 1);
+#ifndef MMCCAM
MMC_DECLARE_BRIDGE(sdhci_fdt);
#endif
diff --git a/sys/dev/sdhci/sdhci_xenon.c b/sys/dev/sdhci/sdhci_xenon.c
index d8c13d26f5b9..a3b76c30557f 100644
--- a/sys/dev/sdhci/sdhci_xenon.c
+++ b/sys/dev/sdhci/sdhci_xenon.c
@@ -61,6 +61,8 @@ __FBSDID("$FreeBSD$");
#include "mmcbr_if.h"
#include "sdhci_if.h"
+#include "opt_mmccam.h"
+
#define MAX_SLOTS 6
static struct ofw_compat_data compat_data[] = {
@@ -542,5 +544,8 @@ static devclass_t sdhci_xenon_devclass;
DRIVER_MODULE(sdhci_xenon, simplebus, sdhci_xenon_driver, sdhci_xenon_devclass,
NULL, NULL);
+
MODULE_DEPEND(sdhci_xenon, sdhci, 1, 1, 1);
+#ifndef MMCCAM
MMC_DECLARE_BRIDGE(sdhci_xenon);
+#endif
diff --git a/sys/dev/syscons/scmouse.c b/sys/dev/syscons/scmouse.c
index aeff5f9b3e90..03daba3ebfab 100644
--- a/sys/dev/syscons/scmouse.c
+++ b/sys/dev/syscons/scmouse.c
@@ -669,7 +669,7 @@ sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
mouse = (mouse_info_t*)data;
- random_harvest_queue(mouse, sizeof(mouse_info_t), 2, RANDOM_MOUSE);
+ random_harvest_queue(mouse, sizeof(mouse_info_t), RANDOM_MOUSE);
if (cmd == OLD_CONS_MOUSECTL) {
static u_char swapb[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index dd2ecc4627ac..0785bd52c53b 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -3734,7 +3734,7 @@ next_code:
sc_touch_scrn_saver();
if (!(flags & SCGETC_CN))
- random_harvest_queue(&c, sizeof(c), 1, RANDOM_KEYBOARD);
+ random_harvest_queue(&c, sizeof(c), RANDOM_KEYBOARD);
if (sc->kbd_open_level == 0 && scp->kbd_mode != K_XLATE)
return KEYCHAR(c);
diff --git a/sys/dev/ubsec/ubsec.c b/sys/dev/ubsec/ubsec.c
index 1c8c7c60e657..ad89986d1a1e 100644
--- a/sys/dev/ubsec/ubsec.c
+++ b/sys/dev/ubsec/ubsec.c
@@ -260,7 +260,7 @@ static void
default_harvest(struct rndtest_state *rsp, void *buf, u_int count)
{
/* MarkM: FIX!! Check that this does not swamp the harvester! */
- random_harvest_queue(buf, count, count*NBBY/2, RANDOM_PURE_UBSEC);
+ random_harvest_queue(buf, count, RANDOM_PURE_UBSEC);
}
static int
diff --git a/sys/dev/virtio/random/virtio_random.c b/sys/dev/virtio/random/virtio_random.c
index 18326891f05e..15311b9e6fbc 100644
--- a/sys/dev/virtio/random/virtio_random.c
+++ b/sys/dev/virtio/random/virtio_random.c
@@ -217,8 +217,7 @@ vtrnd_harvest(struct vtrnd_softc *sc)
virtqueue_notify(vq);
virtqueue_poll(vq, NULL);
- random_harvest_queue(&value, sizeof(value), sizeof(value) * NBBY / 2,
- RANDOM_PURE_VIRTIO);
+ random_harvest_queue(&value, sizeof(value), RANDOM_PURE_VIRTIO);
}
static void
diff --git a/sys/dev/vt/hw/efifb/efifb.c b/sys/dev/vt/hw/efifb/efifb.c
index 7b8b88cad51a..c3ae3bff30fe 100644
--- a/sys/dev/vt/hw/efifb/efifb.c
+++ b/sys/dev/vt/hw/efifb/efifb.c
@@ -58,6 +58,7 @@ static struct vt_driver vt_efifb_driver = {
.vd_init = vt_efifb_init,
.vd_blank = vt_fb_blank,
.vd_bitblt_text = vt_fb_bitblt_text,
+ .vd_invalidate_text = vt_fb_invalidate_text,
.vd_bitblt_bmp = vt_fb_bitblt_bitmap,
.vd_drawrect = vt_fb_drawrect,
.vd_setpixel = vt_fb_setpixel,
diff --git a/sys/dev/vt/hw/fb/vt_early_fb.c b/sys/dev/vt/hw/fb/vt_early_fb.c
index 15af1aedbd25..e538ace2c052 100644
--- a/sys/dev/vt/hw/fb/vt_early_fb.c
+++ b/sys/dev/vt/hw/fb/vt_early_fb.c
@@ -60,6 +60,7 @@ static struct vt_driver vt_fb_early_driver = {
.vd_init = vt_efb_init,
.vd_blank = vt_fb_blank,
.vd_bitblt_text = vt_fb_bitblt_text,
+ .vd_invalidate_text = vt_fb_invalidate_text,
.vd_bitblt_bmp = vt_fb_bitblt_bitmap,
.vd_drawrect = vt_fb_drawrect,
.vd_setpixel = vt_fb_setpixel,
diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c
index f437b8cf9e7d..091188c5e2da 100644
--- a/sys/dev/vt/hw/fb/vt_fb.c
+++ b/sys/dev/vt/hw/fb/vt_fb.c
@@ -50,6 +50,7 @@ static struct vt_driver vt_fb_driver = {
.vd_fini = vt_fb_fini,
.vd_blank = vt_fb_blank,
.vd_bitblt_text = vt_fb_bitblt_text,
+ .vd_invalidate_text = vt_fb_invalidate_text,
.vd_bitblt_bmp = vt_fb_bitblt_bitmap,
.vd_drawrect = vt_fb_drawrect,
.vd_setpixel = vt_fb_setpixel,
@@ -335,6 +336,7 @@ vt_fb_bitblt_text(struct vt_device *vd, const struct vt_window *vw,
term_char_t c;
term_color_t fg, bg;
const uint8_t *pattern;
+ size_t z;
vf = vw->vw_font;
@@ -351,9 +353,22 @@ vt_fb_bitblt_text(struct vt_device *vd, const struct vt_window *vw,
vt_determine_colors(c,
VTBUF_ISCURSOR(&vw->vw_buf, row, col), &fg, &bg);
+ z = row * PIXEL_WIDTH(VT_FB_MAX_WIDTH) + col;
+ if (vd->vd_drawn && (vd->vd_drawn[z] == c) &&
+ vd->vd_drawnfg && (vd->vd_drawnfg[z] == fg) &&
+ vd->vd_drawnbg && (vd->vd_drawnbg[z] == bg))
+ continue;
+
vt_fb_bitblt_bitmap(vd, vw,
pattern, NULL, vf->vf_width, vf->vf_height,
x, y, fg, bg);
+
+ if (vd->vd_drawn)
+ vd->vd_drawn[z] = c;
+ if (vd->vd_drawnfg)
+ vd->vd_drawnfg[z] = fg;
+ if (vd->vd_drawnbg)
+ vd->vd_drawnbg[z] = bg;
}
}
@@ -380,6 +395,26 @@ vt_fb_bitblt_text(struct vt_device *vd, const struct vt_window *vw,
}
void
+vt_fb_invalidate_text(struct vt_device *vd, const term_rect_t *area)
+{
+ unsigned int col, row;
+ size_t z;
+
+ for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) {
+ for (col = area->tr_begin.tp_col; col < area->tr_end.tp_col;
+ ++col) {
+ z = row * PIXEL_WIDTH(VT_FB_MAX_WIDTH) + col;
+ if (vd->vd_drawn)
+ vd->vd_drawn[z] = 0;
+ if (vd->vd_drawnfg)
+ vd->vd_drawnfg[z] = 0;
+ if (vd->vd_drawnbg)
+ vd->vd_drawnbg[z] = 0;
+ }
+ }
+}
+
+void
vt_fb_postswitch(struct vt_device *vd)
{
struct fb_info *info;
diff --git a/sys/dev/vt/hw/fb/vt_fb.h b/sys/dev/vt/hw/fb/vt_fb.h
index 6a185bab0dcb..42b395e8ff39 100644
--- a/sys/dev/vt/hw/fb/vt_fb.h
+++ b/sys/dev/vt/hw/fb/vt_fb.h
@@ -43,6 +43,7 @@ vd_init_t vt_fb_init;
vd_fini_t vt_fb_fini;
vd_blank_t vt_fb_blank;
vd_bitblt_text_t vt_fb_bitblt_text;
+vd_invalidate_text_t vt_fb_invalidate_text;
vd_bitblt_bmp_t vt_fb_bitblt_bitmap;
vd_drawrect_t vt_fb_drawrect;
vd_setpixel_t vt_fb_setpixel;
diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c
index 6efb6d1eeae9..88a9b1c47338 100644
--- a/sys/dev/vt/hw/vga/vt_vga.c
+++ b/sys/dev/vt/hw/vga/vt_vga.c
@@ -97,6 +97,7 @@ static vd_probe_t vga_probe;
static vd_init_t vga_init;
static vd_blank_t vga_blank;
static vd_bitblt_text_t vga_bitblt_text;
+static vd_invalidate_text_t vga_invalidate_text;
static vd_bitblt_bmp_t vga_bitblt_bitmap;
static vd_drawrect_t vga_drawrect;
static vd_setpixel_t vga_setpixel;
@@ -108,6 +109,7 @@ static const struct vt_driver vt_vga_driver = {
.vd_init = vga_init,
.vd_blank = vga_blank,
.vd_bitblt_text = vga_bitblt_text,
+ .vd_invalidate_text = vga_invalidate_text,
.vd_bitblt_bmp = vga_bitblt_bitmap,
.vd_drawrect = vga_drawrect,
.vd_setpixel = vga_setpixel,
@@ -868,6 +870,7 @@ vga_bitblt_text_txtmode(struct vt_device *vd, const struct vt_window *vw,
term_char_t c;
term_color_t fg, bg;
uint8_t ch, attr;
+ size_t z;
sc = vd->vd_softc;
vb = &vw->vw_buf;
@@ -884,6 +887,12 @@ vga_bitblt_text_txtmode(struct vt_device *vd, const struct vt_window *vw,
vt_determine_colors(c, VTBUF_ISCURSOR(vb, row, col),
&fg, &bg);
+ z = row * PIXEL_WIDTH(VT_FB_MAX_WIDTH) + col;
+ if (vd->vd_drawn && (vd->vd_drawn[z] == c) &&
+ vd->vd_drawnfg && (vd->vd_drawnfg[z] == fg) &&
+ vd->vd_drawnbg && (vd->vd_drawnbg[z] == bg))
+ continue;
+
/*
* Convert character to CP437, which is the
* character set used by the VGA hardware by
@@ -898,6 +907,13 @@ vga_bitblt_text_txtmode(struct vt_device *vd, const struct vt_window *vw,
MEM_WRITE2(sc, (row * 80 + col) * 2 + 0,
ch + ((uint16_t)(attr) << 8));
+
+ if (vd->vd_drawn)
+ vd->vd_drawn[z] = c;
+ if (vd->vd_drawnfg)
+ vd->vd_drawnfg[z] = fg;
+ if (vd->vd_drawnbg)
+ vd->vd_drawnbg[z] = bg;
}
}
}
@@ -914,6 +930,27 @@ vga_bitblt_text(struct vt_device *vd, const struct vt_window *vw,
}
}
+void
+vga_invalidate_text(struct vt_device *vd, const term_rect_t *area)
+{
+ unsigned int col, row;
+ size_t z;
+
+ for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) {
+ for (col = area->tr_begin.tp_col;
+ col < area->tr_end.tp_col;
+ ++col) {
+ z = row * PIXEL_WIDTH(VT_FB_MAX_WIDTH) + col;
+ if (vd->vd_drawn)
+ vd->vd_drawn[z] = 0;
+ if (vd->vd_drawnfg)
+ vd->vd_drawnfg[z] = 0;
+ if (vd->vd_drawnbg)
+ vd->vd_drawnbg[z] = 0;
+ }
+ }
+}
+
static void
vga_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw,
const uint8_t *pattern, const uint8_t *mask,
diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h
index 745f9de836cb..712da20b7634 100644
--- a/sys/dev/vt/vt.h
+++ b/sys/dev/vt/vt.h
@@ -156,11 +156,15 @@ struct vt_device {
#define VDF_INITIALIZED 0x20 /* vtterm_cnprobe already done. */
#define VDF_MOUSECURSOR 0x40 /* Mouse cursor visible. */
#define VDF_QUIET_BELL 0x80 /* Disable bell. */
+#define VDF_SUSPENDED 0x100 /* Device has been suspended. */
#define VDF_DOWNGRADE 0x8000 /* The driver is being downgraded. */
int vd_keyboard; /* (G) Keyboard index. */
unsigned int vd_kbstate; /* (?) Device unit. */
unsigned int vd_unit; /* (c) Device unit. */
int vd_altbrk; /* (?) Alt break seq. state */
+ term_char_t *vd_drawn; /* (?) Most recent char drawn. */
+ term_color_t *vd_drawnfg; /* (?) Most recent fg color drawn. */
+ term_color_t *vd_drawnbg; /* (?) Most recent bg color drawn. */
};
#define VD_PASTEBUF(vd) ((vd)->vd_pastebuf.vpb_buf)
@@ -320,6 +324,8 @@ typedef void vd_postswitch_t(struct vt_device *vd);
typedef void vd_blank_t(struct vt_device *vd, term_color_t color);
typedef void vd_bitblt_text_t(struct vt_device *vd, const struct vt_window *vw,
const term_rect_t *area);
+typedef void vd_invalidate_text_t(struct vt_device *vd,
+ const term_rect_t *area);
typedef void vd_bitblt_bmp_t(struct vt_device *vd, const struct vt_window *vw,
const uint8_t *pattern, const uint8_t *mask,
unsigned int width, unsigned int height,
@@ -345,6 +351,7 @@ struct vt_driver {
vd_drawrect_t *vd_drawrect;
vd_setpixel_t *vd_setpixel;
vd_bitblt_text_t *vd_bitblt_text;
+ vd_invalidate_text_t *vd_invalidate_text;
vd_bitblt_bmp_t *vd_bitblt_bmp;
/* Framebuffer ioctls, if present. */
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index 81a803fcd00f..a4bbb9396952 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -190,6 +190,11 @@ SET_DECLARE(vt_drv_set, struct vt_driver);
struct terminal vt_consterm;
static struct vt_window vt_conswindow;
+#ifndef SC_NO_CONSDRAWN
+static term_char_t vt_consdrawn[PIXEL_HEIGHT(VT_FB_MAX_HEIGHT) * PIXEL_WIDTH(VT_FB_MAX_WIDTH)];
+static term_color_t vt_consdrawnfg[PIXEL_HEIGHT(VT_FB_MAX_HEIGHT) * PIXEL_WIDTH(VT_FB_MAX_WIDTH)];
+static term_color_t vt_consdrawnbg[PIXEL_HEIGHT(VT_FB_MAX_HEIGHT) * PIXEL_WIDTH(VT_FB_MAX_WIDTH)];
+#endif
struct vt_device vt_consdev = {
.vd_driver = NULL,
.vd_softc = NULL,
@@ -210,6 +215,12 @@ struct vt_device vt_consdev = {
.vd_mcursor_fg = TC_WHITE,
.vd_mcursor_bg = TC_BLACK,
#endif
+
+#ifndef SC_NO_CONSDRAWN
+ .vd_drawn = vt_consdrawn,
+ .vd_drawnfg = vt_consdrawnfg,
+ .vd_drawnbg = vt_consdrawnbg,
+#endif
};
static term_char_t vt_constextbuf[(_VTDEFW) * (VBF_DEFAULT_HISTORY_SIZE)];
static term_char_t *vt_constextbufrows[VBF_DEFAULT_HISTORY_SIZE];
@@ -804,7 +815,7 @@ vt_processkey(keyboard_t *kbd, struct vt_device *vd, int c)
{
struct vt_window *vw = vd->vd_curwindow;
- random_harvest_queue(&c, sizeof(c), 1, RANDOM_KEYBOARD);
+ random_harvest_queue(&c, sizeof(c), RANDOM_KEYBOARD);
#if VT_ALT_TO_ESC_HACK
if (c & RELKEY) {
switch (c & ~RELKEY) {
@@ -1181,6 +1192,8 @@ vt_mark_mouse_position_as_dirty(struct vt_device *vd, int locked)
if (!locked)
vtbuf_lock(&vw->vw_buf);
+ if (vd->vd_driver->vd_invalidate_text)
+ vd->vd_driver->vd_invalidate_text(vd, &area);
vtbuf_dirty(&vw->vw_buf, &area);
if (!locked)
vtbuf_unlock(&vw->vw_buf);
@@ -1280,12 +1293,14 @@ vt_flush(struct vt_device *vd)
vtbuf_undirty(&vw->vw_buf, &tarea);
- /* Force a full redraw when the screen contents are invalid. */
- if (vd->vd_flags & VDF_INVALID) {
+ /* Force a full redraw when the screen contents might be invalid. */
+ if (vd->vd_flags & (VDF_INVALID | VDF_SUSPENDED)) {
vd->vd_flags &= ~VDF_INVALID;
vt_set_border(vd, &vw->vw_draw_area, TC_BLACK);
vt_termrect(vd, vf, &tarea);
+ if (vd->vd_driver->vd_invalidate_text)
+ vd->vd_driver->vd_invalidate_text(vd, &tarea);
if (vt_draw_logo_cpus)
vtterm_draw_cpu_logos(vd);
}
@@ -2824,6 +2839,7 @@ vt_suspend_handler(void *priv)
struct vt_device *vd;
vd = priv;
+ vd->vd_flags |= VDF_SUSPENDED;
if (vd->vd_driver != NULL && vd->vd_driver->vd_suspend != NULL)
vd->vd_driver->vd_suspend(vd);
}
@@ -2836,6 +2852,7 @@ vt_resume_handler(void *priv)
vd = priv;
if (vd->vd_driver != NULL && vd->vd_driver->vd_resume != NULL)
vd->vd_driver->vd_resume(vd);
+ vd->vd_flags &= ~VDF_SUSPENDED;
}
void
diff --git a/sys/dev/vt/vt_sysmouse.c b/sys/dev/vt/vt_sysmouse.c
index 4afb9e1e126b..98915c2a78df 100644
--- a/sys/dev/vt/vt_sysmouse.c
+++ b/sys/dev/vt/vt_sysmouse.c
@@ -214,7 +214,7 @@ sysmouse_process_event(mouse_info_t *mi)
unsigned char buf[MOUSE_SYS_PACKETSIZE];
int x, y, iy, z;
- random_harvest_queue(mi, sizeof *mi, 2, RANDOM_MOUSE);
+ random_harvest_queue(mi, sizeof *mi, RANDOM_MOUSE);
mtx_lock(&sysmouse_lock);
switch (mi->operation) {