Ignore:
Timestamp:
2010-04-23T21:42:26Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6c39a907
Parents:
38aaacc2 (diff), 80badbe (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/net/generic/packet_remote.c

    r38aaacc2 rf4f866c  
    3232
    3333/** @file
    34  *  Packet client interface implementation for standalone remote modules.
     34 *  Packet client interface implementation for remote modules.
    3535 *  @see packet_client.h
    3636 */
     
    4747#include <packet/packet_header.h>
    4848#include <packet/packet_messages.h>
     49#include <packet_remote.h>
    4950
    50 /** Obtains the packet from the packet server as the shared memory block.
    51  *  Creates the local packet mapping as well.
    52  *  @param[in] phone The packet server module phone.
    53  *  @param[out] packet The packet reference pointer to store the received packet reference.
    54  *  @param[in] packet_id The packet identifier.
    55  *  @param[in] size The packet total size in bytes.
    56  *  @returns EOK on success.
    57  *  @returns Other error codes as defined for the pm_add() function.
    58  *  @returns Other error codes as defined for the async_share_in_start() function.
     51/** Obtain the packet from the packet server as the shared memory block.
     52 *
     53 * Create the local packet mapping as well.
     54 *
     55 * @param[in]  phone     The packet server module phone.
     56 * @param[out] packet    The packet reference pointer to store the received
     57 *                       packet reference.
     58 * @param[in]  packet_id The packet identifier.
     59 * @param[in]  size      The packet total size in bytes.
     60 *
     61 * @return EOK on success.
     62 * @return Other error codes as defined for the pm_add() function.
     63 * @return Other error codes as defined for the async_share_in_start() function.
     64 *
    5965 */
    60 int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size);
    61 
    62 int packet_translate(int phone, packet_ref packet, packet_id_t packet_id){
     66static int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){
    6367        ERROR_DECLARE;
    64 
    65         ipcarg_t size;
    66         packet_t next;
    67 
    68         if(! packet){
    69                 return EINVAL;
    70         }
    71         *packet = pm_find(packet_id);
    72         if(!(*packet)){
    73                 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size));
    74                 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
    75         }
    76         if((** packet).next){
    77                 return packet_translate(phone, &next, (** packet).next);
    78         }else return EOK;
    79 }
    80 
    81 int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){
    82         ERROR_DECLARE;
    83 
    84         aid_t message;
     68       
    8569        ipc_call_t answer;
    86         ipcarg_t result;
    87 
    88         message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
     70        aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
    8971        *packet = (packet_t) as_get_mappable_page(size);
    90         if(ERROR_OCCURRED(async_share_in_start_0_0(phone, * packet, size))
    91                 || ERROR_OCCURRED(pm_add(*packet))){
     72        if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size))
     73            || ERROR_OCCURRED(pm_add(*packet))) {
    9274                munmap(*packet, size);
    9375                async_wait_for(message, NULL);
    9476                return ERROR_CODE;
    9577        }
     78       
     79        ipcarg_t result;
    9680        async_wait_for(message, &result);
     81       
    9782        return result;
    9883}
    9984
    100 packet_t packet_get_4(int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix){
     85int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id)
     86{
    10187        ERROR_DECLARE;
     88       
     89        if (!packet)
     90                return EINVAL;
     91       
     92        *packet = pm_find(packet_id);
     93        if (!(*packet)) {
     94                ipcarg_t size;
     95               
     96                ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size));
     97                ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
     98        }
     99        if ((** packet).next) {
     100                packet_t next;
     101               
     102                return packet_translate_remote(phone, &next, (** packet).next);
     103        }
     104       
     105        return EOK;
     106}
    102107
     108packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
     109    size_t max_prefix, size_t max_suffix)
     110{
     111        ERROR_DECLARE;
     112       
    103113        ipcarg_t packet_id;
    104114        ipcarg_t size;
    105         packet_t packet;
    106 
    107         if(ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, &packet_id, &size))){
     115       
     116        if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content,
     117            addr_len, max_prefix, max_suffix, &packet_id, &size)))
    108118                return NULL;
     119       
     120       
     121        packet_t packet = pm_find(packet_id);
     122        if (!packet) {
     123                if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size)))
     124                        return NULL;
    109125        }
    110         packet = pm_find(packet_id);
    111         if(! packet){
    112                 if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){
    113                         return NULL;
    114                 }
    115         }
     126       
    116127        return packet;
    117128}
    118129
    119 packet_t packet_get_1(int phone, size_t content){
     130packet_t packet_get_1_remote(int phone, size_t content)
     131{
    120132        ERROR_DECLARE;
    121 
     133       
    122134        ipcarg_t packet_id;
    123135        ipcarg_t size;
    124         packet_t packet;
    125 
    126         if(ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, &size))){
     136       
     137        if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content,
     138            &packet_id, &size)))
    127139                return NULL;
     140       
     141        packet_t packet = pm_find(packet_id);
     142        if (!packet) {
     143                if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size)))
     144                        return NULL;
    128145        }
    129         packet = pm_find(packet_id);
    130         if(! packet){
    131                 if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){
    132                         return NULL;
    133                 }
    134         }
     146       
    135147        return packet;
    136148}
    137149
    138 void pq_release(int phone, packet_id_t packet_id){
     150void pq_release_remote(int phone, packet_id_t packet_id)
     151{
    139152        async_msg_1(phone, NET_PACKET_RELEASE, packet_id);
    140153}
Note: See TracChangeset for help on using the changeset viewer.