Пример #1
0
static void ipc_cleanup_reply(void)
{
	if ((ipc_read(1) & 0x14) != 0x14)
		return;

	ipc_read(2);
	ipc_bell(4);

	ipc_irq_ack();
	ipc_bell(8);
}
Пример #2
0
int ipc_u32_read(int fd, u32 *n)
{
    if (ipc_read(fd, n, sizeof(*n)))
	return -1;
    *n = ntohl(*n);
    return 0;
}
Пример #3
0
gint
ipc_timeout(gpointer data __attribute__((unused)))
{

  ipc_read();
  return 1;
}
Пример #4
0
/* Task that listens for incomming IPC messages from Host and initiate host
 * command processing.
 */
void ipc_comm_task(void)
{
	int ret = 0;
	uint32_t out_drbl, pkt_len;

	for (;;) {

		ret = task_wait_event_mask(EVENT_FLAG_BIT_READ_IPC
					   | EVENT_FLAG_BIT_WRITE_IPC, -1);

		if ((ret & EVENT_FLAG_BIT_WRITE_IPC))
			continue;
		else if (!(ret & EVENT_FLAG_BIT_READ_IPC))
			continue;

		/* Read the command byte.  This clears the FRMH bit in
		 * the status byte.
		 */
		out_drbl = REG32(IPC_HOST2ISH_DOORBELL);
		pkt_len = out_drbl & IPC_HEADER_LENGTH_MASK;

		ret = ipc_read(IPC_PEER_HOST_ID, ipc_host_args, pkt_len);
		host_cmd_args.command = EC_COMMAND_PROTOCOL_3;

		host_cmd_args.result = EC_RES_SUCCESS;
		host_cmd_flags = ipc_host_args->flags;

		/* We only support new style command (v3) now */
		if (host_cmd_args.command == EC_COMMAND_PROTOCOL_3) {
			ipc_packet.send_response = ipc_send_response_packet;

			ipc_packet.request =
			    (const void *)ipc_get_hostcmd_data_range();
			ipc_packet.request_temp = params_copy;
			ipc_packet.request_max = sizeof(params_copy);
			/* Don't know the request size so pass in
			 * the entire buffer
			 */
			ipc_packet.request_size = EC_LPC_HOST_PACKET_SIZE;

			ipc_packet.response =
			    (void *)ipc_get_hostcmd_data_range();
			ipc_packet.response_max = EC_LPC_HOST_PACKET_SIZE;
			ipc_packet.response_size = 0;

			ipc_packet.driver_result = EC_RES_SUCCESS;
			host_packet_receive(&ipc_packet);
			usleep(10);	/* To force yield */

			continue;
		} else {
			/* Old style command unsupported */
			host_cmd_args.result = EC_RES_INVALID_COMMAND;
		}

		/* Hand off to host command handler */
		host_command_received(&host_cmd_args);
	}
}
Пример #5
0
void check_msg()
{
 static MENU tmenu = {"User msg", 1 };

 ui_nextstate(0);
 while(ipc_read(tmenu.cmd[0], MCMDLEN)>0)
  if(tmenu.cmd[0][0]=='>')
   exec_menu(tmenu);
 ui_nextstate(1);
}
Пример #6
0
Файл: ipc.c Проект: const86/rfs
bool ipc_read_uint32_t(struct ipc *ipc, uint32_t *p)
{
	uint32_t x;

	if (!ipc_read(ipc, &x, sizeof(x)))
		return false;

	*p = ntohl(x);
	return true;
}
Пример #7
0
/* For reading data from a socket - use it in the module task. */
int ipc_accept_buf_read(int server_fd, void *data, int data_len)
{
    int fd, rc;
    
    if ((fd = ipc_accept(server_fd)) < 0)
	return -1;
    rc = ipc_read(fd, data, data_len);
    ipc_server_close(fd, rc);
    return rc;
}
Пример #8
0
static int ipc_varbuf_read(int fd, char **data, int *len)
{
    if (ipc_u32_read(fd, len))
	return -1;
    if (!(*data = malloc_l(*len)))
	goto Error;
    if (ipc_read(fd, *data, *len))
	goto Error;
    return 0;

Error:
    nfree(*data);
    return -1;
}
Пример #9
0
void vfss()
{
    IPC ipc;
    VFSS_TYPE vfss;

#if (VFS_DEBUG_INFO) || (VFS_DEBUG_ERRORS)
    open_stdout();
#endif //(VFS_DEBUG_INFO) || (VFS_DEBUG_ERRORS)

    vfss_init(&vfss);

    for (;;)
    {
        ipc_read(&ipc);
        vfss_request(&vfss, &ipc);
        ipc_write(&ipc);
    }
}
Пример #10
0
static void ipc_recv_reply(void)
{
	for (;;) {
		u32 reply;

		ipc_wait_reply();

		reply = ipc_read(2);
		ipc_bell(4);

		ipc_irq_ack();
		ipc_bell(8);

		if (reply == virt_to_phys(&ipc))
			break;
	}

	sync_before_read(&ipc, sizeof ipc);
}
Пример #11
0
void app()
{
    APP app;
    CC1101 cc1101;
    IPC ipc;

    app_init(&app);

    cc1101_hw_init(&cc1101);

    for (;;)
    {
        ipc_read(&ipc);
        switch (HAL_GROUP(ipc.cmd))
        {
        default:
            error(ERROR_NOT_SUPPORTED);
            break;
        }
        ipc_write(&ipc);
    }
}
Пример #12
0
void loras_main()
{
    IPC ipc;
    LORA lora;
#if (LORA_DEBUG)
    open_stdout();
#endif //LORA_DEBUG
    init(&lora);

    for (;;)
    {
        ipc_read(&ipc);
        switch (HAL_GROUP(ipc.cmd))
        {
        case HAL_LORA:
            loras_request(&lora, &ipc);
            break;
        default:
            error(ERROR_NOT_SUPPORTED);
            break;
        }
        ipc_write(&ipc);
    }
}
Пример #13
0
static void ipc_bell(u32 w)
{
	ipc_write(1, (ipc_read(1) & 0x30) | w);
}
Пример #14
0
	void Connector::ThreadEntry(__unused Thread *thread)
	{
		// Register
		{
			struct
			{
				ipc_header_t header;
				char name[255];
			} message;

			message.header.flags = IPC_HEADER_FLAG_RESPONSE | IPC_HEADER_FLAG_GET_RESPONSE_BITS(IPC_MESSAGE_RIGHT_COPY_SEND);
			message.header.reply = _port;
			message.header.port = ipc_get_special_port(0);
			message.header.size = _name->GetLength();
			message.header.id = 0;

			strcpy(message.name, _name->GetCString());
			ipc_write(&message.header);
		}

		// Work loop
		uint8_t *receiveBuffer = new uint8_t[8192 + sizeof(ipc_header_t)];
		uint8_t *responseBuffer = new uint8_t[8192 + sizeof(ipc_header_t)];

		ipc_header_t *receive = reinterpret_cast<ipc_header_t *>(receiveBuffer);
		ipc_header_t *response = reinterpret_cast<ipc_header_t *>(responseBuffer);

		while(!_thread->IsCancelled())
		{
			receive->port = _port;
			receive->flags = IPC_HEADER_FLAG_BLOCK;
			receive->size = 8192;

			ipc_return_t result = ipc_read(receive);

			if(result == KERN_SUCCESS)
			{
				size_t responseSize = 8192;
				bool hasResponse = DispatchMessage(receive->id, receiveBuffer, receive->size, responseBuffer + sizeof(ipc_header_t), responseSize);

				if(hasResponse)
				{
					response->port = receive->port;
					response->flags = 0;
					response->size = responseSize;

					ipc_write(response);
				}
			}
		}

		delete[] receiveBuffer;
		delete[] responseBuffer;

		// Unregister
		{
			struct
			{
				ipc_header_t header;
				char name[255];
			} message;

			message.header.flags = 0;
			message.header.reply = _port;
			message.header.port = ipc_get_special_port(0);
			message.header.size = _name->GetLength();
			message.header.id = 1;

			strcpy(message.name, _name->GetCString());
			ipc_write(&message.header);
		}
	}
Пример #15
0
static void ipc_wait_ack(void)
{
	while ((ipc_read(1) & 0x22) != 0x22)
		;
}
Пример #16
0
static void ipc_cleanup_request(void)
{
	if ((ipc_read(1) & 0x22) == 0x22)
		ipc_bell(2);
}
Пример #17
0
static void ipc_wait_reply(void)
{
	while ((ipc_read(1) & 0x14) != 0x14)
		;
}