Exemplo n.º 1
0
void SLOF_dma_map_out(long phys, void *virt, long size)
{
	forth_push((long)virt);
	forth_push((long)phys);
	forth_push(size);
	forth_eval("dma-map-out");
}
Exemplo n.º 2
0
/**
 * Call Forth code to try to claim the memory region
 */
int
elf_forth_claim(void *addr, long size)
{
	forth_push((long)addr);
	forth_push(size);
	forth_eval("elf-claim-segment");
	return forth_pop();
}
Exemplo n.º 3
0
long SLOF_dma_map_in(void *virt, long size, int cacheable)
{
	forth_push((long)virt);
	forth_push(size);
	forth_push(cacheable);
	forth_eval("dma-map-in");
	return forth_pop();
}
Exemplo n.º 4
0
/**
 * Standard recv function for the libc.
 *
 * @param fd     socket file descriptor
 * @param buf    pointer to the array where the packet should be stored
 * @param len    maximum length in bytes of the packet
 * @param flags  currently unused, should be 0
 * @return       the number of bytes that have been received successfully
 */
int recv(int fd, void *buf, int len, int flags)
{
	if (!is_valid_fd(fd))
		return -1;

	forth_push((unsigned long)buf);
	forth_push(len);
	forth_push(fd_array[fd].read_xt);
	return forth_eval_pop("EXECUTE");
}
Exemplo n.º 5
0
static type_u find_method(type_u phandle, const char *name)
{
	forth_push((type_u)name);
	forth_push(strlen(name));
	forth_push(phandle);
	forth_eval("find-method");
	if (forth_pop())
		return forth_pop();

	return 0;
}
Exemplo n.º 6
0
/**
 * Standard send function for the libc.
 *
 * @param fd     socket file descriptor
 * @param buf    pointer to the array with the output packet
 * @param len    length in bytes of the packet
 * @param flags  currently unused, should be 0
 * @return       the number of bytes that have been sent successfully
 */
int send(int fd, const void *buf, int len, int flags)
{
	if (!is_valid_fd(fd))
		return -1;

	forth_push((unsigned long)buf);
	forth_push(len);
	forth_push(fd_array[fd].write_xt);
	return forth_eval_pop("EXECUTE");

}
Exemplo n.º 7
0
int socket(int domain, int type, int proto, char *mac_addr)
{
	const char mac_prop_name[] = "local-mac-address";
	type_u phandle;
	uint8_t *prop_addr;
	int prop_len;
	int fd;

	/* search free file descriptor (and skip stdio handlers) */
	for (fd = 3; fd < FILEIO_MAX; ++fd) {
		if (fd_array[fd].type == FILEIO_TYPE_EMPTY) {
			break;
		}
	}
	if (fd == FILEIO_MAX) {
		puts("Can not open socket, file descriptor list is full");
		return -2;
	}

	/* Assume that obp-tftp package is the current one, so
	 * my-parent is the NIC node that we are interested in */
	forth_eval("my-parent ?dup IF ihandle>phandle THEN");
	phandle = forth_pop();
	if (phandle == 0) {
		puts("Can not open socket, no parent instance");
		return -1;
	}
	fd_array[fd].read_xt = find_method(phandle, "read");
	if (!fd_array[fd].read_xt) {
		puts("Can not open socket, no 'read' method");
		return -1;
	}
	fd_array[fd].write_xt = find_method(phandle, "write");
	if (!fd_array[fd].write_xt) {
		puts("Can not open socket, no 'write' method");
		return -1;
	}

	/* Read MAC address from device */
	forth_push((unsigned long)mac_prop_name);
	forth_push(strlen(mac_prop_name));
	forth_push(phandle);
	forth_eval("get-property");
	if (forth_pop())
		return -1;
	prop_len = forth_pop();
	prop_addr = (uint8_t *)forth_pop();
	memcpy(mac_addr, &prop_addr[prop_len - 6], 6);

	fd_array[fd].type = FILEIO_TYPE_SOCKET;

	return fd;
}
Exemplo n.º 8
0
static void push(struct forth* f, double v) { forth_push(f, v); }
Exemplo n.º 9
0
void SLOF_free_mem(void *addr, long size)
{
	forth_push((long)addr);
	forth_push(size);
	forth_eval("free-mem");
}
Exemplo n.º 10
0
void *SLOF_alloc_mem(long size)
{
	forth_push(size);
	forth_eval("alloc-mem");
	return (void *)forth_pop();
}
Exemplo n.º 11
0
void SLOF_dma_free(void *virt, long size)
{
	forth_push((long)virt);
	forth_push(size);
	forth_eval("dma-free");
}
Exemplo n.º 12
0
void *SLOF_dma_alloc(long size)
{
	forth_push(size);
	forth_eval("dma-alloc");
	return (void *)forth_pop();
}