#include <linux/file.h>
#include <linux/fs.h>
#include <linux/interrupt.h>
#include <linux/hw_random.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/uaccess.h>
#include <linux/uio.h>
#include <linux/virtio_config.h>
#include <linux/virtio_ids.h>
#include <linux/virtio.h>
#include <linux/wait.h>
#include <uapi/linux/nsm.h>
#define NSM_DEFAULT_TIMEOUT_MSECS …
struct nsm_data_req { … };
struct nsm_data_resp { … };
struct nsm_msg { … };
struct nsm { … };
static const struct virtio_device_id id_table[] = …;
static struct nsm *file_to_nsm(struct file *file)
{ … }
static struct nsm *hwrng_to_nsm(struct hwrng *rng)
{ … }
#define CBOR_TYPE_MASK …
#define CBOR_TYPE_MAP …
#define CBOR_TYPE_TEXT …
#define CBOR_TYPE_ARRAY …
#define CBOR_HEADER_SIZE_SHORT …
#define CBOR_SHORT_SIZE_MAX_VALUE …
#define CBOR_LONG_SIZE_U8 …
#define CBOR_LONG_SIZE_U16 …
#define CBOR_LONG_SIZE_U32 …
#define CBOR_LONG_SIZE_U64 …
static bool cbor_object_is_array(const u8 *cbor_object, size_t cbor_object_size)
{ … }
static int cbor_object_get_array(u8 *cbor_object, size_t cbor_object_size, u8 **cbor_array)
{ … }
static int fill_req_raw(struct nsm *nsm, struct nsm_data_req *req,
struct nsm_raw *raw)
{ … }
static int parse_resp_raw(struct nsm *nsm, struct nsm_data_resp *resp,
struct nsm_raw *raw)
{ … }
static void nsm_vq_callback(struct virtqueue *vq)
{ … }
static int nsm_sendrecv_msg_locked(struct nsm *nsm)
{ … }
static int fill_req_get_random(struct nsm *nsm, struct nsm_data_req *req)
{ … }
static int parse_resp_get_random(struct nsm *nsm, struct nsm_data_resp *resp,
void *out, size_t max)
{ … }
static int nsm_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
{ … }
static long nsm_dev_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{ … }
static int nsm_device_init_vq(struct virtio_device *vdev)
{ … }
static const struct file_operations nsm_dev_fops = …;
static int nsm_device_probe(struct virtio_device *vdev)
{ … }
static void nsm_device_remove(struct virtio_device *vdev)
{ … }
static struct virtio_driver virtio_nsm_driver = …;
module_virtio_driver(…) …;
MODULE_DEVICE_TABLE(virtio, id_table);
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;