コード例 #1
0
void
memory_manager_ut::test_root_page_table_x64_cr3()
{
    MockRepository mocks;
    setup_mm(mocks);

    RUN_UNITTEST_WITH_MOCKS(mocks, [&]
    {
        this->expect_true(g_pt->cr3() == 0x0000000ABCDEF001F);
    });
}
コード例 #2
0
void
memory_manager_ut::test_root_page_table_x64_init_success()
{
    MockRepository mocks;
    setup_mm(mocks);

    RUN_UNITTEST_WITH_MOCKS(mocks, [&]
    {
        this->expect_no_exception([&] { root_page_table_x64::instance(); });
    });
}
コード例 #3
0
void
memory_manager_ut::test_root_page_table_x64_map_failure()
{
    MockRepository mocks;
    setup_mm(mocks);

    RUN_UNITTEST_WITH_MOCKS(mocks, [&]
    {
        this->expect_exception([&] { g_pt->map(0, 0x54323000, x64::memory_attr::rw_wb); }, ""_ut_ffe);
        this->expect_exception([&] { g_pt->map(0x12347000, 0, x64::memory_attr::rw_wb); }, ""_ut_ffe);
        this->expect_exception([&] { g_pt->map(0x12347000, 0x54323000, 0); }, ""_ut_lee);
    });
}
コード例 #4
0
void
memory_manager_ut::test_root_page_table_x64_map_unmap_twice_success()
{
    MockRepository mocks;
    setup_mm(mocks);

    RUN_UNITTEST_WITH_MOCKS(mocks, [&]
    {
        this->expect_no_exception([&] { g_pt->map(0x12347000, 0x54323000, x64::memory_attr::rw_wb); });
        this->expect_no_exception([&] { g_pt->unmap(0x12347000); });
        this->expect_no_exception([&] { g_pt->unmap(0x12347000); });
    });
}
コード例 #5
0
void
memory_manager_ut::test_root_page_table_x64_map_add_md_failure()
{
    MockRepository mocks;
    auto &&mm = setup_mm(mocks);

    mocks.OnCall(mm, memory_manager_x64::add_md).Throw(std::runtime_error("error"));

    RUN_UNITTEST_WITH_MOCKS(mocks, [&]
    {
        this->expect_exception([&] { g_pt->map(0x12347000, 0x54323000, x64::memory_attr::rw_wb); }, ""_ut_ree);
    });
}
コード例 #6
0
void
memory_manager_ut::test_root_page_table_x64_init_failure()
{
    MockRepository mocks;
    auto &&mm = setup_mm(mocks);

    mocks.OnCall(mm, memory_manager_x64::add_md).With(0xDEADBEEF, _, _).Throw(std::runtime_error("error"));

    RUN_UNITTEST_WITH_MOCKS(mocks, [&]
    {
        this->expect_no_exception([&] { root_page_table_x64::instance(); });
        this->expect_true(g_terminate_called);
    });
}
コード例 #7
0
ファイル: main.c プロジェクト: lkundrak/elks
void start_kernel(void)
{
    seg_t base, end;

/* We set the scheduler up as task #0, and this as task #1 */

    setup_arch(&base, &end);
    mm_init(base, end);
    init_IRQ();
    init_console();

#if 0
    calibrate_delay();
#endif

    setup_mm();			/* Architecture specifics */
    tty_init();
    buffer_init();

#ifdef CONFIG_SOCKET
    sock_init();
#endif

    device_setup();
    inode_init();
    fs_init();
    sched_init();

    printk("ELKS version %s\n", system_utsname.release);

    task[0].t_kstackm = KSTACK_MAGIC;
    task[0].next_run = task[0].prev_run = &task[0];
    kfork_proc(&task[1], init_task);

    /* 
     * We are now the idle task. We won't run unless no other process can run.
     */
    while (1){
        schedule();
    }

}
コード例 #8
0
ファイル: setup.c プロジェクト: codercold/xen-4.4
/* C entry point for boot CPU */
void __init start_xen(unsigned long boot_phys_offset,
                      unsigned long fdt_paddr,
                      unsigned long cpuid)
{
    size_t fdt_size;
    int cpus, i;
    const char *cmdline;

    setup_cache();

    percpu_init_areas();
    set_processor_id(0); /* needed early, for smp_processor_id() */

    smp_clear_cpu_maps();

    /* This is mapped by head.S */
    device_tree_flattened = (void *)BOOT_FDT_VIRT_START
        + (fdt_paddr & ((1 << SECOND_SHIFT) - 1));
    fdt_size = device_tree_early_init(device_tree_flattened, fdt_paddr);

    cmdline = device_tree_bootargs(device_tree_flattened);
    early_printk("Command line: %s\n", cmdline);
    cmdline_parse(cmdline);

    setup_pagetables(boot_phys_offset, get_xen_paddr());
    setup_mm(fdt_paddr, fdt_size);

    vm_init();
    dt_unflatten_host_device_tree();
    dt_irq_xlate = gic_irq_xlate;

    dt_uart_init();
    console_init_preirq();

    system_state = SYS_STATE_boot;

    processor_id();

    platform_init();

    smp_init_cpus();
    cpus = smp_get_max_cpus();

    init_xen_time();

    gic_init();

    set_current((struct vcpu *)0xfffff000); /* debug sanity */
    idle_vcpu[0] = current;

    init_traps();

    setup_virt_paging();

    p2m_vmid_allocator_init();

    softirq_init();

    tasklet_subsys_init();

    init_IRQ();

    gic_route_ppis();
    gic_route_spis();

    init_maintenance_interrupt();
    init_timer_interrupt();

    timer_init();

    init_idle_domain();

    rcu_init();

    arch_init_memory();

    local_irq_enable();
    local_abort_enable();

    smp_prepare_cpus(cpus);

    initialize_keytable();

    console_init_postirq();

    do_presmp_initcalls();

    for_each_present_cpu ( i )
    {
        if ( (num_online_cpus() < cpus) && !cpu_online(i) )
        {
            int ret = cpu_up(i);
            if ( ret != 0 )
                printk("Failed to bring up CPU %u (error %d)\n", i, ret);
        }
    }

    printk("Brought up %ld CPUs\n", (long)num_online_cpus());
    /* TODO: smp_cpus_done(); */

    do_initcalls();

    /* Create initial domain 0. */
    dom0 = domain_create(0, 0, 0);
    if ( IS_ERR(dom0) || (alloc_dom0_vcpu0() == NULL) )
            panic("Error creating domain 0");

    dom0->is_privileged = 1;
    dom0->target = NULL;

    if ( construct_dom0(dom0) != 0)
            panic("Could not set up DOM0 guest OS");

    /* Scrub RAM that is still free and so may go to an unprivileged domain. */
    scrub_heap_pages();

    init_constructors();

    console_endboot();

    /* Hide UART from DOM0 if we're using it */
    serial_endboot();

    system_state = SYS_STATE_active;

    domain_unpause_by_systemcontroller(dom0);

    /* Switch on to the dynamically allocated stack for the idle vcpu
     * since the static one we're running on is about to be freed. */
    memcpy(idle_vcpu[0]->arch.cpu_info, get_cpu_info(),
           sizeof(struct cpu_info));
    switch_stack_and_jump(idle_vcpu[0]->arch.cpu_info, init_done);
}
コード例 #9
0
ファイル: setup.c プロジェクト: caomw/xen
/* C entry point for boot CPU */
void __init start_xen(unsigned long boot_phys_offset,
                      unsigned long fdt_paddr,
                      unsigned long cpuid)
{
    size_t fdt_size;
    int cpus, i;
    paddr_t xen_paddr;
    const char *cmdline;
    struct bootmodule *xen_bootmodule;
    struct domain *dom0;
    struct xen_arch_domainconfig config;

    setup_cache();

    percpu_init_areas();
    set_processor_id(0); /* needed early, for smp_processor_id() */

    set_current((struct vcpu *)0xfffff000); /* debug sanity */
    idle_vcpu[0] = current;

    setup_virtual_regions(NULL, NULL);
    /* Initialize traps early allow us to get backtrace when an error occurred */
    init_traps();

    smp_clear_cpu_maps();

    /* This is mapped by head.S */
    device_tree_flattened = (void *)BOOT_FDT_VIRT_START
        + (fdt_paddr & ((1 << SECOND_SHIFT) - 1));
    fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr);

    cmdline = boot_fdt_cmdline(device_tree_flattened);
    printk("Command line: %s\n", cmdline);
    cmdline_parse(cmdline);

    /* Register Xen's load address as a boot module. */
    xen_bootmodule = add_boot_module(BOOTMOD_XEN,
                             (paddr_t)(uintptr_t)(_start + boot_phys_offset),
                             (paddr_t)(uintptr_t)(_end - _start + 1), NULL);
    BUG_ON(!xen_bootmodule);

    xen_paddr = get_xen_paddr();
    setup_pagetables(boot_phys_offset, xen_paddr);

    /* Update Xen's address now that we have relocated. */
    printk("Update BOOTMOD_XEN from %"PRIpaddr"-%"PRIpaddr" => %"PRIpaddr"-%"PRIpaddr"\n",
           xen_bootmodule->start, xen_bootmodule->start + xen_bootmodule->size,
           xen_paddr, xen_paddr + xen_bootmodule->size);
    xen_bootmodule->start = xen_paddr;

    setup_mm(fdt_paddr, fdt_size);

    /* Parse the ACPI tables for possible boot-time configuration */
    acpi_boot_table_init();

    end_boot_allocator();

    vm_init();
    dt_unflatten_host_device_tree();

    init_IRQ();

    platform_init();

    preinit_xen_time();

    gic_preinit();

    arm_uart_init();
    console_init_preirq();
    console_init_ring();

    system_state = SYS_STATE_boot;

    processor_id();

    smp_init_cpus();
    cpus = smp_get_max_cpus();

    init_xen_time();

    gic_init();

    p2m_vmid_allocator_init();

    softirq_init();

    tasklet_subsys_init();


    xsm_dt_init();

    init_maintenance_interrupt();
    init_timer_interrupt();

    timer_init();

    init_idle_domain();

    rcu_init();

    arch_init_memory();

    local_irq_enable();
    local_abort_enable();

    smp_prepare_cpus(cpus);

    initialize_keytable();

    console_init_postirq();

    do_presmp_initcalls();

    for_each_present_cpu ( i )
    {
        if ( (num_online_cpus() < cpus) && !cpu_online(i) )
        {
            int ret = cpu_up(i);
            if ( ret != 0 )
                printk("Failed to bring up CPU %u (error %d)\n", i, ret);
        }
    }

    printk("Brought up %ld CPUs\n", (long)num_online_cpus());
    /* TODO: smp_cpus_done(); */

    setup_virt_paging();

    iommu_setup();

    do_initcalls();

    /*
     * It needs to be called after do_initcalls to be able to use
     * stop_machine (tasklets initialized via an initcall).
     */
    apply_alternatives_all();

    /* Create initial domain 0. */
    /* The vGIC for DOM0 is exactly emulating the hardware GIC */
    config.gic_version = XEN_DOMCTL_CONFIG_GIC_NATIVE;
    config.nr_spis = gic_number_lines() - 32;

    dom0 = domain_create(0, 0, 0, &config);
    if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) )
            panic("Error creating domain 0");

    dom0->is_privileged = 1;
    dom0->target = NULL;

    if ( construct_dom0(dom0) != 0)
            panic("Could not set up DOM0 guest OS");

    /* Scrub RAM that is still free and so may go to an unprivileged domain. */
    scrub_heap_pages();

    init_constructors();

    console_endboot();

    /* Hide UART from DOM0 if we're using it */
    serial_endboot();

    system_state = SYS_STATE_active;

    /* Must be done past setting system_state. */
    unregister_init_virtual_region();

    domain_unpause_by_systemcontroller(dom0);

    /* Switch on to the dynamically allocated stack for the idle vcpu
     * since the static one we're running on is about to be freed. */
    memcpy(idle_vcpu[0]->arch.cpu_info, get_cpu_info(),
           sizeof(struct cpu_info));
    switch_stack_and_jump(idle_vcpu[0]->arch.cpu_info, init_done);
}
コード例 #10
0
// mark as section .img.main.text, to be referenced in linker script
int __img_main_text __main(void){ 
      //char *p =  &_dsu_sbss;
      unsigned long mem,  i,j, k, ctx;
      struct leon_setup *args;
      void (*kernel)(unsigned long);
             
      main(); 
      
      /* kernel args at first PAGE, bootloader Pagetablehirarchy at second PAGE*/ 
      args = (struct leon_setup *) LEONSETUP_MEM_BASEADDR;
      mem = LEONSETUP_MEM_BASEADDR + PAGE_SIZE;
      args ->args[0] = 0;
      args ->freq_kh = BOOTLOADER_FREQ_KHZ;
      args ->uart_baud[0] = BOOTLOADER_BAUD;
      args ->uart_baud[1] = BOOTLOADER_BAUD;
      args ->root_dev = Root_RAM0;
      /* should be romfs */
      args ->root_mountflags_or = MS_RDONLY;
      args ->initrd_start = (unsigned long)(&initrd_start - LEONSETUP_MEM_BASEADDR);
      args ->initrd_size = &initrd_end-&initrd_start;
        
      /* copy from rom */    
      if ( (unsigned long)(&initrd_start) < LEONSETUP_MEM_BASEADDR ) {
	char *p1,*p2;
	args ->initrd_start = PAGE_ALIGN( ((unsigned long)(&kernel_end)) - KERNBASE) ;
	p1 = (char *)(args ->initrd_start + LEONSETUP_MEM_BASEADDR);
	p2 = &initrd_start;
	puts("* Copying rdimage from rom 0x%x to ram %x ...\r\n",p2,p1);
	for (i = 0, j = 0; i < args ->initrd_size;i++,j++) {
	  p1[i] = p2[i];
	  if (j > 50000) {puts(".");j = 0;}
	}
	puts ("\r\n");
      }

      /*Setting up Page Table Hirarchy*/
      puts("* Setting up Page Table Hirarchy\r\n");
      setup_mm(&mem,&ctx);
      
      /*Setting up Kernel params*/
      j = PAGE_ALIGN(LEONSETUP_MEM_BASEADDR);
      k = (LEONSETUP_MEM_BASEADDR + BOOTLOADER_ramsize) - j;
#ifdef CONFIG_BLK_DEV_INITRD


      sputs((char *)&args ->args[0] , PAGE_SIZE, " LD_LIBRARY_PATH=/lib initrd=0x%x,0x%x  ", //LD_LIBRARY_PATH=/lib
	    args ->initrd_start + LEONSETUP_MEM_BASEADDR,
	    args ->initrd_start + LEONSETUP_MEM_BASEADDR + args ->initrd_size);
 
      //console=ttyLeon0,38400n8r console=ttyLeon0,19200n8r console=tty
#endif
      
      puts("* calling kernel  with arguments: %s\r\n",(char *)&args ->args[0]);
      
      srmmu_set_ctable_ptr((unsigned long) ctx);
      srmmu_set_context(0);
      
      __asm__ __volatile__("flush\n\t");

      srmmu_set_mmureg(0x1); 
      kernel = (void (*)(unsigned long)) KERNBASE+LOAD_ADDR;
      kernel(KERNBASE);

      return 1;
}