forked from MIrrors/gasket-driver
The Gasket (Google ASIC Software, Kernel Extensions, and Tools) kernel framework is a generic, flexible system that supports thin kernel drivers. Gasket kernel drivers are expected to handle opening and closing devices, mmap'ing BAR space as requested, a small selection of ioctls, and handling page table translation (covered below). Any other functions should be handled by userspace code. The Gasket common module is not enough to run a device. In order to customize the Gasket code for a given piece of hardware, a device specific module must be created. At a minimum, this module must define a struct gasket_driver_desc containing the device-specific data for use by the framework; in addition, the module must declare an __init function that calls gasket_register_device with the module's gasket_driver_desc struct. Finally, the driver must define an exit function that calls gasket_unregister_device with the module's gasket_driver_desc struct. One of the core assumptions of the Gasket framework is that precisely one process is allowed to have an open write handle to the device node at any given time. (That process may, once it has one write handle, open any number of additional write handles.) This is accomplished by tracking open and close data for each driver instance. Change-Id: I0ce1dc1dc9c533026adbc3aacaefb830ecdbc3e9 Signed-off-by: Rob Springer <rspringer@google.com> Signed-off-by: John Joseph <jnjoseph@google.com> Signed-off-by: Simon Que <sque@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
72 lines
3.1 KiB
C
72 lines
3.1 KiB
C
/* Common logging utilities for the Gasket driver framework.
|
|
*
|
|
* Copyright (C) 2018 Google, Inc.
|
|
*
|
|
* This software is licensed under the terms of the GNU General Public
|
|
* License version 2, as published by the Free Software Foundation, and
|
|
* may be copied, distributed, and modified under those terms.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <linux/pci.h>
|
|
#include <linux/printk.h>
|
|
|
|
#ifndef _GASKET_LOGGING_H_
|
|
#define _GASKET_LOGGING_H_
|
|
|
|
/* Base macro; other logging can/should be built on top of this. */
|
|
#define gasket_dev_log(level, device, pci_dev, format, arg...) \
|
|
if (false) { \
|
|
if (pci_dev) { \
|
|
dev_##level(&(pci_dev)->dev, "%s: " format "\n", \
|
|
__func__, ##arg); \
|
|
} else { \
|
|
gasket_nodev_log(level, format, ##arg); \
|
|
} \
|
|
}
|
|
|
|
/* "No-device" logging macros. */
|
|
#define gasket_nodev_log(level, format, arg...) \
|
|
if (false) pr_##level("gasket: %s: " format "\n", __func__, ##arg)
|
|
|
|
#define gasket_nodev_debug(format, arg...) \
|
|
if (false) gasket_nodev_log(debug, format, ##arg)
|
|
|
|
#define gasket_nodev_info(format, arg...) \
|
|
if (false) gasket_nodev_log(info, format, ##arg)
|
|
|
|
#define gasket_nodev_warn(format, arg...) \
|
|
if (false) gasket_nodev_log(warn, format, ##arg)
|
|
|
|
#define gasket_nodev_error(format, arg...) \
|
|
if (false) gasket_nodev_log(err, format, ##arg)
|
|
|
|
/* gasket_dev logging macros */
|
|
#define gasket_log_info(gasket_dev, format, arg...) \
|
|
if (false) gasket_dev_log(info, (gasket_dev)->dev_info.device, \
|
|
(gasket_dev)->pci_dev, format, ##arg)
|
|
|
|
#define gasket_log_warn(gasket_dev, format, arg...) \
|
|
if (false) gasket_dev_log(warn, (gasket_dev)->dev_info.device, \
|
|
(gasket_dev)->pci_dev, format, ##arg)
|
|
|
|
#define gasket_log_error(gasket_dev, format, arg...) \
|
|
if (false) gasket_dev_log(err, (gasket_dev)->dev_info.device, \
|
|
(gasket_dev)->pci_dev, format, ##arg)
|
|
|
|
#define gasket_log_debug(gasket_dev, format, arg...) \
|
|
if (false){ \
|
|
if ((gasket_dev)->pci_dev) { \
|
|
dev_dbg(&((gasket_dev)->pci_dev)->dev, "%s: " format \
|
|
"\n", __func__, ##arg); \
|
|
} else { \
|
|
gasket_nodev_log(debug, format, ##arg); \
|
|
} \
|
|
}
|
|
|
|
#endif
|