Exemple #1
0
static void _alloc_command(void)
{
        if (!_cmdline.commands_size)
                __alloc(32);

        if (_cmdline.commands_size <= _cmdline.num_commands)
                __alloc(2 * _cmdline.commands_size);
}
Exemple #2
0
array_t create_array(compare_t fun)
{
	array_t list;

	__alloc(&list);
	__priv_alloc(&list->priv);
	list->add = add;
	list->add_first = add_first;
	list->add_last = add_last;
	list->del = del;
	list->del_first = del_first;
	list->del_last = del_last;
	list->compare = fun;
	list->copy = copy;
	list->copy_idx = copy_idx;
	list->copy_len = copy_len;
	list->get_index = get_index;
	list->get_size = get_size;
	list->get_count = get_count;
	list->lookup = lookup;
	list->replace = replace;
	list->priv->count = 0;
	list->priv->size = MINSIZE;
	__set(list->priv->size, &list->priv->array);

	return list;
}
Exemple #3
0
DC_object_t *DC_object_alloc (long size,
		                      const char *cls,
		                      void *data,
		                      DC_object_t* (*__alloc) (const char*, unsigned int, void*),
                              void (*__free) (const char*, DC_object_t*, void*),
		                      void (*__release)(DC_object_t*, void*)) {
	DC_object_t *obj = NULL;

    //assert (__release != NULL);

    if (!__alloc) __alloc = __alloc_zone;
    if (!__free) __free   = __free_zone;

    obj = __alloc (cls, size, data);

    if (obj) {
        obj->data     = data;
        obj->refcount = 1;
        strncpy(obj->class_name, cls, sizeof(obj->class_name) - 1);
        obj->PRI (release) = __release;
        obj->PRI (alloc)   = __alloc;
        obj->PRI (free)    = __free;
    }
	return obj;
}
Exemple #4
0
void *allocate_contiguous_memory(unsigned long size,
	int mem_type, unsigned long align, int cached)
{
	unsigned long aligned_size = PFN_ALIGN(size);
	struct mem_pool *mpool;

	mpool = mem_type_to_memory_pool(mem_type);
	if (!mpool)
		return NULL;
	return __alloc(mpool, aligned_size, align, cached);

}
Exemple #5
0
/*
** Parse command line and setup argc and argv.
** Must be executed with es == psp
*/
_parse() {
  char *ptr;
#asm
  mov     cl,es:[80h]  ; get parameter string length
  mov     ch,0       
  push    cx           ; save it
  inc     cx
  push    cx           ; 1st __alloc() arg
  mov     ax,1
  push    ax           ; 2nd __alloc() arg
  call    __alloc      ; allocate zeroed memory for args
  add     sp,4
  mov     [bp-2],ax    ; ptr = addr of allocated memory
  pop     cx
  push    es           ; exchange
  push    ds           ; es         (source)
  pop     es           ;    and
  pop     ds           ;        ds  (destination)
  mov     si,81h       ; source offset
  mov     di,[bp-2]    ; destination offset
  rep     movsb        ; move string
  mov     al,0
  stosb                ; terminate with null byte
  push    es
  pop     ds           ; restore ds
#endasm
  _vec[0]=_arg1;       /* first arg = "*" */
  while (*ptr) {
    if(isspace(*ptr)) {++ptr; continue;}
    if(_cnt < 20) _vec[_cnt++] = ptr;
    while(*ptr) {
      if(isspace(*ptr)) {*ptr = NULL; ++ptr; break;}
      ++ptr;
      }
    }
  }
PUBLIC static FIASCO_INIT_CPU
void
Kmem::init_cpu(Cpu &cpu)
{
  void *cpu_mem = Kmem_alloc::allocator()->unaligned_alloc(1024);
  printf("Allocate cpu_mem @ %p\n", cpu_mem);

  // now initialize the global descriptor table
  cpu.init_gdt(__alloc(&cpu_mem, Gdt::gdt_max), user_max());

  // Allocate the task segment as the last thing from cpu_page_vm
  // because with IO protection enabled the task segment includes the
  // rest of the page and the following IO bitmap (2 pages).
  //
  // Allocate additional 256 bytes for emergency stack right beneath
  // the tss. It is needed if we get an NMI or debug exception at
  // entry_sys_fast_ipc/entry_sys_fast_ipc_c/entry_sys_fast_ipc_log.
  Address tss_mem = alloc_tss(sizeof(Tss) + 256);
  assert(tss_mem + sizeof(Tss) + 256 < Mem_layout::Io_bitmap);
  tss_mem += 256;

  // this is actually tss_size + 1, including the io_bitmap_delimiter byte
  size_t tss_size;
  tss_size = Mem_layout::Io_bitmap + (Mem_layout::Io_port_max / 8) - tss_mem;

  assert(tss_size < 0x100000); // must fit into 20 Bits

  cpu.init_tss(tss_mem, tss_size);

  // force GDT... to memory before loading the registers
  asm volatile ( "" : : : "memory" );

  // set up the x86 CPU's memory model
  cpu.set_gdt();
  cpu.set_ldt(0);

  cpu.set_ds(Gdt::data_segment());
  cpu.set_es(Gdt::data_segment());
  cpu.set_ss(Gdt::gdt_data_kernel | Gdt::Selector_kernel);
  cpu.set_fs(Gdt::gdt_data_user   | Gdt::Selector_user);
  cpu.set_gs(Gdt::gdt_data_user   | Gdt::Selector_user);
  cpu.set_cs();

  // and finally initialize the TSS
  cpu.set_tss();

  init_cpu_arch(cpu, &cpu_mem);
}
Exemple #7
0
struct lifo *create_lifo()
{
	lifo_t lifo;

        __alloc(&lifo);

	lifo->poof = poof_lifo;
	lifo->peek = peek_lifo;
	lifo->push = push_lifo;

	lifo->get_size = get_size;
	lifo->get_prev = get_prev;
	lifo->get_next = get_next;

	return lifo;
}
Exemple #8
0
struct dequeue *create_dequeue()
{
	dec_t dec;

	__alloc(&dec);
        
	dec->get_size = get_size;
	dec->get_prev = get_prev;
	dec->get_next = get_next;

	dec->poof_head = poof_head;
	dec->poof_tail = poof_tail;
	dec->push_head = push_head;
	dec->push_tail = push_tail;
	dec->peek_head = peek_head;
	dec->peek_tail = peek_tail;

	return dec;
}
Exemple #9
0
struct val *_strsym_alloc_static(const char *s, enum val_type type)
{
	return __alloc(type, s, USE_STRLEN, false, false);
}
Exemple #10
0
struct val *_strsym_alloc(char *s, enum val_type type)
{
	return __alloc(type, s, USE_STRLEN, true, false);
}
Exemple #11
0
struct val *_strsym_dup_len(const char *s, size_t len, enum val_type type)
{
	return __alloc(type, s, len, false, true);
}
Exemple #12
0
struct val *_strsym_dup(const char *s, enum val_type type)
{
	return __alloc(type, s, USE_STRLEN, false, true);
}