My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sw_modinit.h
Go to the documentation of this file.
1 /*
2  * OpenVirtualization:
3  * For additional details and support contact developer@sierraware.com.
4  * Additional documentation can be found at www.openvirtualization.org
5  *
6  * Copyright (C) 2010-2014 SierraWare
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  *
22  */
23 /*
24  * Header for module initialization implementation functions
25  */
26 
27 #ifndef _SW_MODINIT_H_
28 #define _SW_MODINIT_H_
29 
30 #include <sw_list.h>
31 #include <sw_types.h>
32 
33 #define __init __attribute__((section(".init")))
34 #define __mod_init __attribute__((section(".mod_init"))) __attribute__((used))
35 #define __mod_exit __attribute__((section(".mod_exit"))) __attribute__((used))
36 
46 typedef void (*mod_init_fn_call) (void);
47 
56 typedef void (*mod_exit_fn_call) (void);
57 
58 #define SW_MODULE_INIT(fn) \
59  static __mod_init mod_init_fn_call mod_init_fn = fn
60 
61 #define SW_MODULE_EXIT(fn) \
62  static __mod_exit mod_exit_fn_call mod_exit_fn = fn
63 
64 
69  struct list head;
70  void (*open) ();
71  void (*close) ();
72  void (*read) (void);
73  void (*write) ();
74  void (*ioctl) (void);
75  u32 dev_id;
76  char sw_dev_name[20];
77 };
78 
85  struct list dev_list;
86 };
87 
88 extern struct sw_devices_head sw_dev_head;
89 
94 void sw_open();
95 
100 void sw_close();
101 
107 void sw_read(void);
108 
113 void sw_write();
114 
119 void sw_ioctl(void);
120 
128 void sw_device_register(struct sw_file_operations* sw_dev);
129 
136 void sw_device_unregister(struct sw_file_operations* sw_dev);
137 
142 void modules_init(void);
143 #endif
Definition: sw_modinit.h:68
void sw_write()
write system call for devices
Definition: sw_modinit.c:119
char sw_dev_name[20]
Definition: sw_modinit.h:76
This contains the list of devices registered during Initialisation.
Definition: sw_modinit.h:84
void(* mod_exit_fn_call)(void)
Typedef of function called during module exit.
Definition: sw_modinit.h:56
void sw_open()
open system call for devices
struct list head
Definition: sw_modinit.h:69
void(* open)()
Definition: sw_modinit.h:70
void sw_read(void)
Read system call for devices.
Definition: sw_modinit.c:107
void sw_close()
close system call for devices
void sw_ioctl(void)
ioctl system call for devices
Definition: sw_modinit.c:131
void sw_device_register(struct sw_file_operations *sw_dev)
This function is called by each module for registration.
Definition: sw_modinit.c:53
void(* write)()
Definition: sw_modinit.h:73
void modules_init(void)
This function calls the initialization function of all the modules.
Definition: sw_list.h:56
void(* read)(void)
Definition: sw_modinit.h:72
struct list dev_list
Definition: sw_modinit.h:85
void(* close)()
Definition: sw_modinit.h:71
void(* mod_init_fn_call)(void)
Typedef of initialization functions in all the modules.
Definition: sw_modinit.h:46
void(* ioctl)(void)
Definition: sw_modinit.h:74
struct sw_devices_head sw_dev_head
Definition: sw_modinit.c:33
u32 dev_id
Definition: sw_modinit.h:75
void sw_device_unregister(struct sw_file_operations *sw_dev)
This function is called by each module to unregister them.
Definition: sw_modinit.c:65