コード例 #1
0
ファイル: init.c プロジェクト: rocsan/g-bios
static void __INIT__ auto_boot(void)
{
    int time_out = 3;
    char *argv[] = {"boot"};

    while (1) {
        int index;

        printf("\rAutoboot after %d seconds. "
               "Press any key to interrupt.", time_out);

        if (0 == time_out)
            break;

        for (index = 0; index < 10; index++) {
            mdelay(1000);

            if (uart_rxbuf_count()) {
                puts("\n");
                return;
            }
        }

        time_out--;
    }

    puts("\n");

    exec(ARRAY_ELEM_NUM(argv), argv);
}
コード例 #2
0
ファイル: ext4.c プロジェクト: JansZeng/g-bios
static int ext4_inode_read_block(struct inode *in, int blk_no, char *blk_buf)
{
	struct ext4_inode_info *e4_info = EXT4_I(in);
	int blk_index[in->i_size / in->i_sb->s_blocksize];

	get_block_indexs(in->i_sb, e4_info->i_e4in, 0, (__le32 *)blk_index, ARRAY_ELEM_NUM(blk_index));

	__ext4_read_block(in->i_sb, blk_buf, blk_index[blk_no]);

	return 0;
}
コード例 #3
0
ファイル: board-evm3530.c プロジェクト: longli/s5pv210_test
static int __INIT__ evm3530_init(struct board_desc *board, const struct board_id *id)
{
	int i, ret;

	for (i = 0; i < ARRAY_ELEM_NUM(evm3530_devices); i++) {
		ret = platform_device_register(evm3530_devices[i]);
		if (ret < 0)
			return ret;
	}

	return 0;
}
コード例 #4
0
ファイル: board-devkit8000.c プロジェクト: JansZeng/g-bios
static int __init devkit8000_init(struct board_desc *board)
{
	int i, ret;

	for (i = 0; i < ARRAY_ELEM_NUM(devkit8000_devices); i++) {
		ret = platform_device_register(devkit8000_devices[i]);
		if (ret < 0)
			return ret;
	}

	return 0;
}
コード例 #5
0
ファイル: shell.c プロジェクト: extraice/g-bios
// fixme: move to task.c
int exec(int argc, char *argv[])
{
	int ret;
	const struct command *exe;
	struct task *current;
	int (*main)(int, char *[]);

	// fixme
	for (exe = build_in_cmd; exe < build_in_cmd + ARRAY_ELEM_NUM(build_in_cmd); exe++) {
		if (!strncmp(exe->name, argv[0], MAX_ARG_LEN)) {
			goto L1;
		}
	}

	for (exe = g_exe_begin; exe < g_exe_end; exe++) {
		if (!strncmp(exe->name, argv[0], MAX_ARG_LEN)) {
			goto L1;
		}
	}

	printf("  command \"%s\" not found!\n"
		   "  Please use \"help\" to get g-bios command list.\n", argv[0]);
	return -ENOEXEC;

L1:
	main = exe->main;
	if (!main)
		return -EINVAL;

	current = malloc(sizeof(*current));
	if (!current)
		return -ENOMEM;

	current->argc = argc;
	current->argv = argv;
	current->exe  = exe;
	current->help = get_help(argv[0]); // fixme
	set_current_task(current);

	getopt_init();
	ret = main(argc, argv);

	set_current_task(NULL);
	free(current);

	return ret;
}
コード例 #6
0
ファイル: jedec.c プロジェクト: JansZeng/g-bios
static int __init nor_flash_probe(void)
{
	int i;
	__u8 jedec_id[64];
	struct spi_slave *nor_flash;

	nor_flash = get_spi_slave("w25x_nor_flash");
	read_jedec_id(nor_flash, jedec_id);

	for (i = 0; i < ARRAY_ELEM_NUM(nor_ids); i++) {
		if (jedec_id[0] == nor_ids[i].vendor_id) {
			printf("SPI Nor flash detected! flash details:\n"
				"\tmanufacturer ID = 0x%02x\n"
				"\tdevice ID       = 0x%02x, 0x%02x\n",
				jedec_id[0], jedec_id[1], jedec_id[2]);

			return 0;
		}
	}

	printf("SPI Nor Flash not detected!\n");

	return -ENODEV;
}
コード例 #7
0
ファイル: shell.c プロジェクト: extraice/g-bios
static int cmd_match(char *buf, int *cur_pos, int *cur_max)
{
	int	i = 0, j = 0, k;
	char ch;
	__u32 nLen;
	bool bFlag;
	int pre_space_count = 0;
	char (*psz_result)[MAX_ARG_LEN];
	const struct command *exe;

	nLen = g_exe_end - g_exe_begin;
	psz_result = malloc(MAX_ARG_LEN * nLen);
	if (NULL == psz_result) {
		DPRINT("ERROR: fail to malloc, %s,%d", __func__, __LINE__);
		return -ENOMEM;
	}

	pre_space_count = get_pre_space_count(buf);

	for (exe = build_in_cmd; exe < build_in_cmd + ARRAY_ELEM_NUM(build_in_cmd); exe++) {
		if (!*cur_pos || strncmp(exe->name, buf + pre_space_count, *cur_pos - pre_space_count) == 0)
			strcpy(psz_result[j++], exe->name);
	}

	for (exe = g_exe_begin; exe < g_exe_end; exe++) {
		if (!*cur_pos || strncmp(exe->name, buf + pre_space_count, *cur_pos - pre_space_count) == 0)
			strcpy(psz_result[j++], exe->name);
	}

	switch (j) {
	case 0:
		break;

	case 1:
		i = strlen(psz_result[0]) + pre_space_count;

		for (; *cur_pos < i; )
			insert_one_key(psz_result[0][*cur_pos - pre_space_count], buf, cur_pos, cur_max);
		if (*cur_pos == *cur_max)
			insert_one_key(' ', buf, cur_pos, cur_max);

		break;

	default:
		for (i = *cur_pos; (ch = psz_result[0][i - pre_space_count]); *cur_pos = ++i) {
			bFlag = false;
			for (k = 1; k < j; k++) {
				if (ch != psz_result[k][i - pre_space_count])
					bFlag = true;
			}

			if (bFlag) break;
			insert_one_key(ch, buf, cur_pos, cur_max);
		}

		putchar('\n');
		for (i = 1; i < j + 1; i++) {
			printf("%-20s", psz_result[i - 1]);
			if (0 == (i & 0x3))
				putchar('\n');
		}
		if (0 != (j & 0x3))
			putchar('\n');

		show_prompt();
		show_input_buff(buf, *cur_pos, *cur_max);

		break;
	}

	free(psz_result);

	return 0;
}
コード例 #8
0
ファイル: s3c6410_plat.c プロジェクト: RocsanWei/g-bios
static int __INIT__ mw61_init(void)
{
	__u32 val;
	struct spi_slave  *spi_slave;
	struct spi_master *spi_master;

	val = readl(VA(SROM_BASE + SROM_BW));
	val &= ~0xF0;
	val |= 0xD0;
	writel(VA(SROM_BASE + SROM_BW), val);

	val = readl(VA(0x7f0080a0));
	val &= ~(3 << 28);
	val |= 2 << 28;
	writel(VA(0x7f0080a0), val);

	val = readl(VA(0x7f008080));
	val &= ~0xFF;
	val |= 0x11;
	writel(VA(0x7f008080), val);

	val = readl(VA(0x7f008084));
	val |= 0x3;
	writel(VA(0x7f008084), val);

#ifdef CONFIG_IRQ_SUPPORT
	s3c6410_interrupt_init();

#ifdef CONFIG_TIMER_SUPPORT
	s3c6410_timer_init();
#endif
#endif
	// MMC0 GPIO setting
	writel(VA(GPG_BASE + GPCON), 0x2222222);

	//gpio setting, EINT0,1 and EINT7
	val = readl(VA(GPN_CON));
	val &= ~0xffff;
	val |= 2 << 14 | 0xa;
	writel(VA(GPN_CON), val);

	//gpio trigger setting, EINT0,1 and EINT7
	val = readl(VA(EINT0_CON));
	val &= ~0x7;
	val |= 3;
	//set dm9000's interrupt,high level active
	val &= ~(0x7 << 12);
	val |= 0x001 << 12;
	writel(VA(EINT0_CON), val);

	//clean external interrupt
	val = readl(VA(EINT0PEND));
	writel(VA(EINT0PEND), val);

#ifdef CONFIG_SPI
	// master 0
	val = readl(VA(GPC_BASE + GPCCON));
	val &= ~0xFFFF;
	val |= 0x2222;
	writel(VA(GPC_BASE + GPCCON), val);

	set_master_tab(mw61_spi_master, ARRAY_ELEM_NUM(mw61_spi_master));

	set_slave_tab(mw61_spi_slave, ARRAY_ELEM_NUM(mw61_spi_slave));

	spi_slave  = get_spi_slave("w25x_nor_flash");
	spi_master = get_spi_master("s3c6410_spi0");
	list_head_init(&spi_master->slave_list);
	spi_slave_attach(spi_master, spi_slave);
#endif

	return 0;
}
コード例 #9
0
ファイル: board-devkit8000.c プロジェクト: JansZeng/g-bios
		.start = 0x2c000400,
		.size = 4,
		.flag = IORESOURCE_MEM,
	},
