Ejemplo n.º 1
0
int k_main(struct multiboot *mboot, u32 stack)
{
	elf_from_mb(mboot, &kelf);

	/* bring up the kernel subsystems */
	init_subsystems();

	printf("@@@@@@@@@@@@@@@@@@@@@@@@@"
	       "@@@@@@@@@@ EUCLID @@@@@@@"
	       "@@@@@@@@@@@@@@@@@@@@@@@@@"
	       "@@@@@\n");
	printf("Hello, World!\n");

	/* For now let's just push a value to EAX (x86). */
	return (int)0xABCDEFCC;
}
Ejemplo n.º 2
0
/* FIXME:
 * - parse options first
 * - load configuration
 * - select/init gui (no window opened yet)
 * - init buffers / load files
 * - start event loop etc ...
 * - show main window
 */
bool application::run(int ac, char ** av)
{
	bool ret;

	//
	ret = ew::codecs::text::unicode::utf8::init();
	if (ret == false) {
		return false;
	}

	// parse command line
	ret = parse_command_line(ac, av);
	if (ret == false) {
		return false;
	}

	ret = init_subsystems(this);
	if (ret == false) {
		return false;
	}


	// prepare buffers, files, fonts etc ..
	ret = m_priv->setup_modules();

	// prepare buffers, files, fonts etc ..
	ret = m_priv->setup_buffers();

	// start core thread
	m_priv->core_thread = std::make_unique<std::thread>(eedit::core::main, app);

	// ui main loop
	ret = m_priv->main_loop();

	// wait for core completion
	m_priv->core_thread->join();

	// prepare buffers, files, fonts etc ..
	ret = m_priv->release_buffers();

	//
	ret = m_priv->release_modules();

	quit_subsystems(this);

	return ret;
}
Ejemplo n.º 3
0
int main()
{
	int ret = 0;
	struct e3d_window *wnd;
	struct shaders shaders;
	struct ulog_dev *log;

	ulog_flog(NULL, ULOG_INFO, "Starting\n");

	ret = init_subsystems();
	if (ret)
		goto err;

	wnd = e3d_window_new();
	if (!wnd) {
		ret = -1;
		goto err_subs;
	}

	ret = init_shaders(&shaders);
	if (ret)
		goto err_wnd;

	log = debug_log("Game: ");
	if (!log) {
		ret = -ENOMEM;
		goto err_shader;
	}

	ret = game_run(log, wnd, &shaders);

	ulog_unref(log);
err_shader:
	destroy_shaders(&shaders);
err_wnd:
	e3d_window_free(wnd);
err_subs:
	destroy_subsystems();
err:
	if (ret)
		ulog_flog(NULL, ULOG_ERROR, "Abort\n");
	else
		ulog_flog(NULL, ULOG_INFO, "Exiting\n");
	return -ret;
}
Ejemplo n.º 4
0
Archivo: kernel.c Proyecto: drewt/Telos
//-----------------------------------------------------------------------------
void kmain(struct multiboot_info *info, unsigned long magic)
{
	#define bprintf(fmt, ...) _kprintf(0xA, fmt, ## __VA_ARGS__)

	mb_info = info;

	// initialize console so we can print boot status
	console_clear(0);

	// check multiboot magic number
	if (magic != MULTIBOOT_BOOTLOADER_MAGIC) {
		kprintf("Invalid Multiboot magic number\n");
		return;
	}

	bprintf("32 bit Telos " VERSION "\n");

	bprintf("Initializing machine state...\n");
	idt_install();
	gdt_install();
	pic_init(0x20, 0x28);	// map IRQs after exceptions/reserved vectors
	pit_init(100);		// 10ms timer
	clock_init();

	bprintf("Initializing kernel subsystems...\n");
	init_subsystems();

	bprintf("\n----------- MEMORY -----------\n");
	bprintf("Kernel:    %p - %p\n", &_kstart, &_kend);
	bprintf("Userspace: %p - %p\n", &_ustart, &_uend);
	bprintf("Total:     %lx bytes\n", MULTIBOOT_MEM_MAX(mb_info));

	mount_root();

	bprintf("Starting Telos...\n\n");
	sched_start();

	#undef bprintf
}
Ejemplo n.º 5
0
void main()
{
	win7compat_init();
	log_init();
	fork_init();
	/* fork_init() will directly jump to restored thread context if we are a fork child */

	mm_init();
	flags_init();

	/* Parse command line */
	const char *cmdline = GetCommandLineA();
	int len = strlen(cmdline);
	if (len > BLOCK_SIZE) /* TODO: Test if there is sufficient space for argv[] array */
	{
		init_subsystems();
		kprintf("Command line too long.\n");
		process_exit(1, 0);
	}

	startup = mm_mmap(NULL, BLOCK_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,
		INTERNAL_MAP_TOPDOWN | INTERNAL_MAP_NORESET | INTERNAL_MAP_VIRTUALALLOC, NULL, 0);
	*(uintptr_t*) startup = 1;
	char *current_startup_base = startup + sizeof(uintptr_t);
	memcpy(current_startup_base, cmdline, len + 1);
	char *envbuf = (char *)ALIGN_TO(current_startup_base + len + 1, sizeof(void*));
	char *env0 = envbuf;
	ENV("TERM=xterm");
	char *env1 = envbuf;
	ENV("HOME=/root");
	char *env2 = envbuf;
	ENV("DISPLAY=127.0.0.1:0");
	char *env3 = envbuf;
	ENV("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin");
	int argc = 0;
	char **argv = (char **)ALIGN_TO(envbuf, sizeof(void*));

	/* Parse command line */
	int in_quote = 0;
	char *j = current_startup_base;
	for (char *i = current_startup_base; i <= current_startup_base + len; i++)
		if (!in_quote && (*i == ' ' || *i == '\t' || *i == '\r' || *i == '\n' || *i == 0))
		{
			*i = 0;
			if (i > j)
				argv[argc++] = j;
			j = i + 1;
		}
		else if (*i == '"')
		{
			*i = 0;
			if (in_quote)
				argv[argc++] = j;
			in_quote = !in_quote;
			j = i + 1;
		}
	argv[argc] = NULL;
	char **envp = argv + argc + 1;
	int env_size = 4;
	envp[0] = env0;
	envp[1] = env1;
	envp[2] = env2;
	envp[3] = env3;
	envp[4] = NULL;
	char *buffer_base = (char*)(envp + env_size + 1);

	const char *filename = NULL;
	int arg_start;
	for (int i = 1; i < argc; i++)
	{
		if (!strcmp(argv[i], "--session-id"))
		{
			if (++i < argc)
			{
				int len = strlen(argv[i]);
				if (len >= MAX_SESSION_ID_LEN)
				{
					init_subsystems();
					kprintf("--session-id: Session ID too long.\n");
					process_exit(1, 0);
				}
				for (int j = 0; j < len; j++)
				{
					char ch = argv[i][j];
					if (!((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
						ch == '_' || ch == '-'))
					{
						init_subsystems();
						kprintf("--session-id: Invalid characters.\n");
						process_exit(1, 0);
					}
				}
				strcpy(cmdline_flags->global_session_id, argv[i]);
			}
			else
			{
				init_subsystems();
				kprintf("--session-id: No ID given.\n");
				process_exit(1, 0);
			}
		}
		else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
		{
			init_subsystems();
			print_help();
			process_exit(1, 0);
		}
		else if (!strcmp(argv[i], "--usage"))
		{
			init_subsystems();
			print_usage();
			process_exit(1, 0);
		}
		else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v"))
		{
			init_subsystems();
			print_version();
			process_exit(1, 0);
		}
		else if (!strcmp(argv[i], "--dbt-trace"))
			cmdline_flags->dbt_trace = true;
		else if (!strcmp(argv[i], "--dbt-trace-all"))
		{
			cmdline_flags->dbt_trace = true;
			cmdline_flags->dbt_trace_all = true;
		}
		else if (argv[i][0] == '-')
		{
			init_subsystems();
			kprintf("Unrecognized option: %s\n", argv[i]);
			process_exit(1, 0);
		}
		else if (!filename)
		{
			filename = argv[i];
			arg_start = i;
			break;
		}
	}

	init_subsystems();
	if (filename)
	{
		install_syscall_handler();
		int r = do_execve(filename, argc - arg_start, argv + arg_start, env_size, envp, buffer_base, NULL);
		if (r == -L_ENOENT)
		{
			kprintf("Executable not found.");
			process_exit(1, 0);
		}
	}
	print_usage();
	process_exit(1, 0);
}
Ejemplo n.º 6
0
/*
 * Initialize sequence before T-Kernel starts
 */
EXPORT ER init_system( void )
{
	ER	ercd;

	/* Platform dependent initialize sequence */
	DispProgress(0x10);
	ercd = init_device();
	if ( ercd < E_OK ) {
		goto err_ret;
	}

	/* Initialize subsystem */
	DispProgress(0x11);
	ercd = init_subsystems();
	if ( ercd < E_OK ) {
		goto err_ret;
	}

	/* Initialize segment manager */
	DispProgress(0x12);
	ercd = init_segmgr();
	if ( ercd < E_OK ) {
		goto err_ret;
	}
#ifdef _BTRON_
	ercd = init_bk_early();
	if (ercd < E_OK) {
		vd_printf("error init_bk_early\n");
		goto err_ret;
	}

#endif
	/* Initialize memory manager */
	DispProgress(0x13);
	ercd = init_memmgr();
	if ( ercd < E_OK ) {
		goto err_ret;
	}

#ifdef _BTRON_
	/* Initialize slab allocator */
	DispProgress(0x14);
	ercd = init_slab_allocator();
	if ( ercd < E_OK ) {
		vd_printf("init_slab_allocator\n");
		goto err_ret;
	}
	
	/* Initialize bk */
	DispProgress(0x15);
	ercd = init_bk();
	if ( ercd < E_OK ) {
		vd_printf("init_bk\n");
		goto err_ret;
	}
#else
	/* Initialize Imalloc */
	DispProgress(0x14);
	ercd = init_Imalloc();
	if ( ercd < E_OK ) {
		goto err_ret;
	}
#endif

	return(ercd);

err_ret:
#if USE_KERNEL_MESSAGE
	tm_putstring((UB*)"!ERROR! init_kernel\n");
#endif
	//tm_monitor(); /* Stop */
	return(ercd);
}
Ejemplo n.º 7
0
/*
 * Initialize sequence before T-Kernel starts
 */
EXPORT void init_system( void )
{
	ER	ercd;

	/* if i'm first processor, execution */
	if ( get_prid() == 0 ) {
		/* Platform dependent initialize sequence */
		DispProgress(0x10);
		ercd = init_device();
		if ( ercd < E_OK ) {
			goto err_ret;
		}

		/* Initialize subsystem */
		DispProgress(0x11);
		ercd = init_subsystems();
		if ( ercd < E_OK ) {
			goto err_ret;
		}

		/* Initialize segment manager */
		DispProgress(0x12);
		ercd = init_segmgr();
		if ( ercd < E_OK ) {
			goto err_ret;
		}

		/* Initialize memory manager */
		DispProgress(0x13);
		ercd = init_memmgr();
		if ( ercd < E_OK ) {
			goto err_ret;
		}

		/* Initialize Imalloc */
		DispProgress(0x14);
		ercd = init_Imalloc();
		if ( ercd < E_OK ) {
			goto err_ret;
		}
	} else {
		/* Platform dependent initialize sequence */
		DispProgress(0x10);
		ercd = init_device();
		if ( ercd < E_OK ) {
			goto err_ret;
		}

		/* Initialize segment manager */
		DispProgress(0x12);
		ercd = init_segmgr();
		if ( ercd < E_OK ) {
			goto err_ret;
		}
	}

	return;

err_ret:
#if USE_KERNEL_MESSAGE
	tm_putstring((UB*)"!ERROR! init_kernel\n");
#endif
	tm_monitor(); /* Stop */
}