void __lios_startup(void) { if(!malloc_init()) exit(EXIT_FAILURE); exit(main()); }
/* Pintos main program. */ int main (void) { char **argv; /* Clear BSS. */ bss_init (); /* Break command line into arguments and parse options. */ argv = read_command_line (); argv = parse_options (argv); /* Initialize ourselves as a thread so we can use locks, then enable console locking. */ thread_init (); console_init (); /* Greet user. */ printf ("Pintos booting with %'"PRIu32" kB RAM...\n", init_ram_pages * PGSIZE / 1024); /* Initialize memory system. */ palloc_init (user_page_limit); malloc_init (); paging_init (); <<<<<<< HEAD
void main(){ malloc_init(); // Alloc memory for thread&group lists main_memarea = kolibri_new_named_memory(KOBRA_MEMAREA_NAME, KOBRA_MEM_SIZE, KOLIBRI_ACCESS_READ|KOLIBRI_CREATE); halMemHeapInit(&memarea_heap, &return_0, main_memarea.addr, KOBRA_MEM_SIZE); // Init main group list create_group("main"); main_group_list->next = main_group_list->previos = main_group_list; main_group_list->thread_list = main_thread_list = new_thread_list(kolibri_get_my_tid()); main_thread_list->next = main_thread_list->previos = main_thread_list; IPCInit(); // kolibri_IPC_unlock(); // Set event mask // kolibri_event_set_mask(KOLIBRI_IPC_EVENT_MASK); while (1) { Message *msg = IPCWaitMessage(-1); // if (kolibri_event_wait() != KOLIBRI_IPC_EVENT) { // Just ignore this error // continue; // } message_handle(msg); free(msg); // kolibri_IPC_clear_buff(); } }
volatile type* init_clear(int size) { volatile type* a = malloc_init(size); for (int i = 0; i < size; i++) { a[i] = 0; } return a; }
void *malloc(size_t size) { void *ret; ret = NULL; if (!test_bit(&mdata.flags, MALLOC_INITIALIZED)) { if (malloc_init()) goto out; } if (!(test_bit(&mdata.flags, MALLOC_HAS_SPACE)) || ((mdata.num_pages * PAGE_SIZE) < mdata.offset + size)) { /* TODO: if we don't fit the allocation on current memory * poll we need to alloc more*/ printf("ran out of memory, alloc more will be implemented soon\n"); printf("flags: %d, len: %lu, offset: %d, page: 0x%x, addr: 0x%x\n", mdata.flags, size, mdata.offset, (unsigned int)mdata.current_page, (unsigned int)(mdata.current_page + mdata.offset)); clear_bit(&mdata.flags, MALLOC_HAS_SPACE); goto out; } ret = mdata.current_page + mdata.offset; mdata.offset += size; out: return ret; }
//------------------------------------------------------------------------ int start_kernel ( void ) { malloc_init((void*) HEAP_START); init_priorities(); // Initializing the elements int unsorted[MAX_SIZE]; unsorted[0] = 3; unsorted[1] = 8; unsorted[2] = 6; unsorted[3] = 2; unsorted[4] = 4; unsorted[5] = 1; unsorted[6] = 12; unsorted[7] = 10; int i; for (i = 0; i < MAX_SIZE; i++) { create_process(sort, (void*) unsorted[i], 2); } sem_init(&insert_sem, 1); start_sched(); return(0); }
void * safe_malloc(size_t size, const char *file, int line) { int i; #if BEST_FIT int bestFit; size_t smallestSize; #endif char * ret = 0; if ( !zalloc_base ) { // this used to follow the bss but some bios' corrupted it... malloc_init((char *)ZALLOC_ADDR, ZALLOC_LEN, ZALLOC_NODES, malloc_error); } size = ((size + 0xf) & ~0xf); if (size == 0) { if (zerror) (*zerror)((char *)0xdeadbeef, 0, file, line); } #if BEST_FIT smallestSize = 0; bestFit = -1; #endif for (i = 0; i < availableNodes; i++) { // find node with equal size, or if not found, // then smallest node that fits. if ( zavailable[i].size == size ) { zallocate(ret = zavailable[i].start, size); zdelete(zavailable, i); availableNodes--; goto done; } #if BEST_FIT else { if ((zavailable[i].size > size) && ((smallestSize == 0) || (zavailable[i].size < smallestSize))) { bestFit = i; smallestSize = zavailable[i].size; } } #else else if ( zavailable[i].size > size ) { zallocate(ret = zavailable[i].start, size); zavailable[i].start += size; zavailable[i].size -= size; goto done; } #endif }
/*====================================== * CORE : MAINROUTINE *--------------------------------------*/ int main (int argc, char **argv) { {// initialize program arguments char *p1 = SERVER_NAME = argv[0]; char *p2 = p1; while ((p1 = strchr(p2, '/')) != NULL || (p1 = strchr(p2, '\\')) != NULL) { SERVER_NAME = ++p1; p2 = p1; } arg_c = argc; arg_v = argv; } malloc_init();// needed for Show* in display_title() [FlavioJS] #ifdef MINICORE // minimalist Core display_title(); usercheck(); do_init(argc,argv); do_final(); #else// not MINICORE set_server_type(); display_title(); usercheck(); db_init(); signals_init(); timer_init(); socket_init(); plugins_init(); do_init(argc,argv); plugin_event_trigger(EVENT_ATHENA_INIT); {// Main runtime cycle int next; while (runflag != CORE_ST_STOP) { next = do_timer(gettick_nocache()); do_sockets(next); } } plugin_event_trigger(EVENT_ATHENA_FINAL); do_final(); timer_final(); plugins_final(); socket_final(); db_final(); #endif malloc_final(); return 0; }
void mem_init(void) { int i, n; n = sizeof(banks)/sizeof(struct malloc_bank); malloc_init(banks, n, BANK_SDRAM); printf("MEM: registered %d dynamic bank(s):\n", n); for(i=0;i<n;i++) printf("MEM: #%d 0x%08x-0x%08x\n", i, banks[i].addr_start, banks[i].addr_end); }
void __late_init(void) { halInit(); chSysInit(); #if CH_CFG_USE_HEAP == TRUE malloc_init(); #endif #ifdef HAL_USB_PRODUCT_ID setup_usb_strings(); #endif }
/*====================================== * CORE : MAINROUTINE *--------------------------------------*/ int main (int argc, char **argv) { { // Inicializa os argumentos do programa char *p1 = SERVER_NAME = argv[0]; char *p2 = p1; while ( (p1 = strchr (p2, '/')) != NULL || (p1 = strchr (p2, '\\')) != NULL) { SERVER_NAME = ++p1; p2 = p1; } arg_c = argc; arg_v = argv; } malloc_init(); // needed for Show* in display_title() [FlavioJS] #ifndef _WIN32 usercheck(); #endif #ifdef MINICORE // minimalist Core display_title(); do_init (argc, argv); do_final(); #else// not MINICORE set_server_type(); // Define o tipo de servidor (função exclusiva de cada servidor) display_title(); // Mostra o título db_init(); signals_init(); #ifdef _WIN32 cevents_init(); #endif timer_init(); socket_init(); do_init (argc, argv); // Inicializa as funções do servidor { // Ciclo principal do servidor int next; // Enquanto a runflag não for a de Parar, o servidor rodará; do contrário, entrará em processo de finalização while (runflag != CORE_ST_STOP) { next = do_timer (gettick_nocache()); do_sockets (next); } } do_final(); timer_final(); socket_final(); db_final(); #endif malloc_final(); return 0; }
int __libc_start_main() { char *args[1]; args[0] = ""; __do_global_ctors_aux(); malloc_init(256 * 1024); // Alloc 256k for now. int result = main(1, args); __do_global_dtors_aux(); //Cnecin(); return result; }
bool sm_pdex_init(void) { if (pal_fade_control.active) return false; audioDampenMaybe(); sav1_secure_increment(0x29); // this is something the original dex routine does, probably for statistics /* maybe clean up safari stuff here if necessary */ overworld_free_bgmaps(); malloc_init((void *)0x2000000, 0x1C000); set_callback2(region_select_load); return true; }
//------------------------------------------------------------------------ int start_kernel ( void ) { malloc_init((void *) HEAP_START); create_process(&funcOne, (void*) 0); create_process(&funcTwo, (void*) 0); sem_init(&sem_test, 1); start_sched(); /* Pas atteignable vues nos 2 fonctions */ return(0); }
static int usedblocks( void *ptr ) { int i; int retval; malloc_init( ); retval = 0; for ( i = 0; i < _arena_pages; i++ ) { if ( _arena_metadata[i] == ( int ) ptr ) retval++; } return retval; }
int main (int argc, char **argv) { int next; // initialise program arguments { char *p = SERVER_NAME = argv[0]; while ((p = strchr(p, '/')) != NULL) SERVER_NAME = ++p; arg_c = argc; arg_v = argv; } set_server_type(); display_title(); usercheck(); malloc_init(); /* 一番最初に実行する必要がある */ db_init(); signals_init(); timer_init(); socket_init(); plugins_init(); do_init(argc,argv); graph_init(); plugin_event_trigger("Athena_Init"); while (runflag) { next = do_timer(gettick_nocache()); do_sendrecv(next); #ifndef TURBO do_parsepacket(); #endif } plugin_event_trigger("Athena_Final"); graph_final(); do_final(); timer_final(); plugins_final(); socket_final(); db_final(); malloc_final(); return 0; }
void mem_init() { for (int i = 0; i < 16; i++) { if (bootparams->devtable[i].type == DEV_TYPE_RAM) { ram_start_page = bootparams->devtable[i].start / PAGE_SIZE; ram_end_page = bootparams->devtable[i].end / PAGE_SIZE; ram_pages = ram_end_page - ram_start_page; page_alloc_init(); malloc_init(); return; } } puts("No RAM found?!?!"); shutdown(); }
static void populate_memory_info(struct atag *atags) { /* Only the first memory region will work for now. */ if (is_first_region == 1) return; is_first_region = 1; gBootArgs.physBase = atags->u.mem.start; gBootArgs.memSize = atags->u.mem.size; malloc_init((char *)atags->u.mem.start + atags->u.mem.size - MALLOC_SIZE, MALLOC_SIZE); is_malloc_inited = 1; }
int start_kernel ( void ) { malloc_init((void *) HEAP_START); current_process = &idle; idle.next = ready_queue; int j; for(j = 0; j < NB; j++) { create_process(philosopher, 512, (void*) j); } yield(); return(0); }
int main() { void * ptr; int i, s, d; malloc_init(); for (i = 0; i < 100; i++) { printf("premalloc %d\n", i); ptr = malloc(64); printf("postmalloc %d\n", i); } printf("\n\nPRINTING CHUNKS:\n"); print_memory_chunks(); return 0; // To make compiler happy }
void * malloc(unsigned int size) { if (!malloc_initialized) malloc_init(); if (size == 0) return 0; /* so says ANSI */ /* use the special allocator for small sizes */ if (size <= 56) return small_malloc(size); /* use the standard free list for large sizes */ return big_malloc(size); }
TEE_Result init_teecore(void) { static int is_first = 1; unsigned long a, s; /* (DEBUG) for inits at 1st TEE service: when UART is setup */ if (!is_first) return TEE_SUCCESS; is_first = 0; #ifndef WITH_UART_DRV /* UART tracing support */ asc_init(); IMSG("teecore: uart trace init"); #endif /* core malloc pool init */ #ifdef CFG_TEE_MALLOC_START a = CFG_TEE_MALLOC_START; s = CFG_TEE_MALLOC_SIZE; #else a = (unsigned long)&teecore_heap_start; s = (unsigned long)&teecore_heap_end; a = ((a + 1) & ~0x0FFFF) + 0x10000; /* 64kB aligned */ s = s & ~0x0FFFF; /* 64kB aligned */ s = s - a; #endif IMSG("teecore heap: paddr=0x%lX size=0x%lX (%ldkB)", a, s, s / 1024); malloc_init((void *)a, s); /* init support for futur mapping of TAs */ tee_mmu_kmap_init(); teecore_init_ta_ram(); teecore_init_pub_ram(); /* Libtomcrypt initialization */ tee_ltc_init(); /* time initialization */ time_source_init(); IMSG("teecore inits done"); return TEE_SUCCESS; }
void * malloc(size_t size) { int i; char *ret = 0; #if 0 extern char _DATA__end; #endif if (!zalloc_base) { // this used to follow the bss but some bios' corrupted it... malloc_init((char *)ZALLOC_ADDR, ZALLOC_LEN, ZALLOC_NODES); } size = ((size + 0xf) & ~0xf); for (i=0; i<availableNodes; i++) { // uses first possible node, doesn't try to find best fit if (zavailable[i].size == size) { zallocate(ret = zavailable[i].start, size); zdelete(zavailable, i); availableNodes--; goto done; } else if (zavailable[i].size > size) { zallocate(ret = zavailable[i].start, size); zavailable[i].start += size; zavailable[i].size -= size; goto done; } } done: #if 0 /* if (ret + size >= (char*)_sp()) _stop("stack clobbered"); */ if (ret + size >= (char *)(ZALLOC_ADDR + ZALLOC_LEN)) _stop("Out of memory"); #endif if (ret != 0) bzero(ret, size); return (void *)ret; }
//------------------------------------------------------------------------ int notmain ( void ) { malloc_init((void *) HEAP_START); music_init(); create_process(processus_A, 128); create_process(processus_A, 128); create_process(play_music, 2048); create_process(processus_B, 128); create_process(processus_B, 128); start_sched(); return(0); }
//------------------------------------------------------------------------ int notmain ( void ) { DISABLE_IRQ(); init_hw(); malloc_init( (void*)0x50000); //On cree les deux processus create_process(STACK_SIZE,funcA, NULL,2); create_process(STACK_SIZE,funcB, NULL,2); create_process(STACK_SIZE,funcC, NULL,1); //On lance l'ordonnanceur start_sched(); /* Pas atteignable vues nos 2 fonctions */ return(0); }
void free( void *ptr ) { int n; malloc_init( ); // n = 0; n = ( ( unsigned char * ) ptr - _arena_data ) / PAGESIZE; if ( ( n < 0 ) || ( n > _arena_pages ) ) { /* Outside heap. Bad. */ G_dprintf("free: ptr Outside heap.\n"); return; } _arena_freestart = n; /* Next allocation tries here, to see if it fits. */ while ( _arena_metadata[n] == ( int ) ptr ) { _arena_metadata[n] = 0; n++; } return; }
int main (int argc, char **argv) { {// initialize program arguments char *p1 = SERVER_NAME = argv[0]; char *p2 = p1; while ((p1 = strchr(p2, '/')) != NULL || (p1 = strchr(p2, '\\')) != NULL) { SERVER_NAME = ++p1; p2 = p1; } arg_c = argc; arg_v = argv; } malloc_init(); set_server_type(); display_title(); usercheck(); signals_init(); timer_init(); socket_init(); do_init(argc,argv); {// Main runtime cycle int next; while (runflag) { next = CTaskMgr::getInstance()->DoTimer(gettick_nocache()); do_sockets(next); } } do_final(); timer_final(); socket_final(); malloc_final(); return 0; }
void interface_init(void) { // Running at new code address - do code relocation fixups malloc_init(); // Setup romfile items. qemu_cfg_init(); coreboot_cbfs_init(); // Setup ivt/bda/ebda ivt_init(); bda_init(); // Other interfaces boot_init(); bios32_init(); pmm_init(); pnp_init(); kbd_init(); mouse_init(); }
int init_tpe(void) { int ret; ret = malloc_init(); if (IN_ERR(ret)) return ret; if (sysctl) { ret = tpe_config_init(); if (IN_ERR(ret)) return ret; } hijack_syscalls(); printk(PKPRE "added to kernel\n"); return ret; }
void malloc(long num_bytes) { void *current_location; void *allocated_location = 0; struct mm_ctrl_block *mcb; if( ! is_initialized ){ malloc_init(); } num_bytes = num_bytes + sizeof(struct mm_ctrl_block); current_location = mm_start; while(current_location != last_valid_addr){ mcb = (struct mm_ctrl_block *)current_location; if( mcb->is_available && mcb->size >= num_bytes){ mcb->is_available = 0; allocated_location = current_location; break; } current_location += mcb->size; } if( ! allocated_location ){ sbrk(num_bytes); allocated_location = last_valid_addr; last_valid_addr += num_bytes; mcb = allocated_location; mcb->is_available = 0; mcb->size = num_bytes; } allocated_location += sizeof(struct mm_ctrl_block); return allocated_location; }