Ignore:
Timestamp:
2010-12-25T21:20:28Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
631ee0c
Parents:
1bfd3d3 (diff), 09178b7f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/packet/generic/packet_server.c

    r1bfd3d3 r973ef9fc  
    3636
    3737#include <packet_server.h>
    38 #include <packet_local.h>
    3938
    4039#include <align.h>
     
    6968        fibril_mutex_t lock;
    7069        /** Free packet queues. */
    71         packet_t free[FREE_QUEUES_COUNT];
     70        packet_t *free[FREE_QUEUES_COUNT];
    7271       
    7372        /**
     
    103102};
    104103
    105 int packet_translate_local(int phone, packet_t *packet, packet_id_t packet_id)
    106 {
    107         if (!packet)
    108                 return EINVAL;
    109        
    110         *packet = pm_find(packet_id);
    111         return (*packet) ? EOK : ENOENT;
    112 }
    113 
    114104/** Clears and initializes the packet according to the given dimensions.
    115105 *
     
    122112 */
    123113static void
    124 packet_init(packet_t packet, size_t addr_len, size_t max_prefix,
     114packet_init(packet_t *packet, size_t addr_len, size_t max_prefix,
    125115    size_t max_content, size_t max_suffix)
    126116{
    127117        // clear the packet content
    128         bzero(((void *) packet) + sizeof(struct packet),
    129             packet->length - sizeof(struct packet));
     118        bzero(((void *) packet) + sizeof(packet_t),
     119            packet->length - sizeof(packet_t));
    130120       
    131121        // clear the packet header
     
    135125        packet->next = 0;
    136126        packet->addr_len = 0;
    137         packet->src_addr = sizeof(struct packet);
     127        packet->src_addr = sizeof(packet_t);
    138128        packet->dest_addr = packet->src_addr + addr_len;
    139129        packet->max_prefix = max_prefix;
     
    144134
    145135/** Creates a new packet of dimensions at least as given.
    146  *
    147  * Should be used only when the global data are locked.
    148136 *
    149137 * @param[in] length    The total length of the packet, including the header,
     
    157145 * @return              NULL if there is not enough memory left.
    158146 */
    159 static packet_t
     147static packet_t *
    160148packet_create(size_t length, size_t addr_len, size_t max_prefix,
    161149    size_t max_content, size_t max_suffix)
    162150{
    163         packet_t packet;
     151        packet_t *packet;
    164152        int rc;
    165153
     154        assert(fibril_mutex_is_locked(&ps_globals.lock));
     155
    166156        // already locked
    167         packet = (packet_t) mmap(NULL, length, PROTO_READ | PROTO_WRITE,
     157        packet = (packet_t *) mmap(NULL, length, PROTO_READ | PROTO_WRITE,
    168158            MAP_SHARED | MAP_ANONYMOUS, 0, 0);
    169159        if (packet == MAP_FAILED)
     
    198188 * @return              NULL if there is not enough memory left.
    199189 */
    200 static packet_t
     190static packet_t *
    201191packet_get_local(size_t addr_len, size_t max_prefix, size_t max_content,
    202192    size_t max_suffix)
    203193{
    204         size_t length = ALIGN_UP(sizeof(struct packet) + 2 * addr_len +
     194        size_t length = ALIGN_UP(sizeof(packet_t) + 2 * addr_len +
    205195            max_prefix + max_content + max_suffix, PAGE_SIZE);
    206196       
    207197        fibril_mutex_lock(&ps_globals.lock);
    208198       
    209         packet_t packet;
     199        packet_t *packet;
    210200        unsigned int index;
    211201       
     
    241231}
    242232
    243 packet_t packet_get_4_local(int phone, size_t max_content, size_t addr_len,
    244     size_t max_prefix, size_t max_suffix)
    245 {
    246         return packet_get_local(addr_len, max_prefix, max_content, max_suffix);
    247 }
    248 
    249 packet_t packet_get_1_local(int phone, size_t content)
    250 {
    251         return packet_get_local(DEFAULT_ADDR_LEN, DEFAULT_PREFIX, content,
    252             DEFAULT_SUFFIX);
    253 }
    254 
    255233/** Release the packet and returns it to the appropriate free packet queue.
    256234 *
    257  * Should be used only when the global data are locked.
    258  *
    259235 * @param[in] packet    The packet to be released.
    260236 *
    261237 */
    262 static void packet_release(packet_t packet)
     238static void packet_release(packet_t *packet)
    263239{
    264240        int index;
    265241        int result;
     242
     243        assert(fibril_mutex_is_locked(&ps_globals.lock));
    266244
    267245        for (index = 0; (index < FREE_QUEUES_COUNT - 1) &&
     
    283261static int packet_release_wrapper(packet_id_t packet_id)
    284262{
    285         packet_t packet;
     263        packet_t *packet;
    286264
    287265        packet = pm_find(packet_id);
     
    294272
    295273        return EOK;
    296 }
    297 
    298 void pq_release_local(int phone, packet_id_t packet_id)
    299 {
    300         (void) packet_release_wrapper(packet_id);
    301274}
    302275
     
    310283 *                      async_share_in_finalize() function.
    311284 */
    312 static int packet_reply(const packet_t packet)
     285static int packet_reply(packet_t *packet)
    313286{
    314287        ipc_callid_t callid;
     
    351324    int *answer_count)
    352325{
    353         packet_t packet;
     326        packet_t *packet;
    354327
    355328        *answer_count = 0;
    356         switch (IPC_GET_METHOD(*call)) {
     329        switch (IPC_GET_IMETHOD(*call)) {
    357330        case IPC_M_PHONE_HUNGUP:
    358331                return EOK;
     
    364337                        return ENOMEM;
    365338                *answer_count = 2;
    366                 IPC_SET_ARG1(*answer, (ipcarg_t) packet->packet_id);
    367                 IPC_SET_ARG2(*answer, (ipcarg_t) packet->length);
     339                IPC_SET_ARG1(*answer, (sysarg_t) packet->packet_id);
     340                IPC_SET_ARG2(*answer, (sysarg_t) packet->length);
    368341                return EOK;
    369342       
     
    378351                        return ENOMEM;
    379352                *answer_count = 2;
    380                 IPC_SET_ARG1(*answer, (ipcarg_t) packet->packet_id);
    381                 IPC_SET_ARG2(*answer, (ipcarg_t) packet->length);
     353                IPC_SET_ARG1(*answer, (sysarg_t) packet->packet_id);
     354                IPC_SET_ARG2(*answer, (sysarg_t) packet->length);
    382355                return EOK;
    383356       
     
    392365                if (!packet_is_valid(packet))
    393366                        return ENOENT;
    394                 IPC_SET_ARG1(*answer, (ipcarg_t) packet->length);
     367                IPC_SET_ARG1(*answer, (sysarg_t) packet->length);
    395368                *answer_count = 1;
    396369                return EOK;
Note: See TracChangeset for help on using the changeset viewer.