#if 0
	[2] = {
		.start = ,
		.size = 1,
	},
#endif
};

static struct platform_device dm9000_device = {
	.dev = {
		.resources = dm9000_res,
		.res_num = ARRAY_ELEM_NUM(dm9000_res),
	},
	.name = "dm9000",
	.init = dm9000_device_init,
};
#endif

// fixme: __INITDATA__
static struct platform_device *devkit8000_devices[] = {
#ifdef CONFIG_DM9000
	&dm9000_device,
#endif
};

static int __init devkit8000_init(struct board_desc *board)
{
コード例 #10
0
ファイル: board-beagle.c プロジェクト: joy-chen/g-bios
	[0] = {
		.start = 0x28000000,
		.size = 4,
		.flag = IORESOURCE_MEM,
	},
	[1] = {
		.start = GPIO_IRQ(19),
		.size = 1,
		.flag = IORESOURCE_IRQ,
	},
};

static struct platform_device smsc91x_device = {
	.dev = {
		.resources = smsc91x_res,
		.res_num = ARRAY_ELEM_NUM(smsc91x_res),
	},
	.name = "SMSC SMSC91X",
	.init = smsc91x_device_init,
};
#endif

// fixme: __INITDATA__
static struct platform_device *beagle_devices[] = {
#ifdef CONFIG_SMSC91X
	&smsc91x_device,
#endif
};

static int __init beagle_init(struct board_desc *board)
{