Esempio n. 1
0
void
umain(void)
{
	envid_t who;

	if ((who = fork()) != 0) {
		// get the ball rolling
		cprintf("send 0 from %x to %x\n", sys_getenvid(), who);
		ipc_send(who, 0, 0, 0);
	}

	while (1) {
		uint32_t i = ipc_recv(&who, 0, 0);
		cprintf("%x got %d from %x\n", sys_getenvid(), i, who);
		if (i == 10)
			return;
		i++;
		ipc_send(who, i, 0, 0);
		if (i == 10)
			return;
	}
}
Esempio n. 2
0
// Reconnect the given socket. Only works for UDP datagram streams.
return_type ipv4_reconnect(ipc_structure_type *ipv4_structure, ipv4_reconnect_type *connect)
{
    message_parameter_type message_parameter;

    message_parameter.protocol = IPC_PROTOCOL_IPV4;
    message_parameter.message_class = IPC_IPV4_RECONNECT;
    message_parameter.data = connect;
    message_parameter.length = sizeof(ipv4_reconnect_type);
    message_parameter.block = TRUE;
    ipc_send(ipv4_structure->output_mailbox_id, &message_parameter);

    return IPV4_RETURN_SUCCESS;
}
Esempio n. 3
0
void
serve_remove(u_int envid, struct Fsreq_remove *rq)
{
    int r = 0;
    u_char path[MAXPATHLEN];    
	if (debug) printf("serve_remove %08x %s\n", envid, rq->req_path);
    memcpy(path, rq->req_path, MAXPATHLEN);
    r = file_remove(path);
    ipc_send(envid, r, 0, 0);
    
	// Your code here
	//panic("serve_remove not implemented");
}
Esempio n. 4
0
static int
xopen(const char *path, int mode)
{
	extern union Fsipc fsipcbuf;
	envid_t fsenv;
	
	strcpy(fsipcbuf.open.req_path, path);
	fsipcbuf.open.req_omode = mode;

	fsenv = ipc_find_env(ENV_TYPE_FS);
	ipc_send(fsenv, FSREQ_OPEN, &fsipcbuf, PTE_P | PTE_W | PTE_U);
	return ipc_recv(NULL, FVA, NULL);
}
Esempio n. 5
0
/*
 * Parse a command of arbitrary length, execute it, place result in *ret.
 */
