1 |
/* IPC message queues. |
/* IPC message queues. |
2 |
Copyright 1999, 2000, 2001 Johan Rydberg, jrydberg@opencores.org. |
Copyright 1999, 2000, 2001, 2002 Johan Rydberg, jrydberg@rtmk.org. |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
19 |
|
|
20 |
#include "ipc-mqueue.h" |
#include "ipc-mqueue.h" |
21 |
#include "ipc-kmsg.h" |
#include "ipc-kmsg.h" |
|
#include "vm-slab.h" |
|
22 |
#include "trace.h" |
#include "trace.h" |
23 |
|
|
|
/* Cache for ipc mqueue structures. */ |
|
|
static struct kmem_cache *mqueue_cache; |
|
|
|
|
24 |
/* Initialize the message queue system. */ |
/* Initialize the message queue system. */ |
25 |
|
|
26 |
void |
void |
27 |
ipc_mqueue_init (void) |
ipc_mqueue_init (void) |
28 |
{ |
{ |
|
mqueue_cache = kmem_cache_create ("ipc mqueue cache", |
|
|
sizeof (struct ipc_mqueue), 0); |
|
|
assert (mqueue_cache); |
|
29 |
} |
} |
30 |
|
|
31 |
/* Create a new message queue for a port. Returns a new queue |
/* Create a new message queue for a port. Returns a new queue |
32 |
with default queue limit, NULL if we can not allocate memory. */ |
with default queue limit, NULL if we can not allocate memory. */ |
33 |
|
|
34 |
struct ipc_mqueue * |
void |
35 |
ipc_mqueue_create (void) |
ipc_mqueue_create (struct ipc_mqueue *imq) |
36 |
{ |
{ |
37 |
struct ipc_mqueue *imq; |
queue_init (& imq->queue); |
|
|
|
|
imq = (struct ipc_mqueue *) kmem_cache_alloc (mqueue_cache); |
|
|
if (imq == 0) |
|
|
return (struct ipc_mqueue *) 0; |
|
|
|
|
|
queue_init (&imq->queue); |
|
38 |
imq->qlimit = RTMK_PORT_QLIMIT_DEFAULT; |
imq->qlimit = RTMK_PORT_QLIMIT_DEFAULT; |
39 |
imq->msgcount = 0; |
imq->msgcount = 0; |
|
|
|
|
return imq; |
|
40 |
} |
} |
41 |
|
|
42 |
/* Destroy message queue, releasing all messages on it. */ |
/* Destroy message queue, releasing all messages on it. */ |
59 |
ikm = next; |
ikm = next; |
60 |
} |
} |
61 |
} |
} |
|
|
|
|
kmem_cache_free (mqueue_cache, imq); |
|
62 |
} |
} |
63 |
|
|
64 |
/* This function tries to enqueue a kernel message on the message |
/* This function tries to enqueue a kernel message on the message |