void __po_hi_c_driver_rasta_common_init () { if (__po_hi_c_driver_rasta_common_is_init == 1) { __PO_HI_DEBUG_DEBUG ("[RASTA COMMON] RASTA already initialized, pass init\n"); return; } __PO_HI_DEBUG_DEBUG ("[RASTA COMMON] Init\n"); init_pci(); __PO_HI_DEBUG_DEBUG ("[RASTA COMMON] Initializing RASTA ..."); /* if (__po_hi_rasta_register() ){ __PO_HI_DEBUG_DEBUG (" ERROR !\n"); return; } */ if (rasta_register() ){ __PO_HI_DEBUG_DEBUG(" ERROR !\n"); return; } __PO_HI_DEBUG_DEBUG (" OK !\n"); __po_hi_c_driver_rasta_common_is_init = 1; }
void kmain(uint32_t magic, multiboot_info_t *mboot, uintptr_t ebp) { monitor_clear(); printf("Booting Dionysus!\n"); ASSERT(magic == MULTIBOOT_BOOTLOADER_MAGIC && "Not booted with multiboot."); ASSERT(mboot->flags & MULTIBOOT_INFO_MEMORY && "No memory info."); ASSERT(mboot->flags & MULTIBOOT_INFO_MEM_MAP && "No memory map."); printf("Initializing GDT\n"); init_gdt(); printf("Initializing IDT\n"); init_idt(); // Check for modules if (mboot->flags & MULTIBOOT_INFO_MODS && mboot->mods_count) { multiboot_module_t *mods = (multiboot_module_t *)mboot->mods_addr; placement_address = mods[mboot->mods_count - 1].mod_end + KERNEL_BASE; } printf("Setting up paging\n"); init_paging(mboot->mem_lower + mboot->mem_upper, mboot->mmap_addr, mboot->mmap_length); printf("Initializing timers\n"); init_time(); init_timer(); printf("Starting task scheduling\n"); init_tasking(ebp); init_syscalls(); printf("Initializing vfs\n"); init_vfs(); printf("Initializing driver subsystem\n"); init_blockdev(); init_chardev(); init_term(); printf("Enumerating PCI bus(ses)\n"); init_pci(); dump_pci(); init_devfs(); ASSERT(mount(NULL, "/dev", "devfs", 0) == 0); init_ide(); halt(); }
void kernel_main(char boot_disk_id, void *memory_map, BootModuleInfo *boot_module_list) { init_memory_manager(memory_map); init_tty(); clear(); init_interrupts(); init_pci(); int arr[10000]; textcolor(2); printf("Structure size: %d\n",sizeof(arr)); printf("kernel_page_dir = 0x%x\n", kernel_page_dir); printf("memory_size = %d MB\n", memory_size / 1024 / 1024); printf("get_page_info(kernel_page_dir, 0xB8000) = 0x%x\n", get_page_info(kernel_page_dir, (void*)0xB8000)); }
static void vm_reset_vdevs(struct vmctx *ctx) { /* * The current virtual devices doesn't define virtual * device reset function. So we call vdev deinit/init * pairing to emulate the device reset operation. * * pci/ioapic deinit/init is needed because of dependency * of pci irq allocation/free. * * acpi build is necessary because irq for each vdev * could be assigned with different number after reset. */ atkbdc_deinit(ctx); if (debugexit_enabled) deinit_debugexit(); vhpet_deinit(ctx); vpit_deinit(ctx); vrtc_deinit(ctx); deinit_pci(ctx); pci_irq_deinit(ctx); ioapic_deinit(); pci_irq_init(ctx); atkbdc_init(ctx); vrtc_init(ctx); vpit_init(ctx); vhpet_init(ctx); if (debugexit_enabled) init_debugexit(); ioapic_init(ctx); init_pci(ctx); if (acpi) { acpi_build(ctx, guest_ncpus); } }
int __po_hi_driver_xc4v_fpga_initialize() { int ret; int instance = 0; int pbus = 0; int pdev = 0; int pfun = 0; init_pci (); ret = BSP_pciFindDevice (__PO_HI_DRIVER_XC4V_VENDOR_ID, __PO_HI_DRIVER_XC4V_DEVICE_ID, instance, &pbus, &pdev, &pfun); if (ret != 0) { __DEBUGMSG ("Device not found, return =%d\n"); return 0; } else { __DEBUGMSG ("Device found, bus=0x%x, dev=0x%x, fun=0x%x\n", pbus, pdev, pfun); } pci_read_config_dword(pbus, pdev, pfun, 0x10, &__po_hi_driver_xc4v_bar0); __DEBUGMSG ("Configuration, bar0=0x%x\n", __po_hi_driver_xc4v_bar0); /* * The three lines above are equivalent to the Configure_XC4V * Ada procedure */ __po_hi_driver_xc4v_fpga_set_page0_register (0x80000000); __po_hi_driver_xc4v_fpga_set_grpci_mmap (0x400, 0x40000000); __po_hi_driver_xc4v_fpga_set_page1_register (0x400, 0x40000000); /* * Equivalent to the Configure_IO_Port procedure of Ada */ __po_hi_driver_xc4v_fpga_configure_ioports (); __po_hi_driver_xc4v_drv_addr = __po_hi_driver_xc4v_bar0; return 1; }
/** * This is the architecture-independent kernel entry point. Before it is * called, architecture-specific code has done the bare minimum initialization * necessary. This function initializes the kernel and its various subsystems. * It calls back to architecture-specific code at several well defined points, * which all architectures must implement (e.g., setup_arch()). * * \callgraph */ void start_kernel() { unsigned int cpu; unsigned int timeout; int status; /* * Parse the kernel boot command line. * This is where boot-time configurable variables get set, * e.g., the ones with param() and DRIVER_PARAM() specifiers. */ parse_params(lwk_command_line); /* * Initialize the console subsystem. * printk()'s will be visible after this. */ console_init(); /* * Hello, Dave. */ printk("%s", lwk_banner); printk(KERN_DEBUG "%s\n", lwk_command_line); sort_exception_table(); /* * Do architecture specific initialization. * This detects memory, CPUs, architecture dependent irqs, etc. */ setup_arch(); /* * Setup the architecture independent interrupt handling. */ irq_init(); /* * Initialize the kernel memory subsystem. Up until now, the simple * boot-time memory allocator (bootmem) has been used for all dynamic * memory allocation. Here, the bootmem allocator is destroyed and all * of the free pages it was managing are added to the kernel memory * pool (kmem) or the user memory pool (umem). * * After this point, any use of the bootmem allocator will cause a * kernel panic. The normal kernel memory subsystem API should be used * instead (e.g., kmem_alloc() and kmem_free()). */ mem_subsys_init(); /* * Initialize the address space management subsystem. */ aspace_subsys_init(); sched_init_runqueue(0); /* This CPUs scheduler state + idle task */ sched_add_task(current); /* now safe to call schedule() */ /* * Initialize the task scheduling subsystem. */ core_timer_init(0); /* Start the kernel filesystems */ kfs_init(); /* * Initialize the random number generator. */ rand_init(); workq_init(); /* * Boot all of the other CPUs in the system, one at a time. */ printk(KERN_INFO "Number of CPUs detected: %d\n", num_cpus()); for_each_cpu_mask(cpu, cpu_present_map) { /* The bootstrap CPU (that's us) is already booted. */ if (cpu == 0) { cpu_set(cpu, cpu_online_map); continue; } printk(KERN_DEBUG "Booting CPU %u.\n", cpu); arch_boot_cpu(cpu); /* Wait for ACK that CPU has booted (5 seconds max). */ for (timeout = 0; timeout < 50000; timeout++) { if (cpu_isset(cpu, cpu_online_map)) break; udelay(100); } if (!cpu_isset(cpu, cpu_online_map)) panic("Failed to boot CPU %d.\n", cpu); } /* * Initialize the PCI subsystem. */ init_pci(); /* * Enable external interrupts. */ local_irq_enable(); #ifdef CONFIG_NETWORK /* * Bring up any network devices. */ netdev_init(); #endif #ifdef CONFIG_CRAY_GEMINI driver_init_list("net", "gemini"); #endif #ifdef CONFIG_BLOCK_DEVICE /** * Initialize the block devices */ blkdev_init(); #endif mcheck_init_late(); /* * And any modules that need to be started. */ driver_init_by_name( "module", "*" ); #ifdef CONFIG_KGDB /* * Stop eary (before "late" devices) in KGDB if requested */ kgdb_initial_breakpoint(); #endif /* * Bring up any late init devices. */ driver_init_by_name( "late", "*" ); /* * Bring up the Linux compatibility layer, if enabled. */ linux_init(); #ifdef CONFIG_DEBUG_HW_NOISE /* Measure noise/interference in the underlying hardware/VMM */ extern void measure_noise(int, uint64_t); measure_noise(0, 0); #endif /* * Start up user-space... */ printk(KERN_INFO "Loading initial user-level task (init_task)...\n"); if ((status = create_init_task()) != 0) panic("Failed to create init_task (status=%d).", status); current->state = TASK_EXITED; schedule(); /* This should not return */ BUG(); }
int main(int argc, char *argv[]) { int c, error, gdb_port, err, bvmcons; int max_vcpus; struct vmctx *ctx; uint64_t rip; size_t memsize; bvmcons = 0; progname = basename(argv[0]); gdb_port = 0; guest_ncpus = 1; memsize = 256 * MB; while ((c = getopt(argc, argv, "abehwAHIPWp:g:c:s:S:m:l:")) != -1) { switch (c) { case 'a': disable_x2apic = 1; break; case 'A': acpi = 1; break; case 'b': bvmcons = 1; break; case 'p': pincpu = atoi(optarg); break; case 'c': guest_ncpus = atoi(optarg); break; case 'g': gdb_port = atoi(optarg); break; case 'l': if (lpc_device_parse(optarg) != 0) { errx(EX_USAGE, "invalid lpc device " "configuration '%s'", optarg); } break; case 's': if (pci_parse_slot(optarg, 0) != 0) exit(1); else break; case 'S': if (pci_parse_slot(optarg, 1) != 0) exit(1); else break; case 'm': error = vm_parse_memsize(optarg, &memsize); if (error) errx(EX_USAGE, "invalid memsize '%s'", optarg); break; case 'H': guest_vmexit_on_hlt = 1; break; case 'I': /* * The "-I" option was used to add an ioapic to the * virtual machine. * * An ioapic is now provided unconditionally for each * virtual machine and this option is now deprecated. */ break; case 'P': guest_vmexit_on_pause = 1; break; case 'e': strictio = 1; break; case 'w': strictmsr = 0; break; case 'W': virtio_msix = 0; break; case 'h': usage(0); default: usage(1); } } argc -= optind; argv += optind; if (argc != 1) usage(1); vmname = argv[0]; ctx = vm_open(vmname); if (ctx == NULL) { perror("vm_open"); exit(1); } max_vcpus = num_vcpus_allowed(ctx); if (guest_ncpus > max_vcpus) { fprintf(stderr, "%d vCPUs requested but only %d available\n", guest_ncpus, max_vcpus); exit(1); } fbsdrun_set_capabilities(ctx, BSP); err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL); if (err) { fprintf(stderr, "Unable to setup memory (%d)\n", err); exit(1); } init_mem(); init_inout(); legacy_irq_init(); rtc_init(ctx); /* * Exit if a device emulation finds an error in it's initilization */ if (init_pci(ctx) != 0) exit(1); if (gdb_port != 0) init_dbgport(gdb_port); if (bvmcons) init_bvmcons(); error = vm_get_register(ctx, BSP, VM_REG_GUEST_RIP, &rip); assert(error == 0); /* * build the guest tables, MP etc. */ mptable_build(ctx, guest_ncpus); if (acpi) { error = acpi_build(ctx, guest_ncpus); assert(error == 0); } /* * Change the proc title to include the VM name. */ setproctitle("%s", vmname); /* * Add CPU 0 */ fbsdrun_addcpu(ctx, BSP, rip); /* * Head off to the main event dispatch loop */ mevent_dispatch(); exit(1); }
static int vm_init_vdevs(struct vmctx *ctx) { int ret; init_mem(); init_inout(); pci_irq_init(ctx); atkbdc_init(ctx); ioapic_init(ctx); /* * We don't care ioc_init return value so far. * Will add return value check once ioc is full function. */ ret = ioc_init(ctx); ret = vrtc_init(ctx); if (ret < 0) goto vrtc_fail; ret = vpit_init(ctx); if (ret < 0) goto vpit_fail; ret = vhpet_init(ctx); if (ret < 0) goto vhpet_fail; sci_init(ctx); if (debugexit_enabled) init_debugexit(); ret = monitor_init(ctx); if (ret < 0) goto monitor_fail; ret = init_pci(ctx); if (ret < 0) goto pci_fail; init_vtpm2(ctx); return 0; pci_fail: monitor_close(); monitor_fail: if (debugexit_enabled) deinit_debugexit(); vhpet_deinit(ctx); vhpet_fail: vpit_deinit(ctx); vpit_fail: vrtc_deinit(ctx); vrtc_fail: ioc_deinit(ctx); atkbdc_deinit(ctx); pci_irq_deinit(ctx); ioapic_deinit(); return -1; }
int main(int argc, char *argv[]) { int c, error, gdb_port, err, bvmcons; int max_vcpus, mptgen, memflags; int rtc_localtime; struct vmctx *ctx; uint64_t rip; size_t memsize; char *optstr; bvmcons = 0; progname = basename(argv[0]); gdb_port = 0; guest_ncpus = 1; memsize = 256 * MB; mptgen = 1; rtc_localtime = 1; memflags = 0; optstr = "abehuwxACHIPSWYp:g:c:s:m:l:U:"; while ((c = getopt(argc, argv, optstr)) != -1) { switch (c) { case 'a': x2apic_mode = 0; break; case 'A': acpi = 1; break; case 'b': bvmcons = 1; break; case 'p': if (pincpu_parse(optarg) != 0) { errx(EX_USAGE, "invalid vcpu pinning " "configuration '%s'", optarg); } break; case 'c': guest_ncpus = atoi(optarg); break; case 'C': memflags |= VM_MEM_F_INCORE; break; case 'g': gdb_port = atoi(optarg); break; case 'l': if (lpc_device_parse(optarg) != 0) { errx(EX_USAGE, "invalid lpc device " "configuration '%s'", optarg); } break; case 's': if (pci_parse_slot(optarg) != 0) exit(1); else break; case 'S': memflags |= VM_MEM_F_WIRED; break; case 'm': error = vm_parse_memsize(optarg, &memsize); if (error) errx(EX_USAGE, "invalid memsize '%s'", optarg); break; case 'H': guest_vmexit_on_hlt = 1; break; case 'I': /* * The "-I" option was used to add an ioapic to the * virtual machine. * * An ioapic is now provided unconditionally for each * virtual machine and this option is now deprecated. */ break; case 'P': guest_vmexit_on_pause = 1; break; case 'e': strictio = 1; break; case 'u': rtc_localtime = 0; break; case 'U': guest_uuid_str = optarg; break; case 'w': strictmsr = 0; break; case 'W': virtio_msix = 0; break; case 'x': x2apic_mode = 1; break; case 'Y': mptgen = 0; break; case 'h': usage(0); default: usage(1); } } argc -= optind; argv += optind; if (argc != 1) usage(1); vmname = argv[0]; ctx = do_open(vmname); if (guest_ncpus < 1) { fprintf(stderr, "Invalid guest vCPUs (%d)\n", guest_ncpus); exit(1); } max_vcpus = num_vcpus_allowed(ctx); if (guest_ncpus > max_vcpus) { fprintf(stderr, "%d vCPUs requested but only %d available\n", guest_ncpus, max_vcpus); exit(1); } fbsdrun_set_capabilities(ctx, BSP); vm_set_memflags(ctx, memflags); err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL); if (err) { fprintf(stderr, "Unable to setup memory (%d)\n", errno); exit(1); } error = init_msr(); if (error) { fprintf(stderr, "init_msr error %d", error); exit(1); } init_mem(); init_inout(); pci_irq_init(ctx); ioapic_init(ctx); rtc_init(ctx, rtc_localtime); sci_init(ctx); /* * Exit if a device emulation finds an error in it's initilization */ if (init_pci(ctx) != 0) exit(1); if (gdb_port != 0) init_dbgport(gdb_port); if (bvmcons) init_bvmcons(); if (lpc_bootrom()) { if (vm_set_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, 1)) { fprintf(stderr, "ROM boot failed: unrestricted guest " "capability not available\n"); exit(1); } error = vcpu_reset(ctx, BSP); assert(error == 0); } error = vm_get_register(ctx, BSP, VM_REG_GUEST_RIP, &rip); assert(error == 0); /* * build the guest tables, MP etc. */ if (mptgen) { error = mptable_build(ctx, guest_ncpus); if (error) exit(1); } error = smbios_build(ctx); assert(error == 0); if (acpi) { error = acpi_build(ctx, guest_ncpus); assert(error == 0); } if (lpc_bootrom()) fwctl_init(); /* * Change the proc title to include the VM name. */ setproctitle("%s", vmname); /* * Add CPU 0 */ fbsdrun_addcpu(ctx, BSP, BSP, rip); /* * Head off to the main event dispatch loop */ mevent_dispatch(); exit(1); }