gitee.com/mysnapcore/mysnapd@v0.1.0/interfaces/builtin/gpio_memory_control.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2017 Canonical Ltd
     5   *
     6   * This program is free software: you can redistribute it and/or modify
     7   * it under the terms of the GNU General Public License version 3 as
     8   * published by the Free Software Foundation.
     9   *
    10   * This program is distributed in the hope that it will be useful,
    11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13   * GNU General Public License for more details.
    14   *
    15   * You should have received a copy of the GNU General Public License
    16   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17   *
    18   */
    19  
    20  package builtin
    21  
    22  // https://github.com/raspberrypi/linux/blob/rpi-4.4.y/drivers/char/broadcom/bcm2835-gpiomem.c
    23  const gpioMemoryControlSummary = `allows write access to all gpio memory`
    24  
    25  const gpioMemoryControlBaseDeclarationSlots = `
    26    gpio-memory-control:
    27      allow-installation:
    28        slot-snap-type:
    29          - core
    30      deny-auto-connection: true
    31  `
    32  
    33  const gpioMemoryControlConnectedPlugAppArmor = `
    34  # Description: Allow writing to /dev/gpiomem on kernels that provide it (eg,
    35  # via the bcm2835-gpiomem kernel module). This allows direct access to the
    36  # physical memory for GPIO devices (i.e. a subset of /dev/mem) and therefore
    37  # grants access to all GPIO devices on the system.
    38  /dev/gpiomem rw,
    39  `
    40  
    41  var gpioMemoryControlConnectedPlugUDev = []string{`KERNEL=="gpiomem"`}
    42  
    43  func init() {
    44  	registerIface(&commonInterface{
    45  		name:                  "gpio-memory-control",
    46  		summary:               gpioMemoryControlSummary,
    47  		implicitOnCore:        true,
    48  		implicitOnClassic:     true,
    49  		baseDeclarationSlots:  gpioMemoryControlBaseDeclarationSlots,
    50  		connectedPlugAppArmor: gpioMemoryControlConnectedPlugAppArmor,
    51  		connectedPlugUDev:     gpioMemoryControlConnectedPlugUDev,
    52  	})
    53  }