Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  * Surface System Aggregator Module (SSAM) user-space EC interface.
0004  *
0005  * Definitions, structs, and IOCTLs for the /dev/surface/aggregator misc
0006  * device. This device provides direct user-space access to the SSAM EC.
0007  * Intended for debugging and development.
0008  *
0009  * Copyright (C) 2020-2021 Maximilian Luz <luzmaximilian@gmail.com>
0010  */
0011 
0012 #ifndef _UAPI_LINUX_SURFACE_AGGREGATOR_CDEV_H
0013 #define _UAPI_LINUX_SURFACE_AGGREGATOR_CDEV_H
0014 
0015 #include <linux/ioctl.h>
0016 #include <linux/types.h>
0017 
0018 /**
0019  * enum ssam_cdev_request_flags - Request flags for SSAM cdev request IOCTL.
0020  *
0021  * @SSAM_CDEV_REQUEST_HAS_RESPONSE:
0022  *  Specifies that the request expects a response. If not set, the request
0023  *  will be directly completed after its underlying packet has been
0024  *  transmitted. If set, the request transport system waits for a response
0025  *  of the request.
0026  *
0027  * @SSAM_CDEV_REQUEST_UNSEQUENCED:
0028  *  Specifies that the request should be transmitted via an unsequenced
0029  *  packet. If set, the request must not have a response, meaning that this
0030  *  flag and the %SSAM_CDEV_REQUEST_HAS_RESPONSE flag are mutually
0031  *  exclusive.
0032  */
0033 enum ssam_cdev_request_flags {
0034     SSAM_CDEV_REQUEST_HAS_RESPONSE = 0x01,
0035     SSAM_CDEV_REQUEST_UNSEQUENCED  = 0x02,
0036 };
0037 
0038 /**
0039  * struct ssam_cdev_request - Controller request IOCTL argument.
0040  * @target_category: Target category of the SAM request.
0041  * @target_id:       Target ID of the SAM request.
0042  * @command_id:      Command ID of the SAM request.
0043  * @instance_id:     Instance ID of the SAM request.
0044  * @flags:           Request flags (see &enum ssam_cdev_request_flags).
0045  * @status:          Request status (output).
0046  * @payload:         Request payload (input data).
0047  * @payload.data:    Pointer to request payload data.
0048  * @payload.length:  Length of request payload data (in bytes).
0049  * @response:        Request response (output data).
0050  * @response.data:   Pointer to response buffer.
0051  * @response.length: On input: Capacity of response buffer (in bytes).
0052  *                   On output: Length of request response (number of bytes
0053  *                   in the buffer that are actually used).
0054  */
0055 struct ssam_cdev_request {
0056     __u8 target_category;
0057     __u8 target_id;
0058     __u8 command_id;
0059     __u8 instance_id;
0060     __u16 flags;
0061     __s16 status;
0062 
0063     struct {
0064         __u64 data;
0065         __u16 length;
0066         __u8 __pad[6];
0067     } payload;
0068 
0069     struct {
0070         __u64 data;
0071         __u16 length;
0072         __u8 __pad[6];
0073     } response;
0074 } __attribute__((__packed__));
0075 
0076 /**
0077  * struct ssam_cdev_notifier_desc - Notifier descriptor.
0078  * @priority:        Priority value determining the order in which notifier
0079  *                   callbacks will be called. A higher value means higher
0080  *                   priority, i.e. the associated callback will be executed
0081  *                   earlier than other (lower priority) callbacks.
0082  * @target_category: The event target category for which this notifier should
0083  *                   receive events.
0084  *
0085  * Specifies the notifier that should be registered or unregistered,
0086  * specifically with which priority and for which target category of events.
0087  */
0088 struct ssam_cdev_notifier_desc {
0089     __s32 priority;
0090     __u8 target_category;
0091 } __attribute__((__packed__));
0092 
0093 /**
0094  * struct ssam_cdev_event_desc - Event descriptor.
0095  * @reg:                 Registry via which the event will be enabled/disabled.
0096  * @reg.target_category: Target category for the event registry requests.
0097  * @reg.target_id:       Target ID for the event registry requests.
0098  * @reg.cid_enable:      Command ID for the event-enable request.
0099  * @reg.cid_disable:     Command ID for the event-disable request.
0100  * @id:                  ID specifying the event.
0101  * @id.target_category:  Target category of the event source.
0102  * @id.instance:         Instance ID of the event source.
0103  * @flags:               Flags used for enabling the event.
0104  *
0105  * Specifies which event should be enabled/disabled and how to do that.
0106  */
0107 struct ssam_cdev_event_desc {
0108     struct {
0109         __u8 target_category;
0110         __u8 target_id;
0111         __u8 cid_enable;
0112         __u8 cid_disable;
0113     } reg;
0114 
0115     struct {
0116         __u8 target_category;
0117         __u8 instance;
0118     } id;
0119 
0120     __u8 flags;
0121 } __attribute__((__packed__));
0122 
0123 /**
0124  * struct ssam_cdev_event - SSAM event sent by the EC.
0125  * @target_category: Target category of the event source. See &enum ssam_ssh_tc.
0126  * @target_id:       Target ID of the event source.
0127  * @command_id:      Command ID of the event.
0128  * @instance_id:     Instance ID of the event source.
0129  * @length:          Length of the event payload in bytes.
0130  * @data:            Event payload data.
0131  */
0132 struct ssam_cdev_event {
0133     __u8 target_category;
0134     __u8 target_id;
0135     __u8 command_id;
0136     __u8 instance_id;
0137     __u16 length;
0138     __u8 data[];
0139 } __attribute__((__packed__));
0140 
0141 #define SSAM_CDEV_REQUEST       _IOWR(0xA5, 1, struct ssam_cdev_request)
0142 #define SSAM_CDEV_NOTIF_REGISTER    _IOW(0xA5, 2, struct ssam_cdev_notifier_desc)
0143 #define SSAM_CDEV_NOTIF_UNREGISTER  _IOW(0xA5, 3, struct ssam_cdev_notifier_desc)
0144 #define SSAM_CDEV_EVENT_ENABLE      _IOW(0xA5, 4, struct ssam_cdev_event_desc)
0145 #define SSAM_CDEV_EVENT_DISABLE     _IOW(0xA5, 5, struct ssam_cdev_event_desc)
0146 
0147 #endif /* _UAPI_LINUX_SURFACE_AGGREGATOR_CDEV_H */