示例#1
0
static struct tag *setup_clock_tags(struct tag *params)
{
	params->hdr.tag = ATAG_CLOCK;
	params->hdr.size = tag_size(tag_clock);
	params->u.clock.clock_id = ACLOCK_BOOTCPU;
	params->u.clock.clock_flags = 0;
	params->u.clock.clock_hz = gd->cpu_hz;

#ifdef CONFIG_AT32AP7000
	/*
	 * New kernels don't need this, but we should be backwards
	 * compatible for a while...
	 */
	params = tag_next(params);

	params->hdr.tag = ATAG_CLOCK;
	params->hdr.size = tag_size(tag_clock);
	params->u.clock.clock_id = ACLOCK_HSB;
	params->u.clock.clock_flags = 0;
	params->u.clock.clock_hz = get_hsb_clk_rate();
#endif

	return tag_next(params);
}
示例#2
0
static struct tag *setup_ramdisk_tag(struct tag *params,
				     unsigned long rd_start,
				     unsigned long rd_end)
{
	if (rd_start == rd_end)
		return params;

	params->hdr.tag = ATAG_RDIMG;
	params->hdr.size = tag_size(tag_mem_range);

	params->u.mem_range.addr = rd_start;
	params->u.mem_range.size = rd_end - rd_start;

	return tag_next(params);
}
示例#3
0
文件: atag.c 项目: XVilka/2ndboot-ng
void *atag_build() {
  struct memory_image image;
  struct tag *tag = (struct tag*)ATAG_BASE_ADDR;
	
  tag->hdr.tag = ATAG_CORE;
  tag->hdr.size = tag_size (tag_core);
  tag->u.core.flags = 0;
  tag->u.core.pagesize = 0x00001000;
  tag->u.core.rootdev = 0x0000;
  tag = tag_next(tag);

  if (image_find(IMG_CMDLINE, &image) != NULL) {
    char *atag_cmdline = tag->u.cmdline.cmdline;

    tag->hdr.tag = ATAG_CMDLINE;
    tag->hdr.size = (sizeof(struct tag_header) + image.size + 1 + 3) >> 2;
    memcpy(atag_cmdline, image.data, image.size);
    if (atag_cmdline[image.size-1] == '\xa') {
      atag_cmdline[image.size-1] = '\0';
    } else {
      atag_cmdline[image.size] = '\0';
    }
    tag = tag_next(tag);
  }
示例#4
0
static void
setup_cmdline_tag(const char * line)
{
    int linelen = strlen(line);

    if(!linelen)
        return;                             /* do not insert a tag for an empty commandline */

    params->hdr.tag = ATAG_CMDLINE;         /* Commandline tag */
    params->hdr.size = (sizeof(struct atag_header) + linelen + 1 + 4) >> 2;

    strcpy(params->u.cmdline.cmdline,line); /* place commandline into tag */

    params = tag_next(params);              /* move pointer to next tag */
}
示例#5
0
/* 16-byte serial number tag (alphanumeric string) */
void setup_serial16_tag(struct tag **in_params)
{
	const u8 *sn = 0;

	sn = idme_get_board_serial();
	if (!sn){
                printf("Erro, failed to get_board_serial\n");
		return; /* ignore if NULL was returned. */
        }

        printf("board serial: %s\n", sn);
	params->hdr.tag = ATAG_SERIAL16;
	params->hdr.size = tag_size (tag_id16);
	memcpy(params->u.id16.data, sn, sizeof params->u.id16.data);
	params = tag_next (params);
}
示例#6
0
void setup_serial_tag (struct tag **tmp)
{
	struct tag *params = *tmp;
	struct tag_serialnr serialnr;
	void get_board_serial(struct tag_serialnr *serialnr);

	get_board_serial(&serialnr);
	params->hdr.tag = ATAG_SERIAL;
	params->hdr.size = tag_size (tag_serialnr);
	params->u.serialnr.low = serialnr.low;
	params->u.serialnr.high= serialnr.high;
	params = tag_next (params);
	*tmp = params;
printf("config_serial_tag\n");

}
示例#7
0
static void __init sun6i_fixup(struct tag *tags, char **from,
			       struct meminfo *meminfo)
{
	struct tag *t;

	for (t = tags; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_MEM && t->u.mem.size) {
			pr_debug("[%s]: From boot, get meminfo:\n"
					"\tStart:\t0x%08x\n"
					"\tSize:\t%dMB\n",
					__func__,
					t->u.mem.start,
					t->u.mem.size >> 20);
			return;
		}
	}
示例#8
0
文件: atag.c 项目: JansZeng/g-bios
// fixme
struct tag *setup_mem_atag (struct tag *cur_tag)
{
	int i;

	for (i = 0; i < CONFIG_RAM_BANK_NUM; i++) {
		cur_tag = tag_next(cur_tag);

		cur_tag->hdr.tag  = ATAG_MEM;
		cur_tag->hdr.size = tag_size(tag_mem32);

		cur_tag->u.mem.start = SDRAM_BASE;
		cur_tag->u.mem.size  = SDRAM_SIZE;
	}

	return cur_tag;
}
示例#9
0
void setup_revision_tag(struct tag **in_params)
{
	u32 rev = 0;

#ifdef CONFIG_BOARD_REVISION
	rev = gd->bd->bi_board_revision;
#else
	u32 get_board_rev(void);
	rev = get_board_rev();
#endif

	params->hdr.tag = ATAG_REVISION;
	params->hdr.size = tag_size (tag_revision);
	params->u.revision.rev = rev;
	params = tag_next (params);
}
示例#10
0
static int __init init_atags_procfs(void)
{
	/*
	 * This cannot go into save_atags() because kmalloc and proc don't work
	 * yet when it is called.
	 */
	struct proc_dir_entry *tags_entry;
	struct tag *tag = (struct tag *)atags_copy;
	struct buffer *b;
	size_t size;

	if (tag->hdr.tag != ATAG_CORE) {
		printk(KERN_INFO "No ATAGs?");
		return -EINVAL;
	}

	for (; tag->hdr.size; tag = tag_next(tag))
		;

	/* include the terminating ATAG_NONE */
	size = (char *)tag - atags_copy + sizeof(struct tag_header);

	WARN_ON(tag->hdr.tag != ATAG_NONE);

	b = kmalloc(sizeof(*b) + size, GFP_KERNEL);
	if (!b)
		goto nomem;

	b->size = size;
	memcpy(b->data, atags_copy, size);

	tags_entry = proc_create_data("atags", 0400, NULL, &atags_fops, b);


	if (!tags_entry)
		goto nomem;

	atags_buffer = b;

	return 0;

nomem:
	kfree(b);
	printk(KERN_ERR "Exporting ATAGs: not enough memory\n");

	return -ENOMEM;
}
示例#11
0
/* bootmode tag (alphanumeric strings) */
void setup_bootmode_tag(struct tag **in_params)
{
#ifdef CONFIG_ENABLE_IDME  
    char bootmode_buf[IDME_MAX_BOOTMODE_LEN+1];
    char postmode_buf[IDME_MAX_BOOTMODE_LEN+1];
    
    unsigned long count = 0;

    memset(bootmode_buf, 0, IDME_MAX_BOOTMODE_LEN+1);
    memset(postmode_buf, 0, IDME_MAX_BOOTMODE_LEN+1);

    if (idme_get_var("bootmode", bootmode_buf, sizeof(bootmode_buf))){
            printf("Error, failed to get the bootmode\n");
            return;
    }

    printf("bootmode: %s\n",bootmode_buf);


    if (idme_get_var("postmode", postmode_buf, sizeof(postmode_buf))){
            printf("Error, failed to get postmode\n");
            return;
    }

    memcpy(&count, postmode_buf, sizeof(unsigned long));
    printf("count in postmode buf = %lu\n", count);

    //    printf("postmode: %s\n", postmode_buf);

    params->hdr.tag = ATAG_BOOTMODE;
    params->hdr.size = tag_size (tag_bootmode);
    memcpy (params->u.bootmode.boot, 
            bootmode_buf, 
            sizeof params->u.bootmode.boot);
    memcpy (params->u.bootmode.post, 
            postmode_buf, 
            sizeof params->u.bootmode.post);
	

    memcpy((char*)&count, params->u.bootmode.post, sizeof(unsigned long));

    printf("postmode in atag = %lu\n", count);

    params = tag_next (params);
#endif

}
static struct tag *setup_memory_tags(struct tag *params)
{
	bd_t *bd = gd->bd;
	int i;

	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
		params->hdr.tag = ATAG_MEM;
		params->hdr.size = tag_size(tag_mem_range);

		params->u.mem_range.addr = bd->bi_dram[i].start;
		params->u.mem_range.size = bd->bi_dram[i].size;

		params = tag_next(params);
	}

	return params;
}
示例#13
0
int __init parse_tag_monodie(const struct tag *tags)
{
#if !defined(CONFIG_MSM_AMSS_VERSION_WINCE)
	struct tag *t = (struct tag *)tags;
	int find = 0;
	for (; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_MONODIE) {
			printk(KERN_DEBUG "find the flash id tag\n");
			find = 1;
			break;
		}
	}

	if (find)
		mono_die = t->u.revision.rev;
	printk(KERN_DEBUG "parse_tag_monodie: mono-die = 0x%x\n", mono_die);
	return mono_die;
