2002-07-09 16:24:59 +04:00
|
|
|
/* ports for IPC */
|
2004-02-23 07:02:24 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Copyright 2002-2004, The OpenBeOS Team. All rights reserved.
|
|
|
|
** Distributed under the terms of the OpenBeOS License.
|
|
|
|
*/
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/*
|
|
|
|
** Copyright 2001, Mark-Jan Bastian. All rights reserved.
|
|
|
|
** Distributed under the terms of the NewOS License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <OS.h>
|
|
|
|
#include <port.h>
|
2002-10-05 05:20:39 +04:00
|
|
|
#include <sem.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <kernel.h>
|
|
|
|
#include <arch/int.h>
|
|
|
|
#include <debug.h>
|
2002-10-30 02:07:06 +03:00
|
|
|
#include <malloc.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <cbuf.h>
|
|
|
|
#include <Errors.h>
|
|
|
|
#include <int.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
struct port_msg {
|
|
|
|
int msg_code;
|
2002-10-30 02:07:06 +03:00
|
|
|
cbuf *data_cbuf;
|
2002-07-09 16:24:59 +04:00
|
|
|
size_t data_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct port_entry {
|
|
|
|
port_id id;
|
2002-08-03 04:41:27 +04:00
|
|
|
team_id owner;
|
2002-07-09 16:24:59 +04:00
|
|
|
int32 capacity;
|
2002-10-26 20:13:36 +04:00
|
|
|
spinlock lock;
|
2002-07-09 16:24:59 +04:00
|
|
|
char *name;
|
|
|
|
sem_id read_sem;
|
|
|
|
sem_id write_sem;
|
|
|
|
int head;
|
|
|
|
int tail;
|
|
|
|
int total_count;
|
|
|
|
bool closed;
|
|
|
|
struct port_msg* msg_queue;
|
|
|
|
};
|
|
|
|
|
|
|
|
// internal API
|
2002-07-18 02:07:37 +04:00
|
|
|
static int dump_port_list(int argc, char **argv);
|
|
|
|
static int dump_port_info(int argc, char **argv);
|
2002-07-09 16:24:59 +04:00
|
|
|
static void _dump_port_info(struct port_entry *port);
|
|
|
|
|
|
|
|
|
|
|
|
// MAX_PORTS must be power of 2
|
|
|
|
#define MAX_PORTS 4096
|
|
|
|
#define MAX_QUEUE_LENGTH 4096
|
|
|
|
#define PORT_MAX_MESSAGE_SIZE 65536
|
|
|
|
|
|
|
|
static struct port_entry *ports = NULL;
|
|
|
|
static region_id port_region = 0;
|
|
|
|
static bool ports_active = false;
|
|
|
|
|
|
|
|
static port_id next_port = 0;
|
|
|
|
|
2002-10-26 20:13:36 +04:00
|
|
|
static spinlock port_spinlock = 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
#define GRAB_PORT_LIST_LOCK() acquire_spinlock(&port_spinlock)
|
|
|
|
#define RELEASE_PORT_LIST_LOCK() release_spinlock(&port_spinlock)
|
|
|
|
#define GRAB_PORT_LOCK(s) acquire_spinlock(&(s).lock)
|
|
|
|
#define RELEASE_PORT_LOCK(s) release_spinlock(&(s).lock)
|
|
|
|
|
2002-08-05 09:25:26 +04:00
|
|
|
|
2002-09-03 06:09:48 +04:00
|
|
|
status_t
|
2002-08-05 09:25:26 +04:00
|
|
|
port_init(kernel_args *ka)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
int i;
|
2003-08-19 18:28:11 +04:00
|
|
|
int size = sizeof(struct port_entry) * MAX_PORTS;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// create and initialize semaphore table
|
2003-08-19 18:28:11 +04:00
|
|
|
port_region = create_area("port_table", (void **)&ports, B_ANY_KERNEL_ADDRESS,
|
|
|
|
size, B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
2002-08-05 09:25:26 +04:00
|
|
|
if (port_region < 0) {
|
2002-07-09 16:24:59 +04:00
|
|
|
panic("unable to allocate kernel port table!\n");
|
|
|
|
}
|
|
|
|
|
2003-08-19 18:28:11 +04:00
|
|
|
memset(ports, 0, size);
|
2002-08-05 09:25:26 +04:00
|
|
|
for (i = 0; i < MAX_PORTS; i++)
|
2002-07-09 16:24:59 +04:00
|
|
|
ports[i].id = -1;
|
|
|
|
|
|
|
|
// add debugger commands
|
2002-07-18 02:07:37 +04:00
|
|
|
add_debugger_command("ports", &dump_port_list, "Dump a list of all active ports");
|
|
|
|
add_debugger_command("port", &dump_port_info, "Dump info about a particular port");
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
ports_active = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-08-05 09:25:26 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
dump_port_list(int argc, char **argv)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2002-08-05 09:25:26 +04:00
|
|
|
for (i = 0; i < MAX_PORTS; i++) {
|
|
|
|
if (ports[i].id >= 0)
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("%p\tid: 0x%lx\t\tname: '%s'\n", &ports[i], ports[i].id, ports[i].name);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
2002-07-18 02:07:37 +04:00
|
|
|
return 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-08-05 09:25:26 +04:00
|
|
|
|
|
|
|
static void
|
|
|
|
_dump_port_info(struct port_entry *port)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2002-09-03 06:09:48 +04:00
|
|
|
int32 cnt;
|
2002-07-09 16:24:59 +04:00
|
|
|
dprintf("PORT: %p\n", port);
|
|
|
|
dprintf("name: '%s'\n", port->name);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("owner: 0x%lx\n", port->owner);
|
|
|
|
dprintf("cap: %ld\n", port->capacity);
|
2002-07-09 16:24:59 +04:00
|
|
|
dprintf("head: %d\n", port->head);
|
|
|
|
dprintf("tail: %d\n", port->tail);
|
|
|
|
get_sem_count(port->read_sem, &cnt);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("read_sem: %ld\n", cnt);
|
2002-07-09 16:24:59 +04:00
|
|
|
get_sem_count(port->read_sem, &cnt);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("write_sem: %ld\n", cnt);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-08-05 09:25:26 +04:00
|
|
|
|
|
|
|
static int
|
|
|
|
dump_port_info(int argc, char **argv)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2002-08-05 09:25:26 +04:00
|
|
|
if (argc < 2) {
|
2002-07-09 16:24:59 +04:00
|
|
|
dprintf("port: not enough arguments\n");
|
2002-07-18 02:07:37 +04:00
|
|
|
return 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// if the argument looks like a hex number, treat it as such
|
2002-08-05 09:25:26 +04:00
|
|
|
if (strlen(argv[1]) > 2 && argv[1][0] == '0' && argv[1][1] == 'x') {
|
2002-07-09 16:24:59 +04:00
|
|
|
unsigned long num = atoul(argv[1]);
|
|
|
|
|
2002-08-05 09:25:26 +04:00
|
|
|
if (num > KERNEL_BASE && num <= (KERNEL_BASE + (KERNEL_SIZE - 1))) {
|
2002-07-09 16:24:59 +04:00
|
|
|
// XXX semi-hack
|
|
|
|
// one can use either address or a port_id, since KERNEL_BASE > MAX_PORTS assumed
|
|
|
|
_dump_port_info((struct port_entry *)num);
|
2002-07-18 02:07:37 +04:00
|
|
|
return 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
} else {
|
|
|
|
unsigned slot = num % MAX_PORTS;
|
|
|
|
if(ports[slot].id != (int)num) {
|
|
|
|
dprintf("port 0x%lx doesn't exist!\n", num);
|
2002-07-18 02:07:37 +04:00
|
|
|
return 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
_dump_port_info(&ports[slot]);
|
2002-07-18 02:07:37 +04:00
|
|
|
return 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// walk through the ports list, trying to match name
|
2002-08-05 09:25:26 +04:00
|
|
|
for (i = 0; i < MAX_PORTS; i++) {
|
|
|
|
if (ports[i].name != NULL
|
|
|
|
&& strcmp(argv[1], ports[i].name) == 0) {
|
|
|
|
_dump_port_info(&ports[i]);
|
|
|
|
return 0;
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
2002-08-05 09:25:26 +04:00
|
|
|
return 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-08-05 09:25:26 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
port_id
|
|
|
|
create_port(int32 queue_length, const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int state;
|
|
|
|
sem_id sem_r, sem_w;
|
|
|
|
port_id retval;
|
2002-09-11 16:25:47 +04:00
|
|
|
int name_len;
|
2002-07-09 16:24:59 +04:00
|
|
|
char *temp_name;
|
2002-09-11 16:25:47 +04:00
|
|
|
struct port_msg *q;
|
2002-08-03 04:41:27 +04:00
|
|
|
team_id owner;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-08-05 09:25:26 +04:00
|
|
|
if (ports_active == false)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
|
2002-09-11 16:25:47 +04:00
|
|
|
// check queue length
|
2002-07-09 16:24:59 +04:00
|
|
|
if (queue_length < 1)
|
|
|
|
return EINVAL;
|
|
|
|
if (queue_length > MAX_QUEUE_LENGTH)
|
|
|
|
return EINVAL;
|
2002-09-11 16:25:47 +04:00
|
|
|
|
|
|
|
// check & dup name
|
|
|
|
if (name == NULL)
|
|
|
|
name = "unnamed port";
|
|
|
|
|
|
|
|
name_len = strlen(name) + 1;
|
2004-02-23 07:02:24 +03:00
|
|
|
name_len = min(name_len, B_OS_NAME_LENGTH);
|
2002-10-30 02:07:06 +03:00
|
|
|
temp_name = (char *)malloc(name_len);
|
2002-09-11 16:25:47 +04:00
|
|
|
if (temp_name == NULL)
|
|
|
|
return ENOMEM;
|
|
|
|
strlcpy(temp_name, name, name_len);
|
|
|
|
|
|
|
|
// alloc queue
|
2002-10-30 02:07:06 +03:00
|
|
|
q = (struct port_msg *)malloc(queue_length * sizeof(struct port_msg));
|
2002-07-09 16:24:59 +04:00
|
|
|
if (q == NULL) {
|
2002-10-30 02:07:06 +03:00
|
|
|
free(temp_name); // dealloc name, too
|
2002-07-09 16:24:59 +04:00
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
2002-09-11 16:25:47 +04:00
|
|
|
// init cbuf list of the queue
|
2002-10-05 05:20:39 +04:00
|
|
|
for (i = 0; i < queue_length; i++)
|
2002-09-11 16:25:47 +04:00
|
|
|
q[i].data_cbuf = 0;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
// create sem_r with owner set to -1
|
|
|
|
sem_r = create_sem_etc(0, temp_name, -1);
|
|
|
|
if (sem_r < 0) {
|
|
|
|
// cleanup
|
2002-10-30 02:07:06 +03:00
|
|
|
free(temp_name);
|
|
|
|
free(q);
|
2002-07-09 16:24:59 +04:00
|
|
|
return sem_r;
|
|
|
|
}
|
|
|
|
|
|
|
|
// create sem_w
|
|
|
|
sem_w = create_sem_etc(queue_length, temp_name, -1);
|
|
|
|
if (sem_w < 0) {
|
|
|
|
// cleanup
|
|
|
|
delete_sem(sem_r);
|
2002-10-30 02:07:06 +03:00
|
|
|
free(temp_name);
|
|
|
|
free(q);
|
2002-07-09 16:24:59 +04:00
|
|
|
return sem_w;
|
|
|
|
}
|
2002-08-03 04:41:27 +04:00
|
|
|
owner = team_get_current_team_id();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LIST_LOCK();
|
|
|
|
|
|
|
|
// find the first empty spot
|
2002-10-05 05:20:39 +04:00
|
|
|
for (i = 0; i < MAX_PORTS; i++) {
|
2002-07-09 16:24:59 +04:00
|
|
|
if(ports[i].id == -1) {
|
|
|
|
// make the port_id be a multiple of the slot it's in
|
|
|
|
if(i >= next_port % MAX_PORTS) {
|
|
|
|
next_port += i - next_port % MAX_PORTS;
|
|
|
|
} else {
|
|
|
|
next_port += MAX_PORTS - (next_port % MAX_PORTS - i);
|
|
|
|
}
|
|
|
|
ports[i].id = next_port++;
|
|
|
|
ports[i].lock = 0;
|
|
|
|
GRAB_PORT_LOCK(ports[i]);
|
|
|
|
RELEASE_PORT_LIST_LOCK();
|
|
|
|
|
|
|
|
ports[i].capacity = queue_length;
|
|
|
|
ports[i].name = temp_name;
|
|
|
|
|
|
|
|
// assign sem
|
|
|
|
ports[i].read_sem = sem_r;
|
|
|
|
ports[i].write_sem = sem_w;
|
|
|
|
ports[i].msg_queue = q;
|
|
|
|
ports[i].head = 0;
|
|
|
|
ports[i].tail = 0;
|
|
|
|
ports[i].total_count= 0;
|
|
|
|
ports[i].owner = owner;
|
|
|
|
retval = ports[i].id;
|
|
|
|
RELEASE_PORT_LOCK(ports[i]);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// not enough ports...
|
|
|
|
RELEASE_PORT_LIST_LOCK();
|
|
|
|
retval = B_NO_MORE_PORTS;
|
|
|
|
dprintf("create_port(): B_NO_MORE_PORTS\n");
|
|
|
|
|
|
|
|
// cleanup
|
|
|
|
delete_sem(sem_w);
|
|
|
|
delete_sem(sem_r);
|
2002-10-30 02:07:06 +03:00
|
|
|
free(temp_name);
|
|
|
|
free(q);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
out:
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-09-11 16:25:47 +04:00
|
|
|
status_t
|
2002-07-09 16:24:59 +04:00
|
|
|
close_port(port_id id)
|
|
|
|
{
|
|
|
|
int state;
|
|
|
|
int slot;
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
if (ports_active == false)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
2002-10-05 05:20:39 +04:00
|
|
|
if (id < 0)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
slot = id % MAX_PORTS;
|
|
|
|
|
|
|
|
// walk through the sem list, trying to match name
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
|
|
|
|
|
|
|
if (ports[slot].id != id) {
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-09-11 16:25:47 +04:00
|
|
|
dprintf("close_port: invalid port_id %ld\n", id);
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
// mark port to disable writing
|
|
|
|
ports[slot].closed = true;
|
|
|
|
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
return B_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-09-03 06:09:48 +04:00
|
|
|
status_t
|
2002-07-09 16:24:59 +04:00
|
|
|
delete_port(port_id id)
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
int state;
|
|
|
|
sem_id r_sem, w_sem;
|
|
|
|
int capacity;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
char *old_name;
|
|
|
|
struct port_msg *q;
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
if (ports_active == false)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
2002-10-05 05:20:39 +04:00
|
|
|
if (id < 0)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
|
|
|
|
slot = id % MAX_PORTS;
|
|
|
|
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
|
|
|
|
2002-10-30 02:07:06 +03:00
|
|
|
if (ports[slot].id != id) {
|
2002-07-09 16:24:59 +04:00
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("delete_port: invalid port_id %ld\n", id);
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mark port as invalid */
|
|
|
|
ports[slot].id = -1;
|
|
|
|
old_name = ports[slot].name;
|
|
|
|
q = ports[slot].msg_queue;
|
|
|
|
r_sem = ports[slot].read_sem;
|
|
|
|
w_sem = ports[slot].write_sem;
|
|
|
|
capacity = ports[slot].capacity;
|
|
|
|
ports[slot].name = NULL;
|
|
|
|
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// delete the cbuf's that are left in the queue (if any)
|
2002-10-30 02:07:06 +03:00
|
|
|
for (i = 0; i < capacity; i++) {
|
2002-07-09 16:24:59 +04:00
|
|
|
if (q[i].data_cbuf != NULL)
|
|
|
|
cbuf_free_chain(q[i].data_cbuf);
|
|
|
|
}
|
|
|
|
|
2002-10-30 02:07:06 +03:00
|
|
|
free(q);
|
|
|
|
free(old_name);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// release the threads that were blocking on this port by deleting the sem
|
2002-07-14 14:10:22 +04:00
|
|
|
// read_port() will see the B_BAD_SEM_ID acq_sem() return value, and act accordingly
|
2002-07-09 16:24:59 +04:00
|
|
|
delete_sem(r_sem);
|
|
|
|
delete_sem(w_sem);
|
|
|
|
|
|
|
|
return B_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
port_id
|
|
|
|
find_port(const char *port_name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int state;
|
|
|
|
int ret_val = B_BAD_PORT_ID;
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
if (ports_active == false)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
2002-10-05 05:20:39 +04:00
|
|
|
if (port_name == NULL)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
|
|
|
|
// lock list of ports
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LIST_LOCK();
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
// loop over list
|
2002-10-05 05:20:39 +04:00
|
|
|
for (i = 0; i < MAX_PORTS; i++) {
|
2002-07-09 16:24:59 +04:00
|
|
|
// lock every individual port before comparing
|
|
|
|
GRAB_PORT_LOCK(ports[i]);
|
|
|
|
if(strcmp(port_name, ports[i].name) == 0) {
|
|
|
|
ret_val = ports[i].id;
|
|
|
|
RELEASE_PORT_LOCK(ports[i]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RELEASE_PORT_LOCK(ports[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RELEASE_PORT_LIST_LOCK();
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
/** Fills the port_info structure with information from the specified
|
|
|
|
* port.
|
|
|
|
* The port lock must be held when called.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
fill_port_info(struct port_entry *port, port_info *info, size_t size)
|
|
|
|
{
|
|
|
|
info->port = port->id;
|
|
|
|
info->team = port->owner;
|
|
|
|
info->capacity = port->capacity;
|
|
|
|
info->total_count = ports->total_count;
|
|
|
|
strlcpy(info->name, ports->name, B_OS_NAME_LENGTH);
|
|
|
|
get_sem_count(port->read_sem, &info->queue_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-03 06:09:48 +04:00
|
|
|
status_t
|
2002-07-09 16:24:59 +04:00
|
|
|
_get_port_info(port_id id, port_info *info, size_t size)
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
int state;
|
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
if (info == NULL || size != sizeof(port_info))
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!ports_active || id < 0)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
|
|
|
|
slot = id % MAX_PORTS;
|
|
|
|
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
if (ports[slot].id != id) {
|
2002-07-09 16:24:59 +04:00
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("get_port_info: invalid port_id %ld\n", id);
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
// fill a port_info struct with info
|
2004-02-23 07:02:24 +03:00
|
|
|
fill_port_info(&ports[slot], info, size);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2004-02-23 07:02:24 +03:00
|
|
|
|
|
|
|
return B_OK;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-09-03 06:09:48 +04:00
|
|
|
status_t
|
2004-02-23 07:02:24 +03:00
|
|
|
_get_next_port_info(team_id team, int32 *_cookie, struct port_info *info, size_t size)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
int state;
|
|
|
|
int slot;
|
2004-02-23 07:02:24 +03:00
|
|
|
|
|
|
|
if (info == NULL || size != sizeof(port_info) || _cookie == NULL || team < B_OK)
|
2002-10-05 05:20:39 +04:00
|
|
|
return B_BAD_VALUE;
|
2004-02-23 07:02:24 +03:00
|
|
|
if (!ports_active)
|
|
|
|
return B_BAD_PORT_ID;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
slot = *_cookie;
|
|
|
|
if (slot >= MAX_PORTS)
|
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
|
|
|
|
if (team == B_CURRENT_TEAM)
|
|
|
|
team = team_get_current_team_id();
|
|
|
|
|
|
|
|
info->port = -1; // used as found flag
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// spinlock
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LIST_LOCK();
|
2004-02-23 07:02:24 +03:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
while (slot < MAX_PORTS) {
|
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
2004-02-23 07:02:24 +03:00
|
|
|
if (ports[slot].id != -1 && ports[slot].owner == team) {
|
|
|
|
// found one!
|
|
|
|
fill_port_info(&ports[slot], info, size);
|
|
|
|
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
|
|
|
slot++;
|
|
|
|
break;
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
|
|
|
slot++;
|
|
|
|
}
|
|
|
|
RELEASE_PORT_LIST_LOCK();
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
if (info->port == -1)
|
|
|
|
return B_BAD_PORT_ID;
|
2004-02-23 07:02:24 +03:00
|
|
|
|
|
|
|
*_cookie = slot;
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
ssize_t
|
|
|
|
port_buffer_size(port_id id)
|
|
|
|
{
|
|
|
|
return port_buffer_size_etc(id, 0, 0);
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
ssize_t
|
2002-10-05 05:20:39 +04:00
|
|
|
port_buffer_size_etc(port_id id, uint32 flags, bigtime_t timeout)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
int res;
|
|
|
|
int t;
|
|
|
|
int len;
|
|
|
|
int state;
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
if (!ports_active || id < 0)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
|
|
|
|
slot = id % MAX_PORTS;
|
|
|
|
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
if (ports[slot].id != id) {
|
2002-07-09 16:24:59 +04:00
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("get_port_info: invalid port_id %ld\n", id);
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// block if no message,
|
|
|
|
// if TIMEOUT flag set, block with timeout
|
|
|
|
|
|
|
|
// XXX - is it a race condition to acquire a sem just after we
|
|
|
|
// unlocked the port ?
|
|
|
|
// XXX: call an acquire_sem which does the release lock, restore int & block the right way
|
|
|
|
res = acquire_sem_etc(ports[slot].read_sem, 1, flags & (B_TIMEOUT | B_CAN_INTERRUPT), timeout);
|
|
|
|
|
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
2002-07-14 14:10:22 +04:00
|
|
|
if (res == B_BAD_SEM_ID) {
|
2002-07-09 16:24:59 +04:00
|
|
|
// somebody deleted the port
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
2002-07-14 14:10:22 +04:00
|
|
|
if (res == B_TIMED_OUT) {
|
2002-07-09 16:24:59 +04:00
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
|
|
|
return B_TIMED_OUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
// once message arrived, read data's length
|
2004-02-23 07:02:24 +03:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
// determine tail
|
|
|
|
// read data's head length
|
|
|
|
t = ports[slot].head;
|
|
|
|
if (t < 0)
|
2002-09-03 06:09:48 +04:00
|
|
|
panic("port %ld: tail < 0", ports[slot].id);
|
2002-07-09 16:24:59 +04:00
|
|
|
if (t > ports[slot].capacity)
|
2002-09-03 06:09:48 +04:00
|
|
|
panic("port %ld: tail > cap %ld", ports[slot].id, ports[slot].capacity);
|
2002-07-09 16:24:59 +04:00
|
|
|
len = ports[slot].msg_queue[t].data_len;
|
|
|
|
|
|
|
|
// restore readsem
|
|
|
|
release_sem(ports[slot].read_sem);
|
|
|
|
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
|
|
|
|
|
|
|
// return length of item at end of queue
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
ssize_t
|
|
|
|
port_count(port_id id)
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
int state;
|
2002-09-03 06:09:48 +04:00
|
|
|
int32 count;
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
if (ports_active == false)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
2002-10-05 05:20:39 +04:00
|
|
|
if (id < 0)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
|
|
|
|
slot = id % MAX_PORTS;
|
|
|
|
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
if (ports[slot].id != id) {
|
2002-07-09 16:24:59 +04:00
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("port_count: invalid port_id %ld\n", id);
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
get_sem_count(ports[slot].read_sem, &count);
|
|
|
|
// do not return negative numbers
|
|
|
|
if (count < 0)
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// return count of messages (sem_count)
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-09-03 06:09:48 +04:00
|
|
|
status_t
|
2003-06-28 20:46:07 +04:00
|
|
|
read_port(port_id port, int32 *msgCode, void *msgBuffer, size_t bufferSize)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2003-06-28 20:46:07 +04:00
|
|
|
return read_port_etc(port, msgCode, msgBuffer, bufferSize, 0, 0);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-09-03 06:09:48 +04:00
|
|
|
status_t
|
2003-06-28 20:46:07 +04:00
|
|
|
read_port_etc(port_id id, int32 *msgCode, void *msgBuffer, size_t bufferSize,
|
2002-10-05 05:20:39 +04:00
|
|
|
uint32 flags, bigtime_t timeout)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2003-06-28 20:46:07 +04:00
|
|
|
int slot;
|
|
|
|
int state;
|
|
|
|
sem_id cached_semid;
|
|
|
|
size_t size;
|
|
|
|
status_t status;
|
|
|
|
int t;
|
|
|
|
cbuf *msgStore;
|
|
|
|
int32 code;
|
|
|
|
bool userCopy = (flags & PORT_FLAG_USE_USER_MEMCPY) > 0;
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
if (ports_active == false
|
|
|
|
|| id < 0)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
if (msgCode == NULL
|
|
|
|
|| (msgBuffer == NULL && bufferSize > 0)
|
|
|
|
|| timeout < 0)
|
|
|
|
return B_BAD_VALUE;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
flags = flags & (B_CAN_INTERRUPT | B_TIMEOUT);
|
2002-07-09 16:24:59 +04:00
|
|
|
slot = id % MAX_PORTS;
|
|
|
|
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
if (ports[slot].id != id) {
|
2002-07-09 16:24:59 +04:00
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("read_port_etc: invalid port_id %ld\n", id);
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
// store sem_id in local variable
|
|
|
|
cached_semid = ports[slot].read_sem;
|
|
|
|
|
|
|
|
// unlock port && enable ints/
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// XXX -> possible race condition if port gets deleted (->sem deleted too), therefore
|
|
|
|
// sem_id is cached in local variable up here
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
status = acquire_sem_etc(cached_semid, 1, flags, timeout);
|
|
|
|
// get 1 entry from the queue, block if needed
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// XXX: possible race condition if port read by two threads...
|
|
|
|
// both threads will read in 2 different slots allocated above, simultaneously
|
|
|
|
// slot is a thread-local variable
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
if (status == B_BAD_SEM_ID || status == EINTR) {
|
2002-07-09 16:24:59 +04:00
|
|
|
/* somebody deleted the port or the sem went away */
|
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
if (status == B_TIMED_OUT) {
|
2002-07-09 16:24:59 +04:00
|
|
|
// timed out, or, if timeout=0, 'would block'
|
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
if (status != B_NO_ERROR) {
|
|
|
|
dprintf("write_port_etc: unknown error %ld\n", status);
|
|
|
|
return status;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
|
|
|
|
|
|
|
t = ports[slot].tail;
|
|
|
|
if (t < 0)
|
2002-09-03 06:09:48 +04:00
|
|
|
panic("port %ld: tail < 0", ports[slot].id);
|
2002-07-09 16:24:59 +04:00
|
|
|
if (t > ports[slot].capacity)
|
2002-09-03 06:09:48 +04:00
|
|
|
panic("port %ld: tail > cap %ld", ports[slot].id, ports[slot].capacity);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
ports[slot].tail = (ports[slot].tail + 1) % ports[slot].capacity;
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
msgStore = ports[slot].msg_queue[t].data_cbuf;
|
|
|
|
code = ports[slot].msg_queue[t].msg_code;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
// mark queue entry unused
|
2003-06-28 20:46:07 +04:00
|
|
|
ports[slot].msg_queue[t].data_cbuf = NULL;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// check output buffer size
|
2003-06-28 20:46:07 +04:00
|
|
|
size = min(bufferSize, ports[slot].msg_queue[t].data_len);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
cached_semid = ports[slot].write_sem;
|
|
|
|
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// copy message
|
2003-06-28 20:46:07 +04:00
|
|
|
*msgCode = code;
|
|
|
|
if (size > 0) {
|
|
|
|
if (userCopy) {
|
|
|
|
if ((status = cbuf_user_memcpy_from_chain(msgBuffer, msgStore, 0, size) < B_OK)) {
|
2002-07-09 16:24:59 +04:00
|
|
|
// leave the port intact, for other threads that might not crash
|
2003-06-28 20:46:07 +04:00
|
|
|
cbuf_free_chain(msgStore);
|
2002-07-09 16:24:59 +04:00
|
|
|
release_sem(cached_semid);
|
2003-06-28 20:46:07 +04:00
|
|
|
return status;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
} else
|
2003-06-28 20:46:07 +04:00
|
|
|
cbuf_memcpy_from_chain(msgBuffer, msgStore, 0, size);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
// free the cbuf
|
2003-06-28 20:46:07 +04:00
|
|
|
cbuf_free_chain(msgStore);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// make one spot in queue available again for write
|
|
|
|
release_sem(cached_semid);
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
return size;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-09-03 06:09:48 +04:00
|
|
|
status_t
|
2003-06-28 20:46:07 +04:00
|
|
|
write_port(port_id id, int32 msgCode, const void *msgBuffer, size_t bufferSize)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2003-06-28 20:46:07 +04:00
|
|
|
return write_port_etc(id, msgCode, msgBuffer, bufferSize, 0, 0);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2002-09-03 06:09:48 +04:00
|
|
|
status_t
|
2003-06-28 20:46:07 +04:00
|
|
|
write_port_etc(port_id id, int32 msgCode, const void *msgBuffer,
|
|
|
|
size_t bufferSize, uint32 flags, bigtime_t timeout)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
int state;
|
2003-06-28 20:46:07 +04:00
|
|
|
status_t status;
|
2002-07-09 16:24:59 +04:00
|
|
|
sem_id cached_semid;
|
|
|
|
int h;
|
2003-06-28 20:46:07 +04:00
|
|
|
cbuf *msgStore;
|
|
|
|
bool userCopy = (flags & PORT_FLAG_USE_USER_MEMCPY) > 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
if (ports_active == false
|
|
|
|
|| id < 0)
|
|
|
|
return B_BAD_PORT_ID;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
// mask irrelevant flags (for acquire_sem() usage)
|
|
|
|
flags = flags & (B_CAN_INTERRUPT | B_TIMEOUT);
|
2002-07-09 16:24:59 +04:00
|
|
|
slot = id % MAX_PORTS;
|
2003-06-28 20:46:07 +04:00
|
|
|
|
|
|
|
if (bufferSize > PORT_MAX_MESSAGE_SIZE)
|
2002-07-09 16:24:59 +04:00
|
|
|
return EINVAL;
|
|
|
|
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
if (ports[slot].id != id) {
|
2002-07-09 16:24:59 +04:00
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("write_port_etc: invalid port_id %ld\n", id);
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ports[slot].closed) {
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("write_port_etc: port %ld closed\n", id);
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
// store sem_id in local variable
|
|
|
|
cached_semid = ports[slot].write_sem;
|
|
|
|
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// XXX -> possible race condition if port gets deleted (->sem deleted too),
|
|
|
|
// and queue is full therefore sem_id is cached in local variable up here
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
status = acquire_sem_etc(cached_semid, 1, flags, timeout);
|
|
|
|
// get 1 entry from the queue, block if needed
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// XXX: possible race condition if port written by two threads...
|
|
|
|
// both threads will write in 2 different slots allocated above, simultaneously
|
|
|
|
// slot is a thread-local variable
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
if (status == B_BAD_PORT_ID || status == B_INTERRUPTED) {
|
2002-07-09 16:24:59 +04:00
|
|
|
/* somebody deleted the port or the sem while we were waiting */
|
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
if (status == B_TIMED_OUT) {
|
|
|
|
// timed out, or, if timeout = 0, 'would block'
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_TIMED_OUT;
|
|
|
|
}
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
if (status != B_NO_ERROR) {
|
|
|
|
dprintf("write_port_etc: unknown error %ld\n", status);
|
|
|
|
return status;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2003-06-28 20:46:07 +04:00
|
|
|
if (bufferSize > 0) {
|
|
|
|
msgStore = cbuf_get_chain(bufferSize);
|
|
|
|
if (msgStore == NULL)
|
|
|
|
return B_NO_MEMORY;
|
|
|
|
|
|
|
|
if (userCopy) {
|
2002-07-09 16:24:59 +04:00
|
|
|
// copy from user memory
|
2003-06-28 20:46:07 +04:00
|
|
|
if ((status = cbuf_user_memcpy_to_chain(msgStore, 0, msgBuffer, bufferSize)) < B_OK)
|
|
|
|
return status;
|
|
|
|
} else {
|
2002-07-09 16:24:59 +04:00
|
|
|
// copy from kernel memory
|
2003-06-28 20:46:07 +04:00
|
|
|
if ((status = cbuf_memcpy_to_chain(msgStore, 0, msgBuffer, bufferSize)) < 0)
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
msgStore = NULL;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// attach copied message to queue
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
|
|
|
|
|
|
|
h = ports[slot].head;
|
|
|
|
if (h < 0)
|
2002-09-03 06:09:48 +04:00
|
|
|
panic("port %ld: head < 0", ports[slot].id);
|
2002-07-09 16:24:59 +04:00
|
|
|
if (h >= ports[slot].capacity)
|
2002-09-03 06:09:48 +04:00
|
|
|
panic("port %ld: head > cap %ld", ports[slot].id, ports[slot].capacity);
|
2003-06-28 20:46:07 +04:00
|
|
|
|
|
|
|
ports[slot].msg_queue[h].msg_code = msgCode;
|
|
|
|
ports[slot].msg_queue[h].data_cbuf = msgStore;
|
|
|
|
ports[slot].msg_queue[h].data_len = bufferSize;
|
2002-07-09 16:24:59 +04:00
|
|
|
ports[slot].head = (ports[slot].head + 1) % ports[slot].capacity;
|
|
|
|
ports[slot].total_count++;
|
|
|
|
|
|
|
|
// store sem_id in local variable
|
|
|
|
cached_semid = ports[slot].read_sem;
|
|
|
|
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// release sem, allowing read (might reschedule)
|
|
|
|
release_sem(cached_semid);
|
|
|
|
|
|
|
|
return B_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2003-06-28 20:53:36 +04:00
|
|
|
status_t
|
|
|
|
set_port_owner(port_id id, team_id team)
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
int state;
|
|
|
|
|
|
|
|
if (ports_active == false
|
|
|
|
|| id < 0)
|
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
|
|
|
|
slot = id % MAX_PORTS;
|
|
|
|
|
|
|
|
state = disable_interrupts();
|
|
|
|
GRAB_PORT_LOCK(ports[slot]);
|
|
|
|
|
|
|
|
if (ports[slot].id != id) {
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
|
|
|
restore_interrupts(state);
|
|
|
|
dprintf("set_port_owner: invalid port_id %ld\n", id);
|
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
// transfer ownership to other team
|
|
|
|
ports[slot].owner = team;
|
|
|
|
|
|
|
|
// unlock port
|
|
|
|
RELEASE_PORT_LOCK(ports[slot]);
|
|
|
|
restore_interrupts(state);
|
|
|
|
|
|
|
|
return B_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** this function cycles through the ports table, deleting all
|
|
|
|
* the ports that are owned by the passed team_id
|
|
|
|
*/
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
delete_owned_ports(team_id owner)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
int state;
|
|
|
|
int i;
|
|
|
|
int count = 0;
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
if (ports_active == false)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_BAD_PORT_ID;
|
|
|
|
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LIST_LOCK();
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
for (i = 0; i < MAX_PORTS; i++) {
|
2002-07-09 16:24:59 +04:00
|
|
|
if(ports[i].id != -1 && ports[i].owner == owner) {
|
|
|
|
port_id id = ports[i].id;
|
|
|
|
|
|
|
|
RELEASE_PORT_LIST_LOCK();
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
delete_port(id);
|
|
|
|
count++;
|
|
|
|
|
2002-07-25 05:05:51 +04:00
|
|
|
state = disable_interrupts();
|
2002-07-09 16:24:59 +04:00
|
|
|
GRAB_PORT_LIST_LOCK();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RELEASE_PORT_LIST_LOCK();
|
2002-07-25 05:05:51 +04:00
|
|
|
restore_interrupts(state);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-27 06:02:24 +03:00
|
|
|
#ifdef DEBUG
|
2002-07-09 16:24:59 +04:00
|
|
|
/*
|
|
|
|
* testcode
|
|
|
|
*/
|
|
|
|
|
2003-01-27 06:02:24 +03:00
|
|
|
static int32 port_test_thread_func(void *arg);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
port_id test_p1, test_p2, test_p3, test_p4;
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
void
|
|
|
|
port_test()
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
char testdata[5];
|
|
|
|
thread_id t;
|
|
|
|
int res;
|
|
|
|
int32 dummy;
|
|
|
|
int32 dummy2;
|
|
|
|
|
|
|
|
strcpy(testdata, "abcd");
|
|
|
|
|
|
|
|
dprintf("porttest: create_port()\n");
|
|
|
|
test_p1 = create_port(1, "test port #1");
|
|
|
|
test_p2 = create_port(10, "test port #2");
|
|
|
|
test_p3 = create_port(1024, "test port #3");
|
|
|
|
test_p4 = create_port(1024, "test port #4");
|
|
|
|
|
|
|
|
dprintf("porttest: find_port()\n");
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("'test port #1' has id %ld (should be %ld)\n", find_port("test port #1"), test_p1);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
dprintf("porttest: write_port() on 1, 2 and 3\n");
|
|
|
|
write_port(test_p1, 1, &testdata, sizeof(testdata));
|
|
|
|
write_port(test_p2, 666, &testdata, sizeof(testdata));
|
|
|
|
write_port(test_p3, 999, &testdata, sizeof(testdata));
|
|
|
|
dprintf("porttest: port_count(test_p1) = %ld\n", port_count(test_p1));
|
|
|
|
|
|
|
|
dprintf("porttest: write_port() on 1 with timeout of 1 sec (blocks 1 sec)\n");
|
|
|
|
write_port_etc(test_p1, 1, &testdata, sizeof(testdata), B_TIMEOUT, 1000000);
|
|
|
|
dprintf("porttest: write_port() on 2 with timeout of 1 sec (wont block)\n");
|
|
|
|
res = write_port_etc(test_p2, 777, &testdata, sizeof(testdata), B_TIMEOUT, 1000000);
|
|
|
|
dprintf("porttest: res=%d, %s\n", res, res == 0 ? "ok" : "BAD");
|
|
|
|
|
|
|
|
dprintf("porttest: read_port() on empty port 4 with timeout of 1 sec (blocks 1 sec)\n");
|
|
|
|
res = read_port_etc(test_p4, &dummy, &dummy2, sizeof(dummy2), B_TIMEOUT, 1000000);
|
|
|
|
dprintf("porttest: res=%d, %s\n", res, res == B_TIMED_OUT ? "ok" : "BAD");
|
|
|
|
|
|
|
|
dprintf("porttest: spawning thread for port 1\n");
|
2003-01-27 06:02:24 +03:00
|
|
|
t = spawn_kernel_thread(port_test_thread_func, "port_test", B_NORMAL_PRIORITY, NULL);
|
|
|
|
resume_thread(t);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
dprintf("porttest: write\n");
|
|
|
|
write_port(test_p1, 1, &testdata, sizeof(testdata));
|
|
|
|
|
|
|
|
// now we can write more (no blocking)
|
|
|
|
dprintf("porttest: write #2\n");
|
|
|
|
write_port(test_p1, 2, &testdata, sizeof(testdata));
|
|
|
|
dprintf("porttest: write #3\n");
|
|
|
|
write_port(test_p1, 3, &testdata, sizeof(testdata));
|
|
|
|
|
|
|
|
dprintf("porttest: waiting on spawned thread\n");
|
2003-09-13 00:49:01 +04:00
|
|
|
wait_for_thread(t, NULL);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
dprintf("porttest: close p1\n");
|
|
|
|
close_port(test_p2);
|
|
|
|
dprintf("porttest: attempt write p1 after close\n");
|
|
|
|
res = write_port(test_p2, 4, &testdata, sizeof(testdata));
|
|
|
|
dprintf("porttest: write_port ret %d\n", res);
|
|
|
|
|
|
|
|
dprintf("porttest: testing delete p2\n");
|
|
|
|
delete_port(test_p2);
|
|
|
|
|
|
|
|
dprintf("porttest: end test main thread\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
2003-01-27 06:02:24 +03:00
|
|
|
static int32
|
|
|
|
port_test_thread_func(void *arg)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2002-09-03 06:09:48 +04:00
|
|
|
int32 msg_code;
|
2002-07-09 16:24:59 +04:00
|
|
|
int n;
|
|
|
|
char buf[6];
|
|
|
|
buf[5] = '\0';
|
|
|
|
|
|
|
|
dprintf("porttest: port_test_thread_func()\n");
|
|
|
|
|
|
|
|
n = read_port(test_p1, &msg_code, &buf, 3);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("read_port #1 code %ld len %d buf %s\n", msg_code, n, buf);
|
2002-07-09 16:24:59 +04:00
|
|
|
n = read_port(test_p1, &msg_code, &buf, 4);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("read_port #1 code %ld len %d buf %s\n", msg_code, n, buf);
|
2002-07-09 16:24:59 +04:00
|
|
|
buf[4] = 'X';
|
|
|
|
n = read_port(test_p1, &msg_code, &buf, 5);
|
2002-09-03 06:09:48 +04:00
|
|
|
dprintf("read_port #1 code %ld len %d buf %s\n", msg_code, n, buf);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
dprintf("porttest: testing delete p1 from other thread\n");
|
|
|
|
delete_port(test_p1);
|
|
|
|
dprintf("porttest: end port_test_thread_func()\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2003-01-27 06:02:24 +03:00
|
|
|
#endif /* DEBUG */
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
// #pragma mark -
|
2002-07-09 16:24:59 +04:00
|
|
|
/*
|
|
|
|
* user level ports
|
|
|
|
*/
|
|
|
|
|
2003-01-27 06:02:24 +03:00
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
port_id
|
2004-02-23 07:02:24 +03:00
|
|
|
user_create_port(int32 queueLength, const char *userName)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2004-02-23 07:02:24 +03:00
|
|
|
char name[B_OS_NAME_LENGTH];
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
if (userName == NULL)
|
|
|
|
return create_port(queueLength, NULL);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
if (!IS_USER_ADDRESS(userName)
|
|
|
|
|| user_strlcpy(name, userName, B_OS_NAME_LENGTH) < B_OK)
|
|
|
|
return B_BAD_ADDRESS;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
return create_port(queueLength, name);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
status_t
|
|
|
|
user_close_port(port_id id)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
return close_port(id);
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
status_t
|
|
|
|
user_delete_port(port_id id)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
return delete_port(id);
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
port_id
|
2004-02-23 07:02:24 +03:00
|
|
|
user_find_port(const char *userName)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2004-02-23 07:02:24 +03:00
|
|
|
char name[B_OS_NAME_LENGTH];
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
if (userName == NULL)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!IS_USER_ADDRESS(userName)
|
|
|
|
|| user_strlcpy(name, userName, B_OS_NAME_LENGTH) < B_OK)
|
|
|
|
return B_BAD_ADDRESS;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
return find_port(name);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
status_t
|
2004-02-23 07:02:24 +03:00
|
|
|
user_get_port_info(port_id id, struct port_info *userInfo)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2004-02-23 07:02:24 +03:00
|
|
|
struct port_info info;
|
|
|
|
status_t status;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
if (userInfo == NULL)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!IS_USER_ADDRESS(userInfo))
|
|
|
|
return B_BAD_ADDRESS;
|
|
|
|
|
|
|
|
status = get_port_info(id, &info);
|
|
|
|
|
|
|
|
// copy back to user space
|
|
|
|
if (status == B_OK && user_memcpy(userInfo, &info, sizeof(struct port_info)) < B_OK)
|
|
|
|
return B_BAD_ADDRESS;
|
|
|
|
|
|
|
|
return status;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
status_t
|
2004-02-23 07:02:24 +03:00
|
|
|
user_get_next_port_info(team_id team, int32 *userCookie, struct port_info *userInfo)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2004-02-23 07:02:24 +03:00
|
|
|
struct port_info info;
|
|
|
|
status_t status;
|
|
|
|
int32 cookie;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
if (userCookie == NULL || userInfo == NULL)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!IS_USER_ADDRESS(userCookie) || !IS_USER_ADDRESS(userInfo)
|
|
|
|
|| user_memcpy(&cookie, userCookie, sizeof(int32)) < B_OK)
|
|
|
|
return B_BAD_ADDRESS;
|
|
|
|
|
|
|
|
status = get_next_port_info(team, &cookie, &info);
|
|
|
|
|
|
|
|
// copy back to user space
|
|
|
|
if (user_memcpy(userCookie, &cookie, sizeof(int32)) < B_OK
|
|
|
|
|| (status == B_OK && user_memcpy(userInfo, &info, sizeof(struct port_info)) < B_OK))
|
|
|
|
return B_BAD_ADDRESS;
|
|
|
|
|
|
|
|
return status;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
ssize_t
|
|
|
|
user_port_buffer_size_etc(port_id port, uint32 flags, bigtime_t timeout)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
return port_buffer_size_etc(port, flags | B_CAN_INTERRUPT, timeout);
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
ssize_t
|
|
|
|
user_port_count(port_id port)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
return port_count(port);
|
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
status_t
|
2004-02-23 07:02:24 +03:00
|
|
|
user_read_port_etc(port_id port, int32 *userCode, void *userBuffer,
|
|
|
|
size_t bufferSize, uint32 flags, bigtime_t timeout)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2004-02-23 07:02:24 +03:00
|
|
|
int32 messageCode;
|
|
|
|
ssize_t status;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
if (userCode == NULL || userBuffer == NULL)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!IS_USER_ADDRESS(userCode) || !IS_USER_ADDRESS(userBuffer))
|
|
|
|
return B_BAD_ADDRESS;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
status = read_port_etc(port, &messageCode, userBuffer, bufferSize,
|
|
|
|
flags | PORT_FLAG_USE_USER_MEMCPY | B_CAN_INTERRUPT, timeout);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
if (status == B_OK && user_memcpy(userCode, &messageCode, sizeof(int32)) < B_OK)
|
|
|
|
return B_BAD_ADDRESS;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-02-23 07:02:24 +03:00
|
|
|
return status;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
status_t
|
|
|
|
user_set_port_owner(port_id port, team_id team)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2002-08-03 04:41:27 +04:00
|
|
|
return set_port_owner(port, team);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-05 05:20:39 +04:00
|
|
|
|
|
|
|
status_t
|
2004-02-23 07:02:24 +03:00
|
|
|
user_write_port_etc(port_id port, int32 messageCode, void *userBuffer,
|
|
|
|
size_t bufferSize, uint32 flags, bigtime_t timeout)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2004-02-23 07:02:24 +03:00
|
|
|
if (userBuffer == NULL)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!IS_USER_ADDRESS(userBuffer))
|
|
|
|
return B_BAD_ADDRESS;
|
|
|
|
|
|
|
|
return write_port_etc(port, messageCode, userBuffer, bufferSize,
|
|
|
|
flags | PORT_FLAG_USE_USER_MEMCPY | B_CAN_INTERRUPT, timeout);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|