Ejemplo n.º 1
0
/*****************************************************************************
 * AddDevice
 *****************************************************************************
 * This function is called by the operating system when the device is added.
 * All adapter drivers can use this code without change.
 */
NTSTATUS AddDevice
(
    IN PDRIVER_OBJECT   DriverObject,
    IN PDEVICE_OBJECT   PhysicalDeviceObject
)
{
    PAGED_CODE ();

    DOUT (DBG_PRINT, ("[AddDevice]"));

    // disable prefast warning 28152 because 
    // DO_DEVICE_INITIALIZING is cleared in PcAddAdapterDevice
#pragma warning(disable:28152)

#ifdef XEN
    NTSTATUS ntStatus = XenInitialize(PhysicalDeviceObject);
    if (!NT_SUCCESS (ntStatus))
        return ntStatus;
#endif

    //
    // Tell portcls (the class driver) to add the device.
    //
    return PcAddAdapterDevice (DriverObject,
                               PhysicalDeviceObject,
                               (PCPFNSTARTDEVICE)StartDevice,
                               MAX_MINIPORTS,
                               0);
}
Ejemplo n.º 2
0
void Layer::logTree()
{
  u32 depth = 0;
  _numLayers = 0;
  _logTree(depth, this);
  DOUT("num layers:"<<_numLayers);
}
Ejemplo n.º 3
0
struct cos_cbuf_item *free_mem_in_local_cache(struct spd_tmem_info *sti)
{
	spdid_t s_spdid;
	struct cos_cbuf_item *cci = NULL, *list;

	assert(sti);
	s_spdid = sti->spdid;

	DOUT("\n Check if in local cache!!!");
	list = &spd_tmem_info_list[s_spdid].tmem_list;
	/* Go through the allocated cbufs, and see if any are not in use... */
	for (cci = FIRST_LIST(list, next, prev) ; 
	     cci != list; 
	     cci = FIRST_LIST(cci, next, prev)) {
		union cbuf_meta cm;
		cm.c_0.v = cci->entry->c_0.v;
		if (!CBUF_IN_USE(cm.c.flags)) goto done;
	}

	if (cci == list) goto err;
done:
	/* DOUT("\n hehe found one!!\n\n"); */
	return cci;
err:
	/* DOUT("\n can not found one!!\n"); */
	cci = NULL;	
	return cci;
}
Ejemplo n.º 4
0
//  all cbufs that created for this component
void mgr_map_client_mem(struct cos_cbuf_item *cci, struct spd_tmem_info *sti)
{
	char *l_addr, *d_addr;
	spdid_t d_spdid;
//	struct cb_desc *d;

	assert(sti && cci);
	assert(EMPTY_LIST(cci, next, prev));

	d_spdid = sti->spdid;

	/* TODO: multiple pages cbuf! */
	d_addr = valloc_alloc(cos_spd_id(), sti->spdid, 1);
	l_addr = cci->desc.addr;  //initialized in cos_init()

	assert(d_addr && l_addr); 

	/* ...map it into the requesting component */
	if (unlikely(!mman_alias_page(cos_spd_id(), (vaddr_t)l_addr, d_spdid, (vaddr_t)d_addr))) 
		goto err;
	/* DOUT("<<<MAPPED>>> mgr addr %p client addr %p\n ",l_addr, d_addr); */
	cci->desc.owner.addr = (vaddr_t)d_addr;
	cci->parent_spdid = d_spdid;
	assert(cci->desc.cbid == 0);
	// add the cbuf to shared vect here? now we do it in the client.
	// and l_addr and d_addr has been assinged
done:
	return;
err:
	DOUT("Cbuf mgr: Cannot alias page to client!\n");
	mman_release_page(cos_spd_id(), (vaddr_t)l_addr, 0);
	/* valloc_free(cos_spd_id(), cos_spd_id(), l_addr, 1); */
	valloc_free(cos_spd_id(), d_spdid, (void *)d_addr, 1);
	goto done;
}
Ejemplo n.º 5
0
static void
mgr_remove_client_mem(struct spd_tmem_info *sti, struct cos_cbuf_item *cci)
{
	__cbuf_c_delete(sti, cci->desc.cbid, &cci->desc);
	/* DOUT("after buf del before map del\n"); */
	cos_map_del(&cb_ids, cci->desc.cbid);

	DOUT("fly..........cbid is %d\n", cci->desc.cbid);

	cci->desc.cbid = 0;
	cci->parent_spdid = 0;

	// Clear our memory to prevent leakage
	memset(cci->desc.addr, 0, PAGE_SIZE);
	/* printc("Removing from local list\n"); */

	REM_LIST(cci, next, prev);

	/* TODO: move all of this into the tmem generic code just like the ++s */
	sti->num_allocated--;
	if (sti->num_allocated == 0) empty_comps++;

	if (sti->num_allocated >= sti->num_desired) over_quota_total--;
	assert(sti->num_allocated == tmem_num_alloc_tmems(sti->spdid));
}
Ejemplo n.º 6
0
struct cos_cbuf_item *mgr_get_client_mem(struct spd_tmem_info *sti)
{
	spdid_t s_spdid;
	/* struct cb_desc *d; */
	struct cos_cbuf_item *cci = NULL, *list;
	assert(sti);
	s_spdid = sti->spdid;

