NewChannel->ChannelCallbackContext = Context;
/* Allocate the ring buffer */
- out = PageAlloc((SendRingBufferSize + RecvRingBufferSize) >> PAGE_SHIFT);
+ out = osd_PageAlloc((SendRingBufferSize + RecvRingBufferSize) >> PAGE_SHIFT);
/* out = kzalloc(sendRingBufferSize + recvRingBufferSize, GFP_KERNEL); */
ASSERT(out);
ASSERT(((unsigned long)out & (PAGE_SIZE-1)) == 0);
openInfo = kmalloc(sizeof(VMBUS_CHANNEL_MSGINFO) + sizeof(VMBUS_CHANNEL_OPEN_CHANNEL), GFP_KERNEL);
ASSERT(openInfo != NULL);
- openInfo->WaitEvent = WaitEventCreate();
+ openInfo->WaitEvent = osd_WaitEventCreate();
openMsg = (VMBUS_CHANNEL_OPEN_CHANNEL*)openInfo->Msg;
openMsg->Header.MessageType = ChannelMessageOpenChannel;
}
/* FIXME: Need to time-out here */
- WaitEventWait(openInfo->WaitEvent);
+ osd_WaitEventWait(openInfo->WaitEvent);
if (openInfo->Response.OpenResult.Status == 0)
{
ASSERT(msgInfo != NULL);
ASSERT(msgCount >0);
- msgInfo->WaitEvent = WaitEventCreate();
+ msgInfo->WaitEvent = osd_WaitEventCreate();
gpadlMsg = (VMBUS_CHANNEL_GPADL_HEADER*)msgInfo->Msg;
gpadlMsg->Header.MessageType = ChannelMessageGpadlHeader;
gpadlMsg->ChildRelId = Channel->OfferMsg.ChildRelId;
ASSERT(ret == 0);
}
}
- WaitEventWait(msgInfo->WaitEvent);
+ osd_WaitEventWait(msgInfo->WaitEvent);
/* At this point, we received the gpadl created msg */
DPRINT_DBG(VMBUS, "Received GPADL created (relid %d, status %d handle %x)",
info = kmalloc(sizeof(VMBUS_CHANNEL_MSGINFO) + sizeof(VMBUS_CHANNEL_GPADL_TEARDOWN), GFP_KERNEL);
ASSERT(info != NULL);
- info->WaitEvent = WaitEventCreate();
+ info->WaitEvent = osd_WaitEventCreate();
msg = (VMBUS_CHANNEL_GPADL_TEARDOWN*)info->Msg;
/* TODO: */
}
- WaitEventWait(info->WaitEvent);
+ osd_WaitEventWait(info->WaitEvent);
/* Received a torndown response */
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
/* Stop callback and cancel the timer asap */
Channel->OnChannelCallback = NULL;
- TimerStop(Channel->PollTimer);
+ osd_TimerStop(Channel->PollTimer);
/* Send a closing message */
info = kmalloc(sizeof(VMBUS_CHANNEL_MSGINFO) + sizeof(VMBUS_CHANNEL_CLOSE_CHANNEL), GFP_KERNEL);
ASSERT(info != NULL);
- /* info->waitEvent = WaitEventCreate(); */
+ /* info->waitEvent = osd_WaitEventCreate(); */
msg = (VMBUS_CHANNEL_CLOSE_CHANNEL*)info->Msg;
msg->Header.MessageType = ChannelMessageCloseChannel;
RingBufferCleanup(&Channel->Outbound);
RingBufferCleanup(&Channel->Inbound);
- PageFree(Channel->RingBufferPages, Channel->RingBufferPageCount);
+ osd_PageFree(Channel->RingBufferPages, Channel->RingBufferPageCount);
kfree(info);
DumpVmbusChannel(Channel);
ASSERT(Channel->OnChannelCallback);
#ifdef ENABLE_POLLING
- TimerStop(Channel->PollTimer);
+ osd_TimerStop(Channel->PollTimer);
Channel->OnChannelCallback(Channel->ChannelCallbackContext);
- TimerStart(Channel->PollTimer, 100 /* 100us */);
+ osd_TimerStart(Channel->PollTimer, 100 /* 100us */);
#else
Channel->OnChannelCallback(Channel->ChannelCallbackContext);
#endif
{
channel->OnChannelCallback(channel->ChannelCallbackContext);
#ifdef ENABLE_POLLING
- TimerStart(channel->PollTimer, 100 /* 100us */);
+ osd_TimerStart(channel->PollTimer, 100 /* 100us */);
#endif
}
}
spin_lock_init(&channel->inbound_lock);
- channel->PollTimer = TimerCreate(VmbusChannelOnTimer, channel);
+ channel->PollTimer = osd_TimerCreate(VmbusChannelOnTimer, channel);
if (!channel->PollTimer)
{
kfree(channel);
channel->ControlWQ = create_workqueue("hv_vmbus_ctl");
if (!channel->ControlWQ)
{
- TimerClose(channel->PollTimer);
+ osd_TimerClose(channel->PollTimer);
kfree(channel);
return NULL;
}
--*/
static void FreeVmbusChannel(VMBUS_CHANNEL* Channel)
{
- TimerClose(Channel->PollTimer);
+ osd_TimerClose(Channel->PollTimer);
/* We have to release the channel's workqueue/thread in the vmbus's workqueue/thread context */
/* ie we can't destroy ourselves. */
openMsg->OpenId == result->OpenId)
{
memcpy(&msgInfo->Response.OpenResult, result, sizeof(VMBUS_CHANNEL_OPEN_RESULT));
- WaitEventSet(msgInfo->WaitEvent);
+ osd_WaitEventSet(msgInfo->WaitEvent);
break;
}
}
(gpadlCreated->Gpadl == gpadlHeader->Gpadl))
{
memcpy(&msgInfo->Response.GpadlCreated, gpadlCreated, sizeof(VMBUS_CHANNEL_GPADL_CREATED));
- WaitEventSet(msgInfo->WaitEvent);
+ osd_WaitEventSet(msgInfo->WaitEvent);
break;
}
}
if (gpadlTorndown->Gpadl == gpadlTeardown->Gpadl)
{
memcpy(&msgInfo->Response.GpadlTorndown, gpadlTorndown, sizeof(VMBUS_CHANNEL_GPADL_TORNDOWN));
- WaitEventSet(msgInfo->WaitEvent);
+ osd_WaitEventSet(msgInfo->WaitEvent);
break;
}
}
{
initiate = (VMBUS_CHANNEL_INITIATE_CONTACT*)requestHeader;
memcpy(&msgInfo->Response.VersionResponse, versionResponse, sizeof(VMBUS_CHANNEL_VERSION_RESPONSE));
- WaitEventSet(msgInfo->WaitEvent);
+ osd_WaitEventSet(msgInfo->WaitEvent);
}
}
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
msgInfo = kmalloc(sizeof(VMBUS_CHANNEL_MSGINFO) + sizeof(VMBUS_CHANNEL_MESSAGE_HEADER), GFP_KERNEL);
ASSERT(msgInfo != NULL);
- msgInfo->WaitEvent = WaitEventCreate();
+ msgInfo->WaitEvent = osd_WaitEventCreate();
msg = (VMBUS_CHANNEL_MESSAGE_HEADER*)msgInfo->Msg;
msg->MessageType = ChannelMessageRequestOffers;
goto Cleanup;
}
- /* WaitEventWait(msgInfo->waitEvent); */
+ /* osd_WaitEventWait(msgInfo->waitEvent); */
/*SpinlockAcquire(gVmbusConnection.channelMsgLock);
REMOVE_ENTRY_LIST(&msgInfo->msgListEntry);
* Setup the vmbus event connection for channel interrupt
* abstraction stuff
*/
- gVmbusConnection.InterruptPage = PageAlloc(1);
+ gVmbusConnection.InterruptPage = osd_PageAlloc(1);
if (gVmbusConnection.InterruptPage == NULL)
{
ret = -1;
* notification facility. The 1st page for parent->child and
* the 2nd page for child->parent
*/
- gVmbusConnection.MonitorPages = PageAlloc(2);
+ gVmbusConnection.MonitorPages = osd_PageAlloc(2);
if (gVmbusConnection.MonitorPages == NULL)
{
ret = -1;
goto Cleanup;
}
- msgInfo->WaitEvent = WaitEventCreate();
+ msgInfo->WaitEvent = osd_WaitEventCreate();
msg = (VMBUS_CHANNEL_INITIATE_CONTACT*)msgInfo->Msg;
msg->Header.MessageType = ChannelMessageInitiateContact;
}
/* Wait for the connection response */
- WaitEventWait(msgInfo->WaitEvent);
+ osd_WaitEventWait(msgInfo->WaitEvent);
REMOVE_ENTRY_LIST(&msgInfo->MsgListEntry);
if (gVmbusConnection.InterruptPage)
{
- PageFree(gVmbusConnection.InterruptPage, 1);
+ osd_PageFree(gVmbusConnection.InterruptPage, 1);
gVmbusConnection.InterruptPage = NULL;
}
if (gVmbusConnection.MonitorPages)
{
- PageFree(gVmbusConnection.MonitorPages, 2);
+ osd_PageFree(gVmbusConnection.MonitorPages, 2);
gVmbusConnection.MonitorPages = NULL;
}
goto Cleanup;
}
- PageFree(gVmbusConnection.InterruptPage, 1);
+ osd_PageFree(gVmbusConnection.InterruptPage, 1);
/* TODO: iterate thru the msg list and free up */
if (gHvContext.GuestId == HV_LINUX_GUEST_ID)
{
/* Allocate the hypercall page memory */
- /* virtAddr = PageAlloc(1); */
- virtAddr = VirtualAllocExec(PAGE_SIZE);
+ /* virtAddr = osd_PageAlloc(1); */
+ virtAddr = osd_VirtualAllocExec(PAGE_SIZE);
if (!virtAddr)
{
}
else
{
- gHvContext.synICMessagePage[0] = PageAlloc(1);
+ gHvContext.synICMessagePage[0] = osd_PageAlloc(1);
if (gHvContext.synICMessagePage[0] == NULL)
{
DPRINT_ERR(VMBUS, "unable to allocate SYNIC message page!!");
goto Cleanup;
}
- gHvContext.synICEventPage[0] = PageAlloc(1);
+ gHvContext.synICEventPage[0] = osd_PageAlloc(1);
if (gHvContext.synICEventPage[0] == NULL)
{
DPRINT_ERR(VMBUS, "unable to allocate SYNIC event page!!");
{
if (gHvContext.synICEventPage[0])
{
- PageFree(gHvContext.synICEventPage[0],1);
+ osd_PageFree(gHvContext.synICEventPage[0],1);
}
if (gHvContext.synICMessagePage[0])
{
- PageFree(gHvContext.synICMessagePage[0], 1);
+ osd_PageFree(gHvContext.synICMessagePage[0], 1);
}
}
WriteMsr(HV_X64_MSR_SIEFP, siefp.AsUINT64);
- PageFree(gHvContext.synICMessagePage[0], 1);
- PageFree(gHvContext.synICEventPage[0], 1);
+ osd_PageFree(gHvContext.synICMessagePage[0], 1);
+ osd_PageFree(gHvContext.synICEventPage[0], 1);
}
DPRINT_EXIT(VMBUS);
ASSERT(netDevice->ReceiveBufferSize > 0);
ASSERT((netDevice->ReceiveBufferSize & (PAGE_SIZE-1)) == 0); /* page-size grandularity */
- netDevice->ReceiveBuffer = PageAlloc(netDevice->ReceiveBufferSize >> PAGE_SHIFT);
+ netDevice->ReceiveBuffer = osd_PageAlloc(netDevice->ReceiveBufferSize >> PAGE_SHIFT);
if (!netDevice->ReceiveBuffer)
{
DPRINT_ERR(NETVSC, "unable to allocate receive buffer of size %d", netDevice->ReceiveBufferSize);
goto Cleanup;
}
- /* WaitEventWait(ext->ChannelInitEvent); */
+ /* osd_WaitEventWait(ext->ChannelInitEvent); */
/* Notify the NetVsp of the gpadl handle */
DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendReceiveBuffer...");
goto Cleanup;
}
- WaitEventWait(netDevice->ChannelInitEvent);
+ osd_WaitEventWait(netDevice->ChannelInitEvent);
/* Check the response */
if (initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Status != NvspStatusSuccess)
ASSERT(netDevice->SendBufferSize > 0);
ASSERT((netDevice->SendBufferSize & (PAGE_SIZE-1)) == 0); /* page-size grandularity */
- netDevice->SendBuffer = PageAlloc(netDevice->SendBufferSize >> PAGE_SHIFT);
+ netDevice->SendBuffer = osd_PageAlloc(netDevice->SendBufferSize >> PAGE_SHIFT);
if (!netDevice->SendBuffer)
{
DPRINT_ERR(NETVSC, "unable to allocate send buffer of size %d", netDevice->SendBufferSize);
goto Cleanup;
}
- /* WaitEventWait(ext->ChannelInitEvent); */
+ /* osd_WaitEventWait(ext->ChannelInitEvent); */
/* Notify the NetVsp of the gpadl handle */
DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendSendBuffer...");
goto Cleanup;
}
- WaitEventWait(netDevice->ChannelInitEvent);
+ osd_WaitEventWait(netDevice->ChannelInitEvent);
/* Check the response */
if (initPacket->Messages.Version1Messages.SendSendBufferComplete.Status != NvspStatusSuccess)
DPRINT_INFO(NETVSC, "Freeing up receive buffer...");
/* Free up the receive buffer */
- PageFree(NetDevice->ReceiveBuffer, NetDevice->ReceiveBufferSize >> PAGE_SHIFT);
+ osd_PageFree(NetDevice->ReceiveBuffer, NetDevice->ReceiveBufferSize >> PAGE_SHIFT);
NetDevice->ReceiveBuffer = NULL;
}
DPRINT_INFO(NETVSC, "Freeing up send buffer...");
/* Free up the receive buffer */
- PageFree(NetDevice->SendBuffer, NetDevice->SendBufferSize >> PAGE_SHIFT);
+ osd_PageFree(NetDevice->SendBuffer, NetDevice->SendBufferSize >> PAGE_SHIFT);
NetDevice->SendBuffer = NULL;
}
goto Cleanup;
}
- WaitEventWait(netDevice->ChannelInitEvent);
+ osd_WaitEventWait(netDevice->ChannelInitEvent);
/* Now, check the response */
/* ASSERT(initPacket->Messages.InitMessages.InitComplete.MaximumMdlChainLength <= MAX_MULTIPAGE_BUFFER_COUNT); */
* packet) since our Vmbus always set the
* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED flag
*/
- /* WaitEventWait(NetVscChannel->ChannelInitEvent); */
+ /* osd_WaitEventWait(NetVscChannel->ChannelInitEvent); */
/* Post the big receive buffer to NetVSP */
ret = NetVscInitializeReceiveBufferWithNetVsp(Device);
INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &packet->ListEntry);
}
- netDevice->ChannelInitEvent = WaitEventCreate();
+ netDevice->ChannelInitEvent = osd_WaitEventCreate();
/* Open the channel */
ret = Device->Driver->VmbusChannelInterface.Open(Device,
{
/* Copy the response back */
memcpy(&netDevice->ChannelInitPacket, nvspPacket, sizeof(NVSP_MESSAGE));
- WaitEventSet(netDevice->ChannelInitEvent);
+ osd_WaitEventSet(netDevice->ChannelInitEvent);
}
else if (nvspPacket->Header.MessageType == NvspMessage1TypeSendRNDISPacketComplete)
{
return NULL;
}
- request->WaitEvent = WaitEventCreate();
+ request->WaitEvent = osd_WaitEventCreate();
if (!request->WaitEvent)
{
kfree(request);
}
}
- WaitEventSet(request->WaitEvent);
+ osd_WaitEventSet(request->WaitEvent);
}
else
{
goto Cleanup;
}
- WaitEventWait(request->WaitEvent);
+ osd_WaitEventWait(request->WaitEvent);
/* Copy the response back */
queryComplete = &request->ResponseMessage.Message.QueryComplete;
goto Cleanup;
}
- ret = WaitEventWaitEx(request->WaitEvent, 2000/*2sec*/);
+ ret = osd_WaitEventWaitEx(request->WaitEvent, 2000/*2sec*/);
if (!ret)
{
ret = -1;
goto Cleanup;
}
- WaitEventWait(request->WaitEvent);
+ osd_WaitEventWait(request->WaitEvent);
initComplete = &request->ResponseMessage.Message.InitializeComplete;
status = initComplete->Status;
/* Now, initiate the vsc/vsp initialization protocol on the open channel */
memset(request, sizeof(STORVSC_REQUEST_EXTENSION), 0);
- request->WaitEvent = WaitEventCreate();
+ request->WaitEvent = osd_WaitEventCreate();
vstorPacket->Operation = VStorOperationBeginInitialization;
vstorPacket->Flags = REQUEST_COMPLETION_FLAG;
goto Cleanup;
}
- WaitEventWait(request->WaitEvent);
+ osd_WaitEventWait(request->WaitEvent);
if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status != 0)
{
goto Cleanup;
}
- WaitEventWait(request->WaitEvent);
+ osd_WaitEventWait(request->WaitEvent);
/* TODO: Check returned version */
if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status != 0)
goto Cleanup;
}
- WaitEventWait(request->WaitEvent);
+ osd_WaitEventWait(request->WaitEvent);
/* TODO: Check returned version */
if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status != 0)
goto Cleanup;
}
- WaitEventWait(request->WaitEvent);
+ osd_WaitEventWait(request->WaitEvent);
if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status != 0)
{
request = &storDevice->ResetRequest;
vstorPacket = &request->VStorPacket;
- request->WaitEvent = WaitEventCreate();
+ request->WaitEvent = osd_WaitEventCreate();
vstorPacket->Operation = VStorOperationResetBus;
vstorPacket->Flags = REQUEST_COMPLETION_FLAG;
}
/* FIXME: Add a timeout */
- WaitEventWait(request->WaitEvent);
+ osd_WaitEventWait(request->WaitEvent);
kfree(request->WaitEvent);
DPRINT_INFO(STORVSC, "host adapter reset completed");
memcpy(&request->VStorPacket, packet, sizeof(VSTOR_PACKET));
- WaitEventSet(request->WaitEvent);
+ osd_WaitEventSet(request->WaitEvent);
}
else
{
/* Osd routines */
-extern void* VirtualAllocExec(unsigned int size);
+extern void *osd_VirtualAllocExec(unsigned int size);
-extern void* PageAlloc(unsigned int count);
-extern void PageFree(void* page, unsigned int count);
+extern void *osd_PageAlloc(unsigned int count);
+extern void osd_PageFree(void* page, unsigned int count);
-extern void* MemMapIO(unsigned long phys, unsigned long size);
-extern void MemUnmapIO(void* virt);
+extern struct osd_timer *osd_TimerCreate(PFN_TIMER_CALLBACK pfnTimerCB, void* context);
+extern void osd_TimerClose(struct osd_timer *t);
+extern int osd_TimerStop(struct osd_timer *t);
+extern void osd_TimerStart(struct osd_timer *t, u32 expirationInUs);
-extern struct osd_timer *TimerCreate(PFN_TIMER_CALLBACK pfnTimerCB, void* context);
-extern void TimerClose(struct osd_timer *t);
-extern int TimerStop(struct osd_timer *t);
-extern void TimerStart(struct osd_timer *t, u32 expirationInUs);
-
-extern struct osd_waitevent *WaitEventCreate(void);
-extern void WaitEventSet(struct osd_waitevent *waitEvent);
-extern int WaitEventWait(struct osd_waitevent *waitEvent);
+extern struct osd_waitevent *osd_WaitEventCreate(void);
+extern void osd_WaitEventSet(struct osd_waitevent *waitEvent);
+extern int osd_WaitEventWait(struct osd_waitevent *waitEvent);
/* If >0, waitEvent got signaled. If ==0, timeout. If < 0, error */
-extern int WaitEventWaitEx(struct osd_waitevent *waitEvent, u32 TimeoutInMs);
+extern int osd_WaitEventWaitEx(struct osd_waitevent *waitEvent, u32 TimeoutInMs);
int osd_schedule_callback(struct workqueue_struct *wq,
void *data;
};
-void* VirtualAllocExec(unsigned int size)
+void *osd_VirtualAllocExec(unsigned int size)
{
#ifdef __x86_64__
return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL_EXEC);
#endif
}
-void* PageAlloc(unsigned int count)
+void *osd_PageAlloc(unsigned int count)
{
void *p;
p = (void *)__get_free_pages(GFP_KERNEL, get_order(count * PAGE_SIZE));
/* return p; */
}
-void PageFree(void* page, unsigned int count)
+void osd_PageFree(void* page, unsigned int count)
{
free_pages((unsigned long)page, get_order(count * PAGE_SIZE));
/*struct page* p = virt_to_page(page);
__free_page(p);*/
}
-void *MemMapIO(unsigned long phys, unsigned long size)
-{
- return (void*)phys_to_virt(phys); /* return ioremap_nocache(phys, size); */
-}
-
-void MemUnmapIO(void *virt)
-{
- /* iounmap(virt); */
-}
-
static void TimerCallback(unsigned long data)
{
struct osd_timer *t = (struct osd_timer *) data;
t->callback(t->context);
}
-struct osd_timer *TimerCreate(PFN_TIMER_CALLBACK pfnTimerCB, void* context)
+struct osd_timer *osd_TimerCreate(PFN_TIMER_CALLBACK pfnTimerCB, void* context)
{
struct osd_timer *t = kmalloc(sizeof(struct osd_timer), GFP_KERNEL);
if (!t)
return t;
}
-void TimerStart(struct osd_timer *t, u32 expirationInUs)
+void osd_TimerStart(struct osd_timer *t, u32 expirationInUs)
{
t->timer.expires = jiffies + usecs_to_jiffies(expirationInUs);
add_timer(&t->timer);
}
-int TimerStop(struct osd_timer *t)
+int osd_TimerStop(struct osd_timer *t)
{
return del_timer(&t->timer);
}
-void TimerClose(struct osd_timer *t)
+void osd_TimerClose(struct osd_timer *t)
{
del_timer(&t->timer);
kfree(t);
}
-struct osd_waitevent *WaitEventCreate(void)
+struct osd_waitevent *osd_WaitEventCreate(void)
{
struct osd_waitevent *wait = kmalloc(sizeof(struct osd_waitevent), GFP_KERNEL);
if (!wait)
return wait;
}
-void WaitEventSet(struct osd_waitevent *waitEvent)
+void osd_WaitEventSet(struct osd_waitevent *waitEvent)
{
waitEvent->condition = 1;
wake_up_interruptible(&waitEvent->event);
}
-int WaitEventWait(struct osd_waitevent *waitEvent)
+int osd_WaitEventWait(struct osd_waitevent *waitEvent)
{
int ret=0;
return ret;
}
-int WaitEventWaitEx(struct osd_waitevent *waitEvent, u32 TimeoutInMs)
+int osd_WaitEventWaitEx(struct osd_waitevent *waitEvent, u32 TimeoutInMs)
{
int ret=0;