1254147Sobrien/*- 2254147Sobrien * Copyright (c) 2013 Arthur Mesh <arthurmesh@gmail.com> 3254147Sobrien * All rights reserved. 4254147Sobrien * 5254147Sobrien * Redistribution and use in source and binary forms, with or without 6254147Sobrien * modification, are permitted provided that the following conditions 7254147Sobrien * are met: 8254147Sobrien * 1. Redistributions of source code must retain the above copyright 9254147Sobrien * notice, this list of conditions and the following disclaimer 10254147Sobrien * in this position and unchanged. 11254147Sobrien * 2. Redistributions in binary form must reproduce the above copyright 12254147Sobrien * notice, this list of conditions and the following disclaimer in the 13254147Sobrien * documentation and/or other materials provided with the distribution. 14254147Sobrien * 15254147Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16254147Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17254147Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18254147Sobrien * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19254147Sobrien * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20254147Sobrien * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21254147Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22254147Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23254147Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24254147Sobrien * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25254147Sobrien * 26254147Sobrien * $FreeBSD$ 27254147Sobrien */ 28254147Sobrien 29256381Smarkm#ifndef SYS_DEV_RANDOM_RANDOM_ADAPTORS_H_INCLUDED 30256381Smarkm#define SYS_DEV_RANDOM_RANDOM_ADAPTORS_H_INCLUDED 31254147Sobrien 32254147Sobrien#include <sys/eventhandler.h> 33254147Sobrien 34256381SmarkmMALLOC_DECLARE(M_ENTROPY); 35256381Smarkm 36254147Sobrienstruct random_adaptors { 37254147Sobrien LIST_ENTRY(random_adaptors) entries; /* list of providers */ 38254147Sobrien const char *name; /* name of random adaptor */ 39254147Sobrien struct random_adaptor *rsp; 40254147Sobrien}; 41254147Sobrien 42254147Sobrienstruct random_adaptor *random_adaptor_get(const char *); 43254147Sobrienint random_adaptor_register(const char *, struct random_adaptor *); 44255362Smarkmvoid random_adaptor_choose(struct random_adaptor **); 45254147Sobrien 46255379Smarkmextern struct random_adaptor *random_adaptor; 47255379Smarkm 48254147Sobrien/* 49254147Sobrien * random_adaptor's should be registered prior to 50254147Sobrien * random module (SI_SUB_DRIVERS/SI_ORDER_MIDDLE) 51254147Sobrien */ 52254147Sobrien#define RANDOM_ADAPTOR_MODULE(name, modevent, ver) \ 53254147Sobrien static moduledata_t name##_mod = { \ 54254147Sobrien #name, \ 55254147Sobrien modevent, \ 56254147Sobrien 0 \ 57254147Sobrien }; \ 58254147Sobrien DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, \ 59254147Sobrien SI_ORDER_SECOND); \ 60254147Sobrien MODULE_VERSION(name, ver); \ 61254147Sobrien MODULE_DEPEND(name, random, 1, 1, 1); 62254147Sobrien 63254147Sobrientypedef void (*random_adaptor_attach_hook)(void *, struct random_adaptor *); 64254147SobrienEVENTHANDLER_DECLARE(random_adaptor_attach, random_adaptor_attach_hook); 65254147Sobrien 66254147Sobrien/* kern.random sysctls */ 67254147Sobrien#ifdef SYSCTL_DECL /* from sysctl.h */ 68254147SobrienSYSCTL_DECL(_kern_random); 69254147Sobrien#endif /* SYSCTL_DECL */ 70254147Sobrien 71256381Smarkm#endif /* SYS_DEV_RANDOM_RANDOM_ADAPTORS_H_INCLUDED */ 72