POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/middleware/portqueueingcreate.c
Go to the documentation of this file.
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Thu Jan 15 23:34:13 2009 
00015  */
00016 
00017 #ifdef POK_NEEDS_PORTS_QUEUEING
00018 
00019 #include <errno.h>
00020 #include <types.h>
00021 #include <core/lockobj.h>
00022 #include <middleware/port.h>
00023 #include <middleware/queue.h>
00024 
00025 extern pok_port_t    pok_ports[POK_CONFIG_NB_PORTS];
00026 
00027 pok_ret_t pok_port_queueing_create (char*                                  name, 
00028                                     const pok_port_size_t                  size, 
00029                                     const pok_port_direction_t             direction,
00030                                     const pok_port_queueing_discipline_t   discipline,
00031                                     pok_port_id_t*                         id)
00032 {
00033    pok_ret_t            ret;
00034    pok_lockobj_attr_t   lockattr;
00035    if (discipline != POK_PORT_QUEUEING_DISCIPLINE_FIFO)
00036    {
00037       return POK_ERRNO_DISCIPLINE;
00038    }
00039 
00040    ret = pok_port_create (name, size, direction, POK_PORT_KIND_QUEUEING, id);
00041 
00042    /*
00043     * FIXME: should be done using another way by reinitializing
00044     * ports when a partition is restarted. At this time, when
00045     * a partition is restarted, the ports are not reinitialized
00046     * so that when the partition restart, it tries to reopen
00047     * ports already created. We pass over actually and keep
00048     * the port in the previous step, but we should reinitialize
00049     * the port while reinitializing the partition AND also
00050     * does not report an OK return code (see below) when trying to re
00051     * create a port that was already created.
00052     */
00053    if (ret == POK_ERRNO_EXISTS)
00054    {
00055       return POK_ERRNO_OK;
00056    }
00057 
00058    if (ret != POK_ERRNO_OK)
00059    {
00060       return ret;
00061    }
00062 
00063    pok_ports[*id].discipline = discipline;
00064    
00065    lockattr.kind              = POK_LOCKOBJ_KIND_EVENT;
00066    lockattr.locking_policy    = POK_LOCKOBJ_POLICY_STANDARD;
00067    ret = pok_lockobj_create (&pok_ports[*id].lock, &lockattr);
00068 
00069    return (ret);
00070 }
00071 
00072 #endif