linux/drivers/firmware/dmi-sysfs.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * dmi-sysfs.c
 *
 * This module exports the DMI tables read-only to userspace through the
 * sysfs file system.
 *
 * Data is currently found below
 *    /sys/firmware/dmi/...
 *
 * DMI attributes are presented in attribute files with names
 * formatted using %d-%d, so that the first integer indicates the
 * structure type (0-255), and the second field is the instance of that
 * entry.
 *
 * Copyright 2011 Google, Inc.
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kobject.h>
#include <linux/dmi.h>
#include <linux/capability.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/io.h>
#include <asm/dmi.h>

#define MAX_ENTRY_TYPE

struct dmi_sysfs_entry {};

/*
 * Global list of dmi_sysfs_entry.  Even though this should only be
 * manipulated at setup and teardown, the lazy nature of the kobject
 * system means we get lazy removes.
 */
static LIST_HEAD(entry_list);
static DEFINE_SPINLOCK(entry_list_lock);

/* dmi_sysfs_attribute - Top level attribute. used by all entries. */
struct dmi_sysfs_attribute {};

#define DMI_SYSFS_ATTR(_entry, _name)

/*
 * dmi_sysfs_mapped_attribute - Attribute where we require the entry be
 * mapped in.  Use in conjunction with dmi_sysfs_specialize_attr_ops.
 */
struct dmi_sysfs_mapped_attribute {};

#define DMI_SYSFS_MAPPED_ATTR(_entry, _name)

/*************************************************
 * Generic DMI entry support.
 *************************************************/
static void dmi_entry_free(struct kobject *kobj)
{}

static struct dmi_sysfs_entry *to_entry(struct kobject *kobj)
{}

static struct dmi_sysfs_attribute *to_attr(struct attribute *attr)
{}

static ssize_t dmi_sysfs_attr_show(struct kobject *kobj,
				   struct attribute *_attr, char *buf)
{}

static const struct sysfs_ops dmi_sysfs_attr_ops =;

dmi_callback;

struct find_dmi_data {};

static void find_dmi_entry_helper(const struct dmi_header *dh,
				  void *_data)
{}

/* State for passing the read parameters through dmi_find_entry() */
struct dmi_read_state {};

static ssize_t find_dmi_entry(struct dmi_sysfs_entry *entry,
			      dmi_callback callback, void *private)
{}

/*
 * Calculate and return the byte length of the dmi entry identified by
 * dh.  This includes both the formatted portion as well as the
 * unformatted string space, including the two trailing nul characters.
 */
static size_t dmi_entry_length(const struct dmi_header *dh)
{}

/*************************************************
 * Support bits for specialized DMI entry support
 *************************************************/
struct dmi_entry_attr_show_data {};

static ssize_t dmi_entry_attr_show_helper(struct dmi_sysfs_entry *entry,
					  const struct dmi_header *dh,
					  void *_data)
{}

static ssize_t dmi_entry_attr_show(struct kobject *kobj,
				   struct attribute *attr,
				   char *buf)
{}

static const struct sysfs_ops dmi_sysfs_specialize_attr_ops =;

/*************************************************
 * Specialized DMI entry support.
 *************************************************/

/*** Type 15 - System Event Table ***/

#define DMI_SEL_ACCESS_METHOD_IO8
#define DMI_SEL_ACCESS_METHOD_IO2x8
#define DMI_SEL_ACCESS_METHOD_IO16
#define DMI_SEL_ACCESS_METHOD_PHYS32
#define DMI_SEL_ACCESS_METHOD_GPNV

struct dmi_system_event_log {} __packed;

#define DMI_SYSFS_SEL_FIELD(_field)

DMI_SYSFS_SEL_FIELD();
DMI_SYSFS_SEL_FIELD();
DMI_SYSFS_SEL_FIELD();
DMI_SYSFS_SEL_FIELD();
DMI_SYSFS_SEL_FIELD();
DMI_SYSFS_SEL_FIELD();
DMI_SYSFS_SEL_FIELD();
DMI_SYSFS_SEL_FIELD();
DMI_SYSFS_SEL_FIELD();
DMI_SYSFS_SEL_FIELD();

