linux/drivers/staging/gasket/gasket.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * Common Gasket device kernel and user space declarations.
   4 *
   5 * Copyright (C) 2018 Google, Inc.
   6 */
   7#ifndef __GASKET_H__
   8#define __GASKET_H__
   9
  10#include <linux/ioctl.h>
  11#include <linux/types.h>
  12
  13/* ioctl structure declarations */
  14
  15/* Ioctl structures are padded to a multiple of 64 bits */
  16/* and padded to put 64 bit values on 64 bit boundaries. */
  17/* Unsigned 64 bit integers are used to hold pointers. */
  18/* This helps compatibility between 32 and 64 bits. */
  19
  20/*
  21 * Common structure for ioctls associating an eventfd with a device interrupt,
  22 * when using the Gasket interrupt module.
  23 */
  24struct gasket_interrupt_eventfd {
  25        u64 interrupt;
  26        u64 event_fd;
  27};
  28
  29/*
  30 * Common structure for ioctls mapping and unmapping buffers when using the
  31 * Gasket page_table module.
  32 */
  33struct gasket_page_table_ioctl {
  34        u64 page_table_index;
  35        u64 size;
  36        u64 host_address;
  37        u64 device_address;
  38};
  39
  40/*
  41 * Common structure for ioctls mapping and unmapping buffers when using the
  42 * Gasket page_table module.
  43 * dma_address: phys addr start of coherent memory, allocated by kernel
  44 */
  45struct gasket_coherent_alloc_config_ioctl {
  46        u64 page_table_index;
  47        u64 enable;
  48        u64 size;
  49        u64 dma_address;
  50};
  51
  52/* Base number for all Gasket-common IOCTLs */
  53#define GASKET_IOCTL_BASE 0xDC
  54
  55/* Reset the device. */
  56#define GASKET_IOCTL_RESET _IO(GASKET_IOCTL_BASE, 0)
  57
  58/* Associate the specified [event]fd with the specified interrupt. */
  59#define GASKET_IOCTL_SET_EVENTFD                                               \
  60        _IOW(GASKET_IOCTL_BASE, 1, struct gasket_interrupt_eventfd)
  61
  62/*
  63 * Clears any eventfd associated with the specified interrupt. The (ulong)
  64 * argument is the interrupt number to clear.
  65 */
  66#define GASKET_IOCTL_CLEAR_EVENTFD _IOW(GASKET_IOCTL_BASE, 2, unsigned long)
  67
  68/*
  69 * [Loopbacks only] Requests that the loopback device send the specified
  70 * interrupt to the host. The (ulong) argument is the number of the interrupt to
  71 * send.
  72 */
  73#define GASKET_IOCTL_LOOPBACK_INTERRUPT                                        \
  74        _IOW(GASKET_IOCTL_BASE, 3, unsigned long)
  75
  76/* Queries the kernel for the number of page tables supported by the device. */
  77#define GASKET_IOCTL_NUMBER_PAGE_TABLES _IOR(GASKET_IOCTL_BASE, 4, u64)
  78
  79/*
  80 * Queries the kernel for the maximum size of the page table.  Only the size and
  81 * page_table_index fields are used from the struct gasket_page_table_ioctl.
  82 */
  83#define GASKET_IOCTL_PAGE_TABLE_SIZE                                           \
  84        _IOWR(GASKET_IOCTL_BASE, 5, struct gasket_page_table_ioctl)
  85
  86/*
  87 * Queries the kernel for the current simple page table size.  Only the size and
  88 * page_table_index fields are used from the struct gasket_page_table_ioctl.
  89 */
  90#define GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE                                    \
  91        _IOWR(GASKET_IOCTL_BASE, 6, struct gasket_page_table_ioctl)
  92
  93/*
  94 * Tells the kernel to change the split between the number of simple and
  95 * extended entries in the given page table. Only the size and page_table_index
  96 * fields are used from the struct gasket_page_table_ioctl.
  97 */
  98#define GASKET_IOCTL_PARTITION_PAGE_TABLE                                      \
  99        _IOW(GASKET_IOCTL_BASE, 7, struct gasket_page_table_ioctl)
 100
 101/*
 102 * Tells the kernel to map size bytes at host_address to device_address in
 103 * page_table_index page table.
 104 */
 105#define GASKET_IOCTL_MAP_BUFFER                                                \
 106        _IOW(GASKET_IOCTL_BASE, 8, struct gasket_page_table_ioctl)
 107
 108/*
 109 * Tells the kernel to unmap size bytes at host_address from device_address in
 110 * page_table_index page table.
 111 */
 112#define GASKET_IOCTL_UNMAP_BUFFER                                              \
 113        _IOW(GASKET_IOCTL_BASE, 9, struct gasket_page_table_ioctl)
 114
 115/* Clear the interrupt counts stored for this device. */
 116#define GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS _IO(GASKET_IOCTL_BASE, 10)
 117
 118/* Enable/Disable and configure the coherent allocator. */
 119#define GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR                                 \
 120        _IOWR(GASKET_IOCTL_BASE, 11, struct gasket_coherent_alloc_config_ioctl)
 121
 122#endif /* __GASKET_H__ */
 123