本文整理汇总了C++中prom_getenv函数的典型用法代码示例。如果您正苦于以下问题:C++ prom_getenv函数的具体用法?C++ prom_getenv怎么用?C++ prom_getenv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prom_getenv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: detect_leds
static void __init detect_leds(void)
{
char *prid, *usb_prod;
/* Default LEDs */
ar7_led_data.num_leds = ARRAY_SIZE(default_leds);
ar7_led_data.leds = default_leds;
/* FIXME: the whole thing is unreliable */
prid = prom_getenv("ProductID");
usb_prod = prom_getenv("usb_prod");
/* If we can't get the product id from PROM, use the default LEDs */
if (!prid)
return;
if (strstr(prid, "Fritz_Box_FON")) {
ar7_led_data.num_leds = ARRAY_SIZE(fb_fon_leds);
ar7_led_data.leds = fb_fon_leds;
} else if (strstr(prid, "Fritz_Box_")) {
ar7_led_data.num_leds = ARRAY_SIZE(fb_sl_leds);
ar7_led_data.leds = fb_sl_leds;
} else if ((!strcmp(prid, "AR7RD") || !strcmp(prid, "AR7DB"))
&& usb_prod != NULL && strstr(usb_prod, "DSL-502T")) {
ar7_led_data.num_leds = ARRAY_SIZE(dsl502t_leds);
ar7_led_data.leds = dsl502t_leds;
} else if (strstr(prid, "DG834")) {
ar7_led_data.num_leds = ARRAY_SIZE(dg834g_leds);
ar7_led_data.leds = dg834g_leds;
}
}
示例2: sni_console_setup
static void __init sni_console_setup(void)
{
#ifndef CONFIG_ARC
char *ctype;
char *cdev;
char *baud;
int port;
static char options[8] __initdata;
cdev = prom_getenv("console_dev");
if (strncmp(cdev, "tty", 3) == 0) {
ctype = prom_getenv("console");
switch (*ctype) {
default:
case 'l':
port = 0;
baud = prom_getenv("lbaud");
break;
case 'r':
port = 1;
baud = prom_getenv("rbaud");
break;
}
if (baud)
strcpy(options, baud);
if (strncmp(cdev, "tty552", 6) == 0)
add_preferred_console("ttyS", port,
baud ? options : NULL);
else
add_preferred_console("ttySC", port,
baud ? options : NULL);
}
#endif
}
示例3: main
void
main()
{
u_int64_t entry;
/* Init prom callback vector. */
init_prom_calls();
/* print a banner */
printf("%s %s\n", bootprog_name, bootprog_rev);
/* switch to OSF pal code. */
OSFpal();
prom_getenv(PROM_E_BOOTED_FILE, boot_file, sizeof(boot_file));
prom_getenv(PROM_E_BOOTED_OSFLAGS, boot_flags, sizeof(boot_flags));
if (boot_file[0] == '\0')
bcopy("bsd", boot_file, sizeof "bsd");
(void)printf("Boot: %s %s\n", boot_file, boot_flags);
if (!loadfile(boot_file, &entry)) {
(void)printf("Entering kernel at 0x%lx...\n", entry);
(*(void (*)())entry)(ffp_save, ptbr_save, 0);
}
(void)printf("Boot failed! Halting...\n");
halt();
}
示例4: main
int
main()
{
char *name, **namep;
u_int64_t entry;
int win;
/* Init prom callback vector. */
init_prom_calls();
/* print a banner */
printf("%s\n", bootprog_name);
/* switch to OSF pal code. */
OSFpal();
prom_getenv(PROM_E_BOOTED_FILE, boot_file, sizeof(boot_file));
prom_getenv(PROM_E_BOOTED_OSFLAGS, boot_flags, sizeof(boot_flags));
if (boot_file[0] != '\0') {
(void)printf("Boot file: %s %s\n", boot_file, boot_flags);
name = boot_file;
} else
name = "bsd";
win = (loadfile(name, &entry) == 0);
if (!win)
goto fail;
/*
* Fill in the bootinfo for the kernel.
*/
bzero(&bootinfo_v1, sizeof(bootinfo_v1));
bootinfo_v1.ssym = ssym;
bootinfo_v1.esym = esym;
bcopy(name, bootinfo_v1.booted_kernel,
sizeof(bootinfo_v1.booted_kernel));
bcopy(boot_flags, bootinfo_v1.boot_flags,
sizeof(bootinfo_v1.boot_flags));
bootinfo_v1.hwrpb = (void *)HWRPB_ADDR;
bootinfo_v1.hwrpbsize = ((struct rpb *)HWRPB_ADDR)->rpb_size;
bootinfo_v1.cngetc = NULL;
bootinfo_v1.cnputc = NULL;
bootinfo_v1.cnpollc = NULL;
(*(void (*)(u_int64_t, u_int64_t, u_int64_t, void *, u_int64_t,
u_int64_t))entry)(ffp_save, ptbr_save, BOOTINFO_MAGIC,
&bootinfo_v1, 1, 0);
fail:
halt();
}
示例5: rtgalaxy_env_get_bootrev
void __init rtgalaxy_env_get_bootrev(void)
{
char *envp;
unsigned short v0, v1, v2;
envp = prom_getenv("bootrev");
if (envp) {
strcpy(rtgalaxy_info.bootrev, envp);
sscanf(envp, "%hx.%hx.%hx", &v0, &v1, &v2);
rtgalaxy_info.company_id = v0;
rtgalaxy_info.board_id = (v0 << 16) | v1;
/* old bootrev format : aa.bb.ccc */
/* new bootrev format : aaaa.bbbb.cccc */
if (envp[2] == '.')
rtgalaxy_info.cpu_id = (v1 & 0xf0) >> 4;
else
rtgalaxy_info.cpu_id = (v1 & 0xff00) >> 8;
#ifdef DEBUG
printk
("bootrev = '%s' => company_id = %04x, cpu_id = %02x, board_id = %08x\n",
rtgalaxy_info.bootrev,
rtgalaxy_info.company_id,
rtgalaxy_info.cpu_id, rtgalaxy_info.board_id);
#endif
}
示例6: console_config
static void __init console_config(void)
{
char console_string[40];
int baud = 0;
char parity = '\0', bits = '\0', flow = '\0';
char *s;
if ((strstr(prom_getcmdline(), "console=")) == NULL) {
s = prom_getenv("modetty0");
if (s) {
while (*s >= '0' && *s <= '9')
baud = baud*10 + *s++ - '0';
if (*s == ',') s++;
if (*s) parity = *s++;
if (*s == ',') s++;
if (*s) bits = *s++;
if (*s == ',') s++;
if (*s == 'h') flow = 'r';
}
if (baud == 0)
baud = 38400;
if (parity != 'n' && parity != 'o' && parity != 'e')
parity = 'n';
if (bits != '7' && bits != '8')
bits = '8';
if (flow == '\0')
flow = 'r';
sprintf(console_string, " console=ttyS0,%d%c%c%c", baud, parity, bits, flow);
strcat(prom_getcmdline(), console_string);
pr_info("Config serial console:%s\n", console_string);
}
}
示例7: prom_init
void __init prom_init(void)
{
unsigned char *memsize_str;
unsigned long memsize;
prom_argc = fw_arg0;
prom_argv = (char **) fw_arg1;
prom_envp = (char **) fw_arg2;
mips_machgroup = MACH_GROUP_ALCHEMY;
/* Set the platform # */
#if defined (CONFIG_MIPS_DB1550)
mips_machtype = MACH_DB1550;
#elif defined (CONFIG_MIPS_DB1500)
mips_machtype = MACH_DB1500;
#elif defined (CONFIG_MIPS_DB1100)
mips_machtype = MACH_DB1100;
#else
mips_machtype = MACH_DB1000;
#endif
prom_init_cmdline();
memsize_str = prom_getenv("memsize");
if (!memsize_str)
memsize = 0x04000000;
else
memsize = simple_strtol(memsize_str, NULL, 0);
add_memory_region(0, memsize, BOOT_MEM_RAM);
}
示例8: msp_usb_setup
static int __init msp_usb_setup(void)
{
char *strp;
char envstr[32];
struct platform_device *msp_devs[NUM_USB_DEVS];
unsigned int val;
/* construct environment name usbmode */
/* set usbmode <host/device> as pmon environment var */
/*
* Could this perhaps be integrated into the "features" env var?
* Use the features key "U", and follow with "H" for host-mode,
* "D" for device-mode. If it works for Ethernet, why not USB...
* -- hammtrev, 2007/03/22
*/
snprintf((char *)&envstr[0], sizeof(envstr), "usbmode");
/* set default host mode */
val = 1;
/* get environment string */
strp = prom_getenv((char *)&envstr[0]);
if (strp) {
/* compare string */
if (!strcmp(strp, "device"))
val = 0;
}
if (val) {
#if defined(CONFIG_USB_EHCI_HCD)
msp_devs[0] = &msp_usbhost0_device.dev;
ppfinit("platform add USB HOST done %s.\n", msp_devs[0]->name);
#ifdef CONFIG_MSP_HAS_DUAL_USB
msp_devs[1] = &msp_usbhost1_device.dev;
ppfinit("platform add USB HOST done %s.\n", msp_devs[1]->name);
#endif
#else
ppfinit("%s: echi_hcd not supported\n", __FILE__);
#endif /* CONFIG_USB_EHCI_HCD */
} else {
#if defined(CONFIG_USB_GADGET)
/* get device mode structure */
msp_devs[0] = &msp_usbdev0_device.dev;
ppfinit("platform add USB DEVICE done %s.\n"
, msp_devs[0]->name);
#ifdef CONFIG_MSP_HAS_DUAL_USB
msp_devs[1] = &msp_usbdev1_device.dev;
ppfinit("platform add USB DEVICE done %s.\n"
, msp_devs[1]->name);
#endif
#else
ppfinit("%s: usb_gadget not supported\n", __FILE__);
#endif /* CONFIG_USB_GADGET */
}
/* add device */
platform_add_devices(msp_devs, ARRAY_SIZE(msp_devs));
return 0;
}
示例9: prom_getmdesc
struct prom_pmemblock * __init prom_getmdesc(void)
{
char *env_str;
unsigned int ramsize, rambase;
env_str = prom_getenv("ramsize");
if (!env_str) {
ramsize = CONFIG_RALINK_RAM_SIZE * 1024 * 1024;
#ifdef DEBUG
printk("ramsize = %d MBytes\n", CONFIG_RALINK_RAM_SIZE );
#endif
} else {
#ifdef DEBUG
printk("ramsize = %s\n", env_str);
#endif
ramsize = simple_strtol(env_str, NULL, 0);
}
env_str = prom_getenv("rambase");
if (!env_str) {
#if defined(CONFIG_RT2880_ASIC) || defined(CONFIG_RT2880_FPGA)
#ifdef DEBUG
printk("rambase not set, set to default (0x08000000)\n");
#endif
rambase = 0x08000000;
#else
#ifdef DEBUG
printk("rambase not set, set to default (0x00000000)\n");
#endif
rambase = 0x00000000;
#endif
} else {
#ifdef DEBUG
printk("rambase = %s\n", env_str);
#endif
rambase = simple_strtol(env_str, NULL, 0);
}
memset(mdesc, 0, sizeof(mdesc));
mdesc[0].type = surfboard_ram;
mdesc[0].base = rambase;
mdesc[0].size = ramsize;
return &mdesc[0];
}
示例10: prom_getmdesc
static struct prom_pmemblock * __init prom_getmdesc(void)
{
char *memsize_str;
unsigned int memsize;
char *ptr;
static char cmdline[COMMAND_LINE_SIZE] __initdata;
memsize_str = prom_getenv("memsize");
if (!memsize_str) {
printk(KERN_WARNING
"memsize not set in boot prom, set to default (32Mb)\n");
physical_memsize = 0x02000000;
} else {
#ifdef DEBUG
pr_debug("prom_memsize = %s\n", memsize_str);
#endif
physical_memsize = simple_strtol(memsize_str, NULL, 0);
}
#ifdef CONFIG_CPU_BIG_ENDIAN
physical_memsize -= PAGE_SIZE;
#endif
strcpy(cmdline, arcs_cmdline);
ptr = strstr(cmdline, "memsize=");
if (ptr && (ptr != cmdline) && (*(ptr - 1) != ' '))
ptr = strstr(ptr, " memsize=");
if (ptr)
memsize = memparse(ptr + 8, &ptr);
else
memsize = physical_memsize;
memset(mdesc, 0, sizeof(mdesc));
mdesc[0].type = yamon_dontuse;
mdesc[0].base = 0x00000000;
mdesc[0].size = 0x00001000;
mdesc[1].type = yamon_prom;
mdesc[1].base = 0x00001000;
mdesc[1].size = 0x000ef000;
mdesc[2].type = yamon_dontuse;
mdesc[2].base = 0x000f0000;
mdesc[2].size = 0x00010000;
mdesc[3].type = yamon_dontuse;
mdesc[3].base = 0x00100000;
mdesc[3].size = CPHYSADDR(PFN_ALIGN((unsigned long)&_end)) - mdesc[3].base;
mdesc[4].type = yamon_free;
mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end));
mdesc[4].size = memsize - mdesc[4].base;
return &mdesc[0];
}
示例11: elf_exec
static int
elf_exec(struct loaded_module *mp)
{
static struct bootinfo_v1 bootinfo_v1;
struct module_metadata *md;
Elf_Ehdr *hdr;
int err;
int flen;
if ((md = mod_findmetadata(mp, MODINFOMD_ELFHDR)) == NULL)
return(EFTYPE); /* XXX actually EFUCKUP */
hdr = (Elf_Ehdr *)&(md->md_data);
/* XXX ffp_save does not appear to be used in the kernel.. */
bzero(&bootinfo_v1, sizeof(bootinfo_v1));
err = bi_load(&bootinfo_v1, &ffp_save, mp);
if (err)
return(err);
/*
* Fill in the bootinfo for the kernel.
*/
strncpy(bootinfo_v1.booted_kernel, mp->m_name,
sizeof(bootinfo_v1.booted_kernel));
flen = prom_getenv(PROM_E_BOOTED_OSFLAGS, bootinfo_v1.boot_flags,
sizeof(bootinfo_v1.boot_flags));
bootinfo_v1.hwrpb = (void *)HWRPB_ADDR;
bootinfo_v1.hwrpbsize = ((struct rpb *)HWRPB_ADDR)->rpb_size;
bootinfo_v1.cngetc = NULL;
bootinfo_v1.cnputc = NULL;
bootinfo_v1.cnpollc = NULL;
/*
* Append the boot command flags.
*/
if (mp->m_args != NULL && *mp->m_args != '\0') {
const char *p = mp->m_args;
do {
if (*p == '-') {
while (*++p != ' ' && *p != '\0')
if (flen < sizeof(bootinfo_v1.boot_flags) - 1)
bootinfo_v1.boot_flags[flen++] = *p;
} else
while (*p != ' ' && *p != '\0')
p++;
while (*p == ' ')
p++;
} while (*p != '\0');
bootinfo_v1.boot_flags[flen] = '\0';
}
printf("Entering %s at 0x%lx...\n", mp->m_name, hdr->e_entry);
closeall();
alpha_pal_imb();
(*(void (*)())hdr->e_entry)(ffp_save, ptbr_save,
BOOTINFO_MAGIC, &bootinfo_v1, 1, 0);
}
示例12: main
int
main()
{
char *name, **namep;
u_int64_t entry;
int win;
/* Init prom callback vector. */
init_prom_calls();
/* print a banner */
printf("\n");
printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
printf("(%s, %s)\n", bootprog_maker, bootprog_date);
printf("\n");
/* switch to OSF pal code. */
OSFpal();
printf("\n");
prom_getenv(PROM_E_BOOTED_FILE, boot_file, sizeof(boot_file));
prom_getenv(PROM_E_BOOTED_OSFLAGS, boot_flags, sizeof(boot_flags));
if (boot_file[0] != 0)
(void)printf("Boot file: %s\n", boot_file);
(void)printf("Boot flags: %s\n", boot_flags);
if (boot_file[0] != '\0')
win = (loadfile(name = boot_file, &entry) == 0);
else
for (namep = kernelnames, win = 0; *namep != NULL && !win;
namep++)
win = (loadfile(name = *namep, &entry) == 0);
printf("\n");
if (win) {
(void)printf("Entering %s at 0x%lx...\n", name, entry);
(*(void (*)())entry)(ffp_save, ptbr_save, esym);
}
(void)printf("Boot failed! Halting...\n");
halt();
}
示例13: plat_time_init
void __init plat_time_init(void)
{
char *endp, *s;
unsigned long cpu_rate = 0;
if (cpu_rate == 0) {
s = prom_getenv("clkfreqhz");
cpu_rate = simple_strtoul(s, &endp, 10);
if (endp != NULL && *endp != 0) {
printk(KERN_ERR
"Clock rate in Hz parse error: %s\n", s);
cpu_rate = 0;
}
}
if (cpu_rate == 0) {
s = prom_getenv("clkfreq");
cpu_rate = 1000 * simple_strtoul(s, &endp, 10);
if (endp != NULL && *endp != 0) {
printk(KERN_ERR
"Clock rate in MHz parse error: %s\n", s);
cpu_rate = 0;
}
}
if (cpu_rate == 0) {
#if defined(CONFIG_PMC_MSP7120_EVAL) \
|| defined(CONFIG_PMC_MSP7120_GW)
cpu_rate = 400000000;
#elif defined(CONFIG_PMC_MSP7120_FPGA)
cpu_rate = 25000000;
#else
cpu_rate = 150000000;
#endif
printk(KERN_ERR
"Failed to determine CPU clock rate, "
"assuming %ld hz ...\n", cpu_rate);
}
printk(KERN_WARNING "Clock rate set to %ld\n", cpu_rate);
/* timer frequency is 1/2 clock rate */
mips_hpt_frequency = cpu_rate/2;
}
示例14: cpmac_get_mac
static void cpmac_get_mac(int instance, unsigned char *dev_addr)
{
int i;
char name[5], default_mac[ETH_ALEN], *mac;
mac = NULL;
sprintf(name, "mac%c", 'a' + instance);
mac = prom_getenv(name);
if (!mac) {
sprintf(name, "mac%c", 'a');
mac = prom_getenv(name);
}
if (!mac) {
random_ether_addr(default_mac);
mac = default_mac;
}
for (i = 0; i < 6; i++)
dev_addr[i] = (char2hex(mac[i * 3]) << 4) +
char2hex(mac[i * 3 + 1]);
}
示例15: get_ethernet_addr
int get_ethernet_addr(char *ethernet_addr)
{
char *ethaddr_str;
ethaddr_str = prom_getenv("ethaddr");
if (!ethaddr_str) {
printk("ethaddr not set in boot prom\n");
return -1;
}
str2eaddr(ethernet_addr, ethaddr_str);
return 0;
}