static int bcm47xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv) { char buf[100]; /* Fill boardinfo structure */ memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo)); if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0) iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0); if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0) iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0); if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0) iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0); /* Fill sprom structure */ memset(&(iv->sprom), 0, sizeof(struct ssb_sprom)); iv->sprom.revision = 3; if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0) str2eaddr(buf, iv->sprom.et0mac); if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0) str2eaddr(buf, iv->sprom.et1mac); if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0) iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 10); if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0) iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 10); if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0) iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10); if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0) iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10); return 0; }
static __init void prom_init_cmdline(void) { char buf[CL_SIZE]; /* Get the kernel command line from CFE */ if (cfe_getenv("LINUX_CMDLINE", buf, CL_SIZE) >= 0) { buf[CL_SIZE-1] = 0; strcpy(arcs_cmdline, buf); } /* Force a console handover by adding a console= argument if needed, * as CFE is not available anymore later in the boot process. */ if ((strstr(arcs_cmdline, "console=")) == NULL) { /* Try to read the default serial port used by CFE */ if ((cfe_getenv("BOOT_CONSOLE", buf, CL_SIZE) < 0) || (strncmp("uart", buf, 4))) /* Default to uart0 */ strcpy(buf, "uart0"); /* Compute the new command line */ snprintf(arcs_cmdline, CL_SIZE, "%s console=ttyS%c,115200", arcs_cmdline, buf[4]); } }
static int cfe_console_setup(struct console *cons, char *str) { char consdev[32]; /* XXXKW think about interaction with 'console=' cmdline arg */ /* If none of the console options are configured, the build will break. */ if (cfe_getenv("BOOT_CONSOLE", consdev, 32) >= 0) { #ifdef CONFIG_SIBYTE_SB1250_DUART if (!strcmp(consdev, "uart0")) { setleds("u0cn"); } else if (!strcmp(consdev, "uart1")) { setleds("u1cn"); #endif #ifdef CONFIG_VGA_CONSOLE } else if (!strcmp(consdev, "pcconsole0")) { setleds("pccn"); #endif } else return -ENODEV; } return 0; }
static int ui_bcm1250cpci_setvxwenv( ui_cmdline_t *cmd, int argc, char *argv[] ) { int var; char *vxw_addr; char str[100]; char vxw_str[100]; for( var = 0; var < (sizeof(var_table) / sizeof(Env_vars)); var++ ) { str[0] = 0; cfe_getenv( var_table[ var ].name, str, sizeof(str) ); /* xprintf( "%s = %s\n", var_table[ var ].name, str ); */ sprintf( vxw_str, var_table[ var ].pattern, str ); /* xprintf( "vxw str = %s\n", vxw_str ); */ vxw_addr = (char *) (LOCAL_MEM_LOCAL_ADRS + var_table[ var ].offset); strcpy( vxw_addr, vxw_str ); } return 0; }
/* * prom_init is called just after the cpu type is determined, from setup_arch() */ void __init prom_init(void) { uint64_t cfe_ept, cfe_handle; unsigned int cfe_eptseal; int argc = fw_arg0; char **envp = (char **) fw_arg2; int *prom_vec = (int *) fw_arg3; _machine_restart = cfe_linux_restart; _machine_halt = cfe_linux_halt; _machine_power_off = cfe_linux_halt; /* * Check if a loader was used; if NOT, the 4 arguments are * what CFE gives us (handle, 0, EPT and EPTSEAL) */ if (argc < 0) { cfe_handle = (uint64_t)(long)argc; cfe_ept = (long)envp; cfe_eptseal = (uint32_t)(unsigned long)prom_vec; } else { if ((int32_t)(long)prom_vec < 0) { /* * Old loader; all it gives us is the handle, * so use the "known" entrypoint and assume * the seal. */ cfe_handle = (uint64_t)(long)prom_vec; cfe_ept = (uint64_t)((int32_t)0x9fc00500); cfe_eptseal = CFE_EPTSEAL; } else { /* * Newer loaders bundle the handle/ept/eptseal * Note: prom_vec is in the loader's useg * which is still alive in the TLB. */ cfe_handle = (uint64_t)((int32_t *)prom_vec)[0]; cfe_ept = (uint64_t)((int32_t *)prom_vec)[2]; cfe_eptseal = (unsigned int)((uint32_t *)prom_vec)[3]; } } if (cfe_eptseal != CFE_EPTSEAL) { /* too early for panic to do any good */ prom_printf("CFE's entrypoint seal doesn't match. Spinning."); while (1) ; } cfe_init(cfe_handle, cfe_ept); /* * Get the handle for (at least) prom_putchar, possibly for * boot console */ cfe_cons_handle = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE); if (cfe_getenv("LINUX_CMDLINE", arcs_cmdline, CL_SIZE) < 0) { if (argc < 0) { /* * It's OK for direct boot to not provide a * command line */ strcpy(arcs_cmdline, "root=/dev/ram0 "); #ifdef CONFIG_SIBYTE_PTSWARM strcat(arcs_cmdline, "console=ttyS0,115200 "); #endif } else { /* The loader should have set the command line */ /* too early for panic to do any good */ prom_printf("LINUX_CMDLINE not defined in cfe."); while (1) ; } } #ifdef CONFIG_BLK_DEV_INITRD { char *ptr; /* Need to find out early whether we've got an initrd. So scan the list looking now */ for (ptr = arcs_cmdline; *ptr; ptr++) { while (*ptr == ' ') { ptr++; } if (!strncmp(ptr, "initrd=", 7)) { initrd_setup(ptr+7); break; } else { while (*ptr && (*ptr != ' ')) { ptr++; } } } } #endif /* CONFIG_BLK_DEV_INITRD */ /* Not sure this is needed, but it's the safe way. */ arcs_cmdline[CL_SIZE-1] = 0; mips_machgroup = MACH_GROUP_SIBYTE; prom_meminit(); }
int __init tivo_init(void) { char buffer[60]; char *value; boardID=0; // is brev on command line? value=cmdline_lookup(arcs_cmdline,"brev="); if (!value) /* board rev arg not passed in, so make an assumption here */ { strcpy(buffer,"0x90002"); /* X3 is alloted the default board revision of 0x9002 */ boardID=simple_strtoul(buffer,NULL,0)<<8; } else { boardID=simple_strtoul(value, NULL, 0)<<8; } // in any case, force board ID into range for this platform if (boardID < kTivoConfigBoardIDPaceBase || boardID > kTivoConfigBoardIDPaceMax) { printk("Missing or invalid BoardID, taking a wild guess...\n"); boardID = kTivoConfigBoardIDX3; } printk(KERN_NOTICE "BoardID is 0x%X\n", boardID); // tell kernel InitTivoConfig( (TivoConfigValue) boardID ); // and user space if (!cmdline_lookup(arcs_cmdline,"boardID=")) cmdline_append(arcs_cmdline, COMMAND_LINE_SIZE, "boardID=0x%X", boardID); // set default HpkImpl if (!cmdline_lookup(arcs_cmdline,"HpkImpl=")) cmdline_append(arcs_cmdline, COMMAND_LINE_SIZE, "HpkImpl=Pac02"); // set default boot device if (!cmdline_lookup(arcs_cmdline,"boot_device=")) { // use sda if firmware reports BOOT_DEVICE=1, else normally use mmca if ((cfe_getenv("BOOT_DEVICE", buffer, sizeof(buffer))==CFE_OK) && (simple_strtoul(buffer,NULL,0) != 0)) cmdline_append(arcs_cmdline, COMMAND_LINE_SIZE,"boot_device=sda"); else cmdline_append(arcs_cmdline, COMMAND_LINE_SIZE,"boot_device=mmca"); } // also set default bmem if not on command line if (!cmdline_lookup(arcs_cmdline,"bmem=")) { unsigned long size, addr; if(!GetTivoConfig(kTivoConfigBmem0Size, &size) && !GetTivoConfig(kTivoConfigBmem0Address,&addr)) { sprintf(buffer,"%lu@%lu",size,addr); bmem_setup(buffer); if(!GetTivoConfig(kTivoConfigBmem1Size, &size) && !GetTivoConfig(kTivoConfigBmem1Address, &addr)) { sprintf(buffer,"%lu@%lu",size,addr); bmem_setup(buffer); } } } // set default sata spread spectrum if (!cmdline_lookup(arcs_cmdline, "sata3_ssc")) cmdline_append(arcs_cmdline, COMMAND_LINE_SIZE, "sata3_ssc"); #ifdef CONFIG_TIVO_DEVEL if (cmdline_lookup(arcs_cmdline, "nfs1")) { cmdline_delete(arcs_cmdline, "nfs1", NULL); cmdline_append(arcs_cmdline, COMMAND_LINE_SIZE, "xnfsinit=192.168.1.250:/Pac02/nfsroot sysgen=true rw"); } if ((value = cmdline_lookup(arcs_cmdline, "nfsinit=")) != NULL || (value = cmdline_lookup(arcs_cmdline, "xnfsinit=")) !=NULL) { // note, leave the [x]nfsinit command intact so it lands in the environment cmdline_delete(arcs_cmdline, "init=", "nfsroot=", NULL); cmdline_append(arcs_cmdline, COMMAND_LINE_SIZE, "init=/devbin/nfsinit nfsroot=%s", value); } #else // disable dsscon by default on release if (!cmdline_lookup(arcs_cmdline, "dsscon=")) cmdline_append(arcs_cmdline, COMMAND_LINE_SIZE, "dsscon=false"); #endif return 0; }
/* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)boot.c 8.1 (Berkeley) 6/10/93 */ #include <lib/libsa/stand.h> #include <lib/libkern/libkern.h> #include <lib/libsa/loadfile.h> #include <sys/param.h> #include <sys/exec.h> #include <sys/exec_ecoff.h> #include "stand/common/common.h" #include "stand/common/cfe_api.h" #include <machine/autoconf.h> #if !defined(UNIFIED_BOOTBLOCK) && !defined(SECONDARY_BOOTBLOCK) #error not UNIFIED_BOOTBLOCK and not SECONDARY_BOOTBLOCK #endif char boot_file[128]; char boot_flags[128]; extern int debug; struct bootinfo_v1 bootinfo; paddr_t ffp_save, ptbr_save; int debug; char *kernelnames[] = { "netbsd", "netbsd.gz", "netbsd.bak", "netbsd.bak.gz", "netbsd.old", "netbsd.old.gz", "onetbsd", "onetbsd.gz", "netbsd.mips", "netbsd.mips.gz", NULL }; int #if defined(UNIFIED_BOOTBLOCK) main(long fwhandle,long evector,long fwentry,long fwseal) #else /* defined(SECONDARY_BOOTBLOCK) */ main(long fwhandle,long fd,long fwentry) #endif { char *name, **namep; u_long marks[MARK_MAX]; u_int32_t entry; int win; /* Init prom callback vector. */ cfe_init(fwhandle,fwentry); /* Init the console device */ init_console(); /* print a banner */ printf("\n"); printf("NetBSD/sbmips " NETBSD_VERS " " BOOT_TYPE_NAME " Bootstrap, Revision %s\n", bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); printf("\n"); /* set up the booted device descriptor */ #if defined(UNIFIED_BOOTBLOCK) if (!booted_dev_open()) { printf("Boot device (%s) open failed.\n", booted_dev_name[0] ? booted_dev_name : "unknown"); goto fail; } #else /* defined(SECONDARY_BOOTBLOCK) */ booted_dev_setfd(fd); #endif printf("\n"); boot_file[0] = 0; cfe_getenv("KERNEL_FILE",boot_file,sizeof(boot_file)); boot_flags[0] = 0; cfe_getenv("BOOT_FLAGS",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 (strchr(boot_flags, 'i') || strchr(boot_flags, 'I')) { printf("Boot file: "); gets(boot_file); } memset(marks, 0, sizeof marks); if (boot_file[0] != '\0') win = loadfile(name = boot_file, marks, LOAD_KERNEL) == 0; else for (namep = kernelnames, win = 0; *namep != NULL && !win; namep++) win = loadfile(name = *namep, marks, LOAD_KERNEL) == 0; entry = marks[MARK_ENTRY]; booted_dev_close(); printf("\n"); if (!win) goto fail; (void)printf("Entering %s at 0x%lx...\n", name, (long)entry); cfe_flushcache(0); bzero(&bootinfo,sizeof(bootinfo)); bootinfo.version = BOOTINFO_VERSION; bootinfo.reserved = 0; bootinfo.ssym = marks[MARK_SYM]; bootinfo.esym = marks[MARK_END]; strncpy(bootinfo.boot_flags,boot_flags,sizeof(bootinfo.boot_flags)); strncpy(bootinfo.booted_kernel,name,sizeof(bootinfo.booted_kernel)); bootinfo.fwhandle = fwhandle; bootinfo.fwentry = fwentry; (*(void (*)(long,long,long,long))entry)(fwhandle, BOOTINFO_MAGIC, (long)&bootinfo, fwentry); (void)printf("KERNEL RETURNED!\n"); fail: (void)printf("Boot failed! Halting...\n"); halt(); return 1; }