コード例 #1
0
int main(void) {
  printf("Testing null syscall...\n");
  TestSyscall((uintptr_t) NACL_SYSCALL(null));

  /*
   * Check tls_get and second_tls_get specifically because they are
   * implemented via fast paths in assembly code.
   */
  printf("Testing tls_get syscall...\n");
  TestSyscall((uintptr_t) NACL_SYSCALL(tls_get));

  printf("Testing second_tls_get syscall...\n");
  TestSyscall((uintptr_t) NACL_SYSCALL(second_tls_get));

  printf("Testing initial register state at thread entry...\n");
  TestInitialRegsAtThreadEntry();

  return 0;
}
コード例 #2
0
ファイル: Main.cpp プロジェクト: dakk/abstract-os
/** 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;	
}