コード例 #1
0
ファイル: manager.c プロジェクト: gvsurenderreddy/CoLinux64
co_rc_t co_os_manager_init(co_manager_t *manager, co_osdep_manager_t *osdep)
{
	co_rc_t rc = CO_RC(OK);
	int i;
	co_osdep_manager_t dep;

	*osdep = dep = co_os_malloc(sizeof(*dep));
	if (dep == NULL)
		return CO_RC(OUT_OF_MEMORY);

	co_global_manager = manager;

	memset(dep, 0, sizeof(*dep));

	co_list_init(&dep->mdl_list);
	co_list_init(&dep->mapped_allocated_list);
	co_list_init(&dep->pages_unused);
	for (i=0; i < PFN_HASH_SIZE; i++)
		co_list_init(&dep->pages_hash[i]);

	MmResetDriverPaging(&co_global_manager);

	rc = co_os_mutex_create(&dep->mutex);

	setup_host_memory_range(manager, dep);

	return rc;
}
コード例 #2
0
ファイル: queue.c プロジェクト: matt81093/Original-Colinux
co_rc_t co_queue_init(co_queue_t *queue)
{
	queue->items_count = 0;

	co_list_init(&queue->head);

	return CO_RC(OK);
}
コード例 #3
0
ファイル: app_com.c プロジェクト: haby77/fireble_passthrough
/*
****************************************************************************************
* @brief          com_init
* @param[in]      None
* @response       None
* @return         None
* @description    Init com state
*****************************************************************************************/
void com_init(void)
{
    //for com uart tx
    com_env.tx_state = COM_UART_TX_IDLE;	//initialize tx state
    com_env.com_conn = COM_DISCONN;
    com_env.com_mode = COM_MODE_IDLE;
    com_env.auto_line_feed = COM_NO_LF;
    co_list_init(&com_env.queue_tx);			//init TX queue
    co_list_init(&com_env.queue_rx);			//init RX queue
	
    com_gpio_init();
	
		show_com_mode(com_env.com_mode);

    if(KE_EVENT_OK != ke_evt_callback_set(EVENT_UART_TX_ID, com_tx_done))
        ASSERT_ERR(0);
    if(KE_EVENT_OK != ke_evt_callback_set(EVENT_UART_RX_FRAME_ID, com_event_uart_rx_frame_handler))
        ASSERT_ERR(0);
    if(KE_EVENT_OK != ke_evt_callback_set(EVENT_UART_RX_TIMEOUT_ID, com_event_uart_rx_timeout_handler))
        ASSERT_ERR(0);

}
コード例 #4
0
ファイル: reactor.c プロジェクト: gongfuPanada/colinux
co_rc_t co_reactor_create(co_reactor_t *out_handle)
{
	co_reactor_t reactor;

	reactor = co_os_malloc(sizeof(*reactor));
	if (!reactor)
		return CO_RC(OUT_OF_MEMORY);

	co_memset(reactor, 0, sizeof(*reactor));

	co_list_init(&reactor->users);

	*out_handle = reactor;

	return CO_RC(OK);
}
コード例 #5
0
ファイル: daemon.c プロジェクト: matt81093/Original-Colinux
co_rc_t co_daemon_create(co_start_parameters_t *start_parameters, co_daemon_t **co_daemon_out)
{
	co_rc_t rc;
	co_daemon_t *daemon;

	init_srand();

	daemon = (co_daemon_t *)co_os_malloc(sizeof(co_daemon_t));
	if (daemon == NULL) {
		rc = CO_RC(ERROR);
		goto out;
	}

	memset(daemon, 0, sizeof(*daemon));

	co_list_init(&daemon->connected_modules);
	co_queue_init(&daemon->up_queue);

	daemon->start_parameters = start_parameters;
	memcpy(daemon->config.config_path, start_parameters->config_path, 
	       sizeof(start_parameters->config_path));

	rc = co_console_create(80, 25, 25, &daemon->console);
	if (!CO_OK(rc))
		goto out_free;

	rc = co_load_config_file(daemon);
	if (!CO_OK(rc)) {
		co_debug("error loading configuration\n");
		goto out_free_console;
	}

	*co_daemon_out = daemon;
	return rc;

out_free_console:
	co_console_destroy(daemon->console);
	
out_free:
	co_os_free(daemon);

out:
	return rc;
}
コード例 #6
0
ファイル: fileio.c プロジェクト: matt81093/Original-Colinux
co_rc_t co_os_file_getdir(char *dirname, co_filesystem_dir_names_t *names)
{
	UNICODE_STRING dirname_unicode;
	OBJECT_ATTRIBUTES attributes;
	NTSTATUS status;
	HANDLE handle;
	FILE_DIRECTORY_INFORMATION *dir_entries_buffer, *entry;
	unsigned long dir_entries_buffer_size = 0x1000;
	IO_STATUS_BLOCK io_status;
	BOOLEAN first_iteration = TRUE;
	co_filesystem_name_t *new_name;
	co_rc_t rc;

	co_list_init(&names->list);

	co_debug_lvl(filesystem, 10, "listing of '%s'", dirname);

	rc = co_winnt_utf8_to_unicode(dirname, &dirname_unicode);
	if (!CO_OK(rc))
		return rc;

	InitializeObjectAttributes(&attributes, &dirname_unicode,
				   OBJ_CASE_INSENSITIVE, NULL, NULL);

	status = ZwCreateFile(&handle, FILE_LIST_DIRECTORY,
			      &attributes, &io_status, NULL, 0, FILE_SHARE_DIRECTORY, 
			      FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE, 
			      NULL, 0);
	
	if (!NT_SUCCESS(status)) {
		co_debug_lvl(filesystem, 5, "error %x ZwCreateFile('%s')", (int)status, dirname);
		rc = co_status_convert(status);
		goto error;
	}

	dir_entries_buffer = co_os_malloc(dir_entries_buffer_size);
	if (!dir_entries_buffer) {
		rc = CO_RC(OUT_OF_MEMORY);
		goto error_1;
	}

	for (;;) {
		status = ZwQueryDirectoryFile(handle, NULL, NULL, 0, &io_status, 
					      dir_entries_buffer, dir_entries_buffer_size, 
					      FileDirectoryInformation, FALSE, NULL, first_iteration);
		if (!NT_SUCCESS(status))
			break;

		entry = dir_entries_buffer;
  
		for (;;) {
			int filename_utf8_length;
			
			filename_utf8_length = co_utf8_wctowbstrlen(entry->FileName, entry->FileNameLength/sizeof(WCHAR));

			new_name = co_os_malloc(filename_utf8_length + sizeof(co_filesystem_name_t) + 2);
			if (!new_name) {
				rc = CO_RC(OUT_OF_MEMORY);
				goto error_2;
			}
			
			if (entry->FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				new_name->type = FUSE_DT_DIR;
			else
				new_name->type = FUSE_DT_REG;

			rc = co_utf8_wcstombs(new_name->name, entry->FileName, filename_utf8_length + 1);
			if (!CO_OK(rc)) {
				co_os_free(new_name);
				goto error_2;
			}

			co_list_add_tail(&new_name->node, &names->list);
			if (entry->NextEntryOffset == 0)
				break;
			
			entry = (FILE_DIRECTORY_INFORMATION *)(((char *)entry) + entry->NextEntryOffset);
		}

		first_iteration = FALSE;
	}


	rc = CO_RC(OK);

error_2:
	if (!CO_OK(rc))
		co_filesystem_getdir_free(names);

	co_os_free(dir_entries_buffer);

error_1:
	ZwClose(handle);
error:
	co_winnt_free_unicode(&dirname_unicode);
	return rc;
}