cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

p_basic.c (1114B)


      1// SPDX-License-Identifier: GPL-2.0
      2/*
      3 * Basic framing protocol for STM devices.
      4 * Copyright (c) 2018, Intel Corporation.
      5 */
      6
      7#include <linux/module.h>
      8#include <linux/device.h>
      9#include <linux/stm.h>
     10#include "stm.h"
     11
     12static ssize_t basic_write(struct stm_data *data, struct stm_output *output,
     13			   unsigned int chan, const char *buf, size_t count)
     14{
     15	unsigned int c = output->channel + chan;
     16	unsigned int m = output->master;
     17	const unsigned char nil = 0;
     18	ssize_t sz;
     19
     20	sz = stm_data_write(data, m, c, true, buf, count);
     21	if (sz > 0)
     22		data->packet(data, m, c, STP_PACKET_FLAG, 0, 0, &nil);
     23
     24	return sz;
     25}
     26
     27static const struct stm_protocol_driver basic_pdrv = {
     28	.owner	= THIS_MODULE,
     29	.name	= "p_basic",
     30	.write	= basic_write,
     31};
     32
     33static int basic_stm_init(void)
     34{
     35	return stm_register_protocol(&basic_pdrv);
     36}
     37
     38static void basic_stm_exit(void)
     39{
     40	stm_unregister_protocol(&basic_pdrv);
     41}
     42
     43module_init(basic_stm_init);
     44module_exit(basic_stm_exit);
     45
     46MODULE_LICENSE("GPL v2");
     47MODULE_DESCRIPTION("Basic STM framing protocol driver");
     48MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@linux.intel.com>");