コード例 #1
0
ファイル: kernel.c プロジェクト: fengzhimin/RPI-OS
void kernel_main()
{

	int i = 0;
	//init_sys_mmu();
	//start_mmu();  /* 开启MMU */
	unsigned int end = (unsigned int)(&__end+PGDR_MASK)&0xffffc000;
  unsigned int physfree =	init_paging(end-0xC0000000);
	init_ram(physfree);

	/* 重定位内核*/
	asm volatile(
		"add sp, sp, #0xC0000000\n\t"
	);

	/*清空恒等隐射*/
	for(i = 1; i < NR_KERN_PAGETABLE; i++)
		PTD[i] = 0;

	uart_init();
	char *_temp = "0000000000\r\n";
	unsigned int temp;
	HexToString((unsigned int)&temp, _temp);
	uart_puts(_temp);
	task_init();
	unsigned char rank = MAX_rank ;
	unsigned int task_func = (unsigned int)task_idle0;
	unsigned char TID = task_create( rank , task_func);
	task_run(TID);
	task_func = (unsigned int)task_idle1;
	TID = task_create( rank , task_func);
	task_run(TID);
	task_func = (unsigned int)task_idle2;
	TID = task_create( rank , task_func);
	task_run(TID);
  task_func = (unsigned int)task_idle3;
	TID = task_create( rank , task_func);
	task_run(TID);
	init_arm_timer(Kernel_1Hz);
	_enable_interrupts();

	while(1)
	{
		char *_ch = "0000000000\r\n";
		for(i = 0; i < 20; i++)
		{
			HexToString(PTD[i], _ch);
			uart_puts(_ch);
		}
		for(i = 0; i < 20; i++)
		{
			HexToString(PTD[i+0xC00], _ch);
			uart_puts(_ch);
		}
		sleep(500);
	}
}
コード例 #2
0
ファイル: android_arm.c プロジェクト: 3a9LL/panda
static void android_arm_init_(ram_addr_t ram_size,
    const char *boot_device,
    const char *kernel_filename,
    const char *kernel_cmdline,
    const char *initrd_filename,
    const char *cpu_model)
{
    CPUState *env;
    qemu_irq *cpu_pic;
    DeviceState *gf_int;
    int i;

    if (!cpu_model)
        cpu_model = "arm926";

    env = cpu_init(cpu_model);

    init_ram(ram_size);

    cpu_pic = arm_pic_init_cpu(env);
    GoldfishBus *gbus = goldfish_bus_init(0xff001000, 1);
    gf_int = goldfish_int_create(gbus, 0xff000000, cpu_pic[ARM_PIC_CPU_IRQ], cpu_pic[ARM_PIC_CPU_FIQ]);
    goldfish_device_init(gf_int, 0xff010000, 10);
    goldfish_timer_create(gbus, 0xff003000, 3);
    goldfish_rtc_create(gbus);
    goldfish_tty_create(gbus, serial_hds[0], 0, 0xff002000, 4);
    for(i = 1; i < MAX_SERIAL_PORTS; i++) {
        printf("android_arm_init serial %d %x\n", i, serial_hds[i]);
        if(serial_hds[i]) {
            printf("serial_hds: %d\n",i);
            goldfish_tty_create(gbus, serial_hds[i], i, 0, 0);
        }
    }

    for(i = 0; i < MAX_NICS; i++) {
        if (nd_table[i].vlan) {
            if (nd_table[i].model == NULL
                || strcmp(nd_table[i].model, "smc91c111") == 0) {
                GoldfishDevice *smc_device;
                smc_device = g_malloc0(sizeof(*smc_device));
                smc_device->name = (char *)"smc91x";
                smc_device->id = i;
                smc_device->size = 0x1000;
                smc_device->irq_count = 1;
                goldfish_add_device_no_io(smc_device);
                smc91c111_init(&nd_table[i], smc_device->base, qdev_get_gpio_in(gf_int, smc_device->irq));
            } else {
                fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
                exit (1);
            }
        }
    }

    goldfish_fb_create(gbus, 0);
#ifdef HAS_AUDIO
    //goldfish_audio_init(0xff004000, 0, audio_input_source);
#endif

    goldfish_mmc_create(gbus, 0xff005000, 0);
    goldfish_memlog_create(gbus, 0xff006000);
    goldfish_battery_create(gbus);
    goldfish_events_create(gbus, gf_int);
    goldfish_nand_create(gbus);
    goldfish_pipe_create(gbus);

#if TEST_SWITCH
    {
        void *sw;
        sw = goldfish_switch_create(gbus, "test", NULL, NULL, 0);
        goldfish_switch_set_state(sw, 1);
        goldfish_switch_create(gbus, "test2", switch_test_write, sw, 1);
    }
#endif

    info.ram_size        = ram_size;
    info.kernel_filename = kernel_filename;
    info.kernel_cmdline  = kernel_cmdline;
    info.initrd_filename = initrd_filename;
    info.nb_cpus         = 1;

    arm_load_kernel(env, &info);
    android_emulation_setup();
}
コード例 #3
0
ファイル: android_arm.c プロジェクト: 3a9LL/panda
void android_arm_resize_ram(ram_addr_t new_size){
    assert(current_machine->init == android_arm_init_);
    qemu_ram_free(ram_offset); // RAM starts at address 0
    init_ram(new_size);
}