void ipc_run(int handle, struct ipc_ret_t *ret, const char *fmt, ...)
{
	va_list ap;
	char *buffer;
	int iret;
	assert(fmt);
	va_start(ap, fmt);
	iret = vasprintf(&buffer, fmt, ap);
	assert(iret>=0);
	va_end(ap);
	assert(buffer);
	ipc_send(handle, buffer, strlen(buffer),ret);
	free(buffer);
}
Esempio n. 6
0
void
serve_dirty(u_int envid, struct Fsreq_dirty *rq)
{
    struct Open *o;
    int r;
	if (debug) printf("serve_dirty %08x %08x %08x\n", envid, rq->req_fileid, rq->req_offset);
    if((r = open_lookup(envid, rq->req_fileid, &o)) < 0)
        goto out_dirty;
    r = file_dirty(&o->o_ff->f_file, rq->req_offset);
out_dirty:
    ipc_send(envid, r, 0, 0);
	// Your code here
	// panic("serve_dirty not implemented");
}
Esempio n. 7
0
void
umain(void)
{
	u_int who, i;

	if ((who = fork()) != 0) {
		// get the ball rolling
		printf("send 0 from %x to %x\n", sys_getenvid(), who);
		ipc_send(who, 0, 0, 0);
	}

	for (;;) {
		i = ipc_recv(&who, 0, 0);
		printf("%x got %d from %x\n", sys_getenvid(), i, who);
		if (i == 10)
			return;
		i++;
		ipc_send(who, i, 0, 0);
		if (i == 10)
			return;
	}
		
}
Esempio n. 8
0
void
serve_remove(u_int envid, struct Fsreq_remove *rq)
{
	if (debug) {
		writef("serve_map %08x %s\n", envid, rq->req_path);
	}

	// Your code here
	int r;
	u_char path[MAXPATHLEN];

	// Copy in the path, making sure it's null-terminated
	user_bcopy(rq->req_path, path, MAXPATHLEN);
	path[MAXPATHLEN - 1] = 0;

	if ((r = file_remove((char *)path)) < 0) {
		ipc_send(envid, r, 0, 0);
		return;
	}

	ipc_send(envid, 0, 0, 0);//PTE_V);
	//	user_panic("serve_remove not implemented");
}
Esempio n. 9
0
void
serve_close(u_int envid, struct Fsreq_close *rq)
{
    struct Open *o;
    int r = 0;
	if (debug) printf("serve_close %08x %08x\n", envid, rq->req_fileid);
    if((r = open_lookup(envid, rq->req_fileid, &o)) < 0)
        goto out_close;
    file_close(&o->o_ff->f_file);
out_close:
    ipc_send(envid, r, 0, 0);
	// Your code here
	// panic("serve_close not implemented");
}
Esempio n. 10
0
void lbs_send_packet(uint32_t type, uint32_t size, uint32_t subType, void* buf)
{	
	struct modem_io pkt;
	struct lbsPacketHeader* hdr;
	void* sendBuf;
	sendBuf = (void*) lbsSendBuf;
	hdr = (struct lbsPacketHeader*) &lbsSendBuf;
	
	/* BIG WTF at the lengths below, shitload of uninitialized, redundant data 
	 * OHAI retarded Samsung devs */
	if(type <= 6 || (type >= 21 && type <= 30)) //common 1
		pkt.datasize = 0x100C;
	else if((type >= 7 && type <= 12) || 
			(type >= 31 && type <= 35)) //supl 2
		pkt.datasize = 0x81C;
	else if((type >= 13 && type <= 14) || 
			(type >= 16 && type <= 18) || 
			(type >= 36 && type <= 39)) //xtra 3
		pkt.datasize = 0x3C;
	else if(type == 15) //large_xtra 5
	{
		sendBuf = malloc(0xA014);
		pkt.datasize = 0xA014;
	}
	else if(type == 19 || type == 20) //baseband 5
		pkt.datasize = 0xDC;
	else
	{
		DEBUG_E("Unknown LBS packet type, abandoning...");
		return;
	}
	if(size > pkt.datasize - sizeof(struct lbsPacketHeader))
	{
		DEBUG_E("Too big LBS packet, type %d, len %d", type, size);
		return;
	}
	
	hdr->type = type;
	hdr->size = size;
	hdr->subType = subType;
	memcpy((char*)(sendBuf) + sizeof(struct lbsPacketHeader), buf, size);
	
	pkt.magic = 0xCAFECAFE;
	pkt.cmd = FIFO_PKT_LBS;
	pkt.data = sendBuf;
	
	ipc_send(&pkt);
	if(type == 15)
		free(sendBuf);
}
Esempio n. 11
0
File: serv.c Progetto: ichaos/jos
void
serve_map(envid_t envid, struct Fsreq_map *rq)
{
	int r;
	char *blk;
	struct OpenFile *o;
	int perm = PTE_U | PTE_P | PTE_AVAIL;
        uint32_t *pdiskbno;

	if (debug)
		cprintf("serve_map %08x %08x %08x\n", envid,
                        rq->req_fileid, rq->req_offset);

	// Map the requested block in the client's address space
	// by using ipc_send.
	// Map read-only unless the file's open mode (o->o_mode) allows writes
	// (see the O_ flags in inc/lib.h).

	// LAB 5: Your code here.
        r = openfile_lookup(envid, rq->req_fileid, &o);
        if (r<0) {
                cprintf("serv.c:serve_map--openfile_lookup failed.\n");
                ipc_send(envid, r, 0, 0);
                return;
        }
        r = file_get_block(o->o_file, rq->req_offset, &blk);
        if (r<0) {
                cprintf("serv.c:serve_map--file_get_walk failed.\n");
                goto out;
        }
        if (o->o_mode&O_RDWR) {//what happens if O_WRONLY?
                perm = PTE_USER;
        }
 out:
        ipc_send(envid, r, blk, perm);
	//panic("serve_map not implemented");
}
Esempio n. 12
0
void
serve_close(u_int envid, struct Fsreq_close *rq)
{
	if (debug) {
		writef("serve_close %08x %08x\n", envid, rq->req_fileid);
	}

	struct Open *pOpen;

	int r;

	if ((r = open_lookup(envid, rq->req_fileid, &pOpen)) < 0) {
		ipc_send(envid, r, 0, 0);
		return;
	}

	//writef("serve_close:pOpen = %x\n",pOpen);
	file_close(pOpen->o_file);
	ipc_send(envid, 0, 0, 0);//PTE_V);

	//	syscall_mem_unmap(0, (u_int)pOpen);
	return;
	//	user_panic("serve_close not implemented");
}
Esempio n. 13
0
// Get the host name of the system.
return_type ipv4_host_name_get(ipc_structure_type *ipv4_structure, char *host_name)
{
    message_parameter_type message_parameter;

    message_parameter.protocol = IPC_PROTOCOL_IPV4;
    message_parameter.message_class = IPC_IPV4_GET_HOST_NAME;
    message_parameter.data = host_name;
    message_parameter.length = 0;
    ipc_send(ipv4_structure->output_mailbox_id, &message_parameter);

    message_parameter.length = IPV4_HOST_NAME_LENGTH;
    ipc_receive(ipv4_structure->input_mailbox_id, &message_parameter, NULL);

    return IPV4_RETURN_SUCCESS;
}
Esempio n. 14
0
// Send an inter-environment request to the file server, and wait for
// a reply.  The request body should be in fsipcbuf, and parts of the
// response may be written back to fsipcbuf.
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
	static envid_t fsenv;
	if (fsenv == 0)
		fsenv = ipc_find_env(ENV_TYPE_FS);

	static_assert(sizeof(fsipcbuf) == PGSIZE);

	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", thisenv->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(fsenv, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
	return ipc_recv(NULL, dstva, NULL);
}
Esempio n. 15
0
void
umain(void)
{
	int i, id;

	// fork the first prime process in the chain
	if ((id=fork()) < 0)
		panic("fork: %e", id);
	if (id == 0)
		primeproc();

	// feed all the integers through
	for (i=2;; i++)
		ipc_send(id, i, 0, 0);
}
Esempio n. 16
0
void
ipc_recv_extension_init(ipc_endpoint_t *ipc, const gpointer UNUSED(msg), guint UNUSED(length))
{
    web_module_load_modules_on_endpoint(ipc);

    /* Notify web extension that pending signals can be released */
    ipc_header_t header = { .type = IPC_TYPE_extension_init, .length = 0 };
    ipc_send(ipc, &header, NULL);
}