#else
	/* We need CONFIG_DEBUG_LL, otherwise our readl() will freeze the device
	 * on boot. (HaRET boot at least.)
	 */
#if !defined(CONFIG_DEBUG_LL) && !defined(CONFIG_MSM_AMSS_BREW)
#error CONFIG_DEBUG_LL is required!
#endif

	int die_selection;

	// restrict to htctopaz for now
	if (!machine_is_htctopaz())
		return mono_die;

	/* Dynamic memory die detection via phys 0x081c94.
	 *   dualdie: 0x00000001
	 *   monodie: 0x00000002
	 */
	die_selection = readl(0x00081c94);

	printk(KERN_DEBUG "%s: die_selection=0x%08x\n", __func__, die_selection);

	mono_die = die_selection == 0x00000002;

	printk(KERN_DEBUG "%s: mono-die = 0x%x\n", __func__, mono_die);
	return mono_die;
#endif
}
示例#14
0
int __init parse_tag_hwid(const struct tag *tags)
{
	int hwid = 0, find = 0;
	struct tag *t = (struct tag *)tags;

	for (; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_HWID) {
			printk(KERN_DEBUG "[K] find the hwid tag\n");
			find = 1;
			break;
		}
	}

	if (find)
		hwid = t->u.revision.rev;
	printk(KERN_DEBUG "[K] parse_tag_hwid: hwid = 0x%x\n", hwid);
	return hwid;
}
int __init parse_tag_monodie(const struct tag *tags)
{
	int find = 0;
	struct tag *t = (struct tag *)tags;

	for (; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_MONODIE) {
			printk(KERN_DEBUG "find the flash id tag\n");
			find = 1;
			break;
		}
	}

	if (find)
		mono_die = t->u.revision.rev;
	printk(KERN_DEBUG "parse_tag_monodie: mono-die = 0x%x\n", mono_die);
	return mono_die;
}
示例#16
0
int __init parse_tag_rfsku(const struct tag *tags)
{
	int find = 0;
	struct tag *t = (struct tag *)tags;

	for (; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_RFSKU) {
			printk(KERN_DEBUG "find the RFSKU tag\n");
			find = 1;
			break;
		}
	}

	if (find) {
		memcpy(rf_sku,&(t->u.rfsku),sizeof(t->u.rfsku));
	}
	return 0;
}
示例#17
0
int __init parse_tag_skuid(const struct tag *tags)
{
	int skuid = 0, find = 0;
	struct tag *t = (struct tag *)tags;

	for (; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_SKUID) {
			printk(KERN_DEBUG "find the skuid tag\n");
			find = 1;
			break;
		}
	}

	if (find)
		skuid = t->u.revision.rev;
	printk(KERN_DEBUG "parse_tag_skuid: hwid = 0x%x\n", skuid);
	return skuid;
}
示例#18
0
int __init parse_tag_cam(const struct tag *tags)
{
    int mem_size = 0, find = 0;
    struct tag *t = (struct tag *)tags;

    for (; t->hdr.size; t = tag_next(t)) {
        if (t->hdr.tag == ATAG_CAM) {
            printk(KERN_DEBUG "find the memsize tag\n");
            find = 1;
            break;
        }
    }

    if (find)
        mem_size = t->u.revision.rev;
    printk(KERN_DEBUG "parse_tag_memsize: %d\n", mem_size);
    return mem_size;
}
int __init parse_tag_security(const struct tag *tags)
{
	int security = 0, find = 0;
	struct tag *t = (struct tag *)tags;

	for (; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_SECURITY) {
			printk(KERN_DEBUG "find the security tag\n");
			find = 1;
			break;
		}
	}

	if (find)
		security = t->u.revision.rev;
	printk(KERN_DEBUG "parse_tag_security: %d\n", security);
	return security;
}
示例#20
0
文件: tags.c 项目: sergeyz/ipaq21x
static void
setup_cmdline_tag(const char line[])
{
    int i=0;
    char *ptr = params->u.cmdline.cmdline;
    while( line[i] != 0x00){
	*(ptr+i) = line[i];
	i++;
    }

    if(i <= 0)
        return;                             /* do not insert a tag for an empty commandline */

    params->hdr.tag = ATAG_CMDLINE;         /* Commandline tag */
    params->hdr.size = (sizeof(struct atag_header) + i + 1 + 4) >> 2;

    params = tag_next(params);              /* move pointer to next tag */
}
示例#21
0
int __init parse_tag_engineerid(const struct tag *tags)
{
    int find = 0;
    struct tag *t = (struct tag *)tags;

    for (; t->hdr.size; t = tag_next(t)) {
        if (t->hdr.tag == ATAG_ENGINEERID) {
            printk(KERN_DEBUG "find the engineer tag\n");
            find = 1;
            break;
        }
    }

    if (find)
        engineerid = t->u.revision.rev;
    printk(KERN_DEBUG "parse_tag_engineerid: hwid = 0x%x\n", engineerid);
    return engineerid;
}
示例#22
0
int __init parse_tag_smi(const struct tag *tags)
{
    int smi_sz = 0, find = 0;
    struct tag *t = (struct tag *)tags;

    for (; t->hdr.size; t = tag_next(t)) {
        if (t->hdr.tag == ATAG_SMI) {
            printk(KERN_DEBUG "find the smi tag\n");
            find = 1;
            break;
        }
    }
    if (!find)
        return -1;

    printk(KERN_DEBUG "parse_tag_smi: smi size = %d\n", t->u.mem.size);
    smi_sz = t->u.mem.size;
    return smi_sz;
}
示例#23
0
static void __init sun8i_fixup(struct tag *tags, char **from,
			       struct meminfo *meminfo)
{
#ifdef CONFIG_EVB_PLATFORM
	struct tag *t;

