39 lines
1.2 KiB
C
39 lines
1.2 KiB
C
// Kernel ke queue declarations shared by implementation files and kernel clients.
|
|
|
|
#pragma once
|
|
// Fixed-depth message queue.
|
|
// Processes share an address space, so a pointer in Param[] is valid on both sides.
|
|
// The queue orders fixed control records and does not copy pointed-to payloads.
|
|
#include <stdint.h>
|
|
#include <kernel/ob_object.h>
|
|
#include <kernel/ke_spinlock.h>
|
|
#include <kernel/ke_list.h>
|
|
#include <kernel/ke_event.h>
|
|
#include <ntlite/status.h>
|
|
|
|
#define QUEUE_MESSAGE_SIZE 56 // Bytes, fixed ABI copy size.
|
|
#define QUEUE_DEPTH 256
|
|
|
|
typedef struct QUEUE_MESSAGE {
|
|
uint32_t Type;
|
|
uint32_t Flags;
|
|
uint64_t Param[6]; // 48 bytes of payload.
|
|
} QUEUE_MESSAGE;
|
|
|
|
typedef char QUEUE_MESSAGE_SIZE_CHECK[
|
|
(sizeof(QUEUE_MESSAGE) == QUEUE_MESSAGE_SIZE) ? 1 : -1
|
|
];
|
|
|
|
typedef struct QUEUE {
|
|
OBJECT Header;
|
|
SPINLOCK Lock;
|
|
QUEUE_MESSAGE Ring[QUEUE_DEPTH];
|
|
uint32_t Head, Tail, Count;
|
|
EVENT* NotEmptyEvent;
|
|
EVENT* NotFullEvent;
|
|
} QUEUE;
|
|
|
|
KSTATUS KeQueueCreate(QUEUE** out);
|
|
KSTATUS KeSendMessage(QUEUE* queue, const QUEUE_MESSAGE* msg, uint64_t timeoutMilliseconds);
|
|
KSTATUS KeReceiveMessage(QUEUE* queue, QUEUE_MESSAGE* msg, uint64_t timeoutMilliseconds);
|