	list = &spd_tmem_info_list[s_spdid].tmem_list;

	for (cci = FIRST_LIST(list, next, prev) ; 
	     cci != list ; 
	     cci = FIRST_LIST(cci, next, prev)) {
		union cbuf_meta cm;
		cm.c_0.v = cci->entry->c_0.v;
		if (!CBUF_IN_USE(cm.c.flags)) break;
	}

	if (cci == list) goto err;
	assert(&cci->desc == cos_map_lookup(&cb_ids, cci->desc.cbid));

	/* struct cb_mapping *m; */
	/* m = FIRST_LIST(&cci->desc.owner, next, prev); */

	mgr_remove_client_mem(sti, cci);

	DOUT("spd: %d Leaving get cli mem:: num_allocated %d  num_desired %d\n",s_spdid, sti->num_allocated, sti->num_desired);

done:
	return cci;
err: 
	cci = NULL;
	goto done;
}
Ejemplo n.º 7
0
Archivo: kvar.c Proyecto: aljoscha/kalt
void kvar_print_vars(kvar_storage_ptr store)
{
    DOUT("kvar_print_vars: dumping all variables\n");
    int index,index2;
    kvar_array_ptr arr;
    for (index = 0; index < MAX_VARS; index++)
    {
        if (store->vars[index].content != NULL)
        {
            switch (store->vars[index].content->type)
            {
                case kvar_type_number:
                    {
                        printf("%s: %d\n", store->vars[index].name, store->vars[index].content->number);
                    } break;
                case kvar_type_array:
                    {
                        printf("%s: [", store->vars[index].name);
                        arr = store->vars[index].content->array;
                        for (index2 = 0; index2 < arr->length-1; index2++)
                        {
                            printf("%d,", arr->array[index2]);
                        }
                        printf("%d]\n", arr->array[index2]);
                    } break;
            } 
        }
    }
}
Ejemplo n.º 8
0
stat_t
SelfHealingSessionServer::HandleConnect(const L4_ThreadId_t& tid, L4_Msg_t& msg)
{
    ENTER;
    L4_Word_t   reg[2];
    addr_t      shm = shmalloc(Session::DEFAULT_SHM_PAGES);

    DOUT("shm allocate @ %.8lX\n", shm);

    if (shm == 0) {
        return ERR_OUT_OF_MEMORY;
    }

    //TODO: Hack: Related to a problem in PersistentPageAllocator.cpp
    for (UInt i = 0; i < Session::DEFAULT_SHM_PAGES; i++) {
        Pager.Release(shm + i * PAGE_SIZE);
    }

    for (UInt i = 0; i < Session::DEFAULT_SHM_PAGES; i++) {
        Pager.Reserve(shm + i * PAGE_SIZE, tid, L4_ReadWriteOnly);
    }

    reg[0] = shm;
    reg[1] = Session::DEFAULT_SHM_PAGES;
    L4_Put(&msg, 0, 2, reg, 0, 0);
    Register(tid, reg[0], reg[1]);

    EXIT;
    return ERR_NONE;
}
Ejemplo n.º 9
0
/*!
 * \return The HWND of the main application window, if it can be identified.
 *      Otherwise NULL is returned.
 */
