asmlinkage void __init init_arch(int argc, char **argv, char **envp, int *prom_vec) { unsigned int s; /* Determine which MIPS variant we are running on. */ cpu_probe(); prom_init(argc, argv, envp, prom_vec); #ifdef CONFIG_SGI_IP22 sgi_sysinit(); #endif cpu_report(); /* * Determine the mmu/cache attached to this machine, * then flush the tlb and caches. On the r4xx0 * variants this also sets CP0_WIRED to zero. */ loadmmu(); /* Disable coprocessors and set FPU for 16/32 FPR register model */ clear_cp0_status(ST0_CU1|ST0_CU2|ST0_CU3|ST0_KX|ST0_SX|ST0_FR); set_cp0_status(ST0_CU0); start_kernel(); }
void __init setup_arch(char **cmdline_p) { /* the variable later on will be used in macros as well */ is_nlm_xlp2xx_compat = is_nlm_xlp2xx(); cpu_probe(); prom_init(); #ifdef CONFIG_EARLY_PRINTK setup_early_printk(); #endif cpu_report(); check_bugs_early(); #if defined(CONFIG_VT) #if defined(CONFIG_VGA_CONSOLE) conswitchp = &vga_con; #elif defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con; #endif #endif arch_mem_init(cmdline_p); resource_init(); plat_smp_setup(); }
main() { int io; char *file; prom_init(); printf(">> OpenBSD BOOT %s\n", version); file = prom_bootfile; if (file == 0 || *file == 0) file = DEFAULT_KERNEL; for (;;) { if (prom_boothow & RB_ASKNAME) { printf("device[%s]: ", prom_bootdevice); gets(dbuf); if (dbuf[0]) prom_bootdevice = dbuf; printf("boot: "); gets(fbuf); if (fbuf[0]) file = fbuf; } if ((io = open(file, 0)) >= 0) break; printf("open: %s: %s\n", file, strerror(errno)); prom_boothow |= RB_ASKNAME; } printf("Booting %s @ 0x%x\n", file, LOADADDR); loadfile(io, LOADADDR); _rtt(); }
asmlinkage void __init init_arch(int argc, char **argv, char **envp, int *prom_vec) { /* Determine which MIPS variant we are running on. */ cpu_probe(); prom_init(argc, argv, envp, prom_vec); cpu_report(); /* * Determine the mmu/cache attached to this machine, then flush the * tlb and caches. On the r4xx0 variants this also sets CP0_WIRED to * zero. */ load_mmu(); /* * On IP27, I am seeing the TS bit set when the kernel is loaded. * Maybe because the kernel is in ckseg0 and not xkphys? Clear it * anyway ... */ clear_c0_status(ST0_BEV|ST0_TS|ST0_CU1|ST0_CU2|ST0_CU3); set_c0_status(ST0_CU0|ST0_KX|ST0_SX|ST0_FR); start_kernel(); }
void __init setup_arch(char **cmdline_p) { cpu_probe(); prom_init(); #ifdef CONFIG_EARLY_PRINTK { extern void setup_early_printk(void); setup_early_printk(); } #endif cpu_report(); #if defined(CONFIG_VT) #if defined(CONFIG_VGA_CONSOLE) conswitchp = &vga_con; #elif defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con; #endif #endif arch_mem_init(cmdline_p); resource_init(); #ifdef CONFIG_SMP plat_smp_setup(); #endif }
int main(int argc, char *argv[]) { char *dummy; register void (*entry)(caddr_t) = (void (*)(caddr_t))PROM_LOADADDR; prom_init(); io.f_flags = F_RAW; if (devopen(&io, 0, &dummy)) { panic("%s: can't open device", progname); } (void)loadboot(&io, (caddr_t)PROM_LOADADDR); (io.f_dev->dv_close)(&io); (*entry)(cputyp == CPU_SUN4 ? (caddr_t)PROM_LOADADDR : (caddr_t)promvec); _rtt(); }
asmlinkage void __init init_arch(int argc, char **argv, char **envp, int *prom_vec) { /* Determine which MIPS variant we are running on. */ cpu_probe(); prom_init(argc, argv, envp, prom_vec); cpu_report(); /* * Determine the mmu/cache attached to this machine, then flush the * tlb and caches. On the r4xx0 variants this also sets CP0_WIRED to * zero. */ load_mmu(); start_kernel(); }
asmlinkage void __init init_arch(int argc, char **argv, char **envp, int *prom_vec) { /* Determine which MIPS variant we are running on. */ unsigned int s; #ifdef CONFIG_RTL865X char chipVersion[16]={0}; int rev; GetChipVersion(chipVersion,sizeof(chipVersion), &rev); printk("************************************\n"); printk("Powered by Realtek RTL%s SoC, rev %d\n",chipVersion, rev); printk("************************************\n"); #endif #ifdef CONFIG_RTL8186 printk("************************************\n"); printk("Powered by Realtek RTL8186 SoC\n"); printk("************************************\n"); #endif cpu_probe(); prom_init(argc, argv, envp, prom_vec); cpu_report(); /* * Determine the mmu/cache attached to this machine, * then flush the tlb and caches. On the r4xx0 * variants this also sets CP0_WIRED to zero. */ #ifdef CONFIG_RTL865X printk("Init MMU (16 entries)\n"); #endif load_mmu(); /* Disable coprocessors and set FPU for 16/32 FPR register model */ clear_c0_status(ST0_CU1|ST0_CU2|ST0_CU3|ST0_KX|ST0_SX|ST0_FR); set_c0_status(ST0_CU0); start_kernel(); }
void __init setup_arch(char **cmdline_p) { cpu_probe(); prom_init(); cpu_report(); #if defined(CONFIG_VT) #if defined(CONFIG_VGA_CONSOLE) conswitchp = &vga_con; #elif defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con; #endif #endif arch_mem_init(cmdline_p); resource_init(); #ifdef CONFIG_SMP plat_smp_setup(); #endif }
/* * This is called from locore.s just after the kernel is remapped * to its proper address, but before the call to main(). The work * done here corresponds to various things done in locore.s on the * hp300 port (and other m68k) but which we prefer to do in C code. * Also do setup specific to the Sun PROM monitor and IDPROM here. */ void _bootstrap(void) { vaddr_t va; /* First, Clear BSS. */ memset(edata, 0, end - edata); /* Initialize the PROM. */ prom_init(); /* Copy the IDPROM from control space. */ idprom_init(); /* Validate the Sun2 model (from IDPROM). */ _verify_hardware(); /* Handle kernel mapping, pmap_bootstrap(), etc. */ _vm_init(); /* * Point interrupts/exceptions to our vector table. * (Until now, we use the one setup by the PROM.) */ setvbr((void **)vector_table); /* Interrupts are enabled later, after autoconfig. */ /* * Now unmap the PROM's physical/virtual pages zero through three. */ for(va = 0; va < PAGE_SIZE * 4; va += PAGE_SIZE) set_pte(va, PG_INVAL); /* * Turn on the LEDs so we know power is on. * Needs idprom_init and obio_init earlier. */ leds_init(); }
void board_init_f(ulong bootflag) { cmd_tbl_t *cmdtp; bd_t *bd; unsigned char *s; init_fnc_t **init_fnc_ptr; int j; int i; char *e; #ifndef CONFIG_SYS_NO_FLASH ulong flash_size; #endif gd = (gd_t *) (CONFIG_SYS_GBL_DATA_OFFSET); /* Clear initial global data */ memset((void *)gd, 0, sizeof(gd_t)); gd->bd = (bd_t *) (gd + 1); /* At end of global data */ gd->baudrate = CONFIG_BAUDRATE; gd->cpu_clk = CONFIG_SYS_CLK_FREQ; bd = gd->bd; bd->bi_memstart = CONFIG_SYS_RAM_BASE; bd->bi_memsize = CONFIG_SYS_RAM_SIZE; bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; #if defined(CONFIG_SYS_SRAM_BASE) && defined(CONFIG_SYS_SRAM_SIZE) bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; #endif bd->bi_baudrate = CONFIG_BAUDRATE; bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ gd->reloc_off = CONFIG_SYS_RELOC_MONITOR_BASE - CONFIG_SYS_MONITOR_BASE; for (init_fnc_ptr = init_sequence, j = 0; *init_fnc_ptr; ++init_fnc_ptr, j++) { #ifdef DEBUG_INIT_SEQUENCE if (j > 9) str_init_seq[9] = '0' + (j / 10); str_init_seq[10] = '0' + (j - (j / 10) * 10); serial_puts(str_init_seq); #endif if ((*init_fnc_ptr + gd->reloc_off) () != 0) { hang(); } } #ifdef DEBUG_INIT_SEQUENCE serial_puts(str_init_seq_done); #endif /* * Now that we have DRAM mapped and working, we can * relocate the code and continue running from DRAM. * * Reserve memory at end of RAM for (top down in that order): * - kernel log buffer * - protected RAM * - LCD framebuffer * - monitor code * - board info struct */ #ifdef DEBUG_MEM_LAYOUT printf("CONFIG_SYS_MONITOR_BASE: 0x%lx\n", CONFIG_SYS_MONITOR_BASE); printf("CONFIG_ENV_ADDR: 0x%lx\n", CONFIG_ENV_ADDR); printf("CONFIG_SYS_RELOC_MONITOR_BASE: 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE, CONFIG_SYS_MONITOR_LEN); printf("CONFIG_SYS_MALLOC_BASE: 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN); printf("CONFIG_SYS_INIT_SP_OFFSET: 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET, CONFIG_SYS_STACK_SIZE); printf("CONFIG_SYS_PROM_OFFSET: 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET, CONFIG_SYS_PROM_SIZE); printf("CONFIG_SYS_GBL_DATA_OFFSET: 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET, CONFIG_SYS_GBL_DATA_SIZE); #endif #ifdef CONFIG_POST post_bootmode_init(); post_run(NULL, POST_ROM | post_bootmode_get(0)); #endif /* * We have to relocate the command table manually */ for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { ulong addr; addr = (ulong) (cmdtp->cmd) + gd->reloc_off; #if DEBUG_COMMANDS printf("Command \"%s\": 0x%08lx => 0x%08lx\n", cmdtp->name, (ulong) (cmdtp->cmd), addr); #endif cmdtp->cmd = (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; addr = (ulong) (cmdtp->name) + gd->reloc_off; cmdtp->name = (char *)addr; if (cmdtp->usage) { addr = (ulong) (cmdtp->usage) + gd->reloc_off; cmdtp->usage = (char *)addr; } #ifdef CONFIG_SYS_LONGHELP if (cmdtp->help) { addr = (ulong) (cmdtp->help) + gd->reloc_off; cmdtp->help = (char *)addr; } #endif } #if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP) puts("AMBA:\n"); do_ambapp_print(NULL, 0, 0, NULL); #endif /* initialize higher level parts of CPU like time base and timers */ cpu_init_r(); /* start timer */ timer_interrupt_init(); /* * Enable Interrupts before any calls to udelay, * the flash driver may use udelay resulting in * a hang if not timer0 IRQ is enabled. */ interrupt_init(); /* The Malloc area is immediately below the monitor copy in RAM */ mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_END - CONFIG_SYS_MALLOC_BASE); malloc_bin_reloc(); #if !defined(CONFIG_SYS_NO_FLASH) puts("FLASH: "); if ((flash_size = flash_init()) > 0) { # ifdef CONFIG_SYS_FLASH_CHECKSUM print_size(flash_size, ""); /* * Compute and print flash CRC if flashchecksum is set to 'y' * * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX */ s = getenv("flashchecksum"); if (s && (*s == 'y')) { printf(" CRC: %08lX", crc32(0, (const unsigned char *)CONFIG_SYS_FLASH_BASE, flash_size) ); } putc('\n'); # else /* !CONFIG_SYS_FLASH_CHECKSUM */ print_size(flash_size, "\n"); # endif /* CONFIG_SYS_FLASH_CHECKSUM */ } else { puts(failed); hang(); } bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* update start of FLASH memory */ bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ #if CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */ #else bd->bi_flashoffset = 0; #endif #else /* CONFIG_SYS_NO_FLASH */ bd->bi_flashsize = 0; bd->bi_flashstart = 0; bd->bi_flashoffset = 0; #endif /* !CONFIG_SYS_NO_FLASH */ #ifdef CONFIG_SPI # if !defined(CONFIG_ENV_IS_IN_EEPROM) spi_init_f(); # endif spi_init_r(); #endif /* relocate environment function pointers etc. */ env_relocate(); #if defined(CONFIG_BOARD_LATE_INIT) board_late_init(); #endif #ifdef CONFIG_ID_EEPROM mac_read_from_eeprom(); #endif /* IP Address */ bd->bi_ip_addr = getenv_IPaddr("ipaddr"); #if defined(CONFIG_PCI) /* * Do pci configuration */ pci_init(); #endif /* Initialize stdio devices */ stdio_init(); /* Initialize the jump table for applications */ jumptable_init(); /* Initialize the console (after the relocation and devices init) */ console_init_r(); #ifdef CONFIG_SERIAL_SOFTWARE_FIFO serial_buffered_init(); #endif #ifdef CONFIG_STATUS_LED status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); #endif udelay(20); set_timer(0); /* Initialize from environment */ if ((s = getenv("loadaddr")) != NULL) { load_addr = simple_strtoul(s, NULL, 16); } #if defined(CONFIG_CMD_NET) if ((s = getenv("bootfile")) != NULL) { copy_filename(BootFile, s, sizeof(BootFile)); } #endif /* CONFIG_CMD_NET */ WATCHDOG_RESET(); #if defined(CONFIG_CMD_DOC) WATCHDOG_RESET(); puts("DOC: "); doc_init(); #endif #ifdef CONFIG_BITBANGMII bb_miiphy_init(); #endif #if defined(CONFIG_CMD_NET) #if defined(CONFIG_NET_MULTI) WATCHDOG_RESET(); puts("Net: "); #endif eth_initialize(bd); #endif #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) WATCHDOG_RESET(); debug("Reset Ethernet PHY\n"); reset_phy(); #endif #ifdef CONFIG_POST post_run(NULL, POST_RAM | post_bootmode_get(0)); #endif #if defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); puts("IDE: "); ide_init(); #endif /* CONFIG_CMD_IDE */ #ifdef CONFIG_LAST_STAGE_INIT WATCHDOG_RESET(); /* * Some parts can be only initialized if all others (like * Interrupts) are up and running (i.e. the PC-style ISA * keyboard). */ last_stage_init(); #endif #ifdef CONFIG_PS2KBD puts("PS/2: "); kbd_init(); #endif prom_init(); /* main_loop */ for (;;) { WATCHDOG_RESET(); main_loop(); } }
/* Here we are launched */ void iquik_main(void *a1, void *a2, void *prom_entry) { char *params; quik_err_t err; load_state_t image; err = prom_init(prom_entry); if (err != ERR_NONE) { prom_exit(); } printk("\niQUIK OldWorld Bootloader\n"); printk("Copyright (C) 2016 Andrei Warkentin <*****@*****.**>\n"); if (bi->flags & SHIM_OF) { printk("This firmware requires a shim to work around bugs\n"); } err = malloc_init(); if (err != ERR_NONE) { goto error; } err = cmd_init(); if (err != ERR_NONE) { goto error; } err = env_init(); if (err != ERR_NONE) { goto error; } err = load_config(); if (err != ERR_NONE) { printk("No configration file parsed: %r\n", err); } for (;;) { params = NULL; err = try_load_loop(&image, ¶ms); if (err == ERR_NONE) { break; } } err = elf_relo(&image); if (err != ERR_NONE) { goto error; } if (bi->flags & BOOT_PRE_2_4 && bi->flags & SHIM_OF) { printk("OF shimming unsupported for pre-2.4 kernels\n"); bi->flags ^= SHIM_OF; } if (bi->flags & DEBUG_BEFORE_BOOT) { if (bi->flags & BOOT_PRE_2_4) { printk("Booting pre-2.4 kernel\n"); } printk("Kernel: 0x%x @ 0x%x\n", image.text_len, image.linked_base); printk("Initrd: 0x%x @ 0x%x\n", bi->initrd_len, bi->initrd_base); printk("Kernel parameters: %s\n", params); printk("Kernel entry: 0x%x\n", image.entry); prom_pause(NULL); } else if (bi->flags & PAUSE_BEFORE_BOOT) { prom_pause(bi->pause_message); } err = elf_boot(&image, params); error: printk("Exiting on error: %r", err); prom_exit(); }
/* * This gets arguments from the first stage boot lader, calls PROM routines * to open and load the program to boot, and then transfers execution to * that new program. */ int main(int argc, char **argv) { char *name, **namep, *dev, *kernel; char bootname[PATH_MAX], bootpath[PATH_MAX]; int win; u_long marks[MARK_MAX]; struct btinfo_symtab bi_syms; struct btinfo_bootpath bi_bpath; extern void prom_init(void); void (*entry)(int, char **, char **, u_int, char *); prom_init(); /* print a banner */ printf("\n"); printf("NetBSD/mipsco " NETBSD_VERS " " BOOT_TYPE_NAME " Bootstrap, Revision %s\n", bootprog_rev); /* initialise bootinfo structure early */ bi_init(BOOTINFO_ADDR); dev = name = NULL; if (argc > 1) { kernel = devsplit(argv[1], bootname); if (*bootname) { dev = bootname; if (*kernel) name = argv[1]; ++argv; --argc; } } if (dev == NULL) { (void) devsplit(argv[0], bootname); dev = bootname; } memset(marks, 0, sizeof marks); if (name != NULL) win = (loadfile(name, marks, LOAD_KERNEL) == 0); else { win = 0; for (namep = kernelnames, win = 0; *namep != NULL && !win; namep++) { kernel = *namep; strcpy(bootpath, dev); strcat(bootpath, kernel); printf("Loading: %s\n", bootpath); win = (loadfile(bootpath, marks, LOAD_ALL) != -1); if (win) { name = bootpath; } } } if (!win) goto fail; strncpy(bi_bpath.bootpath, kernel, BTINFO_BOOTPATH_LEN); bi_add(&bi_bpath, BTINFO_BOOTPATH, sizeof(bi_bpath)); entry = (void *) marks[MARK_ENTRY]; bi_syms.nsym = marks[MARK_NSYM]; bi_syms.ssym = marks[MARK_SYM]; bi_syms.esym = marks[MARK_END]; bi_add(&bi_syms, BTINFO_SYMTAB, sizeof(bi_syms)); printf("Starting at 0x%x\n\n", (u_int)entry); (*entry)(argc, argv, NULL, BOOTINFO_MAGIC, (char *)BOOTINFO_ADDR); (void)printf("KERNEL RETURNED!\n"); fail: (void)printf("Boot failed! Halting...\n"); return (0); }
/* * locore.s code calls bootstrap() just before calling main(). * * What we try to do is as follows: * - Initialize PROM and the console * - Read in part of information provided by a bootloader and find out * kernel load and end addresses * - Initialize ksyms * - Find out number of active CPUs * - Finalize the bootstrap by calling pmap_bootstrap() * * We will try to run out of the prom until we get out of pmap_bootstrap(). */ void bootstrap(void *o0, void *bootargs, void *bootsize, void *o3, void *ofw) { void *bi; long bmagic; char buf[32]; #if NKSYMS || defined(DDB) || defined(MODULAR) struct btinfo_symtab *bi_sym; #endif struct btinfo_count *bi_count; struct btinfo_kernend *bi_kend; struct btinfo_tlb *bi_tlb; struct btinfo_boothowto *bi_howto; extern void *romtba; extern void* get_romtba(void); extern void OF_val2sym32(void *); extern void OF_sym2val32(void *); extern struct consdev consdev_prom; /* Save OpenFrimware entry point */ romp = ofw; romtba = get_romtba(); prom_init(); console_instance = promops.po_stdout; console_node = OF_instance_to_package(promops.po_stdout); /* Initialize the PROM console so printf will not panic */ cn_tab = &consdev_prom; (*cn_tab->cn_init)(cn_tab); DPRINTF(ACDB_BOOTARGS, ("sparc64_init(%p, %p, %p, %p, %p)\n", o0, bootargs, bootsize, o3, ofw)); /* Extract bootinfo pointer */ if ((long)bootsize >= (4 * sizeof(uint64_t))) { /* Loaded by 64-bit bootloader */ bi = (void*)(u_long)(((uint64_t*)bootargs)[3]); bmagic = (long)(((uint64_t*)bootargs)[0]); } else if ((long)bootsize >= (4 * sizeof(uint32_t))) { /* Loaded by 32-bit bootloader */ bi = (void*)(u_long)(((uint32_t*)bootargs)[3]); bmagic = (long)(((uint32_t*)bootargs)[0]); } else { printf("Bad bootinfo size.\n"); die_old_boot_loader: printf("This kernel requires NetBSD boot loader version 1.9 " "or newer\n"); panic("sparc64_init."); } DPRINTF(ACDB_BOOTARGS, ("sparc64_init: bmagic=%lx, bi=%p\n", bmagic, bi)); /* Read in the information provided by NetBSD boot loader */ if (SPARC_MACHINE_OPENFIRMWARE != bmagic) { printf("No bootinfo information.\n"); goto die_old_boot_loader; } bootinfo = (void*)(u_long)((uint64_t*)bi)[1]; LOOKUP_BOOTINFO(bi_kend, BTINFO_KERNEND); if (bi_kend->addr == (vaddr_t)0) { panic("Kernel end address is not found in bootinfo.\n"); } #if NKSYMS || defined(DDB) || defined(MODULAR) LOOKUP_BOOTINFO(bi_sym, BTINFO_SYMTAB); ksyms_addsyms_elf(bi_sym->nsym, (int *)(u_long)bi_sym->ssym, (int *)(u_long)bi_sym->esym); #ifdef DDB #ifdef __arch64__ /* This can only be installed on an 64-bit system cause otherwise our stack is screwed */ OF_set_symbol_lookup(OF_sym2val, OF_val2sym); #else OF_set_symbol_lookup(OF_sym2val32, OF_val2sym32); #endif #endif #endif if (OF_getprop(findroot(), "compatible", buf, sizeof(buf)) > 0) { if (strcmp(buf, "sun4us") == 0) setcputyp(CPU_SUN4US); else if (strcmp(buf, "sun4v") == 0) setcputyp(CPU_SUN4V); } bi_howto = lookup_bootinfo(BTINFO_BOOTHOWTO); if (bi_howto) boothowto = bi_howto->boothowto; LOOKUP_BOOTINFO(bi_count, BTINFO_DTLB_SLOTS); kernel_dtlb_slots = bi_count->count; kernel_itlb_slots = kernel_dtlb_slots-1; bi_count = lookup_bootinfo(BTINFO_ITLB_SLOTS); if (bi_count) kernel_itlb_slots = bi_count->count; LOOKUP_BOOTINFO(bi_tlb, BTINFO_DTLB); kernel_tlbs = &bi_tlb->tlb[0]; get_ncpus(); pmap_bootstrap(KERNBASE, bi_kend->addr); }
static void sun4uv_init(MemoryRegion *address_space_mem, MachineState *machine, const struct hwdef *hwdef) { SPARCCPU *cpu; Nvram *nvram; unsigned int i; uint64_t initrd_addr, initrd_size, kernel_addr, kernel_size, kernel_entry; SabreState *sabre; PCIBus *pci_bus, *pci_busA, *pci_busB; PCIDevice *ebus, *pci_dev; SysBusDevice *s; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DeviceState *iommu, *dev; FWCfgState *fw_cfg; NICInfo *nd; MACAddr macaddr; bool onboard_nic; /* init CPUs */ cpu = sparc64_cpu_devinit(machine->cpu_type, hwdef->prom_addr); /* IOMMU */ iommu = qdev_create(NULL, TYPE_SUN4U_IOMMU); qdev_init_nofail(iommu); /* set up devices */ ram_init(0, machine->ram_size); prom_init(hwdef->prom_addr, bios_name); /* Init sabre (PCI host bridge) */ sabre = SABRE_DEVICE(qdev_create(NULL, TYPE_SABRE)); qdev_prop_set_uint64(DEVICE(sabre), "special-base", PBM_SPECIAL_BASE); qdev_prop_set_uint64(DEVICE(sabre), "mem-base", PBM_MEM_BASE); object_property_set_link(OBJECT(sabre), OBJECT(iommu), "iommu", &error_abort); qdev_init_nofail(DEVICE(sabre)); /* Wire up PCI interrupts to CPU */ for (i = 0; i < IVEC_MAX; i++) { qdev_connect_gpio_out_named(DEVICE(sabre), "ivec-irq", i, qdev_get_gpio_in_named(DEVICE(cpu), "ivec-irq", i)); } pci_bus = PCI_HOST_BRIDGE(sabre)->bus; pci_busA = pci_bridge_get_sec_bus(sabre->bridgeA); pci_busB = pci_bridge_get_sec_bus(sabre->bridgeB); /* Only in-built Simba APBs can exist on the root bus, slot 0 on busA is reserved (leaving no slots free after on-board devices) however slots 0-3 are free on busB */ pci_bus->slot_reserved_mask = 0xfffffffc; pci_busA->slot_reserved_mask = 0xfffffff1; pci_busB->slot_reserved_mask = 0xfffffff0; ebus = pci_create_multifunction(pci_busA, PCI_DEVFN(1, 0), true, TYPE_EBUS); qdev_prop_set_uint64(DEVICE(ebus), "console-serial-base", hwdef->console_serial_base); qdev_init_nofail(DEVICE(ebus)); /* Wire up "well-known" ISA IRQs to PBM legacy obio IRQs */ qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 7, qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_LPT_IRQ)); qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 6, qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_FDD_IRQ)); qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 1, qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_KBD_IRQ)); qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 12, qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_MSE_IRQ)); qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 4, qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_SER_IRQ)); pci_dev = pci_create_simple(pci_busA, PCI_DEVFN(2, 0), "VGA"); memset(&macaddr, 0, sizeof(MACAddr)); onboard_nic = false; for (i = 0; i < nb_nics; i++) { nd = &nd_table[i]; if (!nd->model || strcmp(nd->model, "sunhme") == 0) { if (!onboard_nic) { pci_dev = pci_create_multifunction(pci_busA, PCI_DEVFN(1, 1), true, "sunhme"); memcpy(&macaddr, &nd->macaddr.a, sizeof(MACAddr)); onboard_nic = true; } else { pci_dev = pci_create(pci_busB, -1, "sunhme"); } } else { pci_dev = pci_create(pci_busB, -1, nd->model); } dev = &pci_dev->qdev; qdev_set_nic_properties(dev, nd); qdev_init_nofail(dev); } /* If we don't have an onboard NIC, grab a default MAC address so that * we have a valid machine id */ if (!onboard_nic) { qemu_macaddr_default_if_unset(&macaddr); } ide_drive_get(hd, ARRAY_SIZE(hd)); pci_dev = pci_create(pci_busA, PCI_DEVFN(3, 0), "cmd646-ide"); qdev_prop_set_uint32(&pci_dev->qdev, "secondary", 1); qdev_init_nofail(&pci_dev->qdev); pci_ide_create_devs(pci_dev, hd); /* Map NVRAM into I/O (ebus) space */ nvram = m48t59_init(NULL, 0, 0, NVRAM_SIZE, 1968, 59); s = SYS_BUS_DEVICE(nvram); memory_region_add_subregion(pci_address_space_io(ebus), 0x2000, sysbus_mmio_get_region(s, 0)); initrd_size = 0; initrd_addr = 0; kernel_size = sun4u_load_kernel(machine->kernel_filename, machine->initrd_filename, ram_size, &initrd_size, &initrd_addr, &kernel_addr, &kernel_entry); sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", machine->ram_size, machine->boot_order, kernel_addr, kernel_size, machine->kernel_cmdline, initrd_addr, initrd_size, /* XXX: need an option to load a NVRAM image */ 0, graphic_width, graphic_height, graphic_depth, (uint8_t *)&macaddr); dev = qdev_create(NULL, TYPE_FW_CFG_IO); qdev_prop_set_bit(dev, "dma_enabled", false); object_property_add_child(OBJECT(ebus), TYPE_FW_CFG, OBJECT(dev), NULL); qdev_init_nofail(dev); memory_region_add_subregion(pci_address_space_io(ebus), BIOS_CFG_IOPORT, &FW_CFG_IO(dev)->comb_iomem); fw_cfg = FW_CFG(dev); fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_entry); fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (machine->kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(machine->kernel_cmdline) + 1); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, machine->kernel_cmdline); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0); } fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_order[0]); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_DEPTH, graphic_depth); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); }
void main(void *ofw) { int boothowto, i = 0, isfloppy, kboothowto; char kernel[PROM_MAX_PATH]; char bootline[PROM_MAX_PATH]; /* Initialize OpenFirmware */ romp = ofw; prom_init(); printf("\r>> %s, Revision %s\n", bootprog_name, bootprog_rev); /* Figure boot arguments */ strncpy(bootdev, prom_getbootpath(), sizeof(bootdev) - 1); kboothowto = boothowto = bootoptions(prom_getbootargs(), bootdev, kernel, bootline); isfloppy = bootdev_isfloppy(bootdev); for (;; *kernel = '\0') { if (boothowto & RB_ASKNAME) { char cmdline[PROM_MAX_PATH]; printf("Boot: "); kgets(cmdline, sizeof(cmdline)); if (!strcmp(cmdline,"exit") || !strcmp(cmdline,"halt")) { prom_halt(); } else if (!strcmp(cmdline, "?") || !strcmp(cmdline, "help")) { help(); continue; } boothowto = bootoptions(cmdline, bootdev, kernel, bootline); boothowto |= RB_ASKNAME; i = 0; } if (*kernel == '\0') { if (kernelnames[i] == NULL) { boothowto |= RB_ASKNAME; continue; } strncpy(kernel, kernelnames[i++], PROM_MAX_PATH); } else if (i == 0) { /* * Kernel name was passed via command line -- ask user * again if requested image fails to boot. */ boothowto |= RB_ASKNAME; } check_boot_config(); start_kernel(kernel, bootline, ofw, isfloppy, kboothowto); /* * Try next name from kernel name list if not in askname mode, * enter askname on reaching list's end. */ if ((boothowto & RB_ASKNAME) == 0 && (kernelnames[i] != NULL)) { printf(": trying %s...\n", kernelnames[i]); } else { printf("\n"); boothowto |= RB_ASKNAME; } } (void)printf("Boot failed! Exiting to the Firmware.\n"); prom_halt(); }
/*ARGSUSED*/ int main(void *cookie, char **argv, int argc) { /* * bpath is the boot device path buffer. * bargs is the boot arguments buffer. */ static char bpath[OBP_MAXPATHLEN], bargs[OBP_MAXPATHLEN]; boolean_t user_specified_filename; prom_init("boot", cookie); fiximp(); system_check(); dprintf("\nboot: V%d /boot interface.\n", BO_VERSION); #ifdef HALTBOOT prom_enter_mon(); #endif /* HALTBOOT */ init_memlists(); #ifdef DEBUG_LISTS dprintf("Physmem avail:\n"); if (debug) print_memlist(pfreelistp); dprintf("Virtmem avail:\n"); if (debug) print_memlist(vfreelistp); dprintf("Phys installed:\n"); if (debug) print_memlist(pinstalledp); prom_enter_mon(); #endif /* DEBUG_LISTS */ /* * Initialize the default filename (exported as "default-name" and * used by kadb). */ set_default_filename(defname); /* * Parse the arguments ASAP in case there are any flags which may * affect execution. */ /* * filename is the path to the standalone. Initialize it to the empty * string so we can tell whether the user specified it in the * arguments. */ filename[0] = '\0'; /* * Fetch the boot arguments from the PROM and split the filename off * if it's there. */ init_bootargs(filename, sizeof (filename), bargs, sizeof (bargs)); /* * kadb was delivered as a standalone, and as such, people got used to * typing `boot kadb'. kmdb isn't a standalone - it is loaded by krtld * as just another kernel module. For compatibility, though, when we * see an attempt to `boot kadb' or `boot kmdb', we'll transform that * into a `boot -k' (or equivalent). */ if (strcmp(filename, "kmdb") == 0 || strcmp(filename, "kadb") == 0) { boothowto |= RB_KMDB; *filename = '\0'; /* let boot figure out which unix to use */ } bootflags(bargs, sizeof (bargs)); user_specified_filename = (filename[0] != '\0'); /* Fetch the boot path from the PROM. */ (void) strncpy(bpath, prom_bootpath(), sizeof (bpath) - 1); bpath[sizeof (bpath) - 1] = '\0'; dprintf("arch: %s\n", is_sun4v ? "sun4v" : "sun4u"); dprintf("bootpath: 0x%p %s\n", (void *)bpath, bpath); dprintf("bootargs: 0x%p %s\n", (void *)bargs, bargs); dprintf("filename: 0x%p %s\n", (void *)filename, filename); dprintf("kernname: 0x%p %s\n", (void *)kernname, kernname); /* * *v2path will be exported to the standalone as the boot-path boot * property. */ v2path = bpath; /* * Our memory lists should be "up" by this time */ setup_bootops(); /* * If bpath is a network card, set v2path to a copy of bpath with the * options stripped off. */ mangle_os_bootpath(bpath); /* * Not necessary on sun4v as nvram is virtual * and kept by the guest manager on the SP. */ if (!is_sun4v) { retain_nvram_page(); } if (bootprog(bpath, bargs, user_specified_filename) == 0) { post_mountroot(filename, NULL); /*NOTREACHED*/ } return (0); }
/* * locore.s code calls bootstrap() just before calling main(), after double * mapping the kernel to high memory and setting up the trap base register. * We must finish mapping the kernel properly and glean any bootstrap info. */ void bootstrap(void) { extern uint8_t u0[]; extern struct consdev consdev_prom; #if NKSYMS || defined(DDB) || defined(MODULAR) struct btinfo_symtab *bi_sym; #else extern int end[]; #endif struct btinfo_boothowto *bi_howto; cn_tab = &consdev_prom; prom_init(); /* Find the number of CPUs as early as possible */ sparc_ncpus = find_cpus(); uvm_lwp_setuarea(&lwp0, (vaddr_t)u0); cpuinfo.master = 1; getcpuinfo(&cpuinfo, 0); curlwp = &lwp0; #if defined(SUN4M) || defined(SUN4D) /* Switch to sparc v8 multiply/divide functions on v8 machines */ if (cpu_arch == 8) { extern void sparc_v8_muldiv(void); sparc_v8_muldiv(); } #endif /* SUN4M || SUN4D */ #if !NKSYMS && !defined(DDB) && !defined(MODULAR) /* * We want to reuse the memory where the symbols were stored * by the loader. Relocate the bootinfo array which is loaded * above the symbols (we assume) to the start of BSS. Then * adjust kernel_top accordingly. */ bootinfo_relocate((void *)ALIGN((u_int)end)); #endif pmap_bootstrap(cpuinfo.mmu_ncontext, cpuinfo.mmu_nregion, cpuinfo.mmu_nsegment); #if !defined(MSGBUFSIZE) || MSGBUFSIZE == 8192 /* * Now that the kernel map has been set up, we can enable * the message buffer at the first physical page in the * memory bank where we were loaded. There are 8192 * bytes available for the buffer at this location (see the * comment in locore.s at the top of the .text segment). */ initmsgbuf((void *)KERNBASE, 8192); #endif #if defined(SUN4M) /* * sun4m bootstrap is complex and is totally different for "normal" 4m * and for microSPARC-IIep - so it's split into separate functions. */ if (CPU_ISSUN4M) { #if !defined(MSIIEP) bootstrap4m(); #else bootstrapIIep(); #endif } #endif /* SUN4M */ #if defined(SUN4) || defined(SUN4C) if (CPU_ISSUN4 || CPU_ISSUN4C) { /* Map Interrupt Enable Register */ pmap_kenter_pa(INTRREG_VA, INT_ENABLE_REG_PHYSADR | PMAP_NC | PMAP_OBIO, VM_PROT_READ | VM_PROT_WRITE, 0); pmap_update(pmap_kernel()); /* Disable all interrupts */ *((unsigned char *)INTRREG_VA) = 0; } #endif /* SUN4 || SUN4C */ #if NKSYMS || defined(DDB) || defined(MODULAR) if ((bi_sym = lookup_bootinfo(BTINFO_SYMTAB)) != NULL) { if (bi_sym->ssym < KERNBASE) { /* Assume low-loading boot loader */ bi_sym->ssym += KERNBASE; bi_sym->esym += KERNBASE; } ksyms_addsyms_elf(bi_sym->nsym, (void*)bi_sym->ssym, (void*)bi_sym->esym); } #endif if ((bi_howto = lookup_bootinfo(BTINFO_BOOTHOWTO)) != NULL) { boothowto = bi_howto->boothowto; } }
int main(int argc, char *argv[]) { int error; char *file; u_long marks[MARK_MAX]; extern char start[]; /* top of stack (see srt0.S) */ vaddr_t bstart_va; prom_init(); mmu_init(); printf(">> OpenBSD BOOT %s\n", version); /* * Find the physical memory area that's in use by the boot loader. * Our stack grows down from label `start'; assume we need no more * than 16K of stack space. * The top of the boot loader is the next 4MB boundary. */ bstart_va = (vaddr_t)start - LOWSTACK; if (pmap_extract(bstart_va, &bstart) != 0) panic("can't figure out where we have been loaded"); if (bstart != bstart_va) compat = 0; bend = roundup(bstart, FOURMB); #ifdef DEBUG printf("bstart %p bend %p\n", bstart, bend); #endif file = prom_bootfile; if (file == 0 || *file == 0) file = DEFAULT_KERNEL; for (;;) { if (prom_boothow & RB_ASKNAME) { printf("device[%s]: ", prom_bootdevice); gets(dbuf); if (dbuf[0]) prom_bootdevice = dbuf; printf("boot: "); gets(fbuf); if (fbuf[0]) file = fbuf; } printf("Booting %s\n", file); if ((error = loadk(file, marks)) == 0) break; printf("Cannot load %s: error=%d\n", file, error); prom_boothow |= RB_ASKNAME; } /* Note: args 2-4 not used due to conflicts with SunOS loaders */ (*(entry_t)marks[MARK_ENTRY])(cputyp == CPU_SUN4 ? PROM_LOADADDR : (u_long)promvec, 0, 0, 0, marks[MARK_END], DDB_MAGIC1); _rtt(); }
static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, MachineState *machine) { const char *cpu_model = machine->cpu_model; unsigned int i; void *iommu, *espdma, *ledma, *nvram; qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS], espdma_irq, ledma_irq; qemu_irq esp_reset, dma_enable; qemu_irq fdc_tc; qemu_irq *cpu_halt; unsigned long kernel_size; DriveInfo *fd[MAX_FD]; FWCfgState *fw_cfg; unsigned int num_vsimms; /* init CPUs */ if (!cpu_model) cpu_model = hwdef->default_cpu_model; for(i = 0; i < smp_cpus; i++) { cpu_devinit(cpu_model, i, hwdef->slavio_base, &cpu_irqs[i]); } for (i = smp_cpus; i < MAX_CPUS; i++) cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS); /* set up devices */ ram_init(0, machine->ram_size, hwdef->max_mem); /* models without ECC don't trap when missing ram is accessed */ if (!hwdef->ecc_base) { empty_slot_init(machine->ram_size, hwdef->max_mem - machine->ram_size); } prom_init(hwdef->slavio_base, bios_name); slavio_intctl = slavio_intctl_init(hwdef->intctl_base, hwdef->intctl_base + 0x10000ULL, cpu_irqs); for (i = 0; i < 32; i++) { slavio_irq[i] = qdev_get_gpio_in(slavio_intctl, i); } for (i = 0; i < MAX_CPUS; i++) { slavio_cpu_irq[i] = qdev_get_gpio_in(slavio_intctl, 32 + i); } if (hwdef->idreg_base) { idreg_init(hwdef->idreg_base); } if (hwdef->afx_base) { afx_init(hwdef->afx_base); } iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version, slavio_irq[30]); if (hwdef->iommu_pad_base) { /* On the real hardware (SS-5, LX) the MMU is not padded, but aliased. Software shouldn't use aliased addresses, neither should it crash when does. Using empty_slot instead of aliasing can help with debugging such accesses */ empty_slot_init(hwdef->iommu_pad_base,hwdef->iommu_pad_len); } espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[18], iommu, &espdma_irq, 0); ledma = sparc32_dma_init(hwdef->dma_base + 16ULL, slavio_irq[16], iommu, &ledma_irq, 1); if (graphic_depth != 8 && graphic_depth != 24) { error_report("Unsupported depth: %d", graphic_depth); exit (1); } num_vsimms = 0; if (num_vsimms == 0) { if (vga_interface_type == VGA_CG3) { if (graphic_depth != 8) { error_report("Unsupported depth: %d", graphic_depth); exit(1); } if (!(graphic_width == 1024 && graphic_height == 768) && !(graphic_width == 1152 && graphic_height == 900)) { error_report("Unsupported resolution: %d x %d", graphic_width, graphic_height); exit(1); } /* sbus irq 5 */ cg3_init(hwdef->tcx_base, slavio_irq[11], 0x00100000, graphic_width, graphic_height, graphic_depth); } else { /* If no display specified, default to TCX */ if (graphic_depth != 8 && graphic_depth != 24) { error_report("Unsupported depth: %d", graphic_depth); exit(1); } if (!(graphic_width == 1024 && graphic_height == 768)) { error_report("Unsupported resolution: %d x %d", graphic_width, graphic_height); exit(1); } tcx_init(hwdef->tcx_base, slavio_irq[11], 0x00100000, graphic_width, graphic_height, graphic_depth); } } for (i = num_vsimms; i < MAX_VSIMMS; i++) { /* vsimm registers probed by OBP */ if (hwdef->vsimm[i].reg_base) { empty_slot_init(hwdef->vsimm[i].reg_base, 0x2000); } } if (hwdef->sx_base) { empty_slot_init(hwdef->sx_base, 0x2000); } lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq); nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000, 8); slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus); slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14], display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1); /* Slavio TTYA (base+4, Linux ttyS0) is the first QEMU serial device Slavio TTYB (base+0, Linux ttyS1) is the second QEMU serial device */ escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15], serial_hds[0], serial_hds[1], ESCC_CLOCK, 1); cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1); if (hwdef->apc_base) { apc_init(hwdef->apc_base, cpu_halt[0]); } if (hwdef->fd_base) { /* there is zero or one floppy drive */ memset(fd, 0, sizeof(fd)); fd[0] = drive_get(IF_FLOPPY, 0, 0); sun4m_fdctrl_init(slavio_irq[22], hwdef->fd_base, fd, &fdc_tc); } else { fdc_tc = *qemu_allocate_irqs(dummy_fdc_tc, NULL, 1); } slavio_misc_init(hwdef->slavio_base, hwdef->aux1_base, hwdef->aux2_base, slavio_irq[30], fdc_tc); if (drive_get_max_bus(IF_SCSI) > 0) { fprintf(stderr, "qemu: too many SCSI bus\n"); exit(1); } esp_init(hwdef->esp_base, 2, espdma_memory_read, espdma_memory_write, espdma, espdma_irq, &esp_reset, &dma_enable); qdev_connect_gpio_out(espdma, 0, esp_reset); qdev_connect_gpio_out(espdma, 1, dma_enable); if (hwdef->cs_base) { sysbus_create_simple("SUNW,CS4231", hwdef->cs_base, slavio_irq[5]); } if (hwdef->dbri_base) { /* ISDN chip with attached CS4215 audio codec */ /* prom space */ empty_slot_init(hwdef->dbri_base+0x1000, 0x30); /* reg space */ empty_slot_init(hwdef->dbri_base+0x10000, 0x100); } if (hwdef->bpp_base) { /* parallel port */ empty_slot_init(hwdef->bpp_base, 0x20); } kernel_size = sun4m_load_kernel(machine->kernel_filename, machine->initrd_filename, machine->ram_size); nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, machine->kernel_cmdline, machine->boot_order, machine->ram_size, kernel_size, graphic_width, graphic_height, graphic_depth, hwdef->nvram_machine_id, "Sun4m"); if (hwdef->ecc_base) ecc_init(hwdef->ecc_base, slavio_irq[28], hwdef->ecc_version); fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, graphic_height); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (machine->kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR); pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, machine->kernel_cmdline); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, machine->kernel_cmdline); fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(machine->kernel_cmdline) + 1); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_order[0]); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); }
int main(void) { int error, i; char kernel[MAX_PROM_PATH]; const char *k; u_long marks[MARK_MAX], bootinfo; struct btinfo_symtab bi_sym; struct btinfo_boothowto bi_howto; void *arg; #ifdef HEAP_VARIABLE { extern char end[]; setheap((void *)ALIGN(end), (void *)0xffffffff); } #endif prom_init(); mmu_init(); printf(">> %s, Revision %s\n", bootprog_name, bootprog_rev); /* massage machine prom */ prom_patch(); /* * get default kernel. */ k = prom_getbootfile(); if (k != NULL && *k != '\0') { i = -1; /* not using the kernels */ strcpy(kernel, k); } else { i = 0; strcpy(kernel, kernels[i]); } k = prom_getbootpath(); if (k && *k) strcpy(prom_bootdevice, k); boothowto = bootoptions(prom_getbootargs()); for (;;) { /* * ask for a kernel first .. */ if (boothowto & RB_ASKNAME) { printf("device[%s] (\"halt\" to halt): ", prom_bootdevice); gets(dbuf); if (strcmp(dbuf, "halt") == 0) _rtt(); if (dbuf[0]) strcpy(prom_bootdevice, dbuf); printf("boot (press RETURN to try default list): "); gets(fbuf); if (fbuf[0]) strcpy(kernel, fbuf); else { boothowto &= ~RB_ASKNAME; i = 0; strcpy(kernel, kernels[i]); } } printf("Booting %s\n", kernel); if ((error = loadk(kernel, marks)) == 0) break; if (error != ENOENT) { printf("Cannot load %s: error=%d\n", kernel, error); boothowto |= RB_ASKNAME; } /* * if we have are not in askname mode, and we aren't using the * prom bootfile, try the next one (if it exits). otherwise, * go into askname mode. */ if ((boothowto & RB_ASKNAME) == 0 && i != -1 && kernels[++i]) { strcpy(kernel, kernels[i]); printf(": trying %s...\n", kernel); } else { printf("\n"); boothowto |= RB_ASKNAME; } } marks[MARK_END] = (((u_long)marks[MARK_END] + sizeof(u_long) - 1)) & (-sizeof(u_long)); arg = (prom_version() == PROM_OLDMON) ? (void *)PROM_LOADADDR : romp; /* Setup boot info structure at the end of the kernel image */ bootinfo = bi_init(marks[MARK_END] & loadaddrmask); /* Add kernel symbols to bootinfo */ bi_sym.nsym = marks[MARK_NSYM] & loadaddrmask; bi_sym.ssym = marks[MARK_SYM] & loadaddrmask; bi_sym.esym = marks[MARK_END] & loadaddrmask; bi_add(&bi_sym, BTINFO_SYMTAB, sizeof(bi_sym)); /* Add boothowto */ bi_howto.boothowto = boothowto; bi_add(&bi_howto, BTINFO_BOOTHOWTO, sizeof(bi_howto)); /* Add kernel path to bootinfo */ i = sizeof(struct btinfo_common) + strlen(kernel) + 1; /* Impose limit (somewhat arbitrary) */ if (i < BOOTINFO_SIZE / 2) { union { struct btinfo_kernelfile bi_file; char x[i]; } U; strcpy(U.bi_file.name, kernel); bi_add(&U.bi_file, BTINFO_KERNELFILE, i); } (*(entry_t)marks[MARK_ENTRY])(arg, 0, 0, 0, bootinfo, DDB_MAGIC2); _rtt(); }
static void sun4uv_init(MemoryRegion *address_space_mem, ram_addr_t RAM_size, const char *boot_devices, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, const struct hwdef *hwdef) { SPARCCPU *cpu; M48t59State *nvram; unsigned int i; uint64_t initrd_addr, initrd_size, kernel_addr, kernel_size, kernel_entry; PCIBus *pci_bus, *pci_bus2, *pci_bus3; ISABus *isa_bus; qemu_irq *ivec_irqs, *pbm_irqs; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; void *fw_cfg; /* init CPUs */ cpu = cpu_devinit(cpu_model, hwdef); /* set up devices */ ram_init(0, RAM_size); prom_init(hwdef->prom_addr, bios_name); ivec_irqs = qemu_allocate_irqs(cpu_set_ivec_irq, cpu, IVEC_MAX); pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, ivec_irqs, &pci_bus2, &pci_bus3, &pbm_irqs); pci_vga_init(pci_bus); // XXX Should be pci_bus3 isa_bus = pci_ebus_init(pci_bus, -1, pbm_irqs); i = 0; if (hwdef->console_serial_base) { serial_mm_init(address_space_mem, hwdef->console_serial_base, 0, NULL, 115200, serial_hds[i], DEVICE_BIG_ENDIAN); i++; } for(; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_isa_init(isa_bus, i, serial_hds[i]); } } for(i = 0; i < MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { parallel_init(isa_bus, i, parallel_hds[i]); } } for(i = 0; i < nb_nics; i++) pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); ide_drive_get(hd, MAX_IDE_BUS); pci_cmd646_ide_init(pci_bus, hd, 1); isa_create_simple(isa_bus, "i8042"); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } fdctrl_init_isa(isa_bus, fd); nvram = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); initrd_size = 0; initrd_addr = 0; kernel_size = sun4u_load_kernel(kernel_filename, initrd_filename, ram_size, &initrd_size, &initrd_addr, &kernel_addr, &kernel_entry); sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", RAM_size, boot_devices, kernel_addr, kernel_size, kernel_cmdline, initrd_addr, initrd_size, /* XXX: need an option to load a NVRAM image */ 0, graphic_width, graphic_height, graphic_depth, (uint8_t *)&nd_table[0].macaddr); fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_entry); fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline) + 1); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0); } fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_devices[0]); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_DEPTH, graphic_depth); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); }
static void sun4uv_init(MemoryRegion *address_space_mem, MachineState *machine, const struct hwdef *hwdef) { SPARCCPU *cpu; Nvram *nvram; unsigned int i; uint64_t initrd_addr, initrd_size, kernel_addr, kernel_size, kernel_entry; PCIBus *pci_bus, *pci_bus2, *pci_bus3; ISABus *isa_bus; SysBusDevice *s; qemu_irq *ivec_irqs, *pbm_irqs; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; FWCfgState *fw_cfg; /* init CPUs */ cpu = cpu_devinit(machine->cpu_model, hwdef); /* set up devices */ ram_init(0, machine->ram_size); prom_init(hwdef->prom_addr, bios_name); ivec_irqs = qemu_allocate_irqs(cpu_set_ivec_irq, cpu, IVEC_MAX); pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, ivec_irqs, &pci_bus2, &pci_bus3, &pbm_irqs); pci_vga_init(pci_bus); // XXX Should be pci_bus3 isa_bus = pci_ebus_init(pci_bus, -1, pbm_irqs); i = 0; if (hwdef->console_serial_base) { serial_mm_init(address_space_mem, hwdef->console_serial_base, 0, NULL, 115200, serial_hds[i], DEVICE_BIG_ENDIAN); i++; } serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS); for(i = 0; i < nb_nics; i++) pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); ide_drive_get(hd, ARRAY_SIZE(hd)); pci_cmd646_ide_init(pci_bus, hd, 1); isa_create_simple(isa_bus, "i8042"); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } fdctrl_init_isa(isa_bus, fd); /* Map NVRAM into I/O (ebus) space */ nvram = m48t59_init(NULL, 0, 0, NVRAM_SIZE, 1968, 59); s = SYS_BUS_DEVICE(nvram); memory_region_add_subregion(get_system_io(), 0x2000, sysbus_mmio_get_region(s, 0)); initrd_size = 0; initrd_addr = 0; kernel_size = sun4u_load_kernel(machine->kernel_filename, machine->initrd_filename, ram_size, &initrd_size, &initrd_addr, &kernel_addr, &kernel_entry); sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", machine->ram_size, machine->boot_order, kernel_addr, kernel_size, machine->kernel_cmdline, initrd_addr, initrd_size, /* XXX: need an option to load a NVRAM image */ 0, graphic_width, graphic_height, graphic_depth, (uint8_t *)&nd_table[0].macaddr); fw_cfg = fw_cfg_init_io(BIOS_CFG_IOPORT); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_entry); fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (machine->kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(machine->kernel_cmdline) + 1); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, machine->kernel_cmdline); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0); } fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_order[0]); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_DEPTH, graphic_depth); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); }