	for (t = tags; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_MEM && t->u.mem.size) {
			early_printk("[%s]: From boot, get meminfo:\n"
					"\tStart:\t0x%08x\n"
					"\tSize:\t%dMB\n",
					__func__,
					t->u.mem.start,
					t->u.mem.size >> 20);
			mem_start = t->u.mem.start;
			mem_size = t->u.mem.size;
			return;
		}
	}
static void setup_videolfb_tag (gd_t *gd)
{
	/* An ATAG_VIDEOLFB node tells the kernel where and how large
	 * the framebuffer for video was allocated (among other things).
	 * Note that a _physical_ address is passed !
	 *
	 * We only use it to pass the address and size, the other entries
	 * in the tag_videolfb are not of interest.
	 */
	params->hdr.tag = ATAG_VIDEOLFB;
	params->hdr.size = tag_size (tag_videolfb);

	params->u.videolfb.lfb_base = (u32) gd->fb_base;
	/* Fb size is calculated according to parameters for our panel
	 */
	params->u.videolfb.lfb_size = calc_fbsize();

	params = tag_next (params);
}
示例#25
0
int __init parse_tag_ddr_id(const struct tag *tags)
{
	int ddr_id = -1, find = 0;
	struct tag *t = (struct tag *)tags;

	for (; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_DDR_ID) {
			printk(KERN_DEBUG "find the DDR-ID tag\n");
			find = 1;
			break;
		}
	}

	if (find)
		ddr_id = t->u.revision.rev;

	printk(KERN_DEBUG "parse_tag_ddr_id: %d\n", ddr_id);
	return ddr_id;
}
示例#26
0
int __init parse_tag_pcbid(const struct tag *tags)
{
	int find = 0;
	struct tag *t = (struct tag *)tags;

	for (; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_PCBID) {
			printk(KERN_DEBUG "found the pcbid tag\n");
			find = 1;
			break;
		}
	}

	if (find) {
		pcbid = t->u.revision.rev;
	}
	printk(KERN_DEBUG "parse_tag_pcbid: 0x%x\n", pcbid);
	return pcbid;
}
示例#27
0
static struct tag *setup_memory_tags(struct tag *ktags)
{
	for (int i = 0; i < lib_sysinfo.n_memranges; i++) {
		struct memrange *range = &lib_sysinfo.memrange[i];

		if (range->type != CB_MEM_RAM)
			continue;

		ktags->hdr.tag = ATAG_MEM;
		ktags->hdr.size = tag_size(tag_mem32);
		ktags->u.mem.start = (uint32_t) range->base;
		ktags->u.mem.size = (uint32_t) range->size;
		printf("MEM tag added %#8.8x..%#8.8x\n",
		       ktags->u.mem.start,
		       ktags->u.mem.start + ktags->u.mem.size - 1);
		ktags = tag_next(ktags);
	}
	return ktags;
}
/*=======================================================================*/
static void cmdline_filter(struct tag *cmdline_tag, char *default_cmdline)
{
	const char *undesired_cmds[] = {
		"console=",
		"root=",
	};

	int i;
	int ck_f = 0;
	char *cs, *ce;

	cs = cmdline_tag->u.cmdline.cmdline;
	ce = cs;
	while ((__u32) ce < (__u32) tag_next(cmdline_tag)) {

		while (*cs == ' ' || *cs == '\0') {
			cs++;
			ce = cs;
		}

		if (*ce == ' ' || *ce == '\0') {
			for (i = 0; i < sizeof(undesired_cmds) / sizeof(char *); i++) {
				if (memcmp(cs, undesired_cmds[i], strlen(undesired_cmds[i])) == 0) {
					ck_f = 1;
					break;
				}
			}

			if (ck_f == 0) {
				*ce = '\0';
				/* Append to the default command line */
				strcat(default_cmdline, " ");
				strcat(default_cmdline, cs);
			}
			ck_f = 0;
			cs = ce + 1;
		}
		ce++;
	}
	if (strlen(default_cmdline) >= COMMAND_LINE_SIZE)
		panic("Command line length is too long.\n\r");
}
int __init parse_tag_skuid(const struct tag *tags)
{
	int find = 0;
	struct tag *t = (struct tag *)tags;

	for (; t->hdr.size; t = tag_next(t)) {
		if (t->hdr.tag == ATAG_SKUID) {
			printk(KERN_DEBUG "find the skuid tag\n");
			find = 1;
			break;
		}
	}

	if (find) {
		unsigned char *dptr = (unsigned char *)(&t->u);
		unsigned int sku_id_int = 0;
		char *ptr = SKUID + sizeof(SKUID) - 1;
		int rate = 1;
		int index= 0;

		memcpy(SKUID, dptr, 16);

		for (index = 0;index < sizeof(SKUID);index++) {
			if (0 == *ptr) {
				ptr--;
				continue;
			}
			if (*ptr >= '0' && *ptr <= '9')
				sku_id_int += (*ptr - '0') * rate;
			else if (*ptr >= 'a' && *ptr <= 'f')
				sku_id_int += ((*ptr - 'a') + 10) * rate;
			else if (*ptr >= 'A' && *ptr <= 'F')
				sku_id_int += ((*ptr - 'A') + 10) * rate;
			ptr--;
			rate *= 16;
		}
		sku_id = sku_id_int;
	}
	printk(KERN_INFO "parse_tag_skuid: 0x%s\n", SKUID);
	printk(KERN_INFO "parse_tag_skuid: 0x%x\n", sku_id);
	return 0;
}
示例#30
0
int __init parse_tag_smlog(const struct tag *tags)
{
    int smlog_flag = 0, find = 0;
    struct tag *t = (struct tag *)tags;

    for (; t->hdr.size; t = tag_next(t)) {
        if (t->hdr.tag == ATAG_SMLOG) {
            printk(KERN_DEBUG "[K] find the smlog tag\n");
            find = 1;
            break;
        }
    }

    if (find) {
        smlog_flag = t->u.revision.rev;
    }

    printk(KERN_DEBUG "[K] parse_tag_smlog: %d\n", smlog_flag);
    return smlog_flag;
}