random_adaptors.h revision 254147
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: head/sys/dev/random/random_adaptors.h 254147 2013-08-09 15:31:50Z obrien $ 27254147Sobrien */ 28254147Sobrien 29254147Sobrien#ifndef __RANDOM_ADAPTORS_H__ 30254147Sobrien#define __RANDOM_ADAPTORS_H__ 31254147Sobrien 32254147Sobrien#include <sys/eventhandler.h> 33254147Sobrien 34254147Sobrienstruct random_adaptors { 35254147Sobrien LIST_ENTRY(random_adaptors) entries; /* list of providers */ 36254147Sobrien const char *name; /* name of random adaptor */ 37254147Sobrien struct random_adaptor *rsp; 38254147Sobrien}; 39254147Sobrien 40254147Sobrienstruct random_adaptor *random_adaptor_get(const char *); 41254147Sobrienint random_adaptor_register(const char *, struct random_adaptor *); 42254147Sobrien 43254147Sobrien/* 44254147Sobrien * random_adaptor's should be registered prior to 45254147Sobrien * random module (SI_SUB_DRIVERS/SI_ORDER_MIDDLE) 46254147Sobrien */ 47254147Sobrien#define RANDOM_ADAPTOR_MODULE(name, modevent, ver) \ 48254147Sobrien static moduledata_t name##_mod = { \ 49254147Sobrien #name, \ 50254147Sobrien modevent, \ 51254147Sobrien 0 \ 52254147Sobrien }; \ 53254147Sobrien DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, \ 54254147Sobrien SI_ORDER_SECOND); \ 55254147Sobrien MODULE_VERSION(name, ver); \ 56254147Sobrien MODULE_DEPEND(name, random, 1, 1, 1); 57254147Sobrien 58254147Sobrientypedef void (*random_adaptor_attach_hook)(void *, struct random_adaptor *); 59254147SobrienEVENTHANDLER_DECLARE(random_adaptor_attach, random_adaptor_attach_hook); 60254147Sobrien 61254147Sobrien/* kern.random sysctls */ 62254147Sobrien#ifdef SYSCTL_DECL /* from sysctl.h */ 63254147SobrienSYSCTL_DECL(_kern_random); 64254147Sobrien#endif /* SYSCTL_DECL */ 65254147Sobrien 66254147Sobrien#endif /* __RANDOM_ADAPTORS_H__ */ 67