/*ARGSUSED*/ int openmem(int trystart) { initpkey(); shmid = shmget(pkey, SHMFLAG, 0); if (shmid < 0) { /* Could not find the shared memory */ if (errno != ENOENT) { /* Error other not created yet */ perror("shmget"); exit(1); } if (trystart==1){ /* Create the memory */ startdaemon(); } else if (trystart < 0){ /* Just checking if it exists */ return 0; } else { /* Wanted to use it, but... */ fprintf(stderr,"Warning: Daemon not running!\n"); exit(1); } shmid = shmget(pkey, SHMFLAG, 0); if (shmid < 0) { /* This is a bummer of an error */ ERROR(1, ("Daemon not running (err:%d)\n",errno)); exit(1); } } sharedMemory = (struct memory *) shmat(shmid, 0, 0); if (sharedMemory == (struct memory *) -1) { printf("Error number: %d\n",errno); perror("shared memory"); exit(1); } setup_memory(sharedMemory); opensem(); return 1; }
void __init start_vmm ( const struct multiboot_info *mbi ) { //Initialize serial port COM1, this must be done before calling outf setup_serial(); outf("\n\n\n!!!!!!!!!!!BEGIN!!!!!!!!!!!\n\n\n"); //Parse the command line that user pass to GRUB struct cmdline_option opt = parse_cmdline ( mbi ); //Set up memory layout and store the layout in pml struct pmem_layout pml; setup_memory(mbi, &opt, &pml); struct vm_info vm; vm_create (&vm, pml.vmm_pmem_start, opt.vmm_pmem_size, &(pml.e820)); outf("\n++++++ New virtual machine created. Going to start the VM\n"); vm_init (&vm); //Debug //e820_print_map(&(pml.e820)); outf ("\n++++++ Going to GRUB for the 2nd time\n"); vm_boot (&vm); }
void __init setup_arch(char **cmdline_p) { *cmdline_p = cmd_line; console_verbose(); unflatten_device_tree(); /* NOTE I think that this function is not necessary to call */ /* irq_early_init(); */ setup_cpuinfo(); microblaze_cache_init(); setup_memory(); #ifdef CONFIG_EARLY_PRINTK /* remap early console to virtual address */ remap_early_printk(); #endif xilinx_pci_init(); #if defined(CONFIG_SELFMOD_INTC) || defined(CONFIG_SELFMOD_TIMER) printk(KERN_NOTICE "Self modified code enable\n"); #endif #ifdef CONFIG_VT #if defined(CONFIG_XILINX_CONSOLE) conswitchp = &xil_con; #elif defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con; #endif #endif }
void __init setup_arch(char **cmdline_p) { *cmdline_p = boot_command_line; console_verbose(); unflatten_device_tree(); setup_cpuinfo(); microblaze_cache_init(); setup_memory(); #ifdef CONFIG_EARLY_PRINTK /* remap early console to virtual address */ remap_early_printk(); #endif xilinx_pci_init(); #if defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con; #endif }
static void *fb(void) { if (!fb_vaddr) setup_memory(); return fb_vaddr; }
void __init setup_arch(char **cmdline_p) { *cmdline_p = cmd_line; console_verbose(); unflatten_device_tree(); setup_cpuinfo(); microblaze_cache_init(); setup_memory(); #ifdef CONFIG_EARLY_PRINTK /* */ remap_early_printk(); #endif xilinx_pci_init(); #if defined(CONFIG_SELFMOD_INTC) || defined(CONFIG_SELFMOD_TIMER) printk(KERN_NOTICE "Self modified code enable\n"); #endif #ifdef CONFIG_VT #if defined(CONFIG_XILINX_CONSOLE) conswitchp = &xil_con; #elif defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con; #endif #endif }
int main_name (int argc, const char ** argv) { init_exit_scheme (); scheme_program_name = (argv[0]); initial_C_stack_pointer = ((void *) (&argc)); #ifdef __WIN32__ NT_initialize_win32_system_utilities (); #endif #ifdef PREALLOCATE_HEAP_MEMORY PREALLOCATE_HEAP_MEMORY (); #endif #ifdef __OS2__ OS2_initialize_early (); #endif obstack_init (&scratch_obstack); obstack_init (&ffi_obstack); dstack_initialize (); transaction_initialize (); reload_saved_string = 0; reload_saved_string_length = 0; read_command_line_options (argc, argv); setup_memory ((BLOCKS_TO_BYTES (option_heap_size)), (BLOCKS_TO_BYTES (option_stack_size)), (BLOCKS_TO_BYTES (option_constant_size))); initialize_primitives (); compiler_initialize (option_fasl_file != 0); OS_initialize (); start_scheme (); termination_init_error (); return (0); }
void main(void) { struct mem_timings *mem; void *entry; int is_resume = (get_wakeup_state() != IS_NOT_WAKEUP); /* Clock must be initialized before console_init, otherwise you may need * to re-initialize serial console drivers again. */ mem = setup_clock(); console_init(); setup_power(is_resume); setup_memory(mem, is_resume); if (is_resume) { wakeup(); } setup_storage(); setup_gpio(); setup_graphics(); /* Set SPI (primary CBFS media) clock to 50MHz and configure pinmux. */ exynos_pinmux_spi1(); clock_set_rate(PERIPH_ID_SPI1, 50000000); cbmem_initialize_empty(); entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA, "fallback/coreboot_ram"); stage_exit(entry); }
/* * Name: kernel_main * * Description: Main kernel loop. Never returns. * */ void kernel_main() { terminal_initialize(); setup_memory(); unsigned char *ptr = kmalloc(4096, GFP_KERNEL); printk("%p --> %p\n", ptr, *ptr); unsigned long val = 0xdeadbeef; memcpy(ptr, &val, 4); dumpBytes(ptr, 4); printk("pages used %p out of %p\n", mem_stats.nr_used_frames, mem_stats.nr_total_frames); unsigned long virt_addr = boot_kmalloc(); printk("boot_kmalloc = %p\n", virt_addr); virt_addr = boot_kmalloc(); printk("boot_kmalloc = %p\n", virt_addr); ptr = (unsigned char *) 0xc0000000; *ptr = 0x77; // Kernel never returns from this function. while (1) {} }
void main(void) { extern struct mem_timings mem_timings; void *entry; int is_resume = (get_wakeup_state() != IS_NOT_WAKEUP); /* Clock must be initialized before console_init, otherwise you may need * to re-initialize serial console drivers again. */ system_clock_init(); console_init(); setup_power(is_resume); setup_memory(&mem_timings, is_resume); primitive_mem_test(); if (is_resume) { wakeup(); } setup_storage(); setup_gpio(); setup_ec(); simple_spi_test(); /* Set SPI (primary CBFS media) clock to 50MHz. */ /* if this is uncommented SPI will not work correctly. */ clock_set_rate(PERIPH_ID_SPI1, 50000000); simple_spi_test(); entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA, "fallback/coreboot_ram"); simple_spi_test(); stage_exit(entry); }
void main(void) { extern struct mem_timings mem_timings; int is_resume = (get_wakeup_state() != IS_NOT_WAKEUP); int power_init_failed; exynos5420_config_smp(); power_init_failed = setup_power(is_resume); timestamp_init(timestamp_get()); timestamp_add_now(TS_START_ROMSTAGE); /* Clock must be initialized before console_init, otherwise you may need * to re-initialize serial console drivers again. */ system_clock_init(); exynos_pinmux_uart3(); console_init(); exception_init(); if (power_init_failed) die("Failed to intialize power.\n"); /* re-initialize PMIC I2C channel after (re-)setting system clocks */ i2c_init(PMIC_I2C_BUS, 1000000, 0x00); /* 1MHz */ timestamp_add_now(TS_BEFORE_INITRAM); setup_memory(&mem_timings, is_resume); timestamp_add_now(TS_AFTER_INITRAM); primitive_mem_test(); trustzone_init(); if (is_resume) { wakeup(); } setup_gpio(); setup_ec(); simple_spi_test(); /* Set SPI (primary CBFS media) clock to 50MHz. */ /* if this is uncommented SPI will not work correctly. */ clock_set_rate(PERIPH_ID_SPI1, 50000000); exynos_pinmux_spi1(); simple_spi_test(); cbmem_initialize_empty(); simple_spi_test(); timestamp_add_now(TS_END_ROMSTAGE); run_ramstage(); }
int init_cpu(farcpu *cpu, u32int mem_size) { u32int tcpum = setup_memory(mem_size); cpu_reset(cpu); cpu->memory = tcpum; cpu->memory_size = mem_size; cpu->speed = OP4096S; //might as well set it for when it is actually used return 1; }
void __init setup_arch(char **cmdline_p) { /* * print what head.S has found out about the machine */ #ifndef CONFIG_64BIT printk((MACHINE_IS_VM) ? "We are running under VM (31 bit mode)\n" : "We are running native (31 bit mode)\n"); printk((MACHINE_HAS_IEEE) ? "This machine has an IEEE fpu\n" : "This machine has no IEEE fpu\n"); #else /* CONFIG_64BIT */ printk((MACHINE_IS_VM) ? "We are running under VM (64 bit mode)\n" : "We are running native (64 bit mode)\n"); #endif /* CONFIG_64BIT */ /* Save unparsed command line copy for /proc/cmdline */ strlcpy(boot_command_line, COMMAND_LINE, COMMAND_LINE_SIZE); *cmdline_p = COMMAND_LINE; *(*cmdline_p + COMMAND_LINE_SIZE - 1) = '\0'; ROOT_DEV = Root_RAM0; init_mm.start_code = PAGE_OFFSET; init_mm.end_code = (unsigned long) &_etext; init_mm.end_data = (unsigned long) &_edata; init_mm.brk = (unsigned long) &_end; if (MACHINE_HAS_MVCOS) memcpy(&uaccess, &uaccess_mvcos, sizeof(uaccess)); else memcpy(&uaccess, &uaccess_std, sizeof(uaccess)); parse_early_param(); setup_memory_end(); setup_addressing_mode(); setup_memory(); setup_resources(); setup_lowcore(); cpu_init(); __cpu_logical_map[0] = S390_lowcore.cpu_data.cpu_addr; smp_setup_cpu_possible_map(); /* * Create kernel page tables and switch to virtual addressing. */ paging_init(); /* Setup default console */ conmode_default(); }
static void lcd_enable(void) { setup_memory(); if (clcd_init()) { printf("CLCD init failed!\n"); return; } }
void start_kernel(){ setup_memory(); init_video(); flush_tlb(); int *s = (int *)video.fb; int i; for(i = 0; i < video.width * video.height; ++i){ *(s + i) = 0x3242; } while(1){} }
/** * @brief Función principal del kernel. Esta rutina recibe el control del * codigo en ensamblador de start.S. * * @param magic Número mágico pasado por GRUB al código de start,S * @param multiboot_info Apuntador a la estructura de información multiboot */ void cmain(unsigned int magic, void * multiboot_info) { unsigned int i; unsigned int allocations; char * addr; /* Referencia a la estructura de datos multiboot_header en start.S */ extern multiboot_header_t multiboot_header; multiboot_info_location = (unsigned int) multiboot_info; cls(); /* Configurar y cargar la GDT definida en pm.c*/ setup_gdt(); /* Configurar y cargar la IDT definida en idt.c */ setup_idt(); /* Configurar las excepciones definidas en IA-32 */ setup_exceptions(); /* Configurar las IRQ */ setup_irq(); /* Configurar el mapa de bits de memoria del kernel */ setup_memory(); printf("Kernel started\n"); /* Probar la gestion de unidades de memoria */ /* Reservar una unidad */ addr = allocate_unit(); printf("Allocated address: %x = %d\n", addr, addr); addr = allocate_unit_region(0xFFFF); printf("Allocated region: %x\n", addr); addr = allocate_unit(); printf("Allocated address: %x\n", addr); printf("Last allocated address: %x, %u\n",addr, addr); inline_assembly("sti"); printf("Kernel finished\n"); }
void __init setup_arch(char **cmdline_p) { unsigned long max_low_pfn; config_BSP(&command_line[0], COMMAND_LINE_SIZE); /* detect System on Chip parameters */ detect_soc(); /* process 1's initial memory region is the kernel code/data */ init_mm.start_code = (unsigned long) &_stext; init_mm.end_code = (unsigned long) &_etext; init_mm.end_data = (unsigned long) &_edata; init_mm.brk = (unsigned long) &_end; #ifdef CONFIG_BLK_DEV_INITRD initrd_start = (unsigned long)&__initrd_start; initrd_end = (unsigned long)&__initrd_end; #endif /* setup bootmem allocator */ max_low_pfn = setup_memory(); /* paging_init() sets up the MMU and marks all pages as reserved */ paging_init(); #ifdef CONFIG_SERIAL_8250_CONSOLE // early_serial_console_init(command_line); RGD setup_early_serial8250_console(command_line); #endif #if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE) if(!conswitchp) conswitchp = &dummy_con; #endif *cmdline_p = command_line; /* Save command line copy for /proc/cmdline RGD removed 2.6.21*/ //memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); //saved_command_line[COMMAND_LINE_SIZE-1] = '\0'; /* fire up 8051 */ // printk("Starting 8051...\n"); // oc8051_init(); #ifndef CONFIG_OR32_ANONYMOUS printk("Linux/or32 port 2003-2005 OpenCores <*****@*****.**>\n"); #endif /* CONFIG_OR32_ANONYMOUS */ }
void __init setup_arch(char **cmdline_p) { ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV); boot_cpu_data.cpu_clock = M32R_CPUCLK; boot_cpu_data.bus_clock = M32R_BUSCLK; boot_cpu_data.timer_divide = M32R_TIMER_DIVIDE; #ifdef CONFIG_BLK_DEV_RAM rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK; rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0); rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0); #endif if (!MOUNT_ROOT_RDONLY) root_mountflags &= ~MS_RDONLY; #ifdef CONFIG_VT #if defined(CONFIG_VGA_CONSOLE) conswitchp = &vga_con; #elif defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con; #endif #endif #ifdef CONFIG_DISCONTIGMEM nodes_clear(node_online_map); node_set_online(0); node_set_online(1); #endif /* CONFIG_DISCONTIGMEM */ init_mm.start_code = (unsigned long) _text; init_mm.end_code = (unsigned long) _etext; init_mm.end_data = (unsigned long) _edata; init_mm.brk = (unsigned long) _end; code_resource.start = virt_to_phys(_text); code_resource.end = virt_to_phys(_etext)-1; data_resource.start = virt_to_phys(_etext); data_resource.end = virt_to_phys(_edata)-1; parse_mem_cmdline(cmdline_p); setup_memory(); paging_init(); }
void main(void) { struct mem_timings *mem; int is_resume = (get_wakeup_state() != IS_NOT_WAKEUP); timestamp_init(timestamp_get()); timestamp_add_now(TS_START_ROMSTAGE); /* Clock must be initialized before console_init, otherwise you may need * to re-initialize serial console drivers again. */ mem = setup_clock(); console_init(); exception_init(); setup_power(is_resume); timestamp_add_now(TS_BEFORE_INITRAM); setup_memory(mem, is_resume); timestamp_add_now(TS_AFTER_INITRAM); /* This needs to happen on normal boots and on resume. */ trustzone_init(); if (is_resume) { wakeup(); } setup_gpio(); setup_graphics(); /* Set SPI (primary CBFS media) clock to 50MHz and configure pinmux. */ exynos_pinmux_spi1(); clock_set_rate(PERIPH_ID_SPI1, 50000000); cbmem_initialize_empty(); timestamp_add_now(TS_END_ROMSTAGE); run_ramstage(); }
int main(void) { static const size_t default_initial_size = 655360; struct p_bench_specification spec; char *raw_mem = NULL; spec.current_size = default_initial_size; setup_memory(&spec.mem, &raw_mem, spec.current_size); for (const struct p_bench_item *item = benchmark_items; item->name != NULL; ++item) { struct item_data data; item_preface(&data, item); item->benchmark(&spec); item_done(&data, &spec, item->name); } return EXIT_SUCCESS; }
static void pl110_enable(void) { const char *s; setup_memory(); switch (type) { case PL110: s = "ARM AMBA PrimeCell PL110"; break; case PL111: s = "ARM AMBA PrimeCell PL111"; break; default: s = "Unknown"; break; } printf("Detected a '%s' device.\n", s); if (!fb_vaddr || !init(fb_paddr)) { printf("CLCD init failed!\n"); return; } }
int setupmem(void) { struct shmid_ds smbuf; initpkey(); /* Kill any existing segments */ if ((shmid = shmget(pkey, SHMFLAG , 0)) >= 0) { ERROR(2,("setupmem: Killing existing segment\n")); shmctl(shmid, IPC_RMID, (struct shmid_ds *) 0); } /* Get them memory id */ shmid = shmget(pkey, sizeof(struct memory), IPC_CREAT | 0777); if (shmid < 0) { ERROR(1,("setupmem: Can't open shared memory, error %d %i\n", (int)sizeof(struct memory), errno)); return 0; } /* Set memory access restrictions */ shmctl(shmid, IPC_STAT, &smbuf); smbuf.shm_perm.uid = geteuid(); smbuf.shm_perm.mode = 0700; shmctl(shmid, IPC_SET, &smbuf); /* Attach to the memory and bzero it */ sharedMemory = (struct memory *) shmat(shmid, 0, 0); if (sharedMemory == (struct memory *) -1) { /*! @bug EIDRM is seen here, probably due to a race condition, and if so the operation should be retried from shmget. */ ERROR(1,("setupmem: Can't attach to memory, error %i\n",errno)); return 0; } /* Zero the memory vector */ memset((void *) sharedMemory, 0, sizeof (struct memory)); setup_memory(sharedMemory); setupsem(); return 1; }
void __init setup_arch(char **cmdline_p) { #ifdef CONFIG_CMDLINE_FORCE strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); #endif *cmdline_p = cmd_line; console_verbose(); unflatten_device_tree(); /* NOTE I think that this function is not necessary to call */ /* irq_early_init(); */ setup_cpuinfo(); __invalidate_icache_all(); __enable_icache(); __invalidate_dcache_all(); __enable_dcache(); panic_timeout = 120; setup_memory(); #if defined(CONFIG_SELFMOD_INTC) || defined(CONFIG_SELFMOD_TIMER) printk(KERN_NOTICE "Self modified code enable\n"); #endif #ifdef CONFIG_VT #if defined(CONFIG_XILINX_CONSOLE) conswitchp = &xil_con; #elif defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con; #endif #endif }
void __init setup_arch(char **cmdline_p) { /* * print what head.S has found out about the machine */ #ifndef CONFIG_64BIT if (MACHINE_IS_VM) pr_info("Linux is running as a z/VM " "guest operating system in 31-bit mode\n"); else if (MACHINE_IS_LPAR) pr_info("Linux is running natively in 31-bit mode\n"); if (MACHINE_HAS_IEEE) pr_info("The hardware system has IEEE compatible " "floating point units\n"); else pr_info("The hardware system has no IEEE compatible " "floating point units\n"); #else /* CONFIG_64BIT */ if (MACHINE_IS_VM) pr_info("Linux is running as a z/VM " "guest operating system in 64-bit mode\n"); else if (MACHINE_IS_KVM) pr_info("Linux is running under KVM in 64-bit mode\n"); else if (MACHINE_IS_LPAR) pr_info("Linux is running natively in 64-bit mode\n"); #endif /* CONFIG_64BIT */ /* Have one command line that is parsed and saved in /proc/cmdline */ /* boot_command_line has been already set up in early.c */ *cmdline_p = boot_command_line; ROOT_DEV = Root_RAM0; init_mm.start_code = PAGE_OFFSET; init_mm.end_code = (unsigned long) &_etext; init_mm.end_data = (unsigned long) &_edata; init_mm.brk = (unsigned long) &_end; if (MACHINE_HAS_MVCOS) memcpy(&uaccess, &uaccess_mvcos, sizeof(uaccess)); else memcpy(&uaccess, &uaccess_std, sizeof(uaccess)); parse_early_param(); setup_ipl(); setup_memory_end(); setup_addressing_mode(); setup_memory(); setup_resources(); setup_lowcore(); cpu_init(); s390_init_cpu_topology(); /* * Setup capabilities (ELF_HWCAP & ELF_PLATFORM). */ setup_hwcaps(); /* * Create kernel page tables and switch to virtual addressing. */ paging_init(); /* Setup default console */ conmode_default(); set_preferred_console(); /* Setup zfcpdump support */ setup_zfcpdump(console_devno); }
static void lcd_enable(void) { setup_memory(); }
void start_kernel(){ setup_memory(); while(1) ; }
void start_kernel(void) { char str[] = "C FUNCTION START!"; /* * ARCHITECTURE DEPENDENT INITIALIZATIONS */ /* screen - message display */ init_screen(); caos_printf("%s\n", str); /* memory manager */ setup_memory(); /* exception & interrupt */ init_idt(); set_idtr(); /* device & IRQ */ init_char_dev(); keyboard_init(); init_timer(); /* scheduling */ init_scheduler(); /* task management */ setup_task(); init_cpu_tss(); /* after task setup, start scheduler */ start_scheduler(); /*************************************************/ /* * ARCHITECTURE INDEPENDENT PROCESSING */ if (create_task(init, "init") < 0) caos_printf("Create Init fail..\n"); if (create_task(user1, "user1") < 0) caos_printf("Create user1 fail..\n"); if (create_task(user2, "user2") < 0) caos_printf("Create user2 fail..\n"); caos_printf("CaOS KERNEL END!!\n"); /* execute user mode task */ start_init(); while (1); }
int start_kernel(unsigned long magic, unsigned long addr) { multiboot_info_t *mbi; int i=0; /* Initialize GDT */ initialize_gdt(); screen_init_early(); screen_reset(0); printf("Welcome to StarxOS!\n"); /* Am I booted by a Multiboot-compliant boot loader? */ if (magic != MULTIBOOT_BOOTLOADER_MAGIC) { printf("Invalid magic number: %x\n", (unsigned) magic); return -1; } /* Set MBI to the address of the Multiboot information structure. */ mbi = (multiboot_info_t *) addr; /* Print out the flags. */ printf_bochs("Welcome to StarxOS!\n"); printf_bochs("flags = 0x%x\n", (unsigned) mbi->flags); /* Are mem_* valid? */ if ( mbi->flags != 0) printf_bochs ("mem_lower = %x Byte, mem_upper = %x Byte\n", (unsigned) mbi->mem_lower * 0x400, (unsigned) mbi->mem_upper * 0x400); printf_bochs("kernel code: %p\n", &code); printf_bochs("kernel data: %p\n", &data); printf_bochs("kernel bss : %p\n", &bss); printf_bochs("kernel end : %p\n", &end); /* Initialize IDT */ initialize_idt(); /* Initialize Timer */ init_timer(50); /* Enable Interrupt */ asm volatile("sti"); mem_lower = mbi->mem_lower * 0x400; mem_upper = mbi->mem_upper * 0x400; /* Setup memory, and init frame_bitmap */ setup_memory(mem_lower, mem_upper); /* Enable Paging */ init_paging(); /* Init heap */ init_kheap(); u32int *ptr = (u32int*)kmalloc(0x1000+2); *ptr = 0x1234; printf_bochs("ptr:%x *ptr:%x\n", ptr, *ptr); u32int *ptr2 = (u32int*)kmalloc(0x1000+2); *ptr2 = 0x4567; printf_bochs("ptr2:%x *ptr2:%x\n", ptr2, *ptr2); bochs_enter_debugger(); bochs_shutdown(); return 0xBAD; }
struct item_data item_bench(const struct p_bench_item *item, struct p_bench_specification *spec) { struct item_data data, best = { .end = ~(0ULL) }; uint64_t item_start_time = platform_clock(); /* Warm up caches, branch predictors etc. */ /* Calculate inner loop. */ int inner_loop; data.start = platform_clock(); for (int i = 0; i < 50; i++) item->benchmark(spec); data.end = platform_clock(); { float tmp = data.end - data.start; tmp /= 50.0f; /* 50k us seems to work */ tmp = 50000.0f / tmp; inner_loop = ceilf(tmp); } /* Repeat tests to get more stable results between runs */ while (true) { /* Measure 10 iterations so the clocksource's resolution doesn't * play tricks on us */ data.start = platform_clock(); for (int j = 0; j < inner_loop; j++) item->benchmark(spec); data.end = platform_clock(); /* Use best measurement */ if (best.end - best.start > data.end - data.start) best = data; /* Test each function for 1/2 second */ if (data.end - item_start_time >= 500000000ULL) break; } { /* Adjust for iterations in inner loop above */ float tmp = best.end - best.start; tmp /= (float) inner_loop; best.end = best.start + tmp; } return best; } int main(void) { struct p_bench_specification spec = { 0 }; char *raw_mem = NULL; spec.current_size = MAX_ELEMS; setup_memory(&spec.mem, &raw_mem, spec.current_size); bench_printf(";name, size, duration (ns)\n"); for (const struct p_bench_item *item = benchmark_items; item->name != NULL; ++item) { struct item_data best; bool consistent = false; best = item_bench(item, &spec); for (int tries = 0; tries < 50; tries++) { struct item_data snd; float fst_time, snd_time; /* Benchmark again ... */ snd = item_bench(item, &spec); fst_time = best.end - best.start; snd_time = snd.end - snd.start; /* ... and start over if results deviate too much */ if (fst_time / snd_time < 0.995 || snd_time / fst_time < 0.995) { /* Take average so abnormally low results converge over time */ best.end += (snd_time - fst_time) / 2.0f; usleep(100000); continue; } if (fst_time > snd_time) best = snd; consistent = true; break; } if (!consistent) { fprintf(stderr, ";WARNING: %s not consistent\n", item->name); fflush(stderr); } item_done(&best, &spec, item->name); } return EXIT_SUCCESS; } #else /* __epiphany__ */ int main(void) { struct p_bench_specification spec = { 0 }; char *raw_mem = NULL; spec.current_size = MAX_ELEMS; uint32_t nbench = 0; setup_memory(&spec.mem, &raw_mem, spec.current_size); bench_printf(";name, size, duration (ns)\n"); for (const struct p_bench_item *item = benchmark_items; item->name != NULL; ++item) { struct item_data data; data.start = platform_clock(); item->benchmark(&spec); data.end = platform_clock(); strcpy(epiphany_results[nbench].name, item->name); epiphany_results[nbench].ns = data.end - data.start; epiphany_results[nbench].size = (uint64_t) spec.current_size; nbench++; epiphany_status->nbench = nbench; } epiphany_status->done = 1; return EXIT_SUCCESS; } #endif static void setup_output_pointers(struct p_bench_raw_memory *mem, void *p) { /* Assume largest type is 64 bits */ /* TODO: All pointers point to same memory region so output will be bogus */ mem->o1.p_u64 = p; mem->o2.p_u64 = p; mem->o3.p_u64 = p; mem->o4.p_u64 = p; }
void __init setup_arch(char **cmdline_p) { enable_mmu(); ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV); #ifdef CONFIG_BLK_DEV_RAM rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK; rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0); rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0); #endif if (!MOUNT_ROOT_RDONLY) root_mountflags &= ~MS_RDONLY; init_mm.start_code = (unsigned long) _text; init_mm.end_code = (unsigned long) _etext; init_mm.end_data = (unsigned long) _edata; init_mm.brk = (unsigned long) _end; code_resource.start = virt_to_phys(_text); code_resource.end = virt_to_phys(_etext)-1; data_resource.start = virt_to_phys(_etext); data_resource.end = virt_to_phys(_edata)-1; memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START; memory_end = memory_start + __MEMORY_SIZE; #ifdef CONFIG_CMDLINE_BOOL strlcpy(command_line, CONFIG_CMDLINE, sizeof(command_line)); #else strlcpy(command_line, COMMAND_LINE, sizeof(command_line)); #endif /* Save unparsed command line copy for /proc/cmdline */ memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); *cmdline_p = command_line; parse_early_param(); sh_mv_setup(); /* * Find the highest page frame number we have available */ max_pfn = PFN_DOWN(__pa(memory_end)); /* * Determine low and high memory ranges: */ max_low_pfn = max_pfn; min_low_pfn = __MEMORY_START >> PAGE_SHIFT; nodes_clear(node_online_map); /* Setup bootmem with available RAM */ setup_memory(); sparse_init(); #ifdef CONFIG_DUMMY_CONSOLE conswitchp = &dummy_con; #endif /* Perform the machine specific initialisation */ if (likely(sh_mv.mv_setup)) sh_mv.mv_setup(cmdline_p); paging_init(); }