layer2_top.c 3.68 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
/*________________________openair_w3g4free_top.c________________________

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

#ifndef USER_MODE
#define __NO_VERSION__

#include <rtai.h>
#include <rtai_fifos.h>


#include <asm/io.h>
#include <asm/bitops.h>
#include <asm/uaccess.h>
#include <asm/segment.h>
#include <asm/page.h>
#include <asm/delay.h>

#include <linux/init.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/mm.h>
#include <linux/mman.h>

#include <linux/slab.h>
//#include <linux/config.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/fs.h>

#include <linux/errno.h>

#ifdef KERNEL2_6
//#include <linux/config.h>
#include <linux/slab.h>
#endif

#ifdef KERNEL2_4
#include <linux/malloc.h>
#include <linux/wrapper.h>
#endif

#endif


#include <linux/bigphysarea.h>

//#include "defs.h"
//#include "openair_types.h"
#include "LAYER2/MAC/vars.h"
#include "LAYER2/MAC/defs.h"

extern void  macphy_scheduler(u8);
extern MAC_xface *mac_register(void *, void*, void*, void*,void*);
extern int mac_unregister(MAC_xface *);
extern MAC_xface *mac_xface;
extern int mac_top_init();
extern int mac_init_global_param(void);
extern int pdcp_module_init(void);
extern void pdcp_module_cleanup(void);  

/*------------------------------------------------*/
void w3g4free_mac_init(void) {

  int ret;

#ifndef USER_MODE
  printk("[OPENAIR][MAC][TOP] INIT...\n");
#else
  printf("[OPENAIR][MAC][TOP] INIT...\n");
#endif// USER_MODE
  // if(mac_xface->is_cluster_head)
  // mac_top_init();
  //else
  mac_top_init();

#ifndef USER_MODE
  printk("[OPENAIR][MAC][TOP] INIT DONE.\n");
#endif//USER_MODE
  
  

}
/*------------------------------------------------*/
#ifndef USER_MODE

/*------------------------------------------------*/
/*   Prototypes                                   */
/*------------------------------------------------*/
#ifdef KERNEL2_4
static int   init_module( void );
static void  cleanup_module(void);
#else
static int   openair_mac_init_module( void );
static void  openair_mac_cleanup_module(void);
#endif

#ifdef KERNEL2_6 
static int __init openair_mac_init_module( void ) 
#else 
     int init_module( void ) 
#endif //KERNEL2_6
{
    printk("[OPENAIR][MAC][INIT] inserting module\n");

    //    mac_init_global_param();

    mac_xface=mac_register(macphy_scheduler,NULL,w3g4free_mac_init,mrbch_phy_sync_failure,chbch_phy_sync_success);
    if( mac_xface == NULL )
      {
	printk("[OPENAIR][MAC][INIT] Could not get MAC descriptor\n");
	return -1;
      }
    else {
      printk("[OPENAIR][MAC][INIT] Got MAC descriptor \n");
      if(mac_init_global_param()==-1) {
	mac_unregister(mac_xface);
         return -1; 
      }
    }       
    if (pdcp_module_init()!=0) {
      mac_unregister(mac_xface);
      return(-1);
    }
    else{
      printk("[OPENAIR][MAC][INIT] PDCP INIT OK\n");
    }


    return 0;
}

#ifdef KERNEL2_6
static void __exit openair_mac_cleanup_module(void)
#else
  void cleanup_module(void)
#endif //KERNEL2_6
{
  printk("[OPENAIR][MAC][CLEANUP] cleanup module\n");
  mac_unregister(mac_xface);
  pdcp_module_cleanup();  
}

MODULE_AUTHOR
  ("Lionel GAUTHIER <lionel.gauthier@eurecom.fr>, Raymond KNOPP <raymond.knopp@eurecom.fr>, Aawatif MENOUNI <aawatif.menouni@eurecom.fr>,Dominique NUSSBAUM <dominique.nussbaum@eurecom.fr>, Michelle WETTERWALD <michelle.wetterwald@eurecom.fr>, Maxime GUILLAUD <maxime.guillaud@eurecom.fr, Hicham ANOUAR <hicham.anouar@eurecom.fr>");
MODULE_DESCRIPTION ("openair MAC layer module");
MODULE_LICENSE ("GPL");
module_init (openair_mac_init_module);
module_exit (openair_mac_cleanup_module);


#endif //USER_MODE