1 // SPDX-License-Identifier: GPL-2.0-only
3 * AMD Secure Processor Dynamic Boost Control sample library
5 * Copyright (C) 2023 Advanced Micro Devices, Inc.
7 * Author: Mario Limonciello <mario.limonciello@amd.com>
13 #include <sys/ioctl.h>
15 /* if uapi header isn't installed, this might not yet exist */
17 #define __packed __attribute__((packed))
19 #include <linux/psp-dbc.h>
21 int get_nonce(int fd
, void *nonce_out
, void *signature
)
23 struct dbc_user_nonce tmp
= {
24 .auth_needed
= !!signature
,
30 memcpy(tmp
.signature
, signature
, sizeof(tmp
.signature
));
32 if (ioctl(fd
, DBCIOCNONCE
, &tmp
))
34 memcpy(nonce_out
, tmp
.nonce
, sizeof(tmp
.nonce
));
39 int set_uid(int fd
, __u8
*uid
, __u8
*signature
)
41 struct dbc_user_setuid tmp
;
46 memcpy(tmp
.uid
, uid
, sizeof(tmp
.uid
));
47 memcpy(tmp
.signature
, signature
, sizeof(tmp
.signature
));
49 if (ioctl(fd
, DBCIOCUID
, &tmp
))
54 int process_param(int fd
, int msg_index
, __u8
*signature
, int *data
)
56 struct dbc_user_param tmp
= {
57 .msg_index
= msg_index
,
64 memcpy(tmp
.signature
, signature
, sizeof(tmp
.signature
));
66 if (ioctl(fd
, DBCIOCPARAM
, &tmp
))
70 memcpy(signature
, tmp
.signature
, sizeof(tmp
.signature
));