/* * Saves this CPU's banked parts of the distributor * Returns non-zero if an SGI/PPI interrupt is pending (after saving all required context) * Requires 19 words of memory */ int save_gic_distributor_private(appf_u32 * pointer, unsigned gic_distributor_address, int is_secure) { interrupt_distributor *id = (interrupt_distributor *) gic_distributor_address; *pointer = id->enable.set[0]; ++pointer; pointer = copy_words(pointer, id->priority, 8); pointer = copy_words(pointer, id->target, 8); if (is_secure) { *pointer = id->security[0]; ++pointer; } /* Save just the PPI configurations (SGIs are not configurable) */ *pointer = id->configuration[1]; ++pointer; *pointer = id->pending.set[0]; if (*pointer) { return -1; } else { return 0; } }
static void restore_gic_distributor_private(u32 *pointer, unsigned gic_distributor_address) { interrupt_distributor *id = (interrupt_distributor *)gic_distributor_address; unsigned tmp; /* First disable the distributor so we can write to its config registers */ tmp = id->control; id->control = 0; id->enable.set[0] = *pointer; ++pointer; copy_words(id->priority, pointer, 8); pointer += 8; copy_words(id->target, pointer, 8); pointer += 8; #if 1 //wschen 2011-12-30 id->security[0] = *pointer; ++pointer; #endif /* Restore just the PPI configurations (SGIs are not configurable) */ id->configuration[1] = *pointer; ++pointer; id->pending.set[0] = *pointer; id->control = tmp; }
void restore_gic_distributor_shared(appf_u32 *pointer, unsigned gic_distributor_address) { interrupt_distributor *id = (interrupt_distributor *)gic_distributor_address; unsigned num_spis; /* First disable the distributor so we can write to its config registers */ id->control = 0; /* Calculate how many SPIs the GIC supports */ num_spis = 32 * ((id->controller_type) & 0x1f); /* TODO: add nonsecure stuff */ /* Restore rest of GIC configuration */ if (num_spis) { copy_words(id->enable.set + 1, pointer, num_spis / 32); pointer += num_spis / 32; copy_words(id->priority + 8, pointer, num_spis / 4); pointer += num_spis / 4; copy_words(id->target + 8, pointer, num_spis / 4); pointer += num_spis / 4; copy_words(id->configuration + 2, pointer, num_spis / 16); pointer += num_spis / 16; copy_words(id->pending.set + 1, pointer, num_spis / 32); pointer += num_spis / 32; } /* We assume the I and F bits are set in the CPSR so that we will not respond to interrupts! */ /* Restore control register */ id->control = *pointer; return; }
void CountCodePattern::initCounting() { // general count stub; 8 instructions. // 0: lis Temp1, high(count_addr) // 1: lwz Temp2, [low(count_addr) + Temp1] // 2: addi Temp2, Temp2, 1 // 3: stw Temp2, [low(count_addr) + Temp1] // 4: lis Temp1, high(jump_addr) // 5: ori Temp1, Temp1, low(jump_addr) // 6: mtctr Temp1 // 7: balwctr instsSize = 8 * 4; countAddr_offset = 0; lwz_offset = 1; stw_offset = 3; nm_lis_offset = 4; nm_ori_offset = 5; limit_offset = recompile_lis_offset = recompile_ori_offset = BadOffset; Assembler* oldAssembler = theAssembler; Assembler* a = theAssembler = new Assembler(instsSize, instsSize, false, true); a->load_from_address(Temp2, 0, VMAddressOperand, Temp1); // 2 instructions a->addi(Temp2, Temp2, 1, NumberOperand); a->stw(Temp2, 0, VMAddressOperand, Temp1); a->long_branch_to((pc_t)0, CodeAddressOperand, Temp1, false); // 4 instructions pattern = (pc_t)AllocateHeap(instsSize, "countStub pattern"); copy_words((int32*)a->instsStart, (int32*)pattern, instsSize / 4); a->finalize(); theAssembler = oldAssembler; }
static void save_pl310(u32 *pointer, unsigned pl310_address) { pl310_registers *pl310 = (pl310_registers *)pl310_address; pl310_context *context = (pl310_context *)pointer; /* TODO: are all these registers are present in earlier PL310 versions? */ context->aux_control = pl310->aux_control; context->tag_ram_control = pl310->tag_ram_control; context->data_ram_control = pl310->data_ram_control; context->ev_counter_ctrl = pl310->ev_counter_ctrl; context->ev_counter1_cfg = pl310->ev_counter1_cfg; context->ev_counter0_cfg = pl310->ev_counter0_cfg; context->ev_counter1 = pl310->ev_counter1; context->ev_counter0 = pl310->ev_counter0; context->int_mask = pl310->int_mask; context->lock_line_en = pl310->lock_line_en; copy_words((unsigned *)context->lockdown, (unsigned *)pl310->lockdown, 16); context->addr_filtering_start = pl310->addr_filtering_start; context->addr_filtering_end = pl310->addr_filtering_end; context->debug_ctrl = pl310->debug_ctrl; context->prefetch_ctrl = pl310->prefetch_ctrl; context->power_ctrl = pl310->power_ctrl; }
void CountCodePattern::initCounting() { // general count stub; 7 instrs = 12 cycles on SS-2. Could be reduced to // 6 insts / 10 cy if one additional register were available (e.g. could // use %o5 for sends with < 5 args). // 0: sethi count_addr, Temp1 // 1: ld [Temp1+lo(count_addr)], Temp2 // 2: inc Temp2 // 3: st Temp2, [Temp1+lo(count_addr)] // 4: sethi jump_addr, Temp1 // 5: jmpl Temp1 + low(jump_addr), g0 // 6: nop instsSize = 7 * 4; countAddr_offset = 0; ld_offset = 1; st_offset = 3; nm_sethi_offset = 4; nm_jmp_offset = 5; limit_sethi_offset = countAddr_offset2 = recompile_offset = BadOffset; Assembler* a = new Assembler(instsSize, instsSize, false, true); a->SetHiA(0, Temp1); a->LoadI(Temp1, 0, Temp2); a->AddI(Temp2, 1, Temp2); a->StoreI(Temp1, 0, Temp2); a->SetHiX(0, CodeAddressOperand, Temp1); a->JmpLC(Temp1, 0, G0); a->Nop(); pattern = (pc_t)AllocateHeap(instsSize, "countStub pattern"); copy_words((int32*)a->instsStart, (int32*)pattern, instsSize / 4); a->finalize(); }
/* * Saves this CPU's banked parts of the distributor * Returns non-zero if an SGI/PPI interrupt is pending (after saving all required context) * Requires 19 words of memory */ static void save_gic_distributor_private(u32 *pointer, unsigned gic_distributor_address) { interrupt_distributor *id = (interrupt_distributor *)gic_distributor_address; *pointer = id->enable.set[0]; ++pointer; pointer = copy_words(pointer, id->priority, 8); pointer = copy_words(pointer, id->target, 8); #if 1 //wschen 2011-12-30 *pointer = id->security[0]; ++pointer; #endif /* Save just the PPI configurations (SGIs are not configurable) */ *pointer = id->configuration[1]; ++pointer; *pointer = id->pending.set[0]; }
void xDBLe(const point_proj_t P, point_proj_t Q, const f2elm_t A24plus, const f2elm_t C24, const int e) { // Computes [2^e](X:Z) on Montgomery curve with projective constant via e repeated doublings. // Input: projective Montgomery x-coordinates P = (XP:ZP), such that xP=XP/ZP and Montgomery curve constants A+2C and 4C. // Output: projective Montgomery x-coordinates Q <- (2^e)*P. int i; copy_words((digit_t *) P, (digit_t *) Q, 2 * 2 * NWORDS_FIELD); for (i = 0; i < e; i++) { xDBL(Q, Q, A24plus, C24); } }
/* * Saves the shared parts of the distributor * Requires 1 word of memory, plus 20 words for each block of 32 SPIs (max 641 words) * Returns non-zero if an SPI interrupt is pending (after saving all required context) */ static void save_gic_distributor_shared(u32 *pointer, unsigned gic_distributor_address) { interrupt_distributor *id = (interrupt_distributor *)gic_distributor_address; unsigned num_spis, *saved_pending; /* Calculate how many SPIs the GIC supports */ num_spis = 32 * (id->controller_type & 0x1f); /* TODO: add nonsecure stuff */ /* Save rest of GIC configuration */ if (num_spis) { pointer = copy_words(pointer, id->enable.set + 1, num_spis / 32); pointer = copy_words(pointer, id->priority + 8, num_spis / 4); pointer = copy_words(pointer, id->target + 8, num_spis / 4); pointer = copy_words(pointer, id->configuration + 2, num_spis / 16); #if 1 //wschen 2011-12-30 pointer = copy_words(pointer, id->security + 1, num_spis / 32); #endif saved_pending = pointer; pointer = copy_words(pointer, id->pending.set + 1, num_spis / 32); } /* Save control register */ *pointer = id->control; }
/* * Saves the shared parts of the distributor * Requires 1 word of memory, plus 20 words for each block of 32 SPIs (max 641 words) * Returns non-zero if an SPI interrupt is pending (after saving all required context) */ int save_gic_distributor_shared(appf_u32 *pointer, unsigned gic_distributor_address) { interrupt_distributor *id = (interrupt_distributor *)gic_distributor_address; unsigned num_spis, *saved_pending; int i, retval = 0; /* Calculate how many SPIs the GIC supports */ num_spis = 32 * (id->controller_type & 0x1f); /* TODO: add nonsecure stuff */ /* Save rest of GIC configuration */ if (num_spis) { pointer = copy_words(pointer, id->enable.set + 1, num_spis / 32); pointer = copy_words(pointer, id->priority + 8, num_spis / 4); pointer = copy_words(pointer, id->target + 8, num_spis / 4); pointer = copy_words(pointer, id->configuration + 2, num_spis / 16); saved_pending = pointer; pointer = copy_words(pointer, id->pending.set + 1, num_spis / 32); /* Check interrupt pending bits */ for (i=0; i<num_spis/32; ++i) { if (saved_pending[i]) { retval = -1; break; } } } /* Save control register */ *pointer = id->control; ++pointer; return retval; }
void restore_gic_distributor_private(appf_u32 *pointer, unsigned gic_distributor_address, int is_secure) { interrupt_distributor *id = (interrupt_distributor *)gic_distributor_address; /* We assume the distributor is disabled so we can write to its config registers */ id->enable.set[0] = *pointer; ++pointer; copy_words(id->priority, pointer, 8); pointer += 8; copy_words(id->target, pointer, 8); pointer += 8; if (is_secure) { id->security[0] = *pointer; ++pointer; } /* Restore just the PPI configurations (SGIs are not configurable) */ id->configuration[1] = *pointer; ++pointer; id->pending.set[0] = *pointer; }
void nmethod::addDeps(dependencyList *dl) { nmln *d; for (d= dl->start(); d < dl->end(); d++) { for (nmln *p= d->next; p != d; p= p->next) if (p >= deps() && p < depsEnd()) { // nmethod already on this list p->remove(); break; } } for (nmln *nd= deps(); nd < depsEnd(); nd++) if (nd->notEmpty()) { dl->add(nd); // could make this a shade more efficient by adding // a function to dependencyList nd->remove(); } fint ndeps= dl->length(); if (ndeps == depsEnd() - deps()) { // no need to allocate new region, just copy copy_words((int32*)dl->start(), (int32*)deps(), depsLen / sizeof(nmln*)); for (d= deps(); d < depsEnd(); d++) d->relocate(); return; } assert(ndeps > depsEnd() - deps(), "deps didn't grow!"); // now make dl the method's deps fint newDepsLen= ndeps * sizeof(nmln); char *dAddr= Memory->code->allocateDeps(newDepsLen + sizeof(nmethod*)); nmln *newDeps= (nmln*) (dAddr + sizeof(nmethod*)); copy_words((int32*)dl->start(), (int32*)newDeps, newDepsLen / sizeof(nmln*)); for (d= newDeps; d < newDeps + ndeps; d++) d->relocate(); Memory->code->deallocateDeps((char*)dBackLinkAddr(), depsLen + sizeof(nmethod*)); depsAddr= newDeps; depsLen= newDepsLen; *dBackLinkAddr()= this; }
static void restore_pl310(u32 *pointer, unsigned pl310_address, int dormant) { pl310_registers *pl310 = (pl310_registers *)pl310_address; pl310_context *context = (pl310_context *)pointer; int i; /* We may need to disable the PL310 if the boot code has turned it on */ if (pl310->control) { /* Wait for the cache to be idle, then disable */ pl310->cache_sync = 0; while (pl310->cache_sync & C_BIT) { for (i = 10; i > 0; --i) { nop(); } } pl310->control = 0; dsb(); } /* TODO: are all these registers present in earlier PL310 versions? */ pl310->aux_control = context->aux_control; pl310->tag_ram_control = context->tag_ram_control; pl310->data_ram_control = context->data_ram_control; pl310->ev_counter_ctrl = context->ev_counter_ctrl; pl310->ev_counter1_cfg = context->ev_counter1_cfg; pl310->ev_counter0_cfg = context->ev_counter0_cfg; pl310->ev_counter1 = context->ev_counter1; pl310->ev_counter0 = context->ev_counter0; pl310->int_mask = context->int_mask; pl310->lock_line_en = context->lock_line_en; copy_words((unsigned *)pl310->lockdown, (unsigned *)context->lockdown, 16); pl310->addr_filtering_start = context->addr_filtering_start; pl310->addr_filtering_end = context->addr_filtering_end; pl310->debug_ctrl = context->debug_ctrl; pl310->prefetch_ctrl = context->prefetch_ctrl; pl310->power_ctrl = context->power_ctrl; dsb(); /* * If the RAMs were powered off, we need to invalidate the cache */ if (!dormant) { inv_pl310(pl310_address); } }
void CountCodePattern::initComparing() { instsSize = 13 * 4; // 0: sethi count_addr, Temp1 // 1: ld [Temp1+lo(count_addr)], Temp2 // 2: setHi limit, Temp1 // 3: inc Temp2 // 4: cmp Temp2, Temp1 // 5: sethi count_addr, Temp1 // 6: st Temp2, [Temp1+lo(count_addr)] // 7: beq 10 // 8: sethi jump_addr, Temp1 // 9: jmpl Temp1 + low(jump_addr), g0 //10: sethi recompile_addr, Temp2 //11: jmpl Temp2 + low(recompile_addr), linkReg //12: nop countAddr_offset = 0; countAddr_offset2 = 5; ld_offset = 1; st_offset = 6; nm_sethi_offset = 8; nm_jmp_offset = 9; limit_sethi_offset = 2; recompile_offset = 10; Assembler* a = new Assembler(instsSize, instsSize, false, true); a->SetHiA(0, Temp1); a->LoadI(Temp1, 0, Temp2); a->SetHiA(0, Temp1); a->AddI(Temp2, 1, Temp2); a->SubCCR(Temp2, Temp1, G0); a->SetHiA(0, Temp1); a->StoreI(Temp1, 0, Temp2); Label* l = a->BgeForward(false); a->SetHiX(0, CodeAddressOperand, Temp1); a->JmpLC(Temp1, 0, G0); l->define(); a->SetHiP(Memory->code->trapdoors->Recompile_stub_td(), Temp2); a->JmpLP(Temp2, Memory->code->trapdoors->Recompile_stub_td(), RecompileLinkReg); a->Nop(); pattern = (pc_t)AllocateHeap(instsSize, "countStub pattern"); copy_words((int32*)a->instsStart, (int32*)pattern, instsSize / 4); a->finalize(); }
void restore_gic_distributor_shared(appf_u32 * pointer, unsigned gic_distributor_address, int is_secure) { interrupt_distributor *id = (interrupt_distributor *) gic_distributor_address; unsigned num_spis; /* Make sure the distributor is disabled */ gic_distributor_set_enabled(FALSE, gic_distributor_address); /* Calculate how many SPIs the GIC supports */ num_spis = 32 * ((id->controller_type) & 0x1f); /* TODO: add nonsecure stuff */ /* Restore rest of GIC configuration */ if (num_spis) { copy_words(id->enable.set + 1, pointer, num_spis / 32); pointer += num_spis / 32; copy_words(id->priority + 8, pointer, num_spis / 4); pointer += num_spis / 4; copy_words(id->target + 8, pointer, num_spis / 4); pointer += num_spis / 4; copy_words(id->configuration + 2, pointer, num_spis / 16); pointer += num_spis / 16; if (is_secure) { copy_words(id->security + 1, pointer, num_spis / 32); pointer += num_spis / 32; } copy_words(id->pending.set + 1, pointer, num_spis / 32); pointer += num_spis / 32; } /* Restore control register - if the GIC was disabled during save, it will be restored as disabled. */ id->control = *pointer; return; }
ex_format() { #if DISKFLAG register int trackno,i,driveno,nsides; int error,saveMP; char progress[80],trackstr[3]; if (do_dial(fmtaddr,-1,0L) == CANFMT) return; if (midiplexer) saveMP=MPoff(); /* drive A (0) or B (1) ? */ driveno= whichbutton(fmtaddr,DRIVEA,2); /* single (0) or double (1) sided ? */ nsides= whichbutton(fmtaddr,SIDE1,2); graf_mouse(BEE_MOUSE); /* format 80 tracks, 9 sectors per track, 1 or 2 sides, drive A or B, abort on any error */ trackno= 0; copy_words(scrbase,cnxscrsave,800L); /* save progress display area */ set_words(scrbase,800L,0); do { strcpy(progress,FMT_MSG); itoa(trackno,trackstr,2); strcat(progress,trackstr); strcat(progress,FMT2_MSG); gr_text(progress,40-strlen(progress)/2,1); /* centered */ for (i=error=0; !error&&(i<=nsides); i++) if (Flopfmt(scrsave,0L,driveno,9,trackno,i,1,0x87654321L,0xe5e5)) error=1; if (getmouse(&dummy,&dummy)) error=2; /* abort on mouse button */ } while ( ((++trackno)<80) && !error); copy_words(cnxscrsave,scrbase,800L); /* restore progress display area */ if (!error) { set_words(scrsave,4608L,0); if (Flopwr(scrsave,0L,driveno,1,0,0,9)) error=1; /* zero the FAT */ if (!error) { if (Flopwr(scrsave,0L,driveno,1,1,0,9)) error=1; if (!error) { Protobt(scrsave,0x01000000,2+nsides,0); /* write a boot sector */ if (Flopwr(scrsave,0L,driveno,1,0,0,1)) error=1; } } } waitmouse(); /* in case formatting was aborted via mouse */ graf_mouse(ARROWMOUSE); if (!error) make_tone(); /* no error */ if (error==1) form_alert(1,BADFMT); /* error */ if (error==2) form_alert(1,BADFMT2); /* aborted */ if (midiplexer&&saveMP) MPon(); #endif } /* end ex_format() */
static void restore_gic_distributor_shared(u32 *pointer, unsigned gic_distributor_address) { interrupt_distributor *id = (interrupt_distributor *)gic_distributor_address; unsigned num_spis; /* First disable the distributor so we can write to its config registers */ id->control = 0; /* Calculate how many SPIs the GIC supports */ num_spis = 32 * ((id->controller_type) & 0x1f); /* TODO: add nonsecure stuff */ /* Restore rest of GIC configuration */ if (num_spis) { copy_words(id->enable.set + 1, pointer, num_spis / 32); pointer += num_spis / 32; copy_words(id->priority + 8, pointer, num_spis / 4); pointer += num_spis / 4; copy_words(id->target + 8, pointer, num_spis / 4); pointer += num_spis / 4; copy_words(id->configuration + 2, pointer, num_spis / 16); pointer += num_spis / 16; #if 1 //wschen 2011-12-30 copy_words(id->security + 1, pointer, num_spis / 32); pointer += num_spis / 32; #endif copy_words(id->pending.set + 1, pointer, num_spis / 32); if (reg_read(SC_WAKEUP_SRC) & WAKE_SRC_KP) { int i, j; i = MT6575_KP_IRQ_ID / GIC_PRIVATE_SIGNALS; j = MT6575_KP_IRQ_ID % GIC_PRIVATE_SIGNALS; id->pending.set[i] |= (1 << j); } if (reg_read(SC_WAKEUP_SRC) & WAKE_SRC_MSDC1) { int i, j; i = MT6575_MSDC1_IRQ_ID / GIC_PRIVATE_SIGNALS; j = MT6575_MSDC1_IRQ_ID % GIC_PRIVATE_SIGNALS; id->pending.set[i] |= (1 << j); } #ifdef CONFIG_MTK_SC_DEBUG if (reg_read(SC_WAKEUP_SRC) & WAKE_SRC_TS) { int i, j; i = MT6575_TS_IRQ_ID / GIC_PRIVATE_SIGNALS; j = MT6575_TS_IRQ_ID % GIC_PRIVATE_SIGNALS; id->pending.set[i] |= (1 << j); } if (reg_read(SC_WAKEUP_SRC) & WAKE_SRC_LOW_BAT) { int i, j; i = MT6575_LOWBATTERY_IRQ_ID / GIC_PRIVATE_SIGNALS; j = MT6575_LOWBATTERY_IRQ_ID % GIC_PRIVATE_SIGNALS; id->pending.set[i] |= (1 << j); } #endif //CONFIG_MTK_SC_DEBUG pointer += num_spis / 32; } /* We assume the I and F bits are set in the CPSR so that we will not respond to interrupts! */ /* Restore control register */ id->control = *pointer; }
void CountCodePattern::initComparing() { // general count stub; 8 instructions. // 0: lis Temp1, high(count_addr) // 1: lwz Temp2, [low(count_addr) + Temp1] // 2: addi Temp2, Temp2, 1 // 3: stw Temp2, [low(count_addr) + Temp1] // 4: cmpwi Temp2, limit // 5: beq 10 // 6: lis Temp1, high(jump_addr) // 7: ori Temp1, Temp1, low(jump_addr) // 8: mtctr Temp1 // 9: balwctr //10: mflr RecompileTempReg //11: stw RecompileTempReg, SP + saved_pc_offset * 4 //12: bl 13 //13: mflr RecompileLinkReg //14: mtlr RecompileTempReg //15: lis R0, high(recompile_addr) //16: ori R0, R0, low(recompile_addr) //17: mtctr R0 //18: balwctrl instsSize = 19 * 4; countAddr_offset = 0; lwz_offset = 1; stw_offset = 3; limit_offset = 4; nm_lis_offset = 6; nm_ori_offset = 7; recompile_lis_offset = 15; recompile_ori_offset = 16; Assembler* oldAssembler = theAssembler; Assembler* a = theAssembler = new Assembler(instsSize, instsSize, false, true); { // make a new block so that the Label's destructor gets called before we reset theAssembler in Assembler::finalize a->load_from_address(Temp2, 0, VMAddressOperand, Temp1); // 2 instructions a->addi(Temp2, Temp2, 1, NumberOperand); a->stw(Temp2, 0, VMAddressOperand, Temp1); a->cmpwi( Temp2, 0, NumberOperand ); // assuming limit fits in si (assert in countStub_ppc) Label recompile(a->printing); a->beq(recompile, predict_usual); // not likley to recompile, so expect to fall through a->long_branch_to((pc_t)0, CodeAddressOperand, Temp1, false); // 4 instructions recompile.define(); // save link so can use link to get address of this code // also key to profiler -- dmu 2/04 a->mflr(RecompileTempReg); a->stw(RecompileTempReg, saved_pc_offset * oopSize, NumberOperand, SP); Label next; a->bl(next, NumberOperand); // needed to get addr of this code next.define(); a->mflr(RecompileLinkReg); a->mtlr(RecompileTempReg); // call recompiler char* fnaddr = Memory->code->trapdoors->Recompile_stub_td(R0); a->long_branch_to(fnaddr, CodeAddressOperand, R0, false); } pattern = (pc_t)AllocateHeap(instsSize, "countStub pattern"); copy_words((int32*)a->instsStart, (int32*)pattern, instsSize / 4); a->finalize(); theAssembler = oldAssembler; }
init_sys() { WORD work_in[11]; WORD work_out[57]; WORD i; save_critical(); got_blitter = ( (_xbios(64, -1) & 3 ) == 3); if ( (gl_apid = appl_init()) == -1) { exit(-1); } aline = ainit(); if (!init_mem()) exit(-2); /* save initial rez ... we'll see if GEM agrees with this later */ if ( (irez = Getrez()) != 0) { if (irez != 1) { puts("Cyber Paint can't run on black and white systems, sorry"); for (i=0; i<60; i++) { Vsync(); } exit(-3); } } get_cmap(color_env); copy_words(init_cmap, sys_cmap, COLORS); put_cmap(sys_cmap); initted_color = 1; if (!init_pulls()) return(-4); /* save mouse wrap-around */ mouse_bx = *((WORD *)(aline-692)); mouse_by = *((WORD *)(aline-690)); /* save # of colors gem thinks exist */ gem_colr = *((WORD *)(aline-666)); gr_handle = graf_handle(&gr_hwchar, &gr_hhchar, &gr_hwbox, &gr_hhbox); handle = gr_handle; stuff_words(work_in, 1, 10); work_in[10] = 2; v_opnvwk(work_in, &handle, work_out); if (handle == 0) return(-5); if (work_out[0] == 639) { gem_mrez = 1; /* see what GEM thinks rez is in so file-requestor can work */ /* poke in initial mouse location (in case off-screen for lo-rez */ *((WORD *)(aline-602)) = 160; *((WORD *)(aline-600)) = 100; } jim_rez(); pscreen = cscreen = (WORD *)Physbase(); if ((uscreen = askmem(32000)) == NULL) return(-6); if ((start_screen = askmem(32000)) == NULL) return(-7); if ((end_screen = askmem(32000)) == NULL) return(-8); if ((prev_screen = laskmem(2L*32000L)) == NULL) /* prev/next form 64K buffer */ return(-9); next_screen = prev_screen+16000; if ((bscreen = askmem(32000)) == NULL) return(-11); empty_ram_dlt(); zero_screens(); if (!init_input()) return(-13); init_fname(); init_menu_colors(); install_critical(); jimints_on(); cel_mem_alloc = mem_free; /* "user" memory starts here */ return(1); }
nmethod::nmethod(AbstractCompiler* c, bool generateDebugCode) { CHECK_VTBL_VALUE; _instsLen = roundTo(iLen, oopSize); _locsLen = ilLen; depsLen = dLen; // backpointer is just before deps depsAddr = (nmln*) ((char*)dAddr + sizeof(nmethod*)); *dBackLinkAddr() = this; // Copy the nmethodScopes scopeDescs generated by the ScopeDescRecorder // to the allocation area. c->scopeDescRecorder()->copyTo((VtblPtr_t*)sAddr, (int32)this); this->scopes = (nmethodScopes*) sAddr; oldCount = 0; flags.clear(); flags.isDebug = generateDebugCode; setCompiler(c->name()); flags.isUncommonRecompiled = currentProcess->isUncommon(); verifiedOffset = c->verifiedOffset(); diCheckOffset = c->diCheckOffset(); frameCreationOffset = c->frameCreationOffset(); rememberLink.init(); codeTableLink= NULL; diLink.init(c->diLink); if (diLink.notEmpty()) flags.isDI = true; flags.level = c->level(); if (flags.level >= MaxRecompilationLevels) { // added = zzzz warning1("setting invalid nmethod level %ld", flags.level); // fix this flags.level = 0; } flags.version = c->version(); if (c->nmName() == nm_nic && ((FCompiler*)c)->isImpure) makeImpureNIC(); key.set_from(c->L->key); check_store(); clear_frame_chain(); assert(c->frameSize() >= 0, "frame size cannot be negative"); frame_size = c->frameSize(); _incoming_arg_count = c->incoming_arg_count(); get_platform_specific_data(c); Assembler* instsA = c->instructions(); copy_bytes( instsA->instsStart, insts(), instsLen()); copy_words((int32*)instsA->locsStart, (int32*)locs(), ilLen/4); copy_words((int32*)depsStart, (int32*)deps(), depsLen/4); addrDesc *l, *lend; for (l = locs(), lend = locsEnd(); l < lend; l++) { l->initialShift(this, (char*)insts() - (char*)instsA->instsStart, 0); } char* bound = Memory->new_gen->boundary(); for (l = locs(), lend = locsEnd(); l < lend; l++) { if (l->isOop()) OopNCode::check_store(oop(l->referent(this)), bound); // cfront garbage else if (l->isSendDesc()) { l->asSendDesc(this)->dependency()->init(); } else if (l->isDIDesc()) { l->asDIDesc(this)->dependency()->init(); flags.isDI = true; } } for (nmln* d = deps(), *dend = depsEnd(); d < dend; d++) { d->relocate(); } MachineCache::flush_instruction_cache_range(insts(), instsEnd()); MachineCache::flush_instruction_cache_for_debugging(); if (this == (nmethod*)catchThisOne) warning("caught nmethod"); }
void nmethod::moveTo_inner(NCodeBase* p, int32 delta, int32 size) { nmethod* to = (nmethod*)p; if (this == to) return; if (PrintCodeCompaction) { lprintf("*moving nmethod %#lx (", this); printName(0, key.selector); lprintf(") to %#lx\n", to); } OopNCode::moveTo_inner(to, delta, size); assert(iabs((char*)to - (char*)this) >= sizeof(NCodeBase), "nmethods overlap too much"); assert(sizeof(NCodeBase) % oopSize == 0, "should be word-aligned"); // init to's vtable copy_words((int32*)this, (int32*)to, sizeof(NCodeBase) / sizeof(int32)); scopes->_nmethod_backPointer = to; *dBackLinkAddr() = to; flatProfiler->move(insts(), instsEnd(), to->insts()); zoneLink.shift(delta); FOR_MY_CODETABLE_ENTRIES(e) { e->nm= to; } for (nmln *x = linkedSends.next, *y = x->next; x != &linkedSends; x = y, y = y->next) { NCodeBase* s = findThing(x); s->shift_target(x, delta); } linkedSends.shift(delta, this); if (diLink.notEmpty()) { assert(diLink.next->next == &diLink, "diLink should be a pair"); diLink.next->asDIDesc()->shift_jump_addr(delta); } diLink.shift(delta); for (addrDesc* q = locs(), *pend = locsEnd(); q < pend; q++) { if (q->isSendDesc()) { sendDesc* sd = q->asSendDesc(this); sd->shift(delta, this); } else if (q->isDIDesc()) { nmln* l = q->asDIDesc(this)->dependency(); l->shift(delta); } q->shift(this, delta); } if (frame_chain != NoFrameChain && frame_chain != SavedFrameChain) frame_chain->nmethod_moved_by(delta, this); }