uint32 iovMapped = 0;
int32 size = bufSize;
int i;
- void* (*func)(uint64, uint32, char **);
+ HgfsChannelMapVirtAddrFunc getVa;
+
ASSERT(buf);
if (*buf) {
if (mappingType == BUF_WRITEABLE ||
mappingType == BUF_READWRITEABLE) {
- func = transportSession->channelCbTable->getWriteVa;
+ getVa = transportSession->channelCbTable->getWriteVa;
} else {
ASSERT(mappingType == BUF_READABLE);
- func = transportSession->channelCbTable->getReadVa;
+ getVa = transportSession->channelCbTable->getReadVa;
}
/* Looks like we are in the middle of poweroff. */
- if (func == NULL) {
+ if (getVa == NULL) {
return NULL;
}
for (iovCount = startIndex; iovCount < packet->iovCount && size > 0;
iovCount++) {
- packet->iov[iovCount].token = NULL;
+ packet->iov[iovCount].context = NULL;
/* Debugging check: Iov in VMCI should never cross page boundary */
ASSERT_DEVEL(packet->iov[iovCount].len <=
(PAGE_SIZE - PAGE_OFFSET(packet->iov[iovCount].pa)));
- packet->iov[iovCount].va = func(packet->iov[iovCount].pa,
- packet->iov[iovCount].len,
- &packet->iov[iovCount].token);
+ packet->iov[iovCount].va = getVa(packet->iov[iovCount].pa,
+ packet->iov[iovCount].len,
+ &packet->iov[iovCount].context);
ASSERT_DEVEL(packet->iov[iovCount].va);
if (packet->iov[iovCount].va == NULL) {
/* Guest probably passed us bad physical address */
freeMem:
for (i = startIndex; i < iovCount; i++) {
- transportSession->channelCbTable->putVa(&packet->iov[i].token);
+ transportSession->channelCbTable->putVa(&packet->iov[i].context);
packet->iov[i].va = NULL;
}
for (iovCount = startIndex;
iovCount < packet->iovCount && size > 0;
iovCount++) {
- ASSERT_DEVEL(packet->iov[iovCount].token);
- transportSession->channelCbTable->putVa(&packet->iov[iovCount].token);
+ ASSERT_DEVEL(packet->iov[iovCount].context);
+ transportSession->channelCbTable->putVa(&packet->iov[iovCount].context);
size -= packet->iov[iovCount].len;
}
LOG(10, ("%s: Hgfs bufSize = %d \n", __FUNCTION__, size));
copyAmount = remainingSize < packet->iov[iovCount].len ?
remainingSize: packet->iov[iovCount].len;
- packet->iov[iovCount].token = NULL;
+ packet->iov[iovCount].context = NULL;
/* Debugging check: Iov in VMCI should never cross page boundary */
ASSERT_DEVEL(packet->iov[iovCount].len <=
(PAGE_SIZE - PAGE_OFFSET(packet->iov[iovCount].pa)));
- packet->iov[iovCount].va = transportSession->channelCbTable->getWriteVa(packet->iov[iovCount].pa,
- packet->iov[iovCount].len,
- &packet->iov[iovCount].token);
+ packet->iov[iovCount].va =
+ transportSession->channelCbTable->getWriteVa(packet->iov[iovCount].pa,
+ packet->iov[iovCount].len,
+ &packet->iov[iovCount].context);
ASSERT_DEVEL(packet->iov[iovCount].va);
if (packet->iov[iovCount].va != NULL) {
memcpy(packet->iov[iovCount].va, (char *)buf + copiedAmount, copyAmount);
- transportSession->channelCbTable->putVa(&packet->iov[iovCount].token);
+ transportSession->channelCbTable->putVa(&packet->iov[iovCount].context);
remainingSize -= copyAmount;
copiedAmount += copyAmount;
} else {
void *va; /* Virtual addr */
uint64 pa; /* Physical address passed by the guest */
uint32 len; /* length of data; should be <= PAGE_SIZE for VMCI; arbitrary for backdoor */
- char *token; /* Token for physMem_ APIs */
+ void *context; /* Mapping context */
} HgfsVmxIov;
typedef enum {
uint32 maxPacketSize;
}HgfsServerChannelData;
-typedef Bool
-HgfsSessionSendFunc(void *opaqueSession, // IN
- char *buffer, // IN
- size_t bufferLen, // IN
- HgfsSendFlags flags); // IN
/* Default maximum number of open nodes. */
#define HGFS_MAX_CACHED_FILENODES 30
uint32 maxCachedOpenNodes;
}HgfsServerConfig;
+typedef Bool (*HgfsChannelSendFunc)(void *opaqueSession,
+ HgfsPacket *packet,
+ char *buffer,
+ size_t bufferLen,
+ HgfsSendFlags flags);
+typedef void * (*HgfsChannelMapVirtAddrFunc)(uint64 pa, uint32 size, void **context);
+typedef void (*HgfsChannelUnmapVirtAddrFunc)(void **context);
+
typedef struct HgfsServerChannelCallbacks {
- void* (*getReadVa)(uint64 pa, uint32 size, char **token);
- void* (*getWriteVa)(uint64 pa, uint32 size, char **token);
- void (*putVa)(char **token);
- Bool (*send)(void *opaqueSession, HgfsPacket *packet, char *buffer,
- size_t bufferLen, HgfsSendFlags flags);
+ HgfsChannelMapVirtAddrFunc getReadVa;
+ HgfsChannelMapVirtAddrFunc getWriteVa;
+ HgfsChannelUnmapVirtAddrFunc putVa;
+ HgfsChannelSendFunc send;
}HgfsServerChannelCallbacks;
typedef struct HgfsServerSessionCallbacks {