void bootsync(int howto) { static int bootsyncdone = 0; if (bootsyncdone) return; bootsyncdone = 1; /* Make sure we can still manage to do things */ if (__get_cpsr() & I32_bit) { /* * If we get here then boot has been called without RB_NOSYNC * and interrupts were disabled. This means the boot() call * did not come from a user process e.g. shutdown, but must * have come from somewhere in the kernel. */ IRQenable; printf("Warning IRQ's disabled during boot()\n"); } vfs_shutdown(); /* * If we've been adjusting the clock, the todr * will be out of synch; adjust it now unless * the system has been sitting in ddb. */ if ((howto & RB_TIMEBAD) == 0) { resettodr(); } else { printf("WARNING: not updating battery clock\n"); } }
/*! \brief Turn on FIQ */ uint32_t vic_enableFIQ(void) { uint32_t _cpsr; _cpsr = __get_cpsr(); __set_cpsr(_cpsr & FIQ_MASK); return _cpsr; }
/*! \brief Turn OFF FIQ */ uint32_t vic_disableFIQ(void) { uint32_t _cpsr; _cpsr = __get_cpsr(); __set_cpsr(_cpsr | (1<<FIQ_BIT)); return _cpsr; }
unsigned enableFIQ(void) { unsigned _cpsr; _cpsr = __get_cpsr(); __set_cpsr(_cpsr & ~FIQ_MASK); return _cpsr; }
unsigned restoreFIQ(unsigned oldCPSR) { unsigned _cpsr; _cpsr = __get_cpsr(); __set_cpsr((_cpsr & ~FIQ_MASK) | (oldCPSR & FIQ_MASK)); return _cpsr; }
unsigned disableFIQ(void) { unsigned _cpsr; _cpsr = __get_cpsr(); __set_cpsr(_cpsr | FIQ_MASK); return _cpsr; }
PRIVATE s32 idle_task(u32 arg) { unlock_irq(); /* kick off the system, will switch to the main_task */ while(1) { #if 0 PRINT_INFO("in %s %d cpu_mode: %s; lr: 0x%x; sp: 0x%x; cpsr: 0x%x\n", __func__, __LINE__, get_cpu_mode(NULL), __get_lr(), __get_sp(), __get_cpsr()); #endif /* mdelay(100000); */ #if 0 PRINT_INFO("in %s %d cpu_mode: %s; lr: 0x%x; sp: 0x%x; cpsr: 0x%x\n", __func__, __LINE__, get_cpu_mode(NULL), __get_lr(), __get_sp(), __get_cpsr()); #endif } return 0; }
s32 os_main(u32 sp) { struct __os_task__ *ptask; int_init(); uart_init(); dram_init(); timer_init(); mmc_init(); PRINT_INFO("%s\n", sys_banner); coretimer_init(); task_init(); semaphore_init(); PRINT_INFO("cpu_mode: %s; lr: 0x%x; sp: 0x%x; cpsr: 0x%x\n", get_cpu_mode(NULL), __get_lr(), sp, __get_cpsr()); gpio_set_function(GPIO_16, OUTPUT); gpio_set_output(GPIO_16, 0); /* set_log_level(LOG_DEBUG); */ /* create idle task */ if ((ptask = tcb_alloc()) == NULL) { panic(); } tcb_init(ptask, idle_task, 0, 256); /*os_ready_insert(ptask);*/ current_task = &tcb[IDLE_TASK_ID]; /* assume that this is idle_task */ /* create main task */ if ((ptask = tcb_alloc()) == NULL) { panic(); } tcb_init(ptask, main_task, 0, 100); os_ready_insert(ptask); /* 'slip into idle task', cause the os_main() is not a task (it's the god code of system) */ __set_sp(&(task_stack[0][TASK_STK_SIZE])); current_task->state = TASK_RUNNING; idle_task(0); kassert(0); return 0; }