tdmInteractor
_dxfAllocateInteractor (tdmInteractorWin W, int size)
{
  int i ;
  tdmInteractor I = (tdmInteractor) 0 ;

  ENTRY(("_dxfAllocateInteractor(0x%x, %d)", W, size));

  if (! W) goto error ;

  if (W->numUsed == W->numAllocated)
      /* create more interactors */
      I = _allocateMoreInteractors(W) ;
  else
      /* find an unused interactor */
      for (i = 0 ; i < W->numAllocated ; i++)
          if (! IS_USED(W->Interactors[i]))
            {
              I = W->Interactors[i] ;
              break ;
            }

  if (! I) goto error ;
  
  if (size) {
      /* allocate interactor private data */
      if (! (PRIVATE(I) = tdmAllocateLocal(size))) {
          goto error ;
      } else {
          bzero ((char *) PRIVATE(I), size) ;
      }
  }

  WINDOW(I) = W ;
  AUX(I) = (tdmInteractor) 0 ;
  IS_AUX(I) = 0 ;
  IS_GROUP(I) = 0 ;
  IS_USED(I) = 1 ;
  W->numUsed++ ;

  /*
   * Default event mask
   */
  I->eventMask =  DXEVENT_LEFT | DXEVENT_MIDDLE | DXEVENT_RIGHT;

  EXIT(("I = 0x%x", I));
  return I ;

 error:

  EXIT(("ERROR"));
  return (tdmInteractor) 0 ;
}
Exemple #2
0
void _free(void * ptr){
	set_unused(ptr);
	void *next_ptr = NEXT_BLOCK(ptr);
	if( next_ptr!= NULL && !IS_USED(next_ptr)){
		set_block_size(ptr, BLOCK_SIZE(ptr) + BLOCK_SIZE(next_ptr));
	}

	void* pre_ptr = pre_block(ptr);
	if(pre_ptr != NULL && !IS_USED(pre_ptr)){
		set_block_size(pre_ptr, BLOCK_SIZE(ptr) + BLOCK_SIZE(pre_ptr));
	}

}
Exemple #3
0
int stmp3xxx_dma_request(int ch, struct device *dev, const char *name)
{
	struct stmp3xxx_dma_user *user;
	int err = 0;

	user = channels + ch;
	if (!IS_VALID_CHANNEL(ch)) {
		err = -ENODEV;
		goto out;
	}
	if (IS_USED(ch)) {
		err = -EBUSY;
		goto out;
	}
	/* Create a pool to allocate dma commands from */
	user->pool = dma_pool_create(name, dev, pool_item_size,
				     pool_alignment, PAGE_SIZE);
	if (user->pool == NULL) {
		err = -ENOMEM;
		goto out;
	}
	user->name = name;
	user->inuse++;
out:
	return err;
}
Exemple #4
0
int stmp3xxx_dma_free_command(int channel,
			      struct stmp3xxx_dma_descriptor *descriptor)
{
	int err = 0;

	if (!IS_VALID_CHANNEL(channel)) {
		err = -ENODEV;
		goto out;
	}
	if (!IS_USED(channel)) {
		err = -EBUSY;
		goto out;
	}

	/* Return the command memory to the pool */
	dma_pool_free(channels[channel].pool, descriptor->command,
		      descriptor->handle);

	/* Initialise descriptor so we're not tempted to use it */
	descriptor->command = NULL;
	descriptor->handle = 0;
	descriptor->virtual_buf_ptr = NULL;
	descriptor->next_descr = NULL;

	WARN_ON(err);
out:
	return err;
}
Exemple #5
0
int stmp3xxx_dma_allocate_command(int channel,
				  struct stmp3xxx_dma_descriptor *descriptor)
{
	struct stmp3xxx_dma_user *user = channels + channel;
	int err = 0;

	if (!IS_VALID_CHANNEL(channel)) {
		err = -ENODEV;
		goto out;
	}
	if (!IS_USED(channel)) {
		err = -EBUSY;
		goto out;
	}
	if (descriptor == NULL) {
		err = -EINVAL;
		goto out;
	}

	/* Allocate memory for a command from the buffer */
	descriptor->command =
	    dma_pool_alloc(user->pool, GFP_KERNEL, &descriptor->handle);

	/* Check it worked */
	if (!descriptor->command) {
		err = -ENOMEM;
		goto out;
	}

