Example #1
0
s32 sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3)
{
	sys_event.Log("sys_event_port_send(eport_id=0x%x, data1=0x%llx, data2=0x%llx, data3=0x%llx)", eport_id, data1, data2, data3);

	LV2_LOCK;

	const auto port = idm::get<lv2_event_port_t>(eport_id);

	if (!port)
	{
		return CELL_ESRCH;
	}

	const auto queue = port->queue.lock();

	if (!queue)
	{
		return CELL_ENOTCONN;
	}

	if (queue->events.size() >= queue->size)
	{
		return CELL_EBUSY;
	}

	const u64 source = port->name ? port->name : ((u64)process_getpid() << 32) | (u64)eport_id;

	queue->push(lv2_lock, source, data1, data2, data3);

	return CELL_OK;
}
Example #2
0
s32 sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data1, u64 data2)
{
	sys_timer.Warning("sys_timer_connect_event_queue(timer_id=0x%x, queue_id=0x%x, name=0x%llx, data1=0x%llx, data2=0x%llx)", timer_id, queue_id, name, data1, data2);

	LV2_LOCK;

	const auto timer = idm::get<lv2_timer_t>(timer_id);
	const auto queue = idm::get<lv2_event_queue_t>(queue_id);

	if (!timer || !queue)
	{
		return CELL_ESRCH;
	}

	if (!timer->port.expired())
	{
		return CELL_EISCONN;
	}

	timer->port   = queue; // connect event queue
	timer->source = name ? name : ((u64)process_getpid() << 32) | timer_id;
	timer->data1  = data1;
	timer->data2  = data2;

	return CELL_OK;
}
Example #3
0
error_code sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3)
{
	sys_event.trace("sys_event_port_send(eport_id=0x%x, data1=0x%llx, data2=0x%llx, data3=0x%llx)", eport_id, data1, data2, data3);

	const auto port = idm::get<lv2_event_port>(eport_id, [](lv2_event_port& port)
	{
		lv2_lock lock{port};

		return port.queue.lock();
	});

	if (!port)
	{
		return CELL_ESRCH;
	}

	if (!port.value)
	{
		return CELL_ENOTCONN;
	}

	if (!port.value->push(port->name ? port->name : (u64)process_getpid() << 32 | eport_id, data1, data2, data3))
	{
		return CELL_EBUSY;
	}

	return CELL_OK;
}
t_log* log_create(char* file, char *program_name, bool is_active_console, t_log_level detail) {
	t_log* logger = malloc(sizeof(t_log));

	if (logger == NULL) {
		perror("Cannot create logger");
		return NULL;
	}

	FILE *file_opened = NULL;

	if (file != NULL) {
		file_opened = txt_open_for_append(file);

		if (file_opened == NULL) {
			perror("Cannot create/open log file");
			free(logger);
			return NULL;
		}
	}

	logger->file = file_opened;
	logger->is_active_console = is_active_console;
	logger->detail = detail;
	logger->pid = process_getpid();
	logger->program_name = string_duplicate(program_name);
	return logger;
}
Example #5
0
s32 sys_event_port_create(vm::ptr<be_t<u32>> eport_id, int port_type, u64 name)
{
	sys_event.Warning("sys_event_port_create(eport_id_addr=0x%x, port_type=0x%x, name=0x%llx)",
		eport_id.addr(), port_type, name);

	if (port_type != SYS_EVENT_PORT_LOCAL)
	{
		sys_event.Error("sys_event_port_create: invalid port_type(0x%x)", port_type);
		return CELL_EINVAL;
	}

	EventPort* eport = new EventPort();
	u32 id = sys_event.GetNewId(eport, TYPE_EVENT_PORT);
	eport->name = name ? name : ((u64)process_getpid() << 32) | (u64)id;
	*eport_id = id;
	sys_event.Warning("*** sys_event_port created: id = %d", id);

	return CELL_OK;
}
Example #6
0
error_code sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data1, u64 data2)
{
	sys_timer.warning("sys_timer_connect_event_queue(timer_id=0x%x, queue_id=0x%x, name=0x%llx, data1=0x%llx, data2=0x%llx)", timer_id, queue_id, name, data1, data2);

	const auto timer = idm::check<lv2_obj, lv2_timer>(timer_id, [&](lv2_timer& timer) -> CellError
	{
		const auto found = idm::find_unlocked<lv2_obj, lv2_event_queue>(queue_id);

		if (!found)
		{
			return CELL_ESRCH;
		}

		semaphore_lock lock(timer.mutex);

		if (!timer.port.expired())
		{
			return CELL_EISCONN;
		}

		// Connect event queue
		timer.port   = std::static_pointer_cast<lv2_event_queue>(found->second);
		timer.source = name ? name : ((u64)process_getpid() << 32) | timer_id;
		timer.data1  = data1;
		timer.data2  = data2;
		return {};
	});

	if (!timer)
	{
		return CELL_ESRCH;
	}

	if (timer.ret)
	{
		return timer.ret;
	}

	return CELL_OK;
}
Example #7
0
error_code sys_event_port_send(ppu_thread& ppu, u32 eport_id, u64 data1, u64 data2, u64 data3)
{
	sys_event.trace("sys_event_port_send(eport_id=0x%x, data1=0x%llx, data2=0x%llx, data3=0x%llx)", eport_id, data1, data2, data3);

	const auto port = idm::get<lv2_obj, lv2_event_port>(eport_id, [&](lv2_event_port& port) -> CellError
	{
		if (const auto queue = port.queue.lock())
		{
			const u64 source = port.name ? port.name : ((u64)process_getpid() << 32) | (u64)eport_id;

			if (queue->send(source, data1, data2, data3))
			{
				return {};
			}

			return CELL_EBUSY;
		}

		return CELL_ENOTCONN;
	});

	if (!port)
	{
		return CELL_ESRCH;
	}

	if (port.ret)
	{
		if (port.ret == CELL_EBUSY)
		{
			return not_an_error(CELL_EBUSY);
		}

		return port.ret;
	}

	return CELL_OK;
}
Example #8
0
s32 sys_process_getpid()
{
	sys_process.trace("sys_process_getpid() -> 1");
	return process_getpid();
}
Example #9
0
s32 sys_process_getpid()
{
	sys_process.Log("sys_process_getpid() -> 1");
	return process_getpid();
}