nseries.c

来自「xen虚拟机源代码安装包」· C语言 代码 · 共 1,146 行 · 第 1/3 页

C
1,146
字号
    omap_writel(0x480081d4, 0x1d4);		/* PM_EVGENCTRL_MPU */    omap_writel(0x480081d8, 0);			/* PM_EVEGENONTIM_MPU */    omap_writel(0x480081dc, 0);			/* PM_EVEGENOFFTIM_MPU */    omap_writel(0x480081e0, 0xc);		/* PM_PWSTCTRL_MPU */    omap_writel(0x48008200, 0x047e7ff7);	/* CM_FCLKEN1_CORE */    omap_writel(0x48008204, 0x00000004);	/* CM_FCLKEN2_CORE */    omap_writel(0x48008210, 0x047e7ff1);	/* CM_ICLKEN1_CORE */    omap_writel(0x48008214, 0x00000004);	/* CM_ICLKEN2_CORE */    omap_writel(0x4800821c, 0x00000000);	/* CM_ICLKEN4_CORE */    omap_writel(0x48008230, 0);			/* CM_AUTOIDLE1_CORE */    omap_writel(0x48008234, 0);			/* CM_AUTOIDLE2_CORE */    omap_writel(0x48008238, 7);			/* CM_AUTOIDLE3_CORE */    omap_writel(0x4800823c, 0);			/* CM_AUTOIDLE4_CORE */    omap_writel(0x48008240, 0x04360626);	/* CM_CLKSEL1_CORE */    omap_writel(0x48008244, 0x00000014);	/* CM_CLKSEL2_CORE */    omap_writel(0x48008248, 0);			/* CM_CLKSTCTRL_CORE */    omap_writel(0x48008300, 0x00000000);	/* CM_FCLKEN_GFX */    omap_writel(0x48008310, 0x00000000);	/* CM_ICLKEN_GFX */    omap_writel(0x48008340, 0x00000001);	/* CM_CLKSEL_GFX */    omap_writel(0x48008400, 0x00000004);	/* CM_FCLKEN_WKUP */    omap_writel(0x48008410, 0x00000004);	/* CM_ICLKEN_WKUP */    omap_writel(0x48008440, 0x00000000);	/* CM_CLKSEL_WKUP */    omap_writel(0x48008500, 0x000000cf);	/* CM_CLKEN_PLL */    omap_writel(0x48008530, 0x0000000c);	/* CM_AUTOIDLE_PLL */    omap_writel(0x48008540,			/* CM_CLKSEL1_PLL */                    (0x78 << 12) | (6 << 8));    omap_writel(0x48008544, 2);			/* CM_CLKSEL2_PLL */    /* GPMC setup */    n800_gpmc_init(s);    /* Video setup */    n800_dss_init(&s->blizzard);    /* CPU setup */    s->cpu->env->regs[15] = s->cpu->env->boot_info->loader_start;    s->cpu->env->GE = 0x5;}#define OMAP_TAG_NOKIA_BT	0x4e01#define OMAP_TAG_WLAN_CX3110X	0x4e02#define OMAP_TAG_CBUS		0x4e03#define OMAP_TAG_EM_ASIC_BB5	0x4e04static struct omap_gpiosw_info_s {    const char *name;    int line;    int type;} n800_gpiosw_info[] = {    {        "bat_cover", N800_BAT_COVER_GPIO,        OMAP_GPIOSW_TYPE_COVER | OMAP_GPIOSW_INVERTED,    }, {        "cam_act", N800_CAM_ACT_GPIO,        OMAP_GPIOSW_TYPE_ACTIVITY,    }, {        "cam_turn", N800_CAM_TURN_GPIO,        OMAP_GPIOSW_TYPE_ACTIVITY | OMAP_GPIOSW_INVERTED,    }, {        "headphone", N8X0_HEADPHONE_GPIO,        OMAP_GPIOSW_TYPE_CONNECTION | OMAP_GPIOSW_INVERTED,    },    { 0 }}, n810_gpiosw_info[] = {    {        "gps_reset", N810_GPS_RESET_GPIO,        OMAP_GPIOSW_TYPE_ACTIVITY | OMAP_GPIOSW_OUTPUT,    }, {        "gps_wakeup", N810_GPS_WAKEUP_GPIO,        OMAP_GPIOSW_TYPE_ACTIVITY | OMAP_GPIOSW_OUTPUT,    }, {        "headphone", N8X0_HEADPHONE_GPIO,        OMAP_GPIOSW_TYPE_CONNECTION | OMAP_GPIOSW_INVERTED,    }, {        "kb_lock", N810_KB_LOCK_GPIO,        OMAP_GPIOSW_TYPE_COVER | OMAP_GPIOSW_INVERTED,    }, {        "sleepx_led", N810_SLEEPX_LED_GPIO,        OMAP_GPIOSW_TYPE_ACTIVITY | OMAP_GPIOSW_INVERTED | OMAP_GPIOSW_OUTPUT,    }, {        "slide", N810_SLIDE_GPIO,        OMAP_GPIOSW_TYPE_COVER | OMAP_GPIOSW_INVERTED,    },    { 0 }};static struct omap_partition_info_s {    uint32_t offset;    uint32_t size;    int mask;    const char *name;} n800_part_info[] = {    { 0x00000000, 0x00020000, 0x3, "bootloader" },    { 0x00020000, 0x00060000, 0x0, "config" },    { 0x00080000, 0x00200000, 0x0, "kernel" },    { 0x00280000, 0x00200000, 0x3, "initfs" },    { 0x00480000, 0x0fb80000, 0x3, "rootfs" },    { 0, 0, 0, 0 }}, n810_part_info[] = {    { 0x00000000, 0x00020000, 0x3, "bootloader" },    { 0x00020000, 0x00060000, 0x0, "config" },    { 0x00080000, 0x00220000, 0x0, "kernel" },    { 0x002a0000, 0x00400000, 0x0, "initfs" },    { 0x006a0000, 0x0f960000, 0x0, "rootfs" },    { 0, 0, 0, 0 }};static int n8x0_atag_setup(void *p, int model){    uint8_t *b;    uint16_t *w;    uint32_t *l;    struct omap_gpiosw_info_s *gpiosw;    struct omap_partition_info_s *partition;    const char *tag;    w = p;    stw_raw(w ++, OMAP_TAG_UART);		/* u16 tag */    stw_raw(w ++, 4);				/* u16 len */    stw_raw(w ++, (1 << 2) | (1 << 1) | (1 << 0)); /* uint enabled_uarts */    w ++;#if 0    stw_raw(w ++, OMAP_TAG_SERIAL_CONSOLE);	/* u16 tag */    stw_raw(w ++, 4);				/* u16 len */    stw_raw(w ++, XLDR_LL_UART);		/* u8 console_uart */    stw_raw(w ++, 115200);			/* u32 console_speed */#endif    stw_raw(w ++, OMAP_TAG_LCD);		/* u16 tag */    stw_raw(w ++, 36);				/* u16 len */    strcpy((void *) w, "QEMU LCD panel");	/* char panel_name[16] */    w += 8;    strcpy((void *) w, "blizzard");		/* char ctrl_name[16] */    w += 8;    stw_raw(w ++, N810_BLIZZARD_RESET_GPIO);	/* TODO: n800 s16 nreset_gpio */    stw_raw(w ++, 24);				/* u8 data_lines */    stw_raw(w ++, OMAP_TAG_CBUS);		/* u16 tag */    stw_raw(w ++, 8);				/* u16 len */    stw_raw(w ++, N8X0_CBUS_CLK_GPIO);		/* s16 clk_gpio */    stw_raw(w ++, N8X0_CBUS_DAT_GPIO);		/* s16 dat_gpio */    stw_raw(w ++, N8X0_CBUS_SEL_GPIO);		/* s16 sel_gpio */    w ++;    stw_raw(w ++, OMAP_TAG_EM_ASIC_BB5);	/* u16 tag */    stw_raw(w ++, 4);				/* u16 len */    stw_raw(w ++, N8X0_RETU_GPIO);		/* s16 retu_irq_gpio */    stw_raw(w ++, N8X0_TAHVO_GPIO);		/* s16 tahvo_irq_gpio */    gpiosw = (model == 810) ? n810_gpiosw_info : n800_gpiosw_info;    for (; gpiosw->name; gpiosw ++) {        stw_raw(w ++, OMAP_TAG_GPIO_SWITCH);	/* u16 tag */        stw_raw(w ++, 20);			/* u16 len */        strcpy((void *) w, gpiosw->name);	/* char name[12] */        w += 6;        stw_raw(w ++, gpiosw->line);		/* u16 gpio */        stw_raw(w ++, gpiosw->type);        stw_raw(w ++, 0);        stw_raw(w ++, 0);    }    stw_raw(w ++, OMAP_TAG_NOKIA_BT);		/* u16 tag */    stw_raw(w ++, 12);				/* u16 len */    b = (void *) w;    stb_raw(b ++, 0x01);			/* u8 chip_type	(CSR) */    stb_raw(b ++, N8X0_BT_WKUP_GPIO);		/* u8 bt_wakeup_gpio */    stb_raw(b ++, N8X0_BT_HOST_WKUP_GPIO);	/* u8 host_wakeup_gpio */    stb_raw(b ++, N8X0_BT_RESET_GPIO);		/* u8 reset_gpio */    stb_raw(b ++, 1);				/* u8 bt_uart */    memset(b, 0, 6);				/* u8 bd_addr[6] */    b += 6;    stb_raw(b ++, 0x02);			/* u8 bt_sysclk (38.4) */    w = (void *) b;    stw_raw(w ++, OMAP_TAG_WLAN_CX3110X);	/* u16 tag */    stw_raw(w ++, 8);				/* u16 len */    stw_raw(w ++, 0x25);			/* u8 chip_type */    stw_raw(w ++, N8X0_WLAN_PWR_GPIO);		/* s16 power_gpio */    stw_raw(w ++, N8X0_WLAN_IRQ_GPIO);		/* s16 irq_gpio */    stw_raw(w ++, -1);				/* s16 spi_cs_gpio */    stw_raw(w ++, OMAP_TAG_MMC);		/* u16 tag */    stw_raw(w ++, 16);				/* u16 len */    if (model == 810) {        stw_raw(w ++, 0x23f);			/* unsigned flags */        stw_raw(w ++, -1);			/* s16 power_pin */        stw_raw(w ++, -1);			/* s16 switch_pin */        stw_raw(w ++, -1);			/* s16 wp_pin */        stw_raw(w ++, 0x240);			/* unsigned flags */        stw_raw(w ++, 0xc000);			/* s16 power_pin */        stw_raw(w ++, 0x0248);			/* s16 switch_pin */        stw_raw(w ++, 0xc000);			/* s16 wp_pin */    } else {        stw_raw(w ++, 0xf);			/* unsigned flags */        stw_raw(w ++, -1);			/* s16 power_pin */        stw_raw(w ++, -1);			/* s16 switch_pin */        stw_raw(w ++, -1);			/* s16 wp_pin */        stw_raw(w ++, 0);			/* unsigned flags */        stw_raw(w ++, 0);			/* s16 power_pin */        stw_raw(w ++, 0);			/* s16 switch_pin */        stw_raw(w ++, 0);			/* s16 wp_pin */    }    stw_raw(w ++, OMAP_TAG_TEA5761);		/* u16 tag */    stw_raw(w ++, 4);				/* u16 len */    stw_raw(w ++, N8X0_TEA5761_CS_GPIO);	/* u16 enable_gpio */    w ++;    partition = (model == 810) ? n810_part_info : n800_part_info;    for (; partition->name; partition ++) {        stw_raw(w ++, OMAP_TAG_PARTITION);	/* u16 tag */        stw_raw(w ++, 28);			/* u16 len */        strcpy((void *) w, partition->name);	/* char name[16] */        l = (void *) (w + 8);        stl_raw(l ++, partition->size);		/* unsigned int size */        stl_raw(l ++, partition->offset);	/* unsigned int offset */        stl_raw(l ++, partition->mask);		/* unsigned int mask_flags */        w = (void *) l;    }    stw_raw(w ++, OMAP_TAG_BOOT_REASON);	/* u16 tag */    stw_raw(w ++, 12);				/* u16 len */#if 0    strcpy((void *) w, "por");			/* char reason_str[12] */    strcpy((void *) w, "charger");		/* char reason_str[12] */    strcpy((void *) w, "32wd_to");		/* char reason_str[12] */    strcpy((void *) w, "sw_rst");		/* char reason_str[12] */    strcpy((void *) w, "mbus");			/* char reason_str[12] */    strcpy((void *) w, "unknown");		/* char reason_str[12] */    strcpy((void *) w, "swdg_to");		/* char reason_str[12] */    strcpy((void *) w, "sec_vio");		/* char reason_str[12] */    strcpy((void *) w, "pwr_key");		/* char reason_str[12] */    strcpy((void *) w, "rtc_alarm");		/* char reason_str[12] */#else    strcpy((void *) w, "pwr_key");		/* char reason_str[12] */#endif    w += 6;    tag = (model == 810) ? "RX-44" : "RX-34";    stw_raw(w ++, OMAP_TAG_VERSION_STR);	/* u16 tag */    stw_raw(w ++, 24);				/* u16 len */    strcpy((void *) w, "product");		/* char component[12] */    w += 6;    strcpy((void *) w, tag);			/* char version[12] */    w += 6;    stw_raw(w ++, OMAP_TAG_VERSION_STR);	/* u16 tag */    stw_raw(w ++, 24);				/* u16 len */    strcpy((void *) w, "hw-build");		/* char component[12] */    w += 6;    strcpy((void *) w, "QEMU " QEMU_VERSION);	/* char version[12] */    w += 6;    tag = (model == 810) ? "1.1.10-qemu" : "1.1.6-qemu";    stw_raw(w ++, OMAP_TAG_VERSION_STR);	/* u16 tag */    stw_raw(w ++, 24);				/* u16 len */    strcpy((void *) w, "nolo");			/* char component[12] */    w += 6;    strcpy((void *) w, tag);			/* char version[12] */    w += 6;    return (void *) w - p;}static int n800_atag_setup(struct arm_boot_info *info, void *p){    return n8x0_atag_setup(p, 800);}static int n810_atag_setup(struct arm_boot_info *info, void *p){    return n8x0_atag_setup(p, 810);}static void n8x0_init(ram_addr_t ram_size, const char *boot_device,                DisplayState *ds, const char *kernel_filename,                const char *kernel_cmdline, const char *initrd_filename,                const char *cpu_model, struct arm_boot_info *binfo, int model){    struct n800_s *s = (struct n800_s *) qemu_mallocz(sizeof(*s));    int sdram_size = binfo->ram_size;    int onenandram_size = 0x00010000;    if (ram_size < sdram_size + onenandram_size + OMAP242X_SRAM_SIZE) {        fprintf(stderr, "This architecture uses %i bytes of memory\n",                        sdram_size + onenandram_size + OMAP242X_SRAM_SIZE);        exit(1);    }    s->cpu = omap2420_mpu_init(sdram_size, NULL, cpu_model);    n8x0_gpio_setup(s);    n8x0_nand_setup(s);    n8x0_i2c_setup(s);    if (model == 800)        n800_tsc_kbd_setup(s);    else if (model == 810) {        n810_tsc_setup(s);        n810_kbd_setup(s);    }    n8x0_spi_setup(s);    n8x0_dss_setup(s, ds);    n8x0_cbus_setup(s);    if (usb_enabled)        n8x0_usb_setup(s);    /* Setup initial (reset) machine state */    /* Start at the OneNAND bootloader.  */    s->cpu->env->regs[15] = 0;    if (kernel_filename) {        /* Or at the linux loader.  */        binfo->kernel_filename = kernel_filename;        binfo->kernel_cmdline = kernel_cmdline;        binfo->initrd_filename = initrd_filename;        arm_load_kernel(s->cpu->env, binfo);        qemu_register_reset(n8x0_boot_init, s);        n8x0_boot_init(s);    }    dpy_resize(ds, 800, 480);}static struct arm_boot_info n800_binfo = {    .loader_start = OMAP2_Q2_BASE,    /* Actually two chips of 0x4000000 bytes each */    .ram_size = 0x08000000,    .board_id = 0x4f7,    .atag_board = n800_atag_setup,};static struct arm_boot_info n810_binfo = {    .loader_start = OMAP2_Q2_BASE,    /* Actually two chips of 0x4000000 bytes each */    .ram_size = 0x08000000,    /* 0x60c and 0x6bf (WiMAX Edition) have been assigned but are not     * used by some older versions of the bootloader and 5555 is used     * instead (including versions that shipped with many devices).  */    .board_id = 0x60c,    .atag_board = n810_atag_setup,};static void n800_init(ram_addr_t ram_size, int vga_ram_size,                const char *boot_device, DisplayState *ds,                const char *kernel_filename, const char *kernel_cmdline,                const char *initrd_filename, const char *cpu_model){    return n8x0_init(ram_size, boot_device, ds,                    kernel_filename, kernel_cmdline, initrd_filename,                    cpu_model, &n800_binfo, 800);}static void n810_init(ram_addr_t ram_size, int vga_ram_size,                const char *boot_device, DisplayState *ds,                const char *kernel_filename, const char *kernel_cmdline,                const char *initrd_filename, const char *cpu_model){    return n8x0_init(ram_size, boot_device, ds,                    kernel_filename, kernel_cmdline, initrd_filename,                    cpu_model, &n810_binfo, 810);}QEMUMachine n800_machine = {    "n800",    "Nokia N800 tablet aka. RX-34 (OMAP2420)",    n800_init,    (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED,};QEMUMachine n810_machine = {    "n810",    "Nokia N810 tablet aka. RX-44 (OMAP2420)",    n810_init,    (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED,};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?