Пример #1
0
void Thread::setup_lightweight_stack(JVM_SINGLE_ARG_TRAPS) {
  UsingFastOops fast_oops;
  const int stack_size = StackSize;

  GUARANTEE(wakeup_time_offset() % 8 == 0,
            "jlongs in ThreadDesc must be 8 byte aligned");

  // it's here  as Thread::allocate not invoked for the main thread 
  // in ROMized case, and we still need it
#if ENABLE_WTK_PROFILER
  OopDesc* info = WTKProfiler::allocate_thread_data(JVM_SINGLE_ARG_CHECK);
  set_profiler_info(info);
#endif

  // Allocate stack and set stack pointer to bottom
  ExecutionStack::Fast stack = Universe::new_execution_stack(stack_size JVM_CHECK);

  address sp =(address)stack.field_base(JavaStackDirection < 0 ? stack_size
                                        : ExecutionStackDesc::header_size());
#if defined(UNDER_CE)
  // I thought I only needed this for debugging under EVC++, but when I ran
  // cldc_vm under the test utility on the iPaq it hung unless this was
  // uncommented.  Run mintck uses CreateProcess to run the mintck tests.
  // If I run the mintck tests using a .lnk file it works without the
  // following line
  sp = (address)((int)sp |_system_address);
#endif
  set_execution_stack(&stack);
  stack().set_thread(this);
  set_stack_limit();

  sp = setup_stack_asm(sp);
  set_stack_pointer((jint)sp);
}
Пример #2
0
/**
 * Switch into vcore mode to run the scheduler code. 
 **/
void switch_to_vcore() {

	uint32_t vcoreid = vcore_id();

	/* Disable notifications.  Once we do this, we might miss a notif_pending,
	 * so we need to enter vcore entry later.  Need to disable notifs so we
	 * don't get in weird loops */
	struct preempt_data *vcpd = &__procdata.vcore_preempt_data[vcoreid];
	vcpd->notif_enabled = FALSE;

	/* Grab a reference to the currently running thread on this vcore */
	thread_t *t = current_thread; 

	/* Switch to the vcore's tls region */
	extern void** vcore_thread_control_blocks;
	set_tls_desc(vcore_thread_control_blocks[vcoreid], vcoreid);
	
	/* Verify that the thread the vcore thinks was running is the same as the thread
	 * that was actually running */
	assert(current_thread == t);

	/* Set the stack pointer to the stack of the vcore. 
	 * We know this function is always inlined because of the attribute we set
	 * on it, so there will be no stack unwinding when this function "returns".
	 * After this call, make sure you don't use local variables. */
	set_stack_pointer((void*)vcpd->transition_stack);
	assert(in_vcore_context());

	/* Leave the current vcore completely */
	current_thread = NULL; 
	
	/* Restart the vcore and run the scheduler code */
	vcore_entry();
	assert(0);
}
Пример #3
0
void wpc_sound_reset (void)
{
	set_stack_pointer (0x1000);
	set_direct_page_pointer (0x02);

	wpc_sound_init ();
	wpc_sound_main_loop ();
}
Пример #4
0
void vcore_reenter(void (*entry_func)(void))
{
    assert(in_vcore_context());
    struct preempt_data *vcpd = vcpd_of(vcore_id());

    __vcore_reentry_func = entry_func;
    set_stack_pointer((void*)vcpd->vcore_stack);
    cmb();
    __vcore_reenter();
}
Пример #5
0
void smp_idle(void)
{
	/* FP must be zeroed before SP.  Ideally, we'd do both atomically.  If we
	 * take an IRQ/NMI in between and set SP first, then a backtrace would be
	 * confused since FP points *below* the SP that the *IRQ handler* is now
	 * using.  By zeroing FP first, at least we won't BT at all (though FP is
	 * still out of sync with SP). */
	set_frame_pointer(0);
	set_stack_pointer(get_stack_top());
	__smp_idle();
}
Пример #6
0
/**
 * Entry point for errors that are nonrecoverable.
 * error_code is one of the values in include/system/errno.h.
 */