static struct attribute *dmi_sysfs_sel_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct kobj_type dmi_system_event_log_ktype =;

#ifdef CONFIG_HAS_IOPORT
sel_io_reader;

static DEFINE_MUTEX(io_port_lock);

static u8 read_sel_8bit_indexed_io(const struct dmi_system_event_log *sel,
				   loff_t offset)
{}

static u8 read_sel_2x8bit_indexed_io(const struct dmi_system_event_log *sel,
				     loff_t offset)
{}

static u8 read_sel_16bit_indexed_io(const struct dmi_system_event_log *sel,
				    loff_t offset)
{}

static sel_io_reader sel_io_readers[] =;

static ssize_t dmi_sel_raw_read_io(struct dmi_sysfs_entry *entry,
				   const struct dmi_system_event_log *sel,
				   char *buf, loff_t pos, size_t count)
{}
#endif

static ssize_t dmi_sel_raw_read_phys32(struct dmi_sysfs_entry *entry,
				       const struct dmi_system_event_log *sel,
				       char *buf, loff_t pos, size_t count)
{}

static ssize_t dmi_sel_raw_read_helper(struct dmi_sysfs_entry *entry,
				       const struct dmi_header *dh,
				       void *_state)
{}

static ssize_t dmi_sel_raw_read(struct file *filp, struct kobject *kobj,
				struct bin_attribute *bin_attr,
				char *buf, loff_t pos, size_t count)
{}

static struct bin_attribute dmi_sel_raw_attr =;

static int dmi_system_event_log(struct dmi_sysfs_entry *entry)
{}

/*************************************************
 * Generic DMI entry support.
 *************************************************/

static ssize_t dmi_sysfs_entry_length(struct dmi_sysfs_entry *entry, char *buf)
{}

static ssize_t dmi_sysfs_entry_handle(struct dmi_sysfs_entry *entry, char *buf)
{}

static ssize_t dmi_sysfs_entry_type(struct dmi_sysfs_entry *entry, char *buf)
{}

static ssize_t dmi_sysfs_entry_instance(struct dmi_sysfs_entry *entry,
					char *buf)
{}

static ssize_t dmi_sysfs_entry_position(struct dmi_sysfs_entry *entry,
					char *buf)
{}

static DMI_SYSFS_ATTR(entry, length);
static DMI_SYSFS_ATTR(entry, handle);
static DMI_SYSFS_ATTR(entry, type);
static DMI_SYSFS_ATTR(entry, instance);
static DMI_SYSFS_ATTR(entry, position);

static struct attribute *dmi_sysfs_entry_attrs[] =;
ATTRIBUTE_GROUPS();

static ssize_t dmi_entry_raw_read_helper(struct dmi_sysfs_entry *entry,
					 const struct dmi_header *dh,
					 void *_state)
{}

static ssize_t dmi_entry_raw_read(struct file *filp,
				  struct kobject *kobj,
				  struct bin_attribute *bin_attr,
				  char *buf, loff_t pos, size_t count)
{}

static const struct bin_attribute dmi_entry_raw_attr =;

static void dmi_sysfs_entry_release(struct kobject *kobj)
{}

static const struct kobj_type dmi_sysfs_entry_ktype =;

static struct kset *dmi_kset;

/* Global count of all instances seen.  Only for setup */
static int __initdata instance_counts[MAX_ENTRY_TYPE + 1];

/* Global positional count of all entries seen.  Only for setup */
static int __initdata position_count;

static void __init dmi_sysfs_register_handle(const struct dmi_header *dh,
					     void *_ret)
{}

static void cleanup_entry_list(void)
{}

static int __init dmi_sysfs_init(void)
{}

/* clean up everything. */
static void __exit dmi_sysfs_exit(void)
{}

module_init();
module_exit(dmi_sysfs_exit);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();