Now includes sem.h (since it needs the private create_sem_etc() call).
Cleaned up the source a bit. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1378 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+67
-42
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <port.h>
|
#include <port.h>
|
||||||
|
#include <sem.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <arch/int.h>
|
#include <arch/int.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
struct port_msg {
|
struct port_msg {
|
||||||
int msg_code;
|
int msg_code;
|
||||||
cbuf* data_cbuf;
|
cbuf* data_cbuf;
|
||||||
@@ -276,6 +278,7 @@ out:
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
close_port(port_id id)
|
close_port(port_id id)
|
||||||
{
|
{
|
||||||
@@ -308,6 +311,7 @@ close_port(port_id id)
|
|||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
delete_port(port_id id)
|
delete_port(port_id id)
|
||||||
{
|
{
|
||||||
@@ -366,6 +370,7 @@ delete_port(port_id id)
|
|||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
port_id
|
port_id
|
||||||
find_port(const char *port_name)
|
find_port(const char *port_name)
|
||||||
{
|
{
|
||||||
@@ -400,6 +405,7 @@ find_port(const char *port_name)
|
|||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
_get_port_info(port_id id, port_info *info, size_t size)
|
_get_port_info(port_id id, port_info *info, size_t size)
|
||||||
{
|
{
|
||||||
@@ -440,9 +446,9 @@ _get_port_info(port_id id, port_info *info, size_t size)
|
|||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
_get_next_port_info(team_id team, int32 *cookie, struct port_info *info,
|
_get_next_port_info(team_id team, int32 *cookie, struct port_info *info, size_t size)
|
||||||
size_t size)
|
|
||||||
{
|
{
|
||||||
int state;
|
int state;
|
||||||
int slot;
|
int slot;
|
||||||
@@ -450,7 +456,7 @@ _get_next_port_info(team_id team, int32 *cookie, struct port_info *info,
|
|||||||
if (ports_active == false)
|
if (ports_active == false)
|
||||||
return B_BAD_PORT_ID;
|
return B_BAD_PORT_ID;
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return EINVAL;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if (*cookie == NULL) {
|
if (*cookie == NULL) {
|
||||||
// return first found
|
// return first found
|
||||||
@@ -495,16 +501,16 @@ _get_next_port_info(team_id team, int32 *cookie, struct port_info *info,
|
|||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
port_buffer_size(port_id id)
|
port_buffer_size(port_id id)
|
||||||
{
|
{
|
||||||
return port_buffer_size_etc(id, 0, 0);
|
return port_buffer_size_etc(id, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
port_buffer_size_etc(port_id id,
|
port_buffer_size_etc(port_id id, uint32 flags, bigtime_t timeout)
|
||||||
uint32 flags,
|
|
||||||
bigtime_t timeout)
|
|
||||||
{
|
{
|
||||||
int slot;
|
int slot;
|
||||||
int res;
|
int res;
|
||||||
@@ -570,6 +576,7 @@ port_buffer_size_etc(port_id id,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
port_count(port_id id)
|
port_count(port_id id)
|
||||||
{
|
{
|
||||||
@@ -606,22 +613,17 @@ port_count(port_id id)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
read_port(port_id port,
|
read_port(port_id port, int32 *msg_code, void *msg_buffer, size_t buffer_size)
|
||||||
int32 *msg_code,
|
|
||||||
void *msg_buffer,
|
|
||||||
size_t buffer_size)
|
|
||||||
{
|
{
|
||||||
return read_port_etc(port, msg_code, msg_buffer, buffer_size, 0, 0);
|
return read_port_etc(port, msg_code, msg_buffer, buffer_size, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
read_port_etc(port_id id,
|
read_port_etc(port_id id, int32 *msg_code, void *msg_buffer, size_t buffer_size,
|
||||||
int32 *msg_code,
|
uint32 flags, bigtime_t timeout)
|
||||||
void *msg_buffer,
|
|
||||||
size_t buffer_size,
|
|
||||||
uint32 flags,
|
|
||||||
bigtime_t timeout)
|
|
||||||
{
|
{
|
||||||
int slot;
|
int slot;
|
||||||
int state;
|
int state;
|
||||||
@@ -736,6 +738,7 @@ read_port_etc(port_id id,
|
|||||||
return siz;
|
return siz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
set_port_owner(port_id id, team_id team)
|
set_port_owner(port_id id, team_id team)
|
||||||
{
|
{
|
||||||
@@ -769,22 +772,17 @@ set_port_owner(port_id id, team_id team)
|
|||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
write_port(port_id id,
|
write_port(port_id id, int32 msg_code, const void *msg_buffer, size_t buffer_size)
|
||||||
int32 msg_code,
|
|
||||||
const void *msg_buffer,
|
|
||||||
size_t buffer_size)
|
|
||||||
{
|
{
|
||||||
return write_port_etc(id, msg_code, msg_buffer, buffer_size, 0, 0);
|
return write_port_etc(id, msg_code, msg_buffer, buffer_size, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
write_port_etc(port_id id,
|
write_port_etc(port_id id, int32 msg_code, const void *msg_buffer,
|
||||||
int32 msg_code,
|
size_t buffer_size, uint32 flags, bigtime_t timeout)
|
||||||
const void *msg_buffer,
|
|
||||||
size_t buffer_size,
|
|
||||||
uint32 flags,
|
|
||||||
bigtime_t timeout)
|
|
||||||
{
|
{
|
||||||
int slot;
|
int slot;
|
||||||
int state;
|
int state;
|
||||||
@@ -905,9 +903,12 @@ write_port_etc(port_id id,
|
|||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* this function cycles through the ports table, deleting all the ports that are owned by
|
/* this function cycles through the ports table, deleting all the ports that are owned by
|
||||||
the passed team_id */
|
the passed team_id */
|
||||||
int delete_owned_ports(team_id owner)
|
|
||||||
|
int
|
||||||
|
delete_owned_ports(team_id owner)
|
||||||
{
|
{
|
||||||
int state;
|
int state;
|
||||||
int i;
|
int i;
|
||||||
@@ -947,7 +948,8 @@ int delete_owned_ports(team_id owner)
|
|||||||
|
|
||||||
port_id test_p1, test_p2, test_p3, test_p4;
|
port_id test_p1, test_p2, test_p3, test_p4;
|
||||||
|
|
||||||
void port_test()
|
void
|
||||||
|
port_test()
|
||||||
{
|
{
|
||||||
char testdata[5];
|
char testdata[5];
|
||||||
thread_id t;
|
thread_id t;
|
||||||
@@ -1012,7 +1014,9 @@ void port_test()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int port_test_thread_func(void* arg)
|
|
||||||
|
int
|
||||||
|
port_test_thread_func(void* arg)
|
||||||
{
|
{
|
||||||
int32 msg_code;
|
int32 msg_code;
|
||||||
int n;
|
int n;
|
||||||
@@ -1036,11 +1040,14 @@ int port_test_thread_func(void* arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
/*
|
/*
|
||||||
* user level ports
|
* user level ports
|
||||||
*/
|
*/
|
||||||
|
|
||||||
port_id user_create_port(int32 queue_length, const char *uname)
|
port_id
|
||||||
|
user_create_port(int32 queue_length, const char *uname)
|
||||||
{
|
{
|
||||||
if(uname != NULL) {
|
if(uname != NULL) {
|
||||||
char name[SYS_MAX_OS_NAME_LEN];
|
char name[SYS_MAX_OS_NAME_LEN];
|
||||||
@@ -1060,17 +1067,23 @@ port_id user_create_port(int32 queue_length, const char *uname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t user_close_port(port_id id)
|
|
||||||
|
status_t
|
||||||
|
user_close_port(port_id id)
|
||||||
{
|
{
|
||||||
return close_port(id);
|
return close_port(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t user_delete_port(port_id id)
|
|
||||||
|
status_t
|
||||||
|
user_delete_port(port_id id)
|
||||||
{
|
{
|
||||||
return delete_port(id);
|
return delete_port(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
port_id user_find_port(const char *port_name)
|
|
||||||
|
port_id
|
||||||
|
user_find_port(const char *port_name)
|
||||||
{
|
{
|
||||||
if (port_name != NULL) {
|
if (port_name != NULL) {
|
||||||
char name[SYS_MAX_OS_NAME_LEN];
|
char name[SYS_MAX_OS_NAME_LEN];
|
||||||
@@ -1090,7 +1103,9 @@ port_id user_find_port(const char *port_name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t user_get_port_info(port_id id, struct port_info *uinfo)
|
|
||||||
|
status_t
|
||||||
|
user_get_port_info(port_id id, struct port_info *uinfo)
|
||||||
{
|
{
|
||||||
status_t res;
|
status_t res;
|
||||||
struct port_info info;
|
struct port_info info;
|
||||||
@@ -1109,9 +1124,9 @@ status_t user_get_port_info(port_id id, struct port_info *uinfo)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t user_get_next_port_info(team_id uteam,
|
|
||||||
int32 *ucookie,
|
status_t
|
||||||
struct port_info *uinfo)
|
user_get_next_port_info(team_id uteam, int32 *ucookie, struct port_info *uinfo)
|
||||||
{
|
{
|
||||||
status_t res;
|
status_t res;
|
||||||
struct port_info info;
|
struct port_info info;
|
||||||
@@ -1143,17 +1158,23 @@ status_t user_get_next_port_info(team_id uteam,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t user_port_buffer_size_etc(port_id port, uint32 flags, bigtime_t timeout)
|
|
||||||
|
ssize_t
|
||||||
|
user_port_buffer_size_etc(port_id port, uint32 flags, bigtime_t timeout)
|
||||||
{
|
{
|
||||||
return port_buffer_size_etc(port, flags | B_CAN_INTERRUPT, timeout);
|
return port_buffer_size_etc(port, flags | B_CAN_INTERRUPT, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t user_port_count(port_id port)
|
|
||||||
|
ssize_t
|
||||||
|
user_port_count(port_id port)
|
||||||
{
|
{
|
||||||
return port_count(port);
|
return port_count(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t user_read_port_etc(port_id uport, int32 *umsg_code, void *umsg_buffer,
|
|
||||||
|
status_t
|
||||||
|
user_read_port_etc(port_id uport, int32 *umsg_code, void *umsg_buffer,
|
||||||
size_t ubuffer_size, uint32 uflags, bigtime_t utimeout)
|
size_t ubuffer_size, uint32 uflags, bigtime_t utimeout)
|
||||||
{
|
{
|
||||||
ssize_t res;
|
ssize_t res;
|
||||||
@@ -1180,12 +1201,16 @@ status_t user_read_port_etc(port_id uport, int32 *umsg_code, void *umsg_buffer,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t user_set_port_owner(port_id port, team_id team)
|
|
||||||
|
status_t
|
||||||
|
user_set_port_owner(port_id port, team_id team)
|
||||||
{
|
{
|
||||||
return set_port_owner(port, team);
|
return set_port_owner(port, team);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t user_write_port_etc(port_id uport, int32 umsg_code, void *umsg_buffer,
|
|
||||||
|
status_t
|
||||||
|
user_write_port_etc(port_id uport, int32 umsg_code, void *umsg_buffer,
|
||||||
size_t ubuffer_size, uint32 uflags, bigtime_t utimeout)
|
size_t ubuffer_size, uint32 uflags, bigtime_t utimeout)
|
||||||
{
|
{
|
||||||
if (umsg_buffer == NULL)
|
if (umsg_buffer == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user