__noreturn__
void fatal (errcode_t error_code)
{
	new_fatal_error = TRUE;
#ifdef __m6809__
	set_stack_pointer (6133);
#endif

	/* Don't allow any more interrupts, since they might be the
	source of the error.  Since FIRQ is disabled, we can only
	do mono display at this point.   Also note that idle
	cannot run anymore, because task scheduling can't proceed
	without the system clock moving. */
	periodic_ok = 0;
	disable_interrupts ();

	/* Reset hardware outputs */
#ifdef CONFIG_GI
	pinio_write_gi (0);
#endif

	/* TODO - this whole function needs porting to Whitestar */
	/* Maybe just call platform_init again? */
#ifdef CONFIG_PLATFORM_WPC
	if (WPC_HAS_CAP (WPC_CAP_FLIPTRONIC))
		wpc_write_flippers (0);
#endif
#ifdef CONFIG_TICKET
	pinio_write_ticket (0);
#endif
	pinio_disable_flippers ();
	pinio_write_solenoid_set (0, 0);
	pinio_write_solenoid_set (1, 0);
	pinio_write_solenoid_set (2, 0);
	pinio_write_solenoid_set (3, 0);
#ifdef MACHINE_SOL_EXTBOARD1
	pinio_write_solenoid_set (5, 0);
#endif

	/* Audit the error. */
	audit_increment (&system_audits.fatal_errors);
	audit_assign (&system_audits.lockup1_addr, error_code);
	audit_assign (&system_audits.lockup1_pid_lef, task_getgid ());
	log_event (SEV_ERROR, MOD_SYSTEM, EV_SYSTEM_FATAL, error_code);

	/* Dump all debugging information */
#ifdef DEBUGGER
	dbprintf ("Fatal error %d\n", error_code);
	db_dump_all ();
#endif

	/* In native mode, exit whenever a fatal occurs.  If the
	   simulator is compiled in, let it clean up first. */
#ifdef CONFIG_SIM
	sim_exit (error_code);
#else
#ifdef CONFIG_NATIVE
	native_exit ();
	exit (error_code);
#endif
#endif

	/* Defining STOP_ON_ERROR is helpful during debugging a problem.
	Having the machine reset makes it hard to debug after the fact. */
#ifdef STOP_ON_ERROR
	while (1);
#endif

	/* Restart the system */
	warm_reboot ();
}
Пример #7
0
int run_vm(void) {
#if !defined(VM_CLOCKINTERRUPTHANDLER_INTERRUPT)
	Object temp;
	int32* mainMethodJavaStack;
#endif

	int16 execp = 0;
	/* Required for certain compilers. */
	init_compiler_specifics();

	/* Function below allocates the initial heap. This is done in
	 * initDefaultRAMAllocationPoint in allocation_point.c
	 */
	init_vm();

#if defined(ENABLE_DEBUG)
	connectToDebugger();
	sendStartEvent();
	while (awaitCommandFromDebugger(0, 0, 0) != RESUME_EVENT) {;}
#endif

	/* Allocating the main stack is delegated to the target specific function
	 * 'get_java_stack_base'. On some architectures/environments it is located
	 * at fixed positions in certain compiler specific sections. The implementor
	 * can allocate the stack in the heap if so desired.
	 * */
	mainMethodJavaStack = get_java_stack_base(JAVA_STACK_SIZE);

#if defined(VM_CLOCKINTERRUPTHANDLER_INTERRUPT)
	/* If more threads are started we give the main thread a new C stack pointer.
	 * In case of no other threads running the main thread just inherits the
	 * current C stack.
	 *
	 * In this case we save the current C stack so we may restore it later. This
	 * is required to terminate the process properly.
	 */
	mainStackPointer = (pointer) get_stack_pointer();

	/* mainMethodJavaStack contains both Java and C stack. Java stack grows
	 * upwards from the beginning, C stack downwards from the end. */
	stackPointer = (pointer) &mainMethodJavaStack[JAVA_STACK_SIZE - 2];
	/* 'set_stack_pointer' sets the C stack */
	stackPointer = (pointer) & mainMethodJavaStack[JAVA_STACK_SIZE - 2];
	set_stack_pointer();
#endif

#if defined(REPORTCYCLES)
	papi_start();
	papi_mark();
	papi_mark();
	papi_mark();
	papi_mark();
	papi_mark();
	papi_mark();
#endif

#if defined(LDC2_W_OPCODE_USED) || defined(LDC_W_OPCODE_USED) || defined(LDC_OPCODE_USED) || defined(HANDLELDCWITHINDEX_USED)
	execp = initializeConstants(mainMethodJavaStack);
	if (execp == -1) {
#endif

		execp = initializeExceptions(mainMethodJavaStack);
		if (execp == -1) {

#if defined(INVOKECLASSINITIALIZERS)
			execp = invokeClassInitializers(mainMethodJavaStack);
			if (execp == -1) {
#endif
				/* This is only for testing. All tests will write 0 (null) to
				 * '*mainMethodJavaStack' if the test is successful.
				 */
				*mainMethodJavaStack = (int32) (pointer) &temp;

#if defined(VM_CLOCKINTERRUPTHANDLER_ENABLE_USED)
				start_system_tick();
#endif

#if defined(DEVICES_SYSTEM_INITIALIZESYSTEMCLASS)
				execp = enterMethodInterpreter(
				DEVICES_SYSTEM_INITIALIZESYSTEMCLASS, mainMethodJavaStack);
				if (execp == -1) {
#endif
						/* Start the VM */
						execp = enterMethodInterpreter(mainMethodIndex,
								mainMethodJavaStack);
#if defined(VM_CLOCKINTERRUPTHANDLER_ENABLE_USED)
						stop_system_tick();
#endif
#if defined(DEVICES_SYSTEM_INITIALIZESYSTEMCLASS)
				}
#endif
			}
			/* TODO: use executeWithStack instead */
#if defined(INVOKECLASSINITIALIZERS)
		}
#endif

#if defined(LDC2_W_OPCODE_USED) || defined(LDC_W_OPCODE_USED) || defined(LDC_OPCODE_USED) || defined(HANDLELDCWITHINDEX_USED)
	}
#endif

#if defined(REPORTCYCLES)
	papi_mark();
#endif

	mark_error();

	if (execp >= 0) {
#if defined(JAVA_LANG_THROWABLE_INIT_)
		handleException(execp);
#endif
#if defined(VM_CLOCKINTERRUPTHANDLER_INTERRUPT)
		/* Restore C stack pointer. Otherwise we could not return from here properly */
		stackPointer = (pointer) mainStackPointer;
		set_stack_pointer();
#endif
		return ERROR;
	}

#if defined(VM_CLOCKINTERRUPTHANDLER_INTERRUPT)
	/* Restore C stack pointer. Otherwise we could not return from here properly */
	stackPointer = (pointer) mainStackPointer;
	set_stack_pointer();
#endif

#if defined(ENABLE_DEBUG)
	disconnectFromDebugger();
#endif

	if (*mainMethodJavaStack) {
		return ERROR;
	} else {
		mark_success();
		return SUCCESS;
	}

	return 0;
}