void nulluser(void) { /* Platform-specific initialization */ platforminit(); /* General initialization */ sysinit(); /* Enable interrupts */ enable(); /* Spawn the main thread */ ready(create(main, INITSTK, INITPRIO, "MAIN", 0), RESCHED_YES); // kprintf("init done \n"); /* null thread has nothing else to do but cannot exit */ while (TRUE) { #ifndef DEBUG pause(); #endif /* DEBUG */ // kprintf("null process \n"); } }
/** * Intializes the system and becomes the null thread. * This is where the system begins after the C environment has been * established. Interrupts are initially DISABLED, and must eventually * be enabled explicitly. This routine turns itself into the null thread * after initialization. Because the null thread must always remain ready * to run, it cannot execute code that might cause it to be suspended, wait * for a semaphore, or put to sleep, or exit. In particular, it must not * do I/O unless it uses kprintf for synchronous output. */ int nulluser(void) { kprintf(VERSION); kprintf("\r\r\n\n"); platforminit(); #ifdef DETAIL /* Output detected platform. */ kprintf("Processor identification: 0x%08X\r\n", cpuid); kprintf("Detected platform as: %s, %s\r\r\n\n", platform.family, platform.name); #endif sysinit(); /* Output Xinu memory layout */ kprintf("%10d bytes physical memory.\r\n", (ulong)platform.maxaddr & 0x7FFFFFFF); #ifdef KSEG0_BASE #ifdef DETAIL kprintf(" [0x%08X to 0x%08X]\r\n", (ulong)KSEG0_BASE, (ulong)(platform.maxaddr - 1)); #endif kprintf("%10d bytes reserved system area.\r\n", (ulong)_start - KSEG0_BASE); #ifdef DETAIL kprintf(" [0x%08X to 0x%08X]\r\n", (ulong)KSEG0_BASE, (ulong)_start - 1); #endif #endif /* KSEG0_BASE */ kprintf("%10d bytes Xinu code.\r\n", (ulong)&_end - (ulong)_start); #ifdef DETAIL kprintf(" [0x%08X to 0x%08X]\r\n", (ulong)_start, (ulong)&_end - 1); #endif kprintf("%10d bytes stack space.\r\n", (ulong)memheap - (ulong)&_end); #ifdef DETAIL kprintf(" [0x%08X to 0x%08X]\r\n", (ulong)&_end, (ulong)memheap - 1); #endif kprintf("%10d bytes heap space.\r\n", (ulong)platform.maxaddr - (ulong)memheap); #ifdef DETAIL kprintf(" [0x%08X to 0x%08X]\r\r\n\n", (ulong)memheap, (ulong)platform.maxaddr - 1); #endif kprintf("\r\n"); #ifdef CONSOLE open(CONSOLE, SERIAL0); #endif /* CONSOLE */ /* enable interrupts here */ enable(); ready(create ((void *)main, INITSTK, INITPRIO, "MAIN", 2, 0, NULL), RESCHED_YES); while (TRUE) { #ifndef DEBUG pause(); #endif /* DEBUG */ } return OK; }
/** * Intializes the system and becomes the null process. * This is where the system begins after the C environment has been * established. Interrupts are initially DISABLED, and must eventually * be enabled explicitly. This routine turns itself into the null process * after initialization. Because the null process must always remain ready * to run, it cannot execute code that might cause it to be suspended, wait * for a semaphore, or put to sleep, or exit. In particular, it must not * do I/O unless it uses kprintf for synchronous output. */ int nulluser() { kprintf(VERSION); kprintf("\r\n\r\n"); platforminit(); #ifdef DETAIL /* Output detected platform. */ kprintf("Processor identification: 0x%08X\r\n", cpuid); kprintf("Detected platform as: %s\r\n\r\n",platform.name); #endif sysinit(); /* Output XINU memory layout */ kprintf("%10d bytes physical memory.\r\n", (ulong) platform.maxaddr & 0x7FFFFFFF ); #ifdef DETAIL kprintf(" [0x%08X to 0x%08X]\r\n", (ulong) KSEG0_BASE, (ulong) (platform.maxaddr - 1)); #endif kprintf("%10d bytes reserved system area.\r\n", (ulong) _start - KSEG0_BASE); #ifdef DETAIL kprintf(" [0x%08X to 0x%08X]\r\n", (ulong) KSEG0_BASE, (ulong) _start - 1); #endif kprintf("%10d bytes XINU code.\r\n", (ulong) &end - (ulong) _start); #ifdef DETAIL kprintf(" [0x%08X to 0x%08X]\r\n", (ulong) _start, (ulong) &end - 1); #endif kprintf("%10d bytes stack space.\r\n", (ulong) minheap - (ulong) &end); #ifdef DETAIL kprintf(" [0x%08X to 0x%08X]\r\n", (ulong) &end, (ulong) minheap - 1); #endif kprintf("%10d bytes heap space.\r\n", (ulong) platform.maxaddr - (ulong) minheap); #ifdef DETAIL kprintf(" [0x%08X to 0x%08X]\r\n\r\n", (ulong) minheap, (ulong) platform.maxaddr - 1); #endif ready(create((void *)main, INITSTK, 1, "MAIN", 2, 0, NULL), 0); /* enable interrupts here */ enable(); while(1) { if(nonempty(readylist)) resched(); /* If there are no processes left in the system, completed. */ if (numproc <= 1) { kprintf("\r\n\r\nAll user processes have completed.\r\n\r\n"); while (1) ; } } }