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 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!"); }
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 i386_detect_memory(); i386_vm_init(); page_init(); page_check(); // Lab 3 user environment initialization functions env_init(); idt_init(); // Lab 4 multitasking initialization functions pic_init(); kclock_init(); // Should always have an idle process as first one. ENV_CREATE(user_idle); // Start fs. ENV_CREATE(fs_fs); ENV_CREATE(user_icode); #if defined(TEST) // Don't touch -- used by grading script! ENV_CREATE2(TEST, TESTSIZE) #else // Touch all you want. // ENV_CREATE(user_icode); // ENV_CREATE(user_pipereadeof); // ENV_CREATE(user_pipewriteeof); // ENV_CREATE(user_testpipe); // ENV_CREATE(user_primespipe); // ENV_CREATE(user_testpiperace); // ENV_CREATE(user_testpiperace2); // ENV_CREATE(user_testfdsharing); #endif // TEST* // Should not be necessary - drain keyboard because interrupt has given up. kbd_intr(); // Schedule and run the first user environment! sched_yield(); }
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 i386_detect_memory(); i386_vm_init(); // Lab 3 user environment initialization functions env_init(); idt_init(); // Lab 4 multitasking initialization functions pic_init(); kclock_init(); time_init(); pci_init(); // Should always have an idle process as first one. ENV_CREATE(user_idle); // Start fs. ENV_CREATE(fs_fs); #if !defined(TEST_NO_NS) // Start ns. ENV_CREATE(net_ns); #endif #if defined(TEST) // Don't touch -- used by grading script! ENV_CREATE2(TEST, TESTSIZE); #else // Touch all you want. // ENV_CREATE(net_testoutput); // ENV_CREATE(user_echosrv); // ENV_CREATE(user_httpd); // ENV_CREATE(user_writemotd); // ENV_CREATE(user_testfile); ENV_CREATE(user_icode); // ENV_CREATE(user_primes); #endif // TEST* // Schedule and run the first user environment! sched_yield(); }
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(); }
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(); }
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(); }
void i386_init(void) { extern char edata[], end[]; uint32_t *ctorva; // 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 boot_mem_init(); page_init(); page_check(); // Lab 2 interrupt and gate descriptor initialization functions idt_init(); // Test IDT (lab 2 only) __asm__ __volatile__("int3"); cprintf("Breakpoint succeeded!\n"); // Test the stack backtrace function (lab 1 only) //test_backtrace(5); // Lab 3 user environment initialization functions env_init(); #if JOS_MULTIENV // Should always have an idle process as first one. ENV_CREATE(user_idle); #endif #ifdef TEST // Don't touch -- used by grading script! ENV_CREATE2(TEST, TESTSIZE); #else // Touch all you want. ENV_CREATE(user_hello); #endif // TEST* // We only have one user environment for now, so just run it. env_run(&envs[0]); // Drop into the kernel monitor. while (1) monitor(NULL); }
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\n%n", 6828, &chnum1, &chnum2); cprintf("pading space in the right to number 22: %-8d.\n", 22); cprintf("chnum1: %d chnum2: %d\n", chnum1, chnum2); cprintf("%n", NULL); memset(ntest, 0xd, sizeof(ntest) - 1); cprintf("%s%n", ntest, &chnum1); cprintf("chnum1: %d\n", chnum1); cprintf("show me the sign: %+d, %+d\n", 1024, -1024); */ // 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 i386_init(void) { /* __asm __volatile("int $12"); */ 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); extern char end[]; end_debug = read_section_headers((0x10000+KERNBASE), (uintptr_t)end); // Lab 2 memory management initialization functions x64_vm_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: //Starting non-boot CPUs lock_kernel(); 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. //ENV_CREATE(user_icode, ENV_TYPE_USER); // Should not be necessary - drains keyboard because interrupt has given up. //kbd_intr(); //ENV_CREATE(user_primes, ENV_TYPE_USER); //ENV_CREATE(user_testpteshare, ENV_TYPE_USER); //ENV_CREATE(user_testfdsharing, ENV_TYPE_USER); //ENV_CREATE(user_testbss, ENV_TYPE_USER); //ENV_CREATE(user_spawnhello, ENV_TYPE_USER); ENV_CREATE(user_icode, ENV_TYPE_USER); //ENV_CREATE(user_testshell, ENV_TYPE_USER); //ENV_CREATE(user_testfile, ENV_TYPE_USER); //ENV_CREATE(user_primespipe, ENV_TYPE_USER); //ENV_CREATE(user_testkbd, ENV_TYPE_USER); #endif // TEST* // Schedule and run the first user environment! sched_yield(); }
void i386_init(void) { /* __asm __volatile("int $12"); */ 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); #ifdef VMM_GUEST /* Guest VMX extension exposure check */ { uint32_t ecx = 0; cpuid(0x1, NULL, NULL, &ecx, NULL); if (ecx & 0x20) panic("[ERR] VMX extension exposed to guest.\n"); else cprintf("VMX extension hidden from guest.\n"); } #endif #ifndef VMM_GUEST extern char end[]; end_debug = read_section_headers((0x10000+KERNBASE), (uintptr_t)end); #endif // Lab 2 memory management initialization functions x64_vm_init(); // Lab 3 user environment initialization functions env_init(); trap_init(); #ifndef VMM_GUEST // Lab 4 multiprocessor initialization functions lapic_init(); #endif // Lab 4 multitasking initialization functions pic_init(); // Lab 6 hardware initialization functions time_init(); pci_init(); // Acquire the big kernel lock before waking up APs // Your code here: #ifndef VMM_GUEST // Starting non-boot CPUs boot_aps(); #endif cprintf("\nAdding idle"); ENV_CREATE(user_idle, ENV_TYPE_IDLE); #if defined(TEST) // Don't touch -- used by grading script! ENV_CREATE(TEST, ENV_TYPE_USER); #else //start fs cprintf("\nAdding FILE SYSTEM"); ENV_CREATE(fs_fs,ENV_TYPE_FS); #if defined(TEST_EPT_MAP) test_ept_map(); #endif cprintf("\nAdding ICODE"); ENV_CREATE(user_icode,ENV_TYPE_USER); #endif // Should not be necessary - drains keyboard because interrupt has given up. // kbd_intr(); // Schedule and run the first user environment! sched_yield(); }
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); // cprintf("6828 decimal is %o octal!%n\n%n", 6828, &chnum1, &chnum2); // cprintf("pading space in the right to number 22: %-8d.\n", 22); // cprintf("chnum1: %d chnum2: %d\n", chnum1, chnum2); // cprintf("%n", NULL); // memset(ntest, 0xd, sizeof(ntest) - 1); // cprintf("%s%n", ntest, &chnum1); // cprintf("chnum1: %d\n", chnum1); // 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(); #ifdef USE_TICKET_SPIN_LOCK unlock_kernel(); spinlock_test(); lock_kernel(); #endif // Should always have idle processes at first. int i; for (i = 0; i < NCPU; i++) ENV_CREATE(user_idle, ENV_TYPE_IDLE); #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); ENV_CREATE(user_hello, ENV_TYPE_USER); #endif // TEST* // Schedule and run the first user environment! sched_yield(); }
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(); #if defined(LAB1_ONLY) cprintf("6828 decimal is %o octal!\n", 6828); /* ----- Exercise 8 of Lab 1 -----*/ int x=1,y=3,z=4; cprintf("x %d, y %x, z %d\n", x, y, z); unsigned int i = 0x00646c72; cprintf("H%x Wo%s\n", 57616, &i); // Shows He110 World, while the demical 0d57616 = 0xe110 // 'r' = 0x72, 'l' = 0x6c, 'd' = 0x64, '\0' = 0x00 which indicates the end of the string // If the x86 is big-endian, 57616 -> 4321, 0x00646c72 -> 0x726c6400 // Test the stack backtrace function (lab 1 only) test_backtrace(5); #endif // Lab 2 memory management initialization functions i386_detect_memory(); i386_vm_init(); // Lab 3 user environment initialization functions env_init(); idt_init(); // Lab 4 multitasking initialization functions pic_init(); kclock_init(); time_init(); pci_init(); // Should always have an idle process as first one. ENV_CREATE(user_idle); // 0 // Start fs ENV_CREATE(fs_fs); // 1 // Start ns. ENV_CREATE(net_ns); // 2 // Start init #if defined(TEST) // Don't touch -- used by grading script! ENV_CREATE2(TEST, TESTSIZE); #else // Touch all you want. // ENV_CREATE(user_echosrv); // ENV_CREATE(user_httpd); // ENV_CREATE(user_testtime); #endif // TEST* // Schedule and run the first user environment! sched_yield(); }
void i386_init(uint32_t memsize) { extern char etext[],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. /* * From http://en.wikipedia.org/wiki/.bss * In computer programming * .bss or bss (Block Started by Symbol) is used by many compilers and linkers * as the name of the data segment containing static variables * that are filled solely with zero-valued data initially * (i. e., when execution begins). * It is often referred to as the "bss section" or "bss segment". * The program loader initializes the memory allocated for the bss section * when it loads the program. */ 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); cprintf("etext:%08x,edata:%08x,end:%08x\n",etext,edata,end); // Lab 2 memory management initialization functions i386_detect_memory(memsize); i386_vm_init(); // Lab 3 user environment initialization functions env_init(); idt_init(); // Lab 4 multitasking initialization functions pic_init(); kclock_init(); // Should always have an idle process as first one. ENV_CREATE(user_idle); // Start fs. ENV_CREATE(fs_fs); // Start init #if defined(TEST) // Don't touch -- used by grading script! ENV_CREATE2(TEST, TESTSIZE); #else // Touch all you want. ENV_CREATE(user_fairness); //ENV_CREATE(user_pipereadeof); // ENV_CREATE(user_pipewriteeof); #endif // Should not be necessary - drain keyboard because interrupt has given up. kbd_intr(); //while(login() != 0) // continue; // Schedule and run the first user environment! sched_yield(); }
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(); // 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(); // Lab 6 hardware initialization functions time_init(); pci_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); // Start fs. ENV_CREATE(fs_fs, ENV_TYPE_FS); #if !defined(TEST_NO_NS) // Start ns. ENV_CREATE(net_ns, ENV_TYPE_NS); #endif #if defined(TEST) // Don't touch -- used by grading script! ENV_CREATE(TEST, ENV_TYPE_USER); #else // Touch all you want. ENV_CREATE(user_icode, ENV_TYPE_USER); #endif // TEST* // Should not be necessary - drains keyboard because interrupt has given up. kbd_intr(); // Schedule and run the first user environment! sched_yield(); }