示例#1
0
文件: kernel.c 项目: wuxx/sos
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;
}
示例#2
0
文件: test.c 项目: onkwon/yaos
static void test_task()
{
	unsigned long long t;
	unsigned int th, bh;
	unsigned int v;

	int fd;
	char *buf = "abcdefABCDEFabcdefABCDEFabcdefABCDEFabcdefABCDEFabcdef"
		"ABCDEFabcdabcdefABCDEFabcdefABCDEFabcdefABCDEFabcdefABCDEF"
		"abcdefABCDEFabcd";

	sleep(3);
	printk("\nstart write test %x %x\n", current, current->addr);
	//if ((fd = open("/test_write", O_CREATE | O_RDWR)) <= 0) {
	if ((fd = open("/test_write", O_RDWR)) == -ERR_PATH) {
		if ((fd = open("/test_write", O_CREATE | O_RDWR)) < 0) {
			printk("FAILED to create\n");
			goto out;
		}

		int i;
		//for (i = 0; i < 5000; i++) {
		for (i = 0; i < 50; i++) {
			if (write(fd, buf, 128) <= 0)
				break;
			printf("%d written\n", (i+1) * 128);
		}
	}

	close(fd);
out:

	if ((fd = open("/dev_overlap", O_CREATE)) > 0)
		close(fd);
	printf("\nend write test\n");

	printf("test()\n");
	printf("sp : %x, lr : %x\n", __get_sp(), __get_lr());

	while (1) {
		t = get_systick64();
		th = t >> 32;
		bh = t;

		dmb();
		v = systick;

		printf("%08x ", v);
		printf("%08x", th);
		printf("%08x %d (%d sec)\n", bh, v, v/HZ);

		sleep(1);
	}
}
示例#3
0
文件: kernel.c 项目: wuxx/sos
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;
}
示例#4
0
文件: fault.c 项目: onkwon/yaos
void __attribute__((naked)) isr_fault()
{
	/* disable interrupts */
	/* save registers */

	unsigned int sp, lr, psr, usp;

	sp  = __get_sp();
	psr = __get_psr();
	lr  = __get_lr();
	usp = __get_usp();

	debug(MSG_ERROR, "\nFault type: %x <%08x>\n"
		"  (%x=Usage fault, %x=Bus fault, %x=Memory management fault)",
		SCB_SHCSR & 0xfff, SCB_SHCSR, USAGE_FAULT, BUS_FAULT, MM_FAULT);

	debug(MSG_ERROR, "Fault source: ");
	busfault();
	usagefault();

	printk("\nKernel Space\n");
	print_kernel_status((unsigned int *)sp, lr, psr);

	printk("\nUser Space\n");
	print_user_status((unsigned int *)usp);

	printk("\nTask Status\n");
	print_task_status(current);

	printk("\nCurrent Context\n");
	print_context((unsigned int *)usp);

	printk("\nSCB_ICSR  0x%08x\n"
		"SCB_CFSR  0x%08x\n"
		"SCB_HFSR  0x%08x\n"
		"SCB_MMFAR 0x%08x\n"
		"SCB_BFAR  0x%08x\n",
		SCB_ICSR, SCB_CFSR, SCB_HFSR, SCB_MMFAR, SCB_BFAR);

	/* led for debugging */
#ifdef LED_DEBUG
	SET_PORT_CLOCK(ENABLE, PORTD);
	SET_PORT_PIN(PORTD, 2, PIN_OUTPUT_50MHZ);
	unsigned int j;
	while (1) {
		PUT_PORT(PORTD, GET_PORT(PORTD) ^ 4);

		for (i = 100; i; i--) {
			for (j = 10; j; j--) {
				__asm__ __volatile__(
						"nop		\n\t"
						"nop		\n\t"
						"nop		\n\t"
						"nop		\n\t"
						"nop		\n\t"
						"nop		\n\t"
						"nop		\n\t"
						"nop		\n\t"
						"nop		\n\t"
						"nop		\n\t"
						::: "memory");
			}
		}
	}
#endif

	while (1);

	/* restore registers */
	/* enable interrupts */
}