Ejemplo n.º 1
0
Monitor* allocMonitor(Object *obj) {
    Monitor *mon;

    if(mon_free_list != NULL) {
        mon = mon_free_list;
        mon_free_list = mon->next;      
    } else {
        mon = sysMalloc(sizeof(Monitor));
        monitorInit(mon);
    }
    mon->obj = obj;
    /* No need to wrap in LOCKWORD_WRITE as no thread should
     * be modifying it when it's on the free list */
    mon->entering = 0;
    return mon;
}
Ejemplo n.º 2
0
void bootmain(void)
{
	monitorInit(Normal_World);
	
	//int i;
	//for(i=0; i<10; i++)
	while(1)
	{
		//semi_write0("[Fast Model] This is secure world\n");
		cprintf("[TZV] This is secure world\n");
		asm volatile(
			".arch_extension sec\n\t"
			"smc #0\n\t");
	};

	while(1);
}
Ejemplo n.º 3
0
void initialiseThreadStage1(InitArgs *args) {
    size_t size;

    /* Set the default size of the Java stack for each _new_ thread */
    dflt_stack_size = args->java_stack;

    /* Initialise internal locks and pthread state */
    pthread_key_create(&threadKey, NULL);

    pthread_mutex_init(&lock, NULL);
    pthread_cond_init(&cv, NULL);

    pthread_mutex_init(&exit_lock, NULL);
    pthread_cond_init(&exit_cv, NULL);

    pthread_attr_init(&attributes);
    pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_DETACHED);

    /* Ensure the thread stacks are at least 1 megabyte in size */
    pthread_attr_getstacksize(&attributes, &size);
    if(size < 1*MB)
        pthread_attr_setstacksize(&attributes, 1*MB);

    monitorInit(&sleep_mon);
    initHashTable(thread_id_map, HASHTABSZE, TRUE);

    /* We need to cache field and method offsets to create and initialise
       threads.  However, the class loading component requires a valid
       thread and ExecEnv.  To get round this we initialise the main thread
       in two parts.  First part is sufficient to _load_ classes, but it
       is still not fully setup so we don't allow initialisers to run */

    main_thread.stack_base = args->main_stack_base;
    main_thread.tid = pthread_self();
    main_thread.id = genThreadID();
    main_thread.state = RUNNING;
    //main_thread.ee = &main_ee;

    //initialiseJavaStack(&main_ee);
    initialiseJavaStack(&main_thread);
    setThreadSelf(&main_thread);

    // create the nonspec group
    //RopeVM::instance()->new_group_for(0, threadSelf()->get_certain_core());

}
int secure_main(void)
{
	unsigned int csu_reg, i;
	for(csu_reg = 0x021C0000; csu_reg < 0x021C00A0; csu_reg = csu_reg + 4)
		__REG(csu_reg) = 0x00ff00ff; //0x00330033 for Peripheral access policy
		
	// for CORAM secure policy setting
	//csu_reg = 0x021C0000 + 0x**;
	//__REG(csu_reg) = 0x00330033;
	
	// for OCRAM secure status setting
	csu_reg = 0x020e0028;
	__REG(csu_reg) = 0x00003810;
	
	// set for non-secure can access some coprocessor reg
	CP15_SET_NSACR(0x00073fff);
	CP15_SET_CPACR(0x0fffffff);
	
	// set for SCR
	CP15_SET_SCR(0b110000);

	//(*((void(*)(void))0x0090b020))();
	// copy uboot from iram to sadram
	char* dest = (char*)0x27800000;
	char* src  = (char*)0x0090b000;
	for(i=0; i<160096; i++)
		*dest++ = *src++;
	
	// Install monitor
	monitorInit();
	
	while(1) {
		led_ctrl(LED_ON);
		asm volatile ("smc #0\n\t");
	}
	
	return 0;
}