void
ipc_recv_lua_ipc(ipc_endpoint_t *UNUSED(ipc), const ipc_lua_ipc_t *msg, guint length)
{
    ipc_channel_recv(common.L, msg->arg, length);
}
Esempio n. 17
0
void
serve_set_size(u_int envid, struct Fsreq_set_size *rq)
{
    struct Open *o;
    int r = 0;
	if (debug) printf("serve_set_size %08x %08x %08x\n", envid, rq->req_fileid, rq->req_size);
    if((r = open_lookup(envid, rq->req_fileid, &o)) < 0)
        goto out_set_size;
    r = file_set_size(&o->o_ff->f_file, rq->req_size);
    if(r == 0)
        o->o_file->f_size = rq->req_size;
out_set_size:
    ipc_send(envid, r, 0, 0);
	// Your code here
	// panic("serve_set_size not implemented");
}
Esempio n. 18
0
void answer_error_to_client(int err_code, int client_id){
	
	ipc_params_t client_params;
	status client_program;
	
	client_params = get_params_from_pid(client_id, PROGRAM_STATUS, sizeof(struct status), server_params->semid);			
	client_params->socklistener = TRUE;
	client_program.flag = err_code;
	printf("Answering to client: %d\n", client_id);
	ipc_open(client_params, O_WRONLY);
	ipc_send(client_params, &client_program, sizeof(struct status));
	ipc_close(client_params);
	free(client_params->file);
	free(client_params);
	
}
Esempio n. 19
0
// Send a proof over IPC
void send_proof(envid_t to, Proof p) {
  // Copy the proof to UTEMP
  sys_page_alloc(0, UTEMP, PTE_U | PTE_W);
  Heap tempHeap;
  init_heap(&tempHeap, UTEMP, PGSIZE);
  Heap *oldHeap = set_heap(&tempHeap);
  Proof copy = proof_cp(p);
  size_t offset = (uintptr_t)copy - (uintptr_t)UTEMP;

  // Send the proof
  ipc_send(to, offset, UTEMP, PTE_U);
  sys_page_unmap(0, UTEMP);

  // Reset the heap
  set_heap(oldHeap);
}
Esempio n. 20
0
// Get flags.
return_type ipv4_get_flags(ipc_structure_type *ipv4_structure, unsigned int *flags)
{
    message_parameter_type message_parameter;

    message_parameter.protocol = IPC_PROTOCOL_IPV4;
    message_parameter.message_class = IPC_IPV4_GET_FLAGS;
    message_parameter.data = flags;
    message_parameter.length = 0;
    message_parameter.block = TRUE;
    ipc_send(ipv4_structure->output_mailbox_id, &message_parameter);

    message_parameter.length = sizeof(unsigned int);
    ipc_receive(ipv4_structure->input_mailbox_id, &message_parameter, NULL);

    return IPV4_RETURN_SUCCESS;
}
Esempio n. 21
0
static void
process_timer(envid_t envid) {
	uint32_t start, now, to;

	if (envid != timer_envid) {
		cprintf("NS: received timer interrupt from envid %x not timer env\n", envid);
		return;
	}

	start = sys_time_msec();
	thread_yield();
	now = sys_time_msec();

	to = TIMER_INTERVAL - (now - start);
	ipc_send(envid, to, 0, 0);
}
Esempio n. 22
0
// Mark the page containing the requested file offset as dirty.
void
serve_dirty(envid_t envid, struct Fsreq_dirty *rq)
{
	struct OpenFile *o;
	int r;

	if (debug)
		cprintf("serve_dirty %08x %08x %08x\n", envid, rq->req_fileid, rq->req_offset);

	if ((r = openfile_lookup(envid, rq->req_fileid, &o)) < 0)
		goto out;

	r = file_dirty(o->o_file, rq->req_offset);

out:
	ipc_send(envid, r, 0, 0);
}
Esempio n. 23
0
File: job.c Progetto: Tayyib/uludag
static int
send_result(int cmd, const char *data, size_t size)
{
	ipc_start(cmd, chan, chan_id, 0);
	if (CMD_RESULT == cmd) {
		if (bk_app)
			ipc_pack_arg(bk_app, strlen(bk_app));
		else
			ipc_pack_arg("comar", 5);
	}
	if (data) {
		if (size == 0) size = strlen(data);
		ipc_pack_arg(data, size);
	}
	ipc_send(TO_PARENT);
	return 0;
}
Esempio n. 24
0
static int http_post_mp4(char *file, char *obdid, char *token, char *eventid, char *cameraid, 
                          char *ip, int port, char *address)
{
    int bound_len = strlen(BOUNDARY_S) + strlen(FILE_NAME) + strlen(file) + \
                   strlen(FILE_TYPE_MP4) + strlen(BOUNDARY_E) - 2;

    struct stat stat;
    int len;
    char *data;
    ssize_t val;
    char md5[48];

    file_md5(file, md5, sizeof(md5));
    int fd = open(file, O_RDONLY);
    if (fd < 0) {
        return -1;
    }
    fstat(fd, &stat);
    data = (char *) malloc(512 + stat.st_size);
    memset(data, 0, (512 + stat.st_size));
    len = sprintf(data, METHOD, address, obdid, eventid, token, md5, cameraid);
    len += sprintf(data + len, USER_AGENT);
    len += sprintf(data + len, CON_LEN, bound_len + (int)stat.st_size);
    len += sprintf(data + len, CON_TYPE);
    len += sprintf(data + len, BOUNDARY_S);
    len += sprintf(data + len, FILE_NAME, file);
    len += sprintf(data + len, FILE_TYPE_MP4);

    val = read(fd, (void *)(data + len), stat.st_size);
    close(fd);
    if (val < 0){
        free(data);
        return -1;
    }
    len += val; 
    len += sprintf(data + len , "%s", BOUNDARY_E); 
    int skt;
    int res;
    skt = ipc_connect(ip, port);
    if (skt < 0)
        return -1;
    res = ipc_send(skt, (char *)data, len);
    close(skt);
    free(data);
    return res;
}
Esempio n. 25
0
void
serve_close(envid_t envid, struct Fsreq_close *rq)
{
	struct OpenFile *o;
	int r;

	if (debug)
		cprintf("serve_close %08x %08x\n", envid, rq->req_fileid);

	if ((r = openfile_lookup(envid, rq->req_fileid, &o)) < 0)
		goto out;
	file_close(o->o_file);
	r = 0;

out:
	ipc_send(envid, r, 0, 0);
}
Esempio n. 26
0
/**
 * In: RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND
 *   Requests to send a SAT/USAT envelope command to SIM.
 *   The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111
 *
 * Out: IPC_SAT_ENVELOPE_CMD EXEC
 */
