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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
// SPDX-License-Identifier: MIT
/*
* Copyright © 2021 Intel Corporation
*/
#ifndef __INTEL_ALLOCATOR_MSGCHANNEL_H__
#define __INTEL_ALLOCATOR_MSGCHANNEL_H__
#include <unistd.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
enum reqtype {
REQ_STOP,
REQ_OPEN,
REQ_CLOSE,
REQ_ADDRESS_RANGE,
REQ_ALLOC,
REQ_FREE,
REQ_IS_ALLOCATED,
REQ_RESERVE,
REQ_UNRESERVE,
REQ_RESERVE_IF_NOT_ALLOCATED,
REQ_IS_RESERVED,
};
enum resptype {
RESP_OPEN,
RESP_CLOSE,
RESP_ADDRESS_RANGE,
RESP_ALLOC,
RESP_FREE,
RESP_IS_ALLOCATED,
RESP_RESERVE,
RESP_UNRESERVE,
RESP_IS_RESERVED,
RESP_RESERVE_IF_NOT_ALLOCATED,
};
struct alloc_req {
enum reqtype request_type;
/* Common */
pid_t tid;
uint64_t allocator_handle;
union {
struct {
int fd;
uint32_t ctx;
uint32_t vm;
uint64_t start;
uint64_t end;
uint8_t allocator_type;
uint8_t allocator_strategy;
uint64_t default_alignment;
} open;
struct {
uint32_t handle;
uint64_t size;
uint64_t alignment;
uint8_t pat_index;
uint8_t strategy;
} alloc;
struct {
uint32_t handle;
} free;
struct {
uint32_t handle;
uint64_t size;
uint64_t offset;
} is_allocated;
struct {
uint32_t handle;
uint64_t start;
uint64_t end;
} reserve, unreserve;
struct {
uint64_t start;
uint64_t end;
} is_reserved;
};
};
struct alloc_resp {
enum resptype response_type;
pid_t tid;
union {
struct {
uint64_t allocator_handle;
} open;
struct {
bool is_empty;
} close;
struct {
uint64_t start;
uint64_t end;
uint8_t direction;
} address_range;
struct {
uint64_t offset;
} alloc;
struct {
bool freed;
} free;
struct {
bool allocated;
} is_allocated;
struct {
bool reserved;
} reserve, is_reserved;
struct {
bool unreserved;
} unreserve;
struct {
bool allocated;
bool reserved;
} reserve_if_not_allocated;
};
};
struct msg_channel {
bool ready;
void *priv;
void (*init)(struct msg_channel *channel);
void (*deinit)(struct msg_channel *channel);
int (*send_req)(struct msg_channel *channel, struct alloc_req *request);
int (*recv_req)(struct msg_channel *channel, struct alloc_req *request);
int (*send_resp)(struct msg_channel *channel, struct alloc_resp *response);
int (*recv_resp)(struct msg_channel *channel, struct alloc_resp *response);
};
enum msg_channel_type {
CHANNEL_SYSVIPC_MSGQUEUE
};
struct msg_channel *intel_allocator_get_msgchannel(enum msg_channel_type type);
#endif
|