HWND GetOurParentWindow(void)
{
    //! Silly nested class so that we can define a local function.
    class foo {
        foo() {};
    public:
        static BOOL CALLBACK GOPWEnumWindowsProc(
                HWND hwnd,      //!< handle to parent window
                LPARAM lParam   //!< application-defined value
        )
        {
            char szClassName[64];
            if ( GetClassName(hwnd, szClassName, sizeof(szClassName)) &&
                (strcmp(szClassName, "mIRC32") == 0 || strcmp(szClassName, "mIRC") == 0)
                )
            {
                DWORD windowpid;
                GetWindowThreadProcessId(hwnd, &windowpid);
                if (windowpid == GetCurrentProcessId()) {
                    // Found the window that is from our process.
                    *reinterpret_cast<HWND*>(lParam) = hwnd;
                    return FALSE;       // done enumerating.
                }
            }
            return TRUE;        // continue enumerating.
        }
    };

    // Actually do the enumeration call.
    HWND hWnd = NULL;
    EnumWindows(foo::GOPWEnumWindowsProc, (LPARAM) &hWnd);
    DOUT(("GetOurParentWindow: found hwnd %p\n", hWnd));
    return hWnd;
}
Ejemplo n.º 10
0
void EventSystem::logViewStack(const vector<View*>& vs)
{
  for(auto v : vs)
  {
    DOUT("-> "<<v->name());
  }
}
Ejemplo n.º 11
0
// Cue
//
BOOL WaveFile::Cue (void)
{
  BOOL fRtn = SUCCESS;    // assume success

  DOUT ("WaveFile::Cue\n\r");

  // Seek to 'data' chunk from beginning of file
  if (mmioSeek (m_hmmio, m_mmckiRiff.dwDataOffset + sizeof(FOURCC), SEEK_SET) != -1)
  {
    // Descend into 'data' chunk
    m_mmckiData.ckid = mmioFOURCC('d', 'a', 't', 'a');
    if ((m_mmr = mmioDescend (m_hmmio, &m_mmckiData, &m_mmckiRiff, MMIO_FINDCHUNK)) == MMSYSERR_NOERROR)
    {
      // Reset byte counter
      m_nBytesPlayed = 0;
    }
    else
    {
      // UNDONE: set m_mmr
      fRtn = FALSE;
    }
  }
  else
  {
    // mmioSeek error
    m_mmr = MMIOERR_CANNOTSEEK;
    fRtn = FALSE;
  }

  return fRtn;
}
Ejemplo n.º 12
0
//
// This method binds the parameter to a specified value, updating the worklist
// Binding a value updates any combination zeros it completes as a side effect
// Binding a value also adds items to work list as a side effect
//
bool Parameter::Bind(int value, WorkList& worklist)
{
    DOUT(L"Binding " << m_name << L" to value " << value << L".\n");
    assert(!m_bound);
    assert(value < m_valueCount);

    m_result.push_back(value);
    m_currentValue = value;
    m_bound = true;

    for( auto & combination : m_combinations )
    {
        if( combination->AddBinding() == combination->GetParameterCount() - 1 )
        {
            // Add any parameter that completes a combination to work list
            for( int n = 0; n < combination->GetParameterCount(); ++n )
            {
                if( !( (*combination)[ n ] ).GetBoundCount() )
                {
                    worklist.AddItem( &( *combination )[ n ] );
                }
            }
        }
    }

    worklist.Print();
    
    return true;
}
Ejemplo n.º 13
0
void View::logTree()
{
  u32 depth = 0;
  _numViews = 0;
  _logTree(depth, this);
  DOUT("num view:"<<_numViews);
}
Ejemplo n.º 14
0
    void Application::finalize()
    {
      DOUT("Application::finalize()");

      XFree((void *) hiddenMembers->WM_WAKEUP);
      XCloseDisplay(hiddenMembers->display);
      delete hiddenMembers;
    }
