packspu_context.c revision b5e28e9344b7d6cb4e54ad48b788d8e3224e20ff
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "packspu.h"
#include "cr_mem.h"
#include "cr_packfunctions.h"
#include "cr_string.h"
#include "packspu_proto.h"
#define MAGIC_OFFSET 3000
/*
* Allocate a new ThreadInfo structure, setup a connection to the
* the calling thread with crSetTSD().
* We'll always call this function at least once even if we're not
* using threads.
*/
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
struct VBOXUHGSMI *pHgsmi
#endif
)
{
int i;
#ifdef CHROMIUM_THREADSAFE
#else
#endif
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
#endif
for (i=0; i<MAX_THREADS; ++i)
{
{
break;
}
}
if (!CRPACKSPU_IS_WDDM_CRHGSMI())
else
/* connect to the server */
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
, pHgsmi
#endif
);
/* packer setup */
if (!CRPACKSPU_IS_WDDM_CRHGSMI())
{
}
#ifdef CHROMIUM_THREADSAFE
if (!CRPACKSPU_IS_WDDM_CRHGSMI())
{
}
#endif
#ifdef CHROMIUM_THREADSAFE
#endif
return thread;
}
{
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
ThreadInfo * thread;
if (thread)
{
}
crError("packspuNewThread failed");
#endif
return 0;
}
void PACKSPU_APIENTRY
{
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
packspuFlush((void *) thread);
#else
crError("VBoxConFlush not implemented!");
#endif
}
void PACKSPU_APIENTRY
{
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
packspuFlush((void *) thread);
{
}
/*note can't shift the array here, because other threads have TLS references to array elements*/
#if 0
{
int i;
crError("Should not be here since idxThreadInUse should be always 0 for the dummy connection created in packSPUInit!");
for (i=0; i<MAX_THREADS; ++i)
{
{
break;
}
}
}
#endif
#endif
}
{
int writeback = 1;
#ifdef CHROMIUM_THREADSAFE
#endif
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
#endif
if (CRPACKSPU_IS_WDDM_CRHGSMI())
{
if (!con)
{
crError("connection should be specified!");
return;
}
}
else
{
if (!thread)
{
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
#endif
);
}
}
#ifdef CHROMIUM_THREADSAFE
#endif
if (CRPACKSPU_IS_WDDM_CRHGSMI())
{
/* restore the packer context to the tls */
}
}
{
int writeback = 1;
int slot;
#ifdef CHROMIUM_THREADSAFE
#endif
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
#endif
if (CRPACKSPU_IS_WDDM_CRHGSMI())
{
if (!con)
{
crError("connection should be specified!");
return -1;
}
}
else
{
if (!thread)
{
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
#endif
);
}
}
if (shareCtx > 0) {
/* translate to server ctx id */
shareCtx -= MAGIC_OFFSET;
}
}
/* Pack the command */
else
/* Flush buffer and get return value */
{
/* HUMUNGOUS HACK TO MATCH SERVER NUMBERING
*
* The hack exists solely to make file networking work for now. This
* is totally gross, but since the server expects the numbers to start
* from 5000, we need to write them out this way. This would be
* marginally less gross if the numbers (500 and 5000) were maybe
* some sort of #define'd constants somewhere so the client and the
* server could be aware of how each other were numbering things in
* cases like file networking where they actually
* care.
*
* -Humper
*
*/
serverCtx = 5000;
}
else {
}
if (serverCtx < 0) {
#ifdef CHROMIUM_THREADSAFE
#endif
crWarning("Failure in packspu_CreateContext");
if (CRPACKSPU_IS_WDDM_CRHGSMI())
{
/* restore the packer context to the tls */
}
return -1; /* failed */
}
}
/* find an empty context slot */
/* found empty slot */
break;
}
}
}
if (CRPACKSPU_IS_WDDM_CRHGSMI())
{
}
/* Fill in the new context info */
/* XXX fix-up sharedCtx param here */
#ifdef CHROMIUM_THREADSAFE
#endif
if (CRPACKSPU_IS_WDDM_CRHGSMI())
{
/* restore the packer context to the tls */
}
return MAGIC_OFFSET + slot;
}
{
}
{
if (CRPACKSPU_IS_WDDM_CRHGSMI())
{
}
else
if (curContext == context)
{
if (!CRPACKSPU_IS_WDDM_CRHGSMI())
{
}
else
{
}
}
else
{
if (CRPACKSPU_IS_WDDM_CRHGSMI())
{
}
}
}
{
if (!CRPACKSPU_IS_WDDM_CRHGSMI())
{
thread = GET_THREAD_VAL();
if (!thread) {
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
#endif
);
}
}
if (ctx) {
if (CRPACKSPU_IS_WDDM_CRHGSMI())
{
}
else
{
if (newCtx->fAutoFlush)
{
{
/* do a flush for the previously assigned thread
* to ensure all commands issued there are submitted */
if (newCtx->currentThread
{
}
}
}
}
//crStateSetCurrentPointers(newCtx->clientState, &thread->packer->current);
}
else {
if (CRPACKSPU_IS_WDDM_CRHGSMI())
{
thread = GET_THREAD_VAL();
if (!thread)
{
return;
}
}
else
{
}
serverCtx = 0;
}
else
{
GET_THREAD(t);
(void) t;
CRASSERT(t);
}
}