	memset(descriptor->command, 0, pool_item_size);
out:
	WARN_ON(err);
	return err;
}
Exemple #6
0
/* TODO combine contiguous regions of freed memory. */
void free(void *ptr)
{
    if (NULL == ptr)
        return;
    if (!IS_USED(ptr))
        return;
    SET_UNUSED(ptr);
}
Exemple #7
0
void *malloc(ssize_t size_)
{
    void *at = mem_ptr;
    uint32_t size = (uint32_t)ROUNDUP(size_, BYTES_PER_LONG) + BYTES_PER_LONG;
    int looped = 0;
    uint32_t expand_size;
    void *expanded;

    /* Scan the current heap for an opening. */
    while (!looped || at < mem_ptr)
    {
        uint32_t at_size = BLOCK_SIZE(at);
        if (!IS_USED(at) && at_size >= size && at_size - size != BYTES_PER_LONG)
        { /* We can use this block. */
            void *leftover = at + size;
            SET_SIZE(at, size);
            SET_USED(at);
            SET_SIZE(leftover, at_size - size);
            SET_UNUSED(leftover);
            mem_ptr = leftover;
            return PTR(at);
        }
        at += at_size;
        if (at >= curr_brk)
        {
            at = orig_brk;
            looped = 1;
        }
    }

    /* Expand the heap. */
    expand_size = size + BUFFER_SIZE;
    expanded = mbrk(curr_brk + expand_size);
    if (expanded != at + expand_size)
        return NULL;
    at = curr_brk;
    curr_brk = expanded;
    SET_SIZE(at, size);
    SET_USED(at);
    SET_SIZE(at + size, expand_size - size);
    SET_UNUSED(at + size);
    return PTR(at);
}
Exemple #8
0
uint32_t edmac_get_dir(uint32_t channel)
{
    if(!IS_USED(edmac_chanlist[channel]))
    {
        return EDMAC_DIR_UNUSED;
    }
    
    if(IS_WRITE(edmac_chanlist[channel]))
    {
        return EDMAC_DIR_WRITE;
    }
    
    if(IS_READ(edmac_chanlist[channel]))
    {
        return EDMAC_DIR_READ;
    }
    
    return EDMAC_DIR_UNUSED;
}
Exemple #9
0
int stmp3xxx_dma_release(int ch)
{
	struct stmp3xxx_dma_user *user = channels + ch;
	int err = 0;

	if (!IS_VALID_CHANNEL(ch)) {
		err = -ENODEV;
		goto out;
	}
	if (!IS_USED(ch)) {
		err = -EBUSY;
		goto out;
	}
	BUG_ON(user->pool == NULL);
	dma_pool_destroy(user->pool);
	user->inuse--;
out:
	return err;
}
Exemple #10
0
void* _malloc(size_t size){
	if(!initialized)
		mem_initialize();

	void* cur = HEAP_START;
	void* end = HEAP_END;
	size += sizeof(header);

	do {
		if(IS_USED(cur) || BLOCK_SIZE(cur) < size)
			continue;

		return allocate_block(cur, size);

	} while(NEXT_BLOCK(cur) >= end);

	/* TODO:단편화 확인 및 재배열 코드 추가 */
	/* 또는 가상메모리 사용할지 고민 중 */

	return NULL;
}
void
_dxfDeallocateInteractor (tdmInteractor interactor)
{
  tdmInteractorWin W ;

  ENTRY(("_dxfDeallocateInteractor(0x%x)", interactor));

  if (! interactor || ! (W = WINDOW(interactor)))
    {
      EXIT(("ERROR"));
      return ;
    }
      
  if (PRIVATE(interactor))
      tdmFree((void *) PRIVATE(interactor)) ;

  bzero ((char *) interactor, sizeof(tdmInteractorT)) ;
  IS_USED(interactor) = 0 ;
  W->numUsed-- ;

  EXIT((""));
}
Exemple #12
0
char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len)
{
	int n = 0;
	struct cpuinfo_arc *cpu = &cpuinfo_arc700[cpu_id];

	FIX_PTR(cpu);
#define IS_AVAIL1(var, str)	((var) ? str : "")
#define IS_AVAIL2(var, str)	((var == 0x2) ? str : "")
#define IS_USED(cfg)		(IS_ENABLED(cfg) ? "(in-use)" : "(not used)")

	n += scnprintf(buf + n, len - n,
		       "Extn [700-Base]\t: %s %s %s %s %s %s\n",
		       IS_AVAIL2(cpu->extn.norm, "norm,"),
		       IS_AVAIL2(cpu->extn.barrel, "barrel-shift,"),
		       IS_AVAIL1(cpu->extn.swap, "swap,"),
		       IS_AVAIL2(cpu->extn.minmax, "minmax,"),
		       IS_AVAIL1(cpu->extn.crc, "crc,"),
		       IS_AVAIL2(cpu->extn.ext_arith, "ext-arith"));

	n += scnprintf(buf + n, len - n, "Extn [700-MPY]\t: %s",
		       mul_type_nm[cpu->extn.mul].str);

	n += scnprintf(buf + n, len - n, "   MAC MPY: %s\n",
		       mac_mul_nm[cpu->extn_mac_mul.type].str);

	if (cpu->core.family == 0x34) {
		n += scnprintf(buf + n, len - n,
		"Extn [700-4.10]\t: LLOCK/SCOND %s, SWAPE %s, RTSC %s\n",
			       IS_USED(CONFIG_ARC_HAS_LLSC),
			       IS_USED(CONFIG_ARC_HAS_SWAPE),
			       IS_USED(CONFIG_ARC_HAS_RTSC));
	}

	n += scnprintf(buf + n, len - n, "Extn [CCM]\t: %s",
		       !(cpu->dccm.sz || cpu->iccm.sz) ? "N/A" : "");

	if (cpu->dccm.sz)
		n += scnprintf(buf + n, len - n, "DCCM: @ %x, %d KB ",
			       cpu->dccm.base_addr, TO_KB(cpu->dccm.sz));

	if (cpu->iccm.sz)
		n += scnprintf(buf + n, len - n, "ICCM: @ %x, %d KB",
			       cpu->iccm.base_addr, TO_KB(cpu->iccm.sz));

	n += scnprintf(buf + n, len - n, "\nExtn [FPU]\t: %s",
		       !(cpu->fp.ver || cpu->dpfp.ver) ? "N/A" : "");

	if (cpu->fp.ver)
		n += scnprintf(buf + n, len - n, "SP [v%d] %s",
			       cpu->fp.ver, cpu->fp.fast ? "(fast)" : "");

	if (cpu->dpfp.ver)
		n += scnprintf(buf + n, len - n, "DP [v%d] %s",
			       cpu->dpfp.ver, cpu->dpfp.fast ? "(fast)" : "");

	n += scnprintf(buf + n, len - n, "\n");

	n += scnprintf(buf + n, len - n,
		       "OS ABI [v3]\t: no-legacy-syscalls\n");

	return buf;
}
void
_dxfDestroyAllInteractors (tdmInteractorWin W)
{
  int i ;
  tdmInteractorCam curr, next ;

  ENTRY(("_dxfDestroyAllInteractors(0x%x)", W));

  if (! W)
    {
      EXIT(("ERROR: bad window"));
      return ;
    }

  /* destroy all used interactors */
  if (W->Interactors)
    {
      for (i = 0 ; i < W->numAllocated ; i++)
          if (IS_USED(W->Interactors[i]))
              /*
               *  Invoke the interactor's destroy method.  It must call
               *  _dxfDeallocateInteractor() itself at some point. 
               */
              tdmDestroyInteractor(W->Interactors[i]) ;

      tdmFree((void *) W->Interactors) ;
      W->Interactors = (tdmInteractor *) 0 ;
    }

  /* destroy all allocated interactor data */
  if (W->extents)
    {
      InteractorArray *array = (InteractorArray *) W->extents ;
      int numInteractorArrays = W->numAllocated / ARRAYSIZE ;

      for (i = 0 ; i < numInteractorArrays ; i++)
        {
          tdmFree((void *) array[i]) ;
          array[i] = (InteractorArray) 0 ;
        }

      tdmFree(W->extents) ;
      W->extents = (void *) 0 ;
    }

  /* destroy all camera info on undo and redo stacks */
  curr = W->Cam ;
  W->Cam = (tdmInteractorCam) 0 ;
  while (curr)
    {
      next = curr->next ;
      curr->next = (tdmInteractorCam) 0 ;

      tdmFree ((void *) curr) ;

      if (next)
          curr = next ;
      else
        {
          curr = W->redo ;
          W->redo = (tdmInteractorCam) 0 ;
        }
    }

  tdmFree((void *) W) ;
  EXIT((""));
}