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

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2020 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://docs.broadcom.com/doc/12358545
    23  // https://github.com/raspberrypi/linux/tree/rpi-5.4.y/drivers/char/broadcom
    24  const vcioSummary = `allows access to VideoCore I/O`
    25  
    26  // The raspberry pi allows programming its GPU from userspace via the /dev/vcio
    27  // device. These operations should be considered privileged since the driver
    28  // assumes trusted input, therefore require manual connection.
    29  const vcioBaseDeclarationSlots = `
    30    vcio:
    31      allow-installation:
    32        slot-snap-type:
    33          - core
    34      deny-auto-connection: true
    35  `
    36  
    37  const vcioConnectedPlugAppArmor = `
    38  # Description: Can access to vcio.
    39  
    40  # vcio v1 access to ARM VideoCore (BCM_VCIO) for userspace GPU programming
    41  /dev/vcio rw,
    42  /sys/devices/virtual/bcm2708_vcio/vcio/** r,
    43  # the vcio driver uses dynamic allocation for its major number and
    44  # https://www.kernel.org/doc/Documentation/admin-guide/devices.txt lists
    45  # 234-254 char as "RESERVED FOR DYNAMIC ASSIGNMENT".
    46  /run/udev/data/c23[4-9]:[0-9]* r,
    47  /run/udev/data/c24[0-9]:[0-9]* r,
    48  /run/udev/data/c25[0-4]:[0-9]* r,
    49  `
    50  
    51  var vcioConnectedPlugUDev = []string{
    52  	`SUBSYSTEM=="bcm2708_vcio", KERNEL=="vcio"`,
    53  }
    54  
    55  func init() {
    56  	registerIface(&commonInterface{
    57  		name:                  "vcio",
    58  		summary:               vcioSummary,
    59  		implicitOnCore:        true,
    60  		implicitOnClassic:     true,
    61  		baseDeclarationSlots:  vcioBaseDeclarationSlots,
    62  		connectedPlugAppArmor: vcioConnectedPlugAppArmor,
    63  		connectedPlugUDev:     vcioConnectedPlugUDev,
    64  	})
    65  }