Exemplo n.º 1
0
void __assertion_handle_failure(const struct __assertion_point *point) {
	if (cpudata_var(assert_recursive_lock)) {
		printk("\nrecursion detected on CPU %d\n",
				cpu_get_id());
		goto out;
	}
	cpudata_var(assert_recursive_lock) = 1;

	spin_lock_ipl_disable(&assert_lock);

	print_oops();
	printk(
		" ASSERTION FAILED on CPU %d\n"
		LOCATION_FUNC_FMT("\t", "\n") "\n"
		"%s\n",

		cpu_get_id(),
		LOCATION_FUNC_ARGS(&point->location),
		point->expression);

	if (*__assertion_message_buff)
		printk("\n\t(%s)\n", __assertion_message_buff);

	whereami();

	spin_unlock(&assert_lock);  /* leave IRQs off */

out:
	arch_shutdown(ARCH_SHUTDOWN_MODE_ABORT);
	/* NOTREACHED */
}
Exemplo n.º 2
0
/* Called to shut down the system and return to the debug handler (if any) */
void arch_return() {
	/* Shut down */
	arch_shutdown();
	
	/* Jump back to the boot loader */
	arch_real_exit();
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: Hooman3/minix
/*===========================================================================*
 *				shutdown 				     *
 *===========================================================================*/
void minix_shutdown(minix_timer_t *tp)
{
/* This function is called from prepare_shutdown or stop_sequence to bring 
 * down MINIX.
 */
  int how;

#ifdef CONFIG_SMP
  /* 
   * FIXME
   *
   * we will need to stop timers on all cpus if SMP is enabled and put them in
   * such a state that we can perform the whole boot process once restarted from
   * monitor again
   */
  if (ncpus > 1)
	  smp_shutdown_aps();
#endif
  hw_intr_disable_all();
  stop_local_timer();

  how = tp ? tmr_arg(tp)->ta_int : 0;

  /* Show shutdown message */
  direct_cls();
  if((how & RB_POWERDOWN) == RB_POWERDOWN)
	direct_print("MINIX has halted and will now power off.\n");
  else if(how & RB_HALT)
	direct_print("MINIX has halted. "
		     "It is safe to turn off your computer.\n");
  else
	direct_print("MINIX will now reset.\n");
  arch_shutdown(how);
}
Exemplo n.º 4
0
/* Everything needed to cleanly shutdown barebox.
 * Should be called before starting an OS to get
 * the devices into a clean state
 */
void shutdown_barebox(void)
{
	devices_shutdown();
#ifdef ARCH_SHUTDOWN
	arch_shutdown();
#endif
}
Exemplo n.º 5
0
void __noreturn reset_cpu(unsigned long addr)
{
    arch_shutdown();

    asm("mov pc, #0");

    hang();
}
Exemplo n.º 6
0
void nucleos_shutdown(timer_t *tp)
{
/* This function is called from prepare_shutdown or stop_sequence to bring
 * down Nucleos. How to shutdown is in the argument: RBT_HALT (return to the
 * monitor), RBT_MONITOR (execute given code), RBT_RESET (hard reset).
 */
	arch_stop_local_timer();
	intr_init(INTS_ORIG, 0);
	arch_shutdown(tp ? tmr_arg(tp)->ta_int : RBT_PANIC);
}
Exemplo n.º 7
0
int entry(unsigned int cpu_id, struct per_cpu *cpu_data)
{
	static volatile bool activate;
	bool master = false;

	cpu_data->cpu_id = cpu_id;

	spin_lock(&init_lock);

	if (master_cpu_id == -1) {
		master = true;
		init_early(cpu_id);
	}

	if (!error)
		cpu_init(cpu_data);

	spin_unlock(&init_lock);

	while (!error && initialized_cpus < hypervisor_header.online_cpus)
		cpu_relax();

	if (!error && master) {
		init_late(cpu_data);
		if (!error) {
			/*
			 * Make sure everything was committed before we signal
			 * the other CPUs that they can continue.
			 */
			memory_barrier();
			activate = true;
		}
	} else {
		while (!error && !activate)
			cpu_relax();
	}

	if (error) {
		if (master)
			arch_shutdown();
		arch_cpu_restore(cpu_data);
		return error;
	}

	if (master)
		printk("Activating hypervisor\n");

	/* point of no return */
	arch_cpu_activate_vmm(cpu_data);
}
Exemplo n.º 8
0
/** Shutdown and reboot */
void 
shutdown(int type)
{
	#ifdef VFS
		delete Managers::Instance->vfsManager;
	#endif
	#ifdef NETWORK
		delete Managers::Instance->netManager;
	#endif
	#ifdef PCIBUS
		delete Managers::Instance->pciBus;
	#endif
	#ifdef UI
		delete Managers::Instance->uiManager;
	#endif
	#ifdef PRINT
		delete Managers::Instance->printManager;
	#endif
	#ifdef MEDIA
		delete  Managers::Instance->mediaManager;
	#endif
	#ifdef SECURITY
		delete Managers::Instance->securityManager;
	#endif


	arch_ksetcl(12);
	printf("\nThe system is going down: ");	
	arch_ksetcl(0x0F);
	
	switch(type)
	{
		case 1:
			puts("Shutdown.\n");
			arch_shutdown();
			break;
		case 2:
			puts("Reboot.\n");
			arch_reboot();
			break;
	}
	while(1);
}
Exemplo n.º 9
0
/*===========================================================================*
 *				shutdown 				     *
 *===========================================================================*/
void minix_shutdown(timer_t *tp)
{
/* This function is called from prepare_shutdown or stop_sequence to bring 
 * down MINIX. How to shutdown is in the argument: RBT_HALT (return to the
 * monitor), RBT_RESET (hard reset). 
 */
  int how;

#ifdef CONFIG_SMP
  /* 
   * FIXME
   *
   * we will need to stop timers on all cpus if SMP is enabled and put them in
   * such a state that we can perform the whole boot process once restarted from
   * monitor again
   */
  if (ncpus > 1)
	  smp_shutdown_aps();
#endif
  hw_intr_disable_all();
  stop_local_timer();

  how = tp ? tmr_arg(tp)->ta_int : RBT_PANIC;

  /* Show shutdown message */
  direct_cls();
  switch(how) {
  case RBT_HALT:
	direct_print("MINIX has halted. "
		     "It is safe to turn off your computer.\n");
	break;
  case RBT_POWEROFF:
	direct_print("MINIX has halted and will now power off.\n");
	break;
  case RBT_DEFAULT:
  case RBT_REBOOT:
  case RBT_RESET:
  default:
	direct_print("MINIX will now reset.\n");
	break;
  }
  arch_shutdown(how);
}
Exemplo n.º 10
0
/*===========================================================================*
 *				shutdown 				     *
 *===========================================================================*/
void minix_shutdown(timer_t *tp)
{
/* This function is called from prepare_shutdown or stop_sequence to bring 
 * down MINIX. How to shutdown is in the argument: RBT_HALT (return to the
 * monitor), RBT_MONITOR (execute given code), RBT_RESET (hard reset). 
 */
#ifdef CONFIG_SMP
  /* 
   * FIXME
   *
   * we will need to stop timers on all cpus if SMP is enabled and put them in
   * such a state that we can perform the whole boot process once restarted from
   * monitor again
   */
  if (ncpus > 1)
	  smp_shutdown_aps();
#endif
  hw_intr_disable_all();
  stop_local_timer();
  arch_shutdown(tp ? tmr_arg(tp)->ta_int : RBT_PANIC);
}
Exemplo n.º 11
0
void minix_shutdown(timer_t *t) { arch_shutdown(RBT_PANIC); }
Exemplo n.º 12
0
/** Main function of the kernel */ 
int 
main() 
{
	uint16_t err;
	char args[12][128];
	extern multiboot_info_t *multiboot;

	
	err = arch_init();
	
	if(err)
	{
		arch_shutdown();
		while(1);
	}

	/* kernel start message */
	arch_kclear();
	arch_ksetcl(COL_H);
	printf("* %s %s (rev %s on %s)\n", NAME, RELEASE_NAME, REVISION, ARCH);
	arch_ksetcl(COL_N);
	puts("Loading...\n");
	printf("Kernel compiled with: %s\n", CONTENTS);
	
	/* mem initialization */
	printf("MemoryManager init, %s\n", ((!mm_init(arch_mem_total())) ? "done" : "fail"));
	

	/* Create all singleton elements */
	Managers::Instance = (Managers *) /*SINGLETON_ADDRESS; */ new Managers();
	Managers::Instance->archManager = new ArchManager();
	Managers::Instance->deviceManager = new DeviceManager();
	Managers::Instance->driverManager = new DriverManager();
	Managers::Instance->taskManager = new TaskManager();
	#ifdef VFS
		Managers::Instance->vfsManager = new VFSManager();
	#endif
	#ifdef NETWORK
		Managers::Instance->netManager = new NetworkManager();
	#endif
	#ifdef PCIBUS
		Managers::Instance->pciBus = new PciBus();
	#endif
	#ifdef UI
		Managers::Instance->uiManager = new UiManager();
	#endif
	#ifdef PRINT
		Managers::Instance->printManager = new PrintManager();
	#endif
	#ifdef MEDIA
		Managers::Instance->mediaManager = new MediaManager();
	#endif
	#ifdef SECURITY
		Managers::Instance->securityManager = new SecurityManager();
	#endif

	Instance = (void *) Managers::Instance;

	/* Parse cmdline commands */
	#ifdef X86
	{
		char *cmd = (char *) multiboot->cmdline;
		int i = 0;
		int k = 0;

		while(*cmd != 0)
		{
			if(*cmd == ' ')
			{
				args[k][i] = 0;
				k++;
				i = 0;
			}
			else
				args[k][i++] = *cmd;
			cmd++;
		}
		args[k][i] = 0;
		args[k+1][0] = 0;
	}
	#endif
	#ifdef PCIBUS
		Managers::Instance->pciBus->Update();
	#endif

	/* Probing all devices */
	printf("Probing devices: ");
	printf("%s\n", Managers::Instance->deviceManager->Probe() == 0 ? "none" : " ");


	/* Mounting filesystems */
	#ifdef VFS
		/* Parse kernel arguments to find a valid fs */
		char fs[16] = {};
		char dev[16] = {};

		int i;
		for(i = 0; (i < 12) && (args[i][0] != 0); i++)
		{
			if(strncmp(args[i], "dev=", strlen("dev=")) == 0)
				strcpy(dev, args[i]+strlen("dev="));
			else if(strncmp(args[i], "fs=", strlen("fs=")) == 0)
				strcpy(fs, args[i]+strlen("fs="));
		}


		/* If there's fs and dev infos, mount the partition */
		if((fs[0] != 0) && (dev[0] != 0))
		{
			bool state;

			printf("Mounting %s with %s, ", dev, fs);

			state = Managers::Instance->vfsManager->Mount("/", Managers::Instance->deviceManager->getDevice(dev), fs);
			state ? printf("done\n") : printf("fail\n");

			#if 0
			ReadDir d;
			i = 0;
			printf("Listing directory /\n");
			while(Managers::Instance->vfsManager->readDir("/", &d, i))
			{
				printf("\t%d -> %s\n", d.Node, d.Name);
				i++;
			}
			#endif
		}
	#endif

	/* Probing all network iface */
	#ifdef NETWORK
		printf("Probing network interfaces: ");
		printf("%s\n", Managers::Instance->netManager->Probe() == 0 ? "none" : " ");
	#endif

	Shell();
	#ifdef TEST
		/* Syscall test */
		printf("Testing syscall and global singleton... ");
		extern void TestSyscall();
		TestSyscall();

		/* Test elf file loading */
		printf("Executing test app\n");
		Managers::Instance->taskManager->Exec("/test", NULL, NULL);
	#endif

	#ifdef UI
		/*  if(!*/Managers::Instance->uiManager->Setup(); //)
		/* {
			printf("Cannot start ui.\n");
			#ifdef SHELL
				Shell();
			#endif
		}
		else*/
			Managers::Instance->uiManager->mainLoop();
	#endif
	#ifndef UI
		#ifdef SHELL
			Shell();
		#endif
	#endif

	printf("\nNothing to do. Infinite loop\n");

	while(1);
	return 0;	
}	
Exemplo n.º 13
0
void minix_shutdown(minix_timer_t *t) { arch_shutdown(0); }
Exemplo n.º 14
0
void 
ArchManager::Shutdown()
{
	arch_shutdown();
}