Ejemplo n.º 15
0
void Device::initWithDeviceId(const string& inDeviceId)
{
  DOUT("opening device: "<<inDeviceId);
  device = alcOpenDevice(inDeviceId.c_str());ALDEBUG_THROW;
  if(!device)
    THROW_RTE("aclOpenDevice returned NULL for id: "+inDeviceId);
  deviceId = inDeviceId;
}
Ejemplo n.º 16
0
//! Method exported to mIRC that can be invoked to subclass a specified 
//! window (by hwnd) and make its window frame blue.
extern "C" int __declspec(dllexport) __stdcall blue_window(
      HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
{
    DOUT(("mIRC callback for blue_window invoked\n"));

    if (data != NULL) {
		HWND hwnd = (HWND) LongToHandle(atoi(data));
        bool bResult = BlueWindow::SubclassNewWindow(hwnd);
        if (bResult) {
            DOUT(("blue_window successfully subclassed new window %p\n", (void*) hwnd));
        } else {
            DOUT(("blue_window failed to subclass new window.\n"));
        }
    }

    return 1;       // mIRC should just continue executing.
}
Ejemplo n.º 17
0
void RemoteProxyHost::start()
{
   if (this->m_thread.is_running())
   {
      DOUT(this->dinfo() << "RemoteProxyHost already running on port: " << this->m_local_port);
      return;
   }
   // We do the following because we want it done in the main thread, so exceptions during start are propagated through.
   // In particular we want to ensure that we dont have 2 servers with the same port number.
   this->dolog(this->dinfo() + std::string("opening connection on port: ") + mylib::to_string(this->m_local_port));
   boost::asio::ip::tcp::endpoint ep(boost::asio::ip::tcp::v4(), this->m_local_port);
   this->m_acceptor.open(ep.protocol());
   this->m_acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(false));
   this->m_acceptor.bind(ep);
   DOUT(this->dinfo() << "Bind ok for " << ep);
   this->m_thread.start( [this]{ this->threadproc(); } );
}
Ejemplo n.º 18
0
void InputEventSystem::run(const char* deviceName)
{
  struct input_event ev[64];
  int fd, rd, value, size = sizeof (struct input_event);
  char name[256] = "Unknown";

  if ((getuid ()) != 0)
  {
    DOUT("You are not root! This may not work...");
  }

  //Open Device
  if ((fd = open (deviceName, O_RDONLY)) == -1)
  {
    DOUT(deviceName << "is not a vaild device.");
    exit(1);
  }

  if(hasAbsolutEvents(fd))
  {
    DOUT("input device provides absolute events");
  }
  else
  {
    DOUT("input device does NOT provide absolute events");
  }

  getTouchBounds(fd);
  DOUT("touch bounds: " << minX << " " << maxX << " " << minY << " " << maxY);

  //Print Device Name
  ioctl (fd, EVIOCGNAME (sizeof (name)), name);
  DOUT ("Reading From : " << deviceName << "(" << name << ")");
  DOUT("reading , elem size: " << size << " max buffer: " << size << " " << size*64);
  while (1){
      if ((rd = read (fd, &ev, size*64 )) < size)
      {
        DOUT("read()");
        exit(0);
      }
      //printf("read bytes: %d elems: %d\n", rd, rd/size);
      u32 num = rd/size;
      parse(ev, num);
/*      value = ev[0].value;

      printf("..\n");
      for(int i=0; i<rd/size; ++i)
      {
        logEvent(&ev[i]);
      }*/

/*      if (value != ' ' && ev.value == 1 && ev.type == 1){ // Only read the key press event
       printf ("Code[%d]\n", (ev.code));
      }*/
  }  
}
Ejemplo n.º 19
0
NTSTATUS DriverEntry (IN PDRIVER_OBJECT pDriverObject, IN PUNICODE_STRING pRegistryPathName)
{
    PAGED_CODE ();
    
    DOUT (DBG_PRINT, ("DriverEntry"));

    return KsInitializeDriver (pDriverObject, pRegistryPathName, &DeviceDescriptor);
}
Ejemplo n.º 20
0
UINT WaveFile::Read (BYTE * pbDest, UINT cbSize)
{
    MMIOINFO mmioinfo;
    UINT cb;

    DOUT ("WaveFile::Read\n\r");

    // Use direct buffer access for reads to maximize performance
    if (m_mmr = mmioGetInfo (m_hmmio, &mmioinfo, 0))
    {
      goto READ_ERROR;
    }

    // Limit read size to chunk size
    cbSize = (cbSize > m_mmckiData.cksize) ? m_mmckiData.cksize : cbSize;

    // Adjust chunk size
    m_mmckiData.cksize -= cbSize;

    // Copy bytes from MMIO buffer
    for (cb = 0; cb < cbSize; cb++)
    {
      // Advance buffer if necessary
      if (mmioinfo.pchNext == mmioinfo.pchEndRead)
      {
        if (m_mmr = mmioAdvance (m_hmmio, &mmioinfo, MMIO_READ))
        {
          goto READ_ERROR;
        }

				if (mmioinfo.pchNext == mmioinfo.pchEndRead)
        {
          m_mmr = MMIOERR_CANNOTREAD;
          goto READ_ERROR;
        }
      }

      // Actual copy
//      *((BYTE*)pbDest+cb) = *((BYTE*)mmioinfo.pchNext)++;
			if( g_bBGMPlaying ) *(pbDest+cb) = *(mmioinfo.pchNext)++;
    }

    // End direct buffer access
    if (m_mmr = mmioSetInfo (m_hmmio, &mmioinfo, 0))
    {
      goto READ_ERROR;
    }

    // Successful read, keep running total of number of data bytes read
    m_nBytesPlayed += cbSize;
    goto READ_DONE;
    
READ_ERROR:
    cbSize = 0;

READ_DONE:
    return (cbSize);
}
Ejemplo n.º 21
0
Library::~Library()
{
  FT_Error error = FT_Done_FreeType(library);
  // don't throw, just log
  if(error)
  {
    DOUT("FT_Done_FreeType error: "<< error);
  }
}
Ejemplo n.º 22
0
Device::~Device()
{
  DOUT("closing device: "<<deviceId);
  ALCboolean result = alcCloseDevice(device);ALDEBUG; // don't throw in destructor
  if(!result)
  {
    EOUT("failed to close device: "<<deviceId<<" , did you attach it to a context?");
  }
}
Ejemplo n.º 23
0
Archivo: kvar.c Proyecto: aljoscha/kalt
void kvar_dispose_storage(kvar_storage_ptr store)
{
    DOUT("kvar_dispose_storage: disposing kvar storage\n");
    int index;
    for (index = 0; index < MAX_VARS; index++)
    {
       kvar_delete(store, store->vars[index].name);
    }
    free(store);
}
Ejemplo n.º 24
0
void _logTree(u32 depth, Layer* current)
{
  string spaces;
  _numLayers++;
  for(u32 i=0; i<depth;++i) { spaces += "-";}
  DOUT(spaces << current->name);
  for(auto layer : current->sublayers)
  {
    _logTree(depth+1, layer.get());
  }
}
Ejemplo n.º 25
0
void
AORB::_initServer()
{
  if (_serverSocket != Nil)
    return;
  if (_serverHost == Nil)
    _serverHost = AORB::getLocalHost();
  _serverSocket = new ServerSocket(_port, 30, acdk::net::InetAddress::getByName(_serverHost));
  _port = _serverSocket->getLocalPort();
  DOUT("AORB::_initServer: " << _serverSocket->toString()->c_str() << "; port=" << _port);
}
Ejemplo n.º 26
0
void _logTree(u32 depth, View* current)
{
  string spaces;
  _numViews++;
  for(u32 i=0; i<depth;++i) { spaces += "-";}
  DOUT(spaces << current->name());
  for(auto view : current->subviews)
  {
    _logTree(depth+1, view.get());
  }
}
Ejemplo n.º 27
0
bool sspDSDeviceGroup::beginImpl()
{
	bool bRet = true;
	for (unsigned int i=0; i<m_pDSBuf.size(); i++)  {
		HRESULT nResult = m_pDSBuf[i]->Play (0, 0, DSBPLAY_LOOPING);
		if (nResult != DS_OK) {
			DOUT(_T("Error, play failed\n\r"));
			bRet = false;
		}
	}
	return bRet;
}
Ejemplo n.º 28
0
Source::~Source()
{
	DOUT("");

  source->stop();
  if (vorbisFile) source->unqueue(vorbisFile->buffer);
	shared_ptr<Engine> ng = engine.lock();
	if(ng)
	{
		ng->destroySource(this);
	}
}
Ejemplo n.º 29
0
/**
 * maps the compoenents spdid info page on startup
 * I do it this way since not every component may require stacks or
 * what spdid's I even have access too.
 * I am not sure if this is the best way to handle this, but it 
 * should work for now.
 */
