register.c 3.84 KB
Newer Older
ghaddab's avatar
ghaddab committed
1
/*******************************************************************************
2
    OpenAirInterface
ghaddab's avatar
ghaddab committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.


    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
17 18
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
ghaddab's avatar
ghaddab committed
19 20 21 22 23
   see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
25

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
ghaddab's avatar
ghaddab committed
27 28

 *******************************************************************************/
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
/*________________________mac_register.c________________________

 Authors : Hicham Anouar, Raymond Knopp
 Company : EURECOM
 Emails  : anouar@eurecom.fr,  knopp@eurecom.fr
________________________________________________________________*/


/*!\brief Registration routines for generic MAC interface.  Register/unregister a MAC.
Upon registration, the MAC retrieves the transport channel (MAC_tch) data structure and provides the
pointer to the macphy_scheduler() routine*/
#define __NO_VERSION__

#undef __PHY_IMPLEMENTATION_DEFS_H__

#include "ARCH/CBMIMO1/DEVICE_DRIVER/defs.h"
#include "defs.h"
#include "extern.h"
#include "SCHED/extern.h"

#ifndef USER_MODE





55
void dummy_macphy_scheduler(uint8_t last_slot)
56 57 58 59
{
  //if (last_slot == 0)
  //  mac_xface->frame++;

60
  msg("[OPENAIR][MAC XFACE] in dummy_macphy_scheduler(): MAC no yet registered!\n");
61 62

  //#ifdef EMOS
63
  //  phy_procedures(last_slot);
64
  //#endif
65

66 67 68 69
}

void dummy_macphy_setparams(void *params)
{
70
  msg("[OPENAIR][MAC XFACE] dummy_macphy_setparams(): no MAC registered!\n");
71 72
}

73
void dummy_macphy_init(void )
74
{
75
  msg("[OPENAIR][MAC XFACE] dummy_macphy_init(): no MAC registered!\n");
76 77
}

78 79 80
MAC_xface *mac_register(void macphy_scheduler(uint8_t last_slot), void macphy_setparams(void *),void macphy_init(void ),void mrbch_phy_sync_failure(unsigned char,unsigned char),
                        void chbch_phy_sync_success(unsigned char,unsigned char))
{
81 82 83 84

  if (openair_daq_vars.mac_registered == 0) {

    msg("[OPENAIR][MAC XFACE] Registering new MAC interface at %p, scheduler %p, setparams at %p, init at %p\n",
85
        mac_xface,macphy_scheduler,macphy_setparams,macphy_init);
86 87 88 89 90 91 92 93
    mac_xface->macphy_scheduler = macphy_scheduler;
    mac_xface->macphy_setparams = macphy_setparams;
    mac_xface->macphy_init      = macphy_init;
#ifndef PC_TARGET
    //    mac_xface->ublaze_mac_xface = ublaze_mac_xface;
#endif
    openair_daq_vars.mac_registered=1;
    return(mac_xface);
94
  } else {
95 96 97
    msg("[OPENAIR][MAC XFACE] MAC interface already registered, aborting ...\n");
    return NULL;
  }
98

99 100 101

}

102 103
int mac_unregister(MAC_xface *mac_xface_rx)
{
104 105 106 107 108 109 110 111

  if (mac_xface_rx == mac_xface) {
    msg("[OPENAIR][MAC XFACE] Unregistering MAC interface\n");
    mac_xface->macphy_scheduler = dummy_macphy_scheduler;
    mac_xface->macphy_setparams = dummy_macphy_setparams;
    mac_xface->macphy_init      = dummy_macphy_init;
    openair_daq_vars.mac_registered=0;
    return(0);
112
  } else {
113 114 115 116 117 118 119 120 121
    msg("[OPENAIR][MAC XFACE] Not the right interface descriptor pointer!!!, aborting ...\n");
    return (-1);
  }

}

EXPORT_SYMBOL(mac_register);
EXPORT_SYMBOL(mac_unregister);
#endif //USER_MODE