Exemplo n.º 1
0
void main()
{
    unsigned addr;

    // Initialize hardware
    discover();

    // Initialize screen
    d_screen = getdevice(screenId);
    addr = d_screen->address;

    asm("SET B, [%vram]");
    interrupt(addr);

    // Initialize keyboard
    d_keyboard = getdevice(keyboardId);

    // Initialize clock
    d_clock = getdevice(clockId);
    updateclockfreq();

    print("Booted!\n");

    kernel();
}
Exemplo n.º 2
0
_CODE_ACCESS int rename(const char *old_name, const char *new_name)
{
   _DEVICE *old_dev, *new_dev;
   int result;

   /*------------------------------------------------------------------------*/
   /* CRITICAL REGION PROTECTS _device[] ACCESS THAT OCCURS IN getdevice()   */
   /* (see file header comment for more on mutex and data coherence).        */
   /*------------------------------------------------------------------------*/
   __TI_resource_lock(__TI_LOCK_DEVICE_TBL);

   old_dev = getdevice(&old_name);
   new_dev = getdevice(&new_name);

   /*------------------------------------------------------------------------*/
   /* IF THE DEVICES ARE NOT THE SAME, RENAME WOULD REQUIRE A FILE COPY.     */
   /*------------------------------------------------------------------------*/
   if (old_dev != new_dev) 
   { 
      __TI_data_synch_INV(&_device, sizeof(_device));
      __TI_resource_unlock(__TI_LOCK_DEVICE_TBL);
      return -1; 
   }

   /*------------------------------------------------------------------------*/
   /* CALL FUNCTION FROM DEVICE TABLE TO PERFORM RENAME FOR THIS DEVICE/FILE */
   /*------------------------------------------------------------------------*/
   result = (*(old_dev->RENAME)) (old_name, new_name);

   __TI_data_synch_INV(&_device, sizeof(_device));
   __TI_resource_unlock(__TI_LOCK_DEVICE_TBL);
   
   return result;
}
Exemplo n.º 3
0
void getfilestats(file_t *file)
{
  file->size = filesize(file->d_name);
  file->inode = getinode(file->d_name);
  file->device = getdevice(file->d_name);
  file->mtime = getmtime(file->d_name);
}
Exemplo n.º 4
0
void* tfileworker(void* argument)
{
	GlobalDate* date = GlobalDate::create();

	vector<Bridge*> bdg_v;
	if(!getdevice(&bdg_v))
		return NULL;
	while(1)
	{
		date->Io->out("please input \"/sourse-path to /dst-path\"\n");
		string command = date->Io->in();
		if(command == "q")
			pthread_exit(NULL);
		string src,dst;
		if (!TaskClass::rsolvepath(command,src,dst))
		{
			date->Io->out("path err, input again\n");
			continue;
		}

		EventClass* repork = new EventClass;
		TaskClass * shelltask = new TaskClass(T_TFILE, command, &bdg_v,repork);
		shelltask->setwrbk(sendshell_cb);
		shelltask->setrdbk(tfile_cb);
		if(shelltask->rgstask() == -1)
		{
			delete repork;
			delete shelltask;
		}

		repork->run();
	}

}
Exemplo n.º 5
0
int is_hardlink(filetree_t *checktree, file_t *file)
{
  file_t *dupe;
  ino_t inode;
  dev_t device;

  inode = getinode(file->d_name);
  device = getdevice(file->d_name);

  if ((inode == checktree->file->inode) && 
      (device == checktree->file->device))
        return 1;

  if (checktree->file->hasdupes)
  {
    dupe = checktree->file->duplicates;

    do {
      if ((inode == dupe->inode) &&
          (device == dupe->device))
            return 1;

      dupe = dupe->duplicates;
    } while (dupe != NULL);
  }

  return 0;
}
Exemplo n.º 6
0
int relink(char *oldfile, char *newfile)
{
  dev_t od;
  dev_t nd;
  ino_t oi;
  ino_t ni;

  od = getdevice(oldfile);
  oi = getinode(oldfile);

  if (link(oldfile, newfile) != 0)
    return 0;

  /* make sure we're working with the right file (the one we created) */
  nd = getdevice(newfile);
  ni = getinode(newfile);

  if (nd != od || oi != ni)
    return 0; /* file is not what we expected */

  return 1;
}
Exemplo n.º 7
0
static
int config(struct audio_config *config)
{
  unsigned int bitdepth;
  int format = 0;
  AuDeviceID device;
  AuElement elements[2];

  bitdepth = config->precision & ~7;
  if (bitdepth == 0 || bitdepth > 16)
    bitdepth = 16;

  switch (config->precision = bitdepth) {
  case 8:
    format    = AuFormatLinearSigned8;
    audio_pcm = audio_pcm_s8;
    break;

  case 16:
# if defined(WORDS_BIGENDIAN)
    format    = AuFormatLinearSigned16MSB;
    audio_pcm = audio_pcm_s16be;
# else
    format    = AuFormatLinearSigned16LSB;
    audio_pcm = audio_pcm_s16le;
# endif
    break;
  }

  device = getdevice(server, &config->channels);
  if (device == AuNone) {
    audio_error = _("could not find an output device");
    return -1;
  }

  AuMakeElementImportClient(&elements[0], config->speed, format,
			    config->channels, AuTrue,
			    config->speed * 2, config->speed, 0, 0);
  AuMakeElementExportDevice(&elements[1], 0, device, config->speed,
			    AuUnlimitedSamples, 0, 0);
  AuSetElements(server, flow, AuTrue, 2, elements, 0);

  AuRegisterEventHandler(server, AuEventHandlerIDMask, 0, flow,
			 eventhandler, 0);

  AuStartFlow(server, flow, 0);

  return 0;
}
Exemplo n.º 8
0
void* shellworker(void * argument)
{
	GlobalDate* date = GlobalDate::create();

	vector<Bridge*> bdg_v;
	if(!getdevice(&bdg_v))
		return NULL;

	date->Io->out("please input shell command !\n");
	string command = date->Io->in();

	EventClass* repork = new EventClass;
	TaskClass * shelltask = new TaskClass(T_SHELL, command, &bdg_v,repork);
	shelltask->setwrbk(sendshell_cb);
	shelltask->setrdbk(reportshell_cb);
	shelltask->rgstask();
	repork->run();
}
Exemplo n.º 9
0
_CODE_ACCESS int unlink(const char *path)
{
   _DEVICE *dev;
   int      result;

   /*------------------------------------------------------------------------*/
   /* GET A DEVICE AND CALL FUNCTION FROM DEVICE TABLE TO PERFORM UNLINK     */
   /* FOR THIS DEVICE/FILE                                                   */
   /*------------------------------------------------------------------------*/
   /* CRITICAL REGION PROTECTS _device[] ACCESS THAT OCCURS IN getdevice()   */
   /* (see file header comment for more on mutex and data coherence).        */
   /*------------------------------------------------------------------------*/
   __TI_resource_lock(__TI_LOCK_DEVICE_TBL);

   dev = getdevice(&path);
   result = (*(dev->UNLINK)) (path);

   __TI_data_synch_INV(&_device, sizeof(_device));
   __TI_resource_unlock(__TI_LOCK_DEVICE_TBL);

   return result;
}
Exemplo n.º 10
0
_CODE_ACCESS int open(const char *path, unsigned flags, int mode)
{
   static _DATA_ACCESS int stream_init = 0;
   struct stream_info *ptr;
   _DEVICE    	      *dev;
   int        	      dev_fd;
   int        	      llv_fd;

   /*-------------------------------------------------------------------------*/
   /* CRITICAL REGION PROTECTS ACCESS TO _stream[] (see file header comment). */
   /*-------------------------------------------------------------------------*/
   __TI_resource_lock(__TI_LOCK_STREAM_TBL);

   /*-------------------------------------------------------------------------*/
   /* INITIALIZE STREAM TABLE FIRST TIME AROUND                               */
   /*-------------------------------------------------------------------------*/
   if (!stream_init)
   {
      for (stream_init = 1, ptr = &_stream[3]; ptr != &_stream[_NSTREAM]; 
            (ptr++)->dev = NULL);
       __TI_data_synch_WBINV(&stream_init, sizeof(stream_init));
   }

   /*-------------------------------------------------------------------------*/
   /* GET THE NEXT AVAILABLE FILE DESCRIPTOR - RETURN -1 IF NONE AVAILABLE    */
   /*-------------------------------------------------------------------------*/
   for (ptr = &_stream[3]; ptr != &_stream[_NSTREAM] && ptr->dev; ++ptr);
   if (ptr == &_stream[_NSTREAM]) 
   { 
      __TI_data_synch_INV(&_stream, sizeof(_stream));
      __TI_resource_unlock(__TI_LOCK_STREAM_TBL);
      return -1;
   }

   llv_fd = ptr - &_stream[0];

   /*------------------------------------------------------------------------*/
   /* GET DEVICE AND PEFORM OPEN - SET STREAM TABLE ENTRY AND FLAGS          */
   /*------------------------------------------------------------------------*/
   /* CRITICAL REGION PROTECTS _device[] ACCESS THAT OCCURS IN getdevice()   */
   /* (see file header comment for more on mutex and data coherence).        */
   /*------------------------------------------------------------------------*/
   __TI_resource_lock(__TI_LOCK_DEVICE_TBL);

   dev    = getdevice(&path);
   dev_fd = (dev->flags & _BUSY) ? -1 : (*(dev->OPEN))(path,flags,llv_fd);

   if (dev_fd < 0) 
   { 
      __TI_data_synch_INV(&_stream, sizeof(_stream));
      __TI_data_synch_INV(&_device, sizeof(_device));
      __TI_resource_unlock(__TI_LOCK_DEVICE_TBL);
      __TI_resource_unlock(__TI_LOCK_STREAM_TBL);
      return dev_fd;
   }
   
   _stream[llv_fd].dev = dev;
   _stream[llv_fd].dfd = dev_fd;
   if (!(dev->flags & _MSA)) dev->flags |= _BUSY;

   __TI_data_synch_WBINV(&_stream, sizeof(_stream));
   __TI_data_synch_WBINV(&_device, sizeof(_device));
   __TI_resource_unlock(__TI_LOCK_DEVICE_TBL);
   __TI_resource_unlock(__TI_LOCK_STREAM_TBL);

   return llv_fd;
}