static inline void
get_cos_info_page(spdid_t spdid)
{
	spdid_t s;
	int i;
	int found = 0;
	void *hp;

	if(spdid > MAX_NUM_SPDS){
		BUG(); 
	}
	for (i = 0; i < MAX_NUM_SPDS; i++) {
		s = cinfo_get_spdid(i);
		if(!s) { 
			printc("Unable to map compoents cinfo page!\n");
			BUG();
		}
            
		if (s == spdid) {
			found = 1;
			break;
		}
	} 
    
	if(!found){
		DOUT("Could not find cinfo for spdid: %d\n", spdid);
		BUG();
	}
    
	hp = cos_get_vas_page();
	if(cinfo_map(cos_spd_id(), (vaddr_t)hp, s)){
		DOUT("Could not map cinfo page for %d\n", spdid);
		BUG();
	}
	spd_stk_info_list[spdid].ci = hp;
	DOUT("mapped -- id: %ld, hp:%x, sp:%x\n",
	     spd_stk_info_list[spdid].ci->cos_this_spd_id, 
	     (unsigned int)spd_stk_info_list[spdid].ci->cos_heap_ptr,
	     (unsigned int)spd_stk_info_list[spdid].ci->cos_stacks.freelists[0].freelist);
}
Ejemplo n.º 30
0
Archivo: kvar.c Proyecto: aljoscha/kalt
void kvar_delete(kvar_storage_ptr store, char *name)
{
    int index;
    kvar_var_ptr var;
    for (index = 0; index < MAX_VARS; index++)
    {
        if (store->vars[index].content != NULL && strcmp(store->vars[index].name, name) == 0)
        {
            var = store->vars[index].content;
            switch (var->type)
            {
                case kvar_type_number:
                    {
                        DOUT("kvar_delete: deleting variable \""); DOUT(name); DOUT("\" of type number\n");
                        free(var);
                    } break;
                case kvar_type_array:
                    {
                        DOUT("kvar_delete: deleting variable \""); DOUT(name); DOUT("\" of type array\n");
                        free(var->array->array);
                        free(var->array);
                        free(var);
                    } break;
            } 
            
            store->vars[index].content = NULL;
            return;
        }
    }

}