static int initr_trap(void) { /* * Setup trap handlers */ #if defined(CONFIG_PPC) trap_init(gd->relocaddr); #else trap_init(CONFIG_SYS_SDRAM_BASE); #endif return 0; }
void mips_init() { printf("init.c:\tmips_init() is called\n"); mips_detect_memory(); mips_vm_init(); page_init(); //page_check(); env_init(); //ENV_CREATE(user_fktest); //ENV_CREATE(user_pt1); ENV_CREATE(user_idle); ENV_CREATE(fs_serv); //ENV_CREATE(user_fktest); //ENV_CREATE(user_pingpong); //ENV_CREATE(user_testfdsharing); //ENV_CREATE(user_testspawn); //ENV_CREATE(user_testpipe); //ENV_CREATE(user_testpiperace); ENV_CREATE(user_icode); trap_init(); kclock_init(); //env_run(&envs[0]); //env_run(&envs[1]); panic("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); while (1); panic("init.c:\tend of mips_init() reached!"); }
int main(void) { /* NOTE! 这些初始化函数的位置别随便改动! */ trap_init(); /* 在设置其他中断之前 */ console_init(); /* 需打印的在这之后 */ keyboard_init(); hd_init(); /* 需读磁盘的放其后 */ /* graph_init(); */ mem_init(); sched_init(); buff_init(); /* 在内存初始化之后 */ inode_init(); file_table_init(); debug_init(); sti(); super_init(0); /* 开中断之后 */ files_init(); /* unsigned short color = rgb_to_565color(255,255,255); draw_rect(0, 0, 800, 600, color, 1); */ move_to_user_mode(); /* * 进程0马上execve(),替换掉用户态空间,这样进程0就 * 可以写时复制了。注意此时原来的用户态堆栈也被丢弃 * 了,换成了新堆栈。更多参见内存管理。 */ if(!execve("/init")) printf("main: execve init-process failed.\n");
void i386_init(void) { extern char edata[], end[]; // Before doing anything else, complete the ELF loading process. // Clear the uninitialized global data (BSS) section of our program. // This ensures that all static/global variables start out zero. memset(edata, 0, end - edata); // Initialize the console. // Can't call cprintf until after we do this! cons_init(); cprintf("6828 decimal is %o octal!\n", 6828); // Lab 2 memory management initialization functions mem_init(); // Lab 3 user environment initialization functions env_init(); trap_init(); #if defined(TEST) // Don't touch -- used by grading script! ENV_CREATE(TEST, ENV_TYPE_USER); #else // Touch all you want. ENV_CREATE(user_hello, ENV_TYPE_USER); #endif // TEST* // We only have one user environment for now, so just run it. env_run(&envs[0]); }
void arch_init (void) { trap_init(); Cache_Read_Disable(); call_user_start(); }
/** * Called plainly from assembler code * * @note The C environment isn't initialized yet */ void __bare_init main_entry(void *fdt, u32 fdt_size) { unsigned long malloc_start, malloc_end; /* clear the BSS first */ memset(__bss_start, 0x00, __bss_stop - __bss_start); cpu_probe(); if (cpu_has_4k_cache) { extern void r4k_cache_init(void); r4k_cache_init(); } trap_init(); malloc_end = _stext; if (MALLOC_SIZE > 0) malloc_start = malloc_end - MALLOC_SIZE; else malloc_start = malloc_end - SZ_8M; pr_debug("initializing malloc pool at 0x%08lx (size 0x%08lx)\n", malloc_start, malloc_end - malloc_start); mem_malloc_init((void *)malloc_start, (void *)_stext - 1); mips_stack_top = malloc_start; glob_fdt = fdt; glob_fdt_size = fdt_size; start_barebox(); }
int main(void){ cli(); cons_init(); mm_init(); trap_init(); god_init(); }
int main(void) { /* Interrupts are still disabled. Do necessary setups, then enable them. */ time_init(); tty_init(); trap_init(); sched_init(); buffer_init(); hd_init(); sti(); move_to_user_mode(); if (!fork()) { /* we count on this going ok */ init(); } /* * NOTE!! * For any other task 'pause()' would mean we have to get a signal to awaken, * but task 0 gets activated at every idle moment (when no other tasks can run). * For task0 'pause()' just means we go check if some other task can run, and * if not we return here. */ // for(;;) pause(); return 0; }
void main(void) /* This really IS void, no error here. */ { /* The startup routine assumes (well, ...) this */ /* * Interrupts are still disabled. Do necessary setups, then * enable them */ time_init(); tty_init(); trap_init(); sched_init(); buffer_init(); hd_init(); sti(); move_to_user_mode(); if (!fork()) { /* we count on this going ok */ init(); } /* * NOTE!! For any other task 'pause()' would mean we have to get a * signal to awaken, but task0 is the sole exception (see 'schedule()') * as task 0 gets activated at every idle moment (when no other tasks * can run). For task0 'pause()' just means we go check if some other * task can run, and if not we return here. */ for(;;) pause(); }
asmlinkage void start_secondary(void) { trap_init(); init_IRQ(); smp_callin(); cpu_idle(NULL); }
void kmain (void) { cpu = &cpus[0]; uart_init (P2V(UART0)); init_vmm (); kpt_freerange (align_up(&end, PT_SZ), P2V_WO(INIT_KERNMAP)); paging_init (INIT_KERNMAP, PHYSTOP); kmem_init (); kmem_init2(P2V(INIT_KERNMAP), P2V(PHYSTOP)); trap_init (); // vector table and stacks for models gic_init(P2V(VIC_BASE)); // arm v2 gic init uart_enable_rx (); // interrupt for uart consoleinit (); // console pinit (); // process (locks) binit (); // buffer cache fileinit (); // file table iinit (); // inode cache ideinit (); // ide (memory block device) #ifdef INCLUDE_REMOVED timer_init (HZ); // the timer (ticker) #endif sti (); userinit(); // first user process scheduler(); // start running processes }
void i386_init(void) { extern char edata[], end[]; // Before doing anything else, complete the ELF loading process. // Clear the uninitialized global data (BSS) section of our program. // This ensures that all static/global variables start out zero. memset(edata, 0, end - edata); // Initialize the console. // Can't call cprintf until after we do this! cons_init(); cprintf("6828 decimal is %o octal!\n", 6828); // Lab 2 memory management initialization functions mem_init(); // Lab 3 user environment initialization functions env_init(); trap_init(); // Lab 4 multiprocessor initialization functions mp_init(); lapic_init(); // Lab 4 multitasking initialization functions pic_init(); // Acquire the big kernel lock before waking up APs // Your code here: lock_kernel(); // Starting non-boot CPUs boot_aps(); // Start fs. ENV_CREATE(fs_fs, ENV_TYPE_FS); #if defined(TEST) // Don't touch -- used by grading script! ENV_CREATE(TEST, ENV_TYPE_USER); #else // Touch all you want. //<<<<<<< HEAD ENV_CREATE(user_icode, ENV_TYPE_USER); //======= // ENV_CREATE(user_dumbfork, ENV_TYPE_USER); //>>>>>>> lab4 #endif // TEST* // Should not be necessary - drains keyboard because interrupt has given up. kbd_intr(); // Schedule and run the first user environment! sched_yield(); }
int main(void){ trap_init(); kputs("Hello kern MAIN!!\n"); smp_startup(); kputs("smp_startup end\n"); RTC_MAIN(); for(;;); }
int main(void){ cli(); cons_init(); printk("Welcome to NONE.\nVersion : "KERNEL_VERSION"\n"); mem_init(); trap_init(); god_init(); }
void i386_init(void) { extern char edata[], end[]; // Before doing anything else, complete the ELF loading process. // Clear the uninitialized global data (BSS) section of our program. // This ensures that all static/global variables start out zero. memset(edata, 0, end - edata); // Initialize the console. // Can't call cprintf until after we do this! cons_init(); //bluesea //经测试,下面的语句会输出:edata f0114300, end f0114970 //因此,edata < end, [edata, end)之间是bss段, kernel需要用的global variable. // > end之后的内存可以用于boot_alloc //cprintf("edata %x, end %x\n", edata, end); cprintf("6828 decimal is %o octal!\n", 6828); // Lab 2 memory management initialization functions mem_init(); // Lab 3 user environment initialization functions env_init(); trap_init(); // Lab 4 multiprocessor initialization functions mp_init(); lapic_init(); // Lab 4 multitasking initialization functions pic_init(); // Acquire the big kernel lock before waking up APs // Your code here: lock_kernel(); // Starting non-boot CPUs boot_aps(); #if defined(TEST) // Don't touch -- used by grading script! ENV_CREATE(TEST, ENV_TYPE_USER); #else // Touch all you want. //ENV_CREATE(user_primes, ENV_TYPE_USER); //ENV_CREATE(user_yield, ENV_TYPE_USER); //ENV_CREATE(user_yield, ENV_TYPE_USER); //ENV_CREATE(user_yield, ENV_TYPE_USER); ENV_CREATE(user_dumbfork, ENV_TYPE_USER); #endif // TEST* // Schedule and run the first user environment! sched_yield(); }
static int initr_trap(void) { /* * Setup trap handlers */ trap_init(gd->relocaddr); return 0; }
void i386_init(void) { extern char edata[], end[]; // Before doing anything else, complete the ELF loading process. // Clear the uninitialized global data (BSS) section of our program. // This ensures that all static/global variables start out zero. memset(edata, 0, end - edata); // Initialize the console. // Can't call cprintf until after we do this! cons_init(); cprintf("372 decimal is %o octal!\n", 372); // Lab 2 memory management initialization functions mem_init(); // Lab 3 user environment initialization functions env_init(); trap_init(); // Lab 4 multiprocessor initialization functions mp_init(); lapic_init(); // Lab 4 multitasking initialization functions pic_init(); // Acquire the big kernel lock before waking up APs // Your code here: lock_kernel(); // Starting non-boot CPUs boot_aps(); // Should always have idle processes at first. int i; for (i = 0; i < NCPU; i++) ENV_CREATE(user_idle, ENV_TYPE_IDLE); // ENV_CREATE(user_yield, ENV_TYPE_USER); // ENV_CREATE(user_yield, ENV_TYPE_USER); // ENV_CREATE(user_yield, ENV_TYPE_USER); #if defined(TEST) // Don't touch -- used by grading script! ENV_CREATE(TEST, ENV_TYPE_USER); #else // Touch all you want. ENV_CREATE(user_primes, ENV_TYPE_USER); #endif // TEST* // Schedule and run the first user environment! sched_yield(); }
asmlinkage void start_secondary(void) { trap_init(); #ifndef CONFIG_OSFMACH3 init_IRQ(); #endif /* CONFIG_OSFMACH3 */ smp_callin(); cpu_idle(NULL); }
void main(void) /* This really IS void, no error here. */ { /* The startup routine assumes (well, ...) this */ /* * Interrupts are still disabled. Do necessary setups, then * enable them */ ROOT_DEV = ORIG_ROOT_DEV; drive_info = DRIVE_INFO; memory_end = (1<<20) + (EXT_MEM_K<<10); memory_end &= 0xfffff000; if (memory_end > 16*1024*1024) memory_end = 16*1024*1024; if (memory_end > 12*1024*1024) buffer_memory_end = 4*1024*1024; else if (memory_end > 6*1024*1024) buffer_memory_end = 2*1024*1024; else buffer_memory_end = 1*1024*1024; main_memory_start = buffer_memory_end; #ifdef RAMDISK main_memory_start += rd_init(main_memory_start, RAMDISK*1024); #endif mem_init(main_memory_start,memory_end); trap_init(); blk_dev_init(); chr_dev_init(); tty_init(); time_init(); sched_init(); buffer_init(buffer_memory_end); hd_init(); floppy_init(); sti(); move_to_user_mode(); setup((void *) &drive_info); (void) open("/dev/tty0",O_RDWR,0); (void) dup(0); (void) dup(0); (void) open("/var/process.log",O_CREAT|O_TRUNC|O_WRONLY,0666); #ifdef dis_func (void) open("/var/dis_func.log",O_CREAT|O_TRUNC|O_WRONLY,0666); #endif if (!fork()) { /* we count on this going ok */ init(); } /* * NOTE!! For any other task 'pause()' would mean we have to get a * signal to awaken, but task0 is the sole exception (see 'schedule()') * as task 0 gets activated at every idle moment (when no other tasks * can run). For task0 'pause()' just means we go check if some other * task can run, and if not we return here. */ for(;;) pause(); }
int boxer_main(int argc, char *argv[]) { int ret; uintptr_t sp; struct elf_data data; if (argc < 2) return -EINVAL; /* XXX needed. Probably does some libc stuff */ printf(" \b"); // printf("%s\n", environ[0]); ret = dune_init(0); if (ret) { printf("sandbox: failed to initialize Dune\n"); return ret; } ret = dune_enter(); if (ret) { printf("sandbox: failed to enter Dune mode\n"); return ret; } ret = load_elf(argv[1], &data); if (ret) return ret; // printf("sandbox: entry addr is %lx\n", data.entry); dune_set_user_fs(0); // default starting fs ret = trap_init(); if (ret) { printf("failed to initialize trap handlers\n"); return ret; } ret = umm_alloc_stack(&sp); if (ret) { printf("failed to alloc stack\n"); return ret; } sp = setup_arguments(sp, argv[1], &argv[2], environ, data); if (!sp) { printf("failed to setup arguments\n"); return -EINVAL; } ret = run_app(sp, data.entry); return ret; }
void arch_sd_init(void) { #ifdef linux linux_init_cpu_monitor(); trap_init(); #elif defined(__APPLE__) darwin_init_cpu_monitor(); #endif }
/* * INITIAL C ENTRY POINT. */ void _minios_start_kernel(start_info_t *si) { bmk_printf_init(minios_putc, NULL); bmk_core_init(STACK_SIZE_PAGE_ORDER, PAGE_SHIFT); arch_init(si); trap_init(); bmk_sched_init(); /* print out some useful information */ minios_printk(" start_info: %p(VA)\n", si); minios_printk(" nr_pages: 0x%lx\n", si->nr_pages); minios_printk(" shared_inf: 0x%08lx(MA)\n", si->shared_info); minios_printk(" pt_base: %p(VA)\n", (void *)si->pt_base); minios_printk("nr_pt_frames: 0x%lx\n", si->nr_pt_frames); minios_printk(" mfn_list: %p(VA)\n", (void *)si->mfn_list); minios_printk(" mod_start: 0x%lx(VA)\n", si->mod_start); minios_printk(" mod_len: %lu\n", si->mod_len); minios_printk(" flags: 0x%x\n", (unsigned int)si->flags); minios_printk(" cmd_line: %s\n", si->cmd_line ? (const char *)si->cmd_line : "NULL"); /* Set up events. */ init_events(); /* ENABLE EVENT DELIVERY. This is disabled at start of day. */ __sti(); arch_print_info(); setup_xen_features(); /* Init memory management. */ init_mm(); /* Init time and timers. */ init_time(); /* Init the console driver. */ init_console(); /* Init grant tables */ init_gnttab(); /* Init XenBus */ init_xenbus(); /* Init scheduler. */ bmk_sched_startmain(_app_main, &start_info); bmk_platform_halt("unreachable"); }
int main(void) { trap_init(); sched_init(); sti(); move_to_user_mode(); myprint("In kernel"); while(1){} return 0; }
CAMLprim value stub_hypervisor_suspend(value unit) { CAMLparam0(); int cancelled; printk("WARNING: stub_hypervisor_suspend not yet implemented\n"); cancelled = 1; #if 0 /* Turn the store and console mfns to pfns - required because xc_domain_restore uses these values */ start_info.store_mfn = mfn_to_pfn(start_info.store_mfn); start_info.console.domU.mfn = mfn_to_pfn(start_info.console.domU.mfn); /* canonicalize_pagetables can't cope with pagetable entries that are outside of the guest's mfns, so we must unmap anything outside of our space */ unmap_shared_info(); /* Actually do the suspend. When this function returns 0, we've been resumed */ cancelled = HYPERVISOR_suspend(virt_to_mfn(&start_info)); if(cancelled) { start_info.store_mfn = pfn_to_mfn(start_info.store_mfn); start_info.console.domU.mfn = pfn_to_mfn(start_info.console.domU.mfn); } /* Reinitialise several things */ trap_init(); init_events(); /* ENABLE EVENT DELIVERY. This is disabled at start of day. */ local_irq_enable(); setup_xen_features(); HYPERVISOR_shared_info = map_shared_info(start_info.shared_info); /* Set up event and failsafe callback addresses. */ HYPERVISOR_set_callbacks( (unsigned long)hypervisor_callback, (unsigned long)failsafe_callback, 0); init_time(); arch_rebuild_p2m(); unmask_evtchn(start_info.console.domU.evtchn); unmask_evtchn(start_info.store_evtchn); #endif CAMLreturn(Val_int(cancelled)); }
/** * Called plainly from assembler code * * @note The C environment isn't initialized yet */ void main_entry(void) { /* clear the BSS first */ memset(__bss_start, 0x00, __bss_stop - __bss_start); cpu_probe(); if (cpu_has_4k_cache) { extern void r4k_cache_init(void); r4k_cache_init(); } trap_init(); start_barebox(); }
/* * Finalize boot-time hw initialization */ void __init mach_start() { /* + means of output */ early_console_init(); /* + x86 segmentation */ init_root_tss(); /* + irq handlers */ interrupts_init(); /* + cpu traps */ trap_init(); /* + hw timer */ timer_init(); }
void main(void) /* This really IS void, no error here. */ { /* The startup routine assumes (well, ...) this */ /* * Interrupts are still disabled. Do necessary setups, then * enable them */ ROOT_DEV = ORIG_ROOT_DEV; drive_info = DRIVE_INFO; memory_end = (1<<20) + (EXT_MEM_K<<10); memory_end &= 0xfffff000; if (memory_end > 16*1024*1024) memory_end = 16*1024*1024; if (memory_end > 12*1024*1024) buffer_memory_end = 4*1024*1024; else if (memory_end > 6*1024*1024) buffer_memory_end = 2*1024*1024; else buffer_memory_end = 1*1024*1024; main_memory_start = buffer_memory_end; #ifdef RAMDISK main_memory_start += rd_init(main_memory_start, RAMDISK*1024); #endif mem_init(main_memory_start,memory_end); trap_init(); /* set the IDT in 0x00080000~0x000807ff(4KB)*/ blk_dev_init(); chr_dev_init(); /* this function do nothing */ tty_init(); /* rs_init() and con_init() */ time_init(); sched_init(); buffer_init(buffer_memory_end); hd_init(); floppy_init(); sti(); move_to_user_mode(); if (!fork()) { /* we count on this going ok */ init(); } /* * NOTE!! For any other task 'pause()' would mean we have to get a * signal to awaken, but task0 is the sole exception (see 'schedule()') * as task 0 gets activated at every idle moment (when no other tasks * can run). For task0 'pause()' just means we go check if some other * task can run, and if not we return here. */ for(;;) pause(); }
/* * We use kgdb_early_setup so that functions we need to call now don't * cause trouble when called again later. */ int kgdb_arch_init(void) { /* Board-specifics. */ /* Force some calls to happen earlier. */ if (kgdb_early_setup == 0) { trap_init(); init_IRQ(); kgdb_early_setup = 1; } /* Set our traps. */ /* This needs to be done more finely grained again, paired in * a before/after in kgdb_handle_exception(...) -- Tom */ set_debug_traps(); notifier_chain_register(&mips_die_chain, &kgdb_notifier); return 0; }
init(void) { int secs; mem_init(); trap_init(); kstdio_init(); stdio_init(); tty_init(); timer_init(); kern_init(); enable_intrs(); #ifdef MV134_TIMER_TEST /* for testing only, XXX */ timer_test_init(); #endif /* gdb_init(); XXX if enabled never returns */ shell_init(); }
/* * INITIAL C ENTRY POINT. */ void start_kernel(start_info_t *si) { static char hello[] = "Bootstrapping...\n"; (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(hello), hello); arch_init(si); trap_init(); /* print out some useful information */ printk("Mirage OS!\n"); printk(" start_info: %p(VA)\n", si); printk(" nr_pages: 0x%lx\n", si->nr_pages); printk(" shared_inf: 0x%08lx(MA)\n", si->shared_info); printk(" pt_base: %p(VA)\n", (void *)si->pt_base); printk("nr_pt_frames: 0x%lx\n", si->nr_pt_frames); printk(" mfn_list: %p(VA)\n", (void *)si->mfn_list); printk(" mod_start: 0x%lx(VA)\n", si->mod_start); printk(" mod_len: %lu\n", si->mod_len); printk(" flags: 0x%x\n", (unsigned int)si->flags); printk(" cmd_line: %s\n", si->cmd_line ? (const char *)si->cmd_line : "NULL"); /* Set up events. */ init_events(); /* ENABLE EVENT DELIVERY. This is disabled at start of day. */ __sti(); arch_print_info(); setup_xen_features(); /* Init memory management. */ init_mm(); /* Init time and timers. */ init_time(); /* Call (possibly overridden) app_main() */ app_main(&start_info); }