void requestSatSendEnvelopeCommand(RIL_Token t, void *data, size_t datalen)
{
	unsigned char buf[264];
	int len = (strlen(data) / 2);

	if(len > 255) {
		ALOGE("%s: data exceeds maximum length", __FUNCTION__);
		ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	}

	memset(buf, 0, sizeof(buf));

	buf[0] = len;
	hex2bin(data, strlen(data), &buf[1]);

	ipc_send(IPC_SAT_ENVELOPE_CMD, IPC_TYPE_EXEC, buf, sizeof(buf), reqGetId(t));
}
Esempio n. 27
0
File: serv.c Progetto: yaobaiwei/JOS
void
serve_remove(envid_t envid, struct Fsreq_remove *rq)
{
	char path[MAXPATHLEN];
	int r;

	if (debug)
		cprintf("serve_remove %08x %s\n", envid, rq->req_path);

	// Copy in the path, making sure it's null-terminated
	memmove(path, rq->req_path, MAXPATHLEN);
	path[MAXPATHLEN-1] = 0;

	// Delete the specified file
	r = file_remove(path);
	ipc_send(envid, r, 0, 0);
}
Esempio n. 28
0
void
umain(void)
{
	envid_t who, id;

	id = sys_getenvid();

	if (env == &envs[1]) {
		while (1) {
			ipc_recv(&who, 0, 0);
			cprintf("%x recv from %x\n", id, who);
		}
	} else {
		cprintf("%x loop sending to %x\n", id, envs[1].env_id);
		while (1)
			ipc_send(envs[1].env_id, 0, 0, 0);
	}
}
Esempio n. 29
0
// Buffer cache IPC helper function.
// Send a buffer cache 'reqtype' IPC (one of the BCREQ_ constants)
// for the file system block containing 'addr'.
// Returns 0 on success, < 0 on error.
//
static int
bcache_ipc(void *addr, int reqtype)
{
	int r;
	blocknum_t b = ((uintptr_t) addr - FSMAP) / BLKSIZE;
	if (b < 0 || b > (blocknum_t) (DISKSIZE / BLKSIZE))
		panic("bcache_ipc: va %08x out of disk address range", addr);
	// Be careful: check 'super' might not be loaded!
	if (b >= 2 && b >= super->s_nblocks)
		panic("bcache_ipc: block %d out of file system bounds", b);

	do {
		ipc_send(ENVID_BUFCACHE, MAKE_BCREQ(b, reqtype), 0, 0);
		r = ipc_recv(0, (void *) (FSMAP + b * PGSIZE), 0);
	} while (r == -E_AGAIN);

	return r;
}
Esempio n. 30
0
static void
virtio_net_getstat(message *m)
{
	int r;
	message reply;

	reply.m_type = DL_STAT_REPLY;

	r = sys_safecopyto(m->m_source, m->m_net_netdrv_dl_getstat_s.grant, 0,
			   (vir_bytes)&virtio_net_stats,
			   sizeof(virtio_net_stats));

	if (r != OK)
		panic("%s: copy to %d failed (%d)", name, m->m_source, r);

	if ((r = ipc_send(m->m_source, &reply)) != OK)
		panic("%s: ipc_send to %d failed (%d)", name, m->m_source, r);
}