aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/selftests/sgx/test_encl.c
blob: 734ea52f9924408332f9b6765a6be7e90d0336a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-License-Identifier: GPL-2.0
/*  Copyright(c) 2016-20 Intel Corporation. */

#include <stddef.h>
#include "defines.h"

static uint8_t encl_buffer[8192] = { 1 };

static void *memcpy(void *dest, const void *src, size_t n)
{
	size_t i;

	for (i = 0; i < n; i++)
		((char *)dest)[i] = ((char *)src)[i];

	return dest;
}

void encl_body(void *rdi,  void *rsi)
{
	struct encl_op *op = (struct encl_op *)rdi;

	switch (op->type) {
	case ENCL_OP_PUT:
		memcpy(&encl_buffer[0], &op->buffer, 8);
		break;

	case ENCL_OP_GET:
		memcpy(&op->buffer, &encl_buffer[0], 8);
		break;

	default:
		break;
	}
}