1
/*********************************************************
2
* Copyright (C) 2006 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation version 2 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* You should have received a copy of the GNU General Public License along
14
* with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
*********************************************************/
22
* VMCI Resource Access Control API.
25
#ifndef _VMCI_RESOURCE_H_
26
#define _VMCI_RESOURCE_H_
28
#define INCLUDE_ALLOW_VMMON
29
#define INCLUDE_ALLOW_VMCORE
30
#define INCLUDE_ALLOW_MODULE
31
#define INCLUDE_ALLOW_VMKERNEL
32
#include "includeCheck.h"
34
#include "vmci_defs.h"
35
#include "vmci_kernel_if.h"
36
#include "vmciHashtable.h"
37
#include "vmciContext.h"
39
#define RESOURCE_CONTAINER(ptr, type, member) \
40
((type *)((char *)(ptr) - offsetof(type, member)))
42
typedef void(*VMCIResourceFreeCB)(void *resource);
45
VMCI_RESOURCE_TYPE_ANY,
46
VMCI_RESOURCE_TYPE_API,
47
VMCI_RESOURCE_TYPE_GROUP,
48
VMCI_RESOURCE_TYPE_DATAGRAM,
49
VMCI_RESOURCE_TYPE_DOORBELL,
52
typedef struct VMCIResource {
53
VMCIHashEntry hashEntry;
54
VMCIResourceType type;
55
VMCIResourceFreeCB containerFreeCB; // Callback to free container
56
// object when refCount is 0.
57
void *containerObject; // Container object reference.
62
int VMCIResource_Init(void);
63
void VMCIResource_Exit(void);
64
void VMCIResource_Sync(void);
66
VMCIId VMCIResource_GetID(VMCIId contextID);
68
int VMCIResource_Add(VMCIResource *resource, VMCIResourceType resourceType,
69
VMCIHandle resourceHandle,
70
VMCIResourceFreeCB containerFreeCB, void *containerObject);
71
void VMCIResource_Remove(VMCIHandle resourceHandle,
72
VMCIResourceType resourceType);
73
VMCIResource *VMCIResource_Get(VMCIHandle resourceHandle,
74
VMCIResourceType resourceType);
75
void VMCIResource_Hold(VMCIResource *resource);
76
int VMCIResource_Release(VMCIResource *resource);
79
#endif // _VMCI_RESOURCE_H_