void *tiny_malloc(size_t size) { void *ret; t_sm *bws_tiny; t_sm *keep; if (!g_pool.tiny_m) { g_pool.tiny_m = (t_sm *)mmap(0, 101 * TINY_M, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); init_mem(g_pool.tiny_m); } bws_tiny = g_pool.tiny_m; while (bws_tiny) { if ((ret = find_alloc(bws_tiny, size, TINY_M))) return (ret); keep = bws_tiny; bws_tiny = bws_tiny->next; } keep->next = (t_sm *)mmap(0, 101 * TINY_M, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); init_mem(keep->next); return (find_alloc(keep->next, size, TINY_M)); }
void *small_malloc(size_t size) { void *ret; t_sm *bws_small; t_sm *keep; if (!g_pool.small_m) { g_pool.small_m = (t_sm *)mmap(0, 101 * SMALL_M, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); init_mem(g_pool.small_m); } bws_small = g_pool.small_m; while (bws_small) { if ((ret = find_alloc(bws_small, size, SMALL_M))) return (ret); keep = bws_small; bws_small = bws_small->next; } keep->next = (t_sm *)mmap(0, 101 * SMALL_M, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); init_mem(keep->next); return (find_alloc(keep->next, size, SMALL_M)); }
int main() { init_env(); // Poorly named. Has nothing to do with env alist. init_mem(); uptr_t *env = refer(NIL); init_syms(env); uptr_t *form_p = refer(NIL); while(1) { print_env(env); print_mem(); printf_P(PSTR("> ")); *form_p = read_form(stdin); while(getc(stdin) != '\r'); print_form(eval(env, *form_p)); printf_P(PSTR("\n")); // print_mem(); __GC__(); } release(2); // Just a formality really... return 0; }
void mesh_parser_init(FILE* f, const char* filename) { mesh_lexer_init(f); H2D_PARSER_FILENAME = filename; init_mem(); init_symbols(); }
/* Function to initialize the timer utility (**V.IMP.** Use this function only once, else all previous timers will be lost and also will cause memory leak) Parameters : none Return Value : 0 = successful -1 = error */ int init_timer(void) { pthread_t tick_proc_thread; int count; /* Initialise the hash table */ for(count=0;count<MAX;count++) timer_ds.hash_table[count] = NULL; /* Initialise present bucket as bucket number 0 */ timer_ds.current_bucket = 0; /* Obtain current time with time rounded up to time granularity */ get_current_time(); /* Initialize mutexes and condition variable */ pthread_mutex_init(&timer_ds.currenttime_mutex, NULL); pthread_mutex_init(&timer_ds.timer_mutex, NULL); pthread_cond_init(&timer_ds.timer_cond,NULL); /* Create a new thread to perform per tick processing */ if( pthread_create(&tick_proc_thread, NULL, per_tick_processing, NULL)!= 0 ){ return(-1); } /* Initialise memory and return whether the operation was successful or not */ return(init_mem(sizeof(timer_info_t))); }
int main() { int choice = -1; //choice of oepration to be performed char cont[100]; //continue to main menu? int i_cont; //intialise memory init_mem(); do { //display main menu disp_menu(); //operation selection do { choice = get_selection(); }while(!is_valid_choice(choice)); //perform selected operation perform_opn(choice); //continue confirmation printf("\n\nContinue to main menu? (1 = yes, any other character = no) : "); scanf("%s",cont); i_cont = atoi(cont); }while(i_cont == 1); //destroy memory destroy_mem(); printf("\n\nProgram Exited Successfully!!\n\n"); return 0; }
void init_cpu (void) { int i; init_mem (); memset (memory+REGISTER_ADDRESS, 0x11, 8 * 4); memory[RL78_SFR_PSW] = 0x06; memory[RL78_SFR_ES] = 0x0f; memory[RL78_SFR_CS] = 0x00; memory[RL78_SFR_PMC] = 0x00; for (i = 0; i < 256; i ++) { int rb0 = (i & RL78_PSW_RBS0) ? 1 : 0; int rb1 = (i & RL78_PSW_RBS1) ? 2 : 0; int rb = rb1 | rb0; regbase_table[i] = (RegBank *)(memory + (3 - rb) * 8 + REGISTER_ADDRESS); } trace_register_init (); /* This means "by default" */ timer_enabled = 2; }
int init_memory(unsigned long arg1){ unsigned long virt_real_start_addr,virt_start_addr,virt_end_addr; unsigned long pc_size; unsigned long current_end_memused=&end; /* till this point memory is used*/ unsigned long phy_end_addr = g_phy_mem_size; ut_log(" Initializing memory phy_endaddr : %x current end:%x symbols_end:%x\n",phy_end_addr,current_end_memused,symbols_end); if (symbols_end != 0){ current_end_memused = symbols_end; } virt_start_addr=initialise_paging_new(phy_end_addr, current_end_memused,&virt_real_start_addr,&virt_end_addr); INIT_LOG(" After Paging initialized Virtual start_addr: %x virtual endaddr: %x current end:%x virtualreal_start:%x\n",virt_start_addr,virt_end_addr,current_end_memused,virt_real_start_addr); INIT_LOG(" code+data : %x -%x size:%dK",&_start,&_end); INIT_LOG(" free area : %x - %x size:%dM\n",virt_start_addr,virt_end_addr,(virt_end_addr-virt_start_addr)/1000000); virt_start_addr=init_free_area( virt_start_addr, virt_end_addr); pc_size = g_pagecache_size ; pc_init((unsigned char *)virt_start_addr,pc_size); ut_log(" pagecache : %x - %x size:%dM",virt_start_addr,virt_start_addr+pc_size,pc_size/1000000); virt_start_addr=virt_start_addr+pc_size; #if 0 /* reserve the test memory for testing */ if (virt_end_addr > (virt_start_addr + (600*1024*1024))){ test_mem_start = virt_start_addr; test_mem_end = virt_start_addr + 512 *1024 *1204 ; /* 512M */ virt_start_addr = test_mem_end + 4096; } #endif init_mem(virt_start_addr, virt_end_addr, virt_real_start_addr); INIT_LOG(" buddy pages: %x - %x size:%dM\n",virt_start_addr, virt_end_addr,(virt_end_addr-virt_start_addr)/1000000); return JSUCCESS; }
//misc :p s32 libAICA_Init() { init_mem(); verify(sizeof(*CommonData)==0x508); verify(sizeof(*DSPData)==0x15C8); CommonData=(CommonData_struct*)&aica_reg[0x2800]; DSPData=(DSPData_struct*)&aica_reg[0x3000]; //slave cpu (arm7) SCIEB=(InterruptInfo*)&aica_reg[0x289C]; SCIPD=(InterruptInfo*)&aica_reg[0x289C+4]; SCIRE=(InterruptInfo*)&aica_reg[0x289C+8]; //Main cpu (sh4) MCIEB=(InterruptInfo*)&aica_reg[0x28B4]; MCIPD=(InterruptInfo*)&aica_reg[0x28B4+4]; MCIRE=(InterruptInfo*)&aica_reg[0x28B4+8]; sgc_Init(); for (int i=0;i<3;i++) timers[i].Init(aica_reg,i); return rv_ok; }
void sim_init() { /* Create memory and register files */ initialized = 1; mem = init_mem(MEM_SIZE); reg = init_reg(); /* create 5 pipe registers */ pc_state = new_pipe(sizeof(pc_ele), (void *) &bubble_pc); if_id_state = new_pipe(sizeof(if_id_ele), (void *) &bubble_if_id); id_ex_state = new_pipe(sizeof(id_ex_ele), (void *) &bubble_id_ex); ex_mem_state = new_pipe(sizeof(ex_mem_ele), (void *) &bubble_ex_mem); mem_wb_state = new_pipe(sizeof(mem_wb_ele), (void *) &bubble_mem_wb); /* connect them to the pipeline stages */ pc_next = pc_state->next; pc_curr = pc_state->current; if_id_next = if_id_state->next; if_id_curr = if_id_state->current; id_ex_next = id_ex_state->next; id_ex_curr = id_ex_state->current; ex_mem_next = ex_mem_state->next; ex_mem_curr = ex_mem_state->current; mem_wb_next = mem_wb_state->next; mem_wb_curr = mem_wb_state->current; sim_reset(); clear_mem(mem); }
int main(){ const char* rows[5] = {"SUM", "SUMSTR", "SUMCONSTSTR", "COPY", "COPYCONSTSTR"}; const char* cols[1] = {"n=1e9 doubles"}; const int n = 1000*1000*1000; double *a, *b; init_mem(a, b, n); double bw[5]; bw[0] = time(a, b, n, SUM); bw[1] = time(a, b, n, SUMSTR); bw[2] = time(a, b, n, SUMCONSTSTR); bw[3] = time(a, b, n, COPY); bw[4] = time(a, b, n, COPYCONSTSTR); verify_dir("DBG/"); char fname[200]; sprintf(fname, "DBG/time_sc_stride_%d.txt", STR); link_cout(fname); Table tbl; tbl.dim(5, 1); tbl.rows(rows); tbl.cols(cols); tbl.data(bw); char banner[200]; sprintf(banner, "memory bw in bytes/cycle, stride = %d\n", STR); tbl.print(banner); unlink_cout(); release_mem(a, b); }
void mesh_parser_init(FILE* f, const char* filename) { mesh_lexer_init(f); parser_filename = filename; init_mem(); init_symbols(); }
SIM_DESC sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *callback, struct bfd *abfd, char **argv) { if (open) fprintf (stderr, "rx minisim: re-opened sim\n"); /* The 'run' interface doesn't use this function, so we don't care about KIND; it's always SIM_OPEN_DEBUG. */ if (kind != SIM_OPEN_DEBUG) fprintf (stderr, "rx minisim: sim_open KIND != SIM_OPEN_DEBUG: %d\n", kind); set_callbacks (callback); /* We don't expect any command-line arguments. */ init_mem (); init_regs (); execution_error_init_debugger (); sim_disasm_init (abfd); open = 1; return &the_minisim; }
SIM_DESC sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *callback, struct bfd *abfd, char **argv) { setbuf (stdout, 0); if (open) fprintf (stderr, "m32c minisim: re-opened sim\n"); /* The 'run' interface doesn't use this function, so we don't care about KIND; it's always SIM_OPEN_DEBUG. */ if (kind != SIM_OPEN_DEBUG) fprintf (stderr, "m32c minisim: sim_open KIND != SIM_OPEN_DEBUG: %d\n", kind); if (abfd) m32c_set_mach (bfd_get_mach (abfd)); /* We can use ABFD, if non-NULL to select the appropriate architecture. But we only support the r8c right now. */ set_callbacks (callback); /* We don't expect any command-line arguments. */ init_mem (); init_regs (); open = 1; return &the_minisim; }
s32 FASTCALL Init(aica_init_params* param) { aica_ram=param->aica_ram; init_mem(); InitHLE(); return rv_ok; }
int main() { init_mem(); memory_test(); // gcollector_test(); leak_msg(); getchar(); return 0; }
state_ptr new_state(int memlen) { state_ptr result = (state_ptr) malloc(sizeof(state_rec)); result->pc = 0; result->r = init_reg(); result->m = init_mem(memlen); result->cc = DEFAULT_CC; return result; }
/* create an y86 image with registers and memory */ y86sim_t *new_y86sim(int slen) { y86sim_t *sim = (y86sim_t*)malloc(sizeof(y86sim_t)); sim->pc = 0; sim->r = init_reg(); sim->m = init_mem(slen); sim->cc = DEFAULT_CC; return sim; }
void *large_malloc(int size) { static int block_count = -1; int mult; mult = (size / getpagesize()) + (size % getpagesize()); if (block_count == -1) { g_g.max_allocs[LARGE] = 0; g_g.memory[0].mem_large = init_mem(getpagesize() * mult, size, LARGE); block_count = 0; } else { g_g.memory[++block_count].mem_large = init_mem(getpagesize() * mult, size, LARGE); } return (g_g.memory[block_count].mem_large.ptr); }
void sim_init() { /* Create memory and register files */ initialized = 1; mem = init_mem(MEM_SIZE); reg = init_reg(); sim_reset(); clear_mem(mem); }
void sim_close (SIM_DESC sd, int quitting) { check_desc (sd); /* Not much to do. At least free up our memory. */ init_mem (); open = 0; }
//called when plugin is used by emu (you should do first time init here) s32 FASTCALL Init(aica_init_params* initp) { memcpy(&aica_params,initp,sizeof(aica_params)); init_mem(); AICA_Init(); InitAudio(); eminf.SetMenuItemStyle(config_scmi,MIS_Grayed,MIS_Grayed); return rv_ok; }
void header(char headrec[]) { // HPRGNAMsrtadd^^len^ char tmp[10]; strncpy(prgname,headrec+1,6); strncpy(tmp,headrec+7,6); sscanf(tmp,"%X",&startaddr); strncpy(tmp,headrec+13,6); sscanf(tmp,"%X",&memlen); mem=(struct memory *)malloc((memlen)*(sizeof(struct memory))); init_mem(); }
void engine() { int i,j; static int lasttick = 0; int start = 0; for(i=0;i<4;i++) for(j=0;j<MAX_SPRITE_Z;j++){ sp_list[i][j].used = 0; } init_mem(); init_p(); i = 0; while(1){ while(tick - lasttick < REFRESH_TICKS); lasttick = tick; disable_irq(CLOCK_IRQ); disable_irq(KEYBOARD_IRQ); draw_rect(0,0,320,200,0); if(start == 0){ int key = get_lastkey(); if(key == VKEY_START){ start = 1; srand(tick/REFRESH_TICKS); } } else { main_p(); for(i=0;i<4;i++) for(j=0;j<MAX_SPRITE_Z;j++){ if(sp_list[i][j].used == 1){ sp_list[i][j].sp->t(sp_list[i][j].sp); sp_list[i][j].sp->d(sp_list[i][j].sp); } } } keys_len = 0; fill_screen(buf); enable_irq(KEYBOARD_IRQ); enable_irq(CLOCK_IRQ); } }
void repl() { env environment; init_mem(&environment, 64 * 1024); init_env(&environment); init(&environment); printf("^C to quit\n\n"); while (1) { printf("> "); write(stdout, eval(parse(stdin), &environment)); } }
void main (int argc, uchar **argv) { int i, j, c; struct stat f_stat; printf("compdic: Utility for compilation of word dictionaries\n"); if (argc!=4) error("Usage:\ncompdic <alphabet> <text_dic> <comp_dic>"); if ((fi=fopen(argv[1],"rb"))==NULL) error("Error opening alphabet file"); memset(codes, 0, 256); for (letter_count=1; (c=getc(fi))>=' '; codes[c] = letter_count++) ; fclose(fi); stat(argv[2],&f_stat); init_mem(letter_count, f_stat.st_size + 50000); if ((fi=fopen(argv[2],"rb"))==NULL) error("Error opening input file"); clear_state(0); owf[0]=0; wf1[0]=0; get_word_info(wf); // init of get_word_inf() while (get_word_info(wf)) { for (i=0; wf[i]==owf[i]; i++) ; // find difference location for (j=strlen(owf)-1; j>=i; j--) state(j, codes[owf[j]]) = save_state(j+1); for (j=i+1; j<=strlen(wf); j++) clear_state(j); state(--j,0) = 1; strcpy(owf, wf); } fclose(fi); for (j=strlen(owf)-1; j>=0; j--) state(j, codes[owf[j]]) = save_state(j+1); save_cell(0, 'S', save_state(0)); save_cell(1, 'T', last_full_cell+1); fo = fopen(argv[3], "wb"); fwrite (cells, sizeof(tcell), last_full_cell+1, fo); fwrite (strings, 1, last_string, fo); fclose(fo); print_statistics(); }
/*device driver module loader function*/ int sharemem_init(void) { int result; dev_t devno = MKDEV(sharemem_major, 0); printk("init_mem ok\n"); /*start acoral*/ if(startAcoral() < 0) { printk("start acoral error\n"); return -1; } printk("startAcoral ok\n"); /* apply for device number*/ if (sharemem_major) result = register_chrdev_region(devno, 1, "sharemem"); else /* dynamic apply*/ { result = alloc_chrdev_region(&devno, 0, 1, "sharemem"); sharemem_major = MAJOR(devno); } if (result < 0) return result; printk("region ok\n"); /*dynamic apply for the memory of device construction*/ sharemem_devp = kmalloc(sizeof(struct sharemem_dev), GFP_KERNEL); if (!sharemem_devp) /*application failed*/ { result = - ENOMEM; goto fail_malloc; } printk("kmalloc ok\n"); memset(sharemem_devp, 0, sizeof(struct sharemem_dev)); if(init_mem() < 0) { printk("init_mem error\n"); return -1; } sharemem_setup_cdev(sharemem_devp, 0); return 0; fail_malloc: unregister_chrdev_region(devno, 1); return result; }
unsigned long init_sysmem (void) { unsigned long freemem = init_mem (); if (CONFIG_KDYNAMIC_MEMORY > freemem) return -1; if (!(memory_pool = alloc_region ((ulong)ebss, RAMTOP, CONFIG_KDYNAMIC_MEMORY))) return -1; // Setting up TLSF with the largest free area, memory_pool will be // zeroed by this function as well printf ("\nSetting up the dynamic memory manager (%d kbytes at 0x%x)\n", CONFIG_KDYNAMIC_MEMORY/1024, memory_pool); if (init_memory_pool (CONFIG_KDYNAMIC_MEMORY, memory_pool) == 0) return -1; return freemem; }
/* ======================================================================== main: This is the main entry point for the VirtualT application. ======================================================================== */ int main(int argc, char **argv) { if (process_args(argc, argv)) /* Parse command line args */ return 1; setup_working_path(argv); /* Create a working dir path */ setup_unix_signals(); /* Setup Unix signal handling */ // Added by JV for prefs init_pref(); /* load user Menu preferences */ check_installation(); /* Test if install needs to be performed */ load_setup_preferences(); /* Load user Peripheral setup preferences */ load_memory_preferences(); /* Load user Memory setup preferences */ load_remote_preferences(); /* Load user Remote Socket preferences */ /* Perform initialization */ init_mem(); /* Initialize Memory */ init_io(); /* Initialize I/O structures */ init_sound(); /* Initialize Sound system */ init_display(); /* Initialize the Display */ init_cpu(); /* Initialize the CPU */ init_throttle_timer(); /* Initialize the throttle timer */ init_remote(); /* Initialize the remote control */ init_lpt(); /* Initialize the printer subsystem */ init_other_windows(); /* Initialize other windows that were opened (memedit, regs, etc. */ get_model_time(); /* Load the emulated time for current model */ /* Perform Emulation */ emulate(); /* Main emulation loop */ /* Save RAM contents after emulation */ save_ram(); save_model_time(); /* Save the emulated time */ /* Cleanup */ deinit_io(); /* Deinitialize I/O */ deinit_sound(); /* Deinitialize sound */ deinit_lpt(); /* Deinitialize the printer */ deinit_throttle_timer(); /* Deinitialize the throttle timer */ deinit_display(); /* Deinitialze and free the main window */ free_mem(); /* Free memory used by ReMem and/or Rampac */ return 0; }
void HariMain(void) { char* buf; int win, x, y; init_mem(); buf = (char*)malloc(144 * 164); win = win_open(buf, 144, 164, -1, "WIN-COLOR2"); for (y = 0; y < 128; ++y) { for (x = 0; x < 128; ++x) buf[(x + 8) + (y + 28) * 144] = rgb2pal(x * 2, y * 2, 0, x, y); } win_refresh(win, 8, 28, 136, 156); getkey(1); api_end(); }