Anthony Liguori | 0bfe3ca | 2009-05-14 19:29:53 +0100 | [diff] [blame] | 1 | /* |
| 2 | * QEMU Module Infrastructure |
| 3 | * |
| 4 | * Copyright IBM, Corp. 2009 |
| 5 | * |
| 6 | * Authors: |
| 7 | * Anthony Liguori <aliguori@us.ibm.com> |
| 8 | * |
| 9 | * This work is licensed under the terms of the GNU GPL, version 2. See |
| 10 | * the COPYING file in the top-level directory. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef QEMU_MODULE_H |
| 15 | #define QEMU_MODULE_H |
| 16 | |
| 17 | /* This should not be used directly. Use block_init etc. instead. */ |
| 18 | #define module_init(function, type) \ |
| 19 | static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \ |
Anthony Liguori | f789743 | 2009-05-14 17:57:31 -0500 | [diff] [blame] | 20 | register_module_init(function, type); \ |
Anthony Liguori | 0bfe3ca | 2009-05-14 19:29:53 +0100 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | typedef enum { |
| 24 | MODULE_INIT_BLOCK, |
Anthony Liguori | f789743 | 2009-05-14 17:57:31 -0500 | [diff] [blame] | 25 | MODULE_INIT_DEVICE, |
Anthony Liguori | f80f9ec | 2009-05-20 18:38:09 -0500 | [diff] [blame] | 26 | MODULE_INIT_MACHINE, |
Anthony Liguori | f789743 | 2009-05-14 17:57:31 -0500 | [diff] [blame] | 27 | MODULE_INIT_MAX |
Anthony Liguori | 0bfe3ca | 2009-05-14 19:29:53 +0100 | [diff] [blame] | 28 | } module_init_type; |
| 29 | |
| 30 | #define block_init(function) module_init(function, MODULE_INIT_BLOCK) |
| 31 | #define device_init(function) module_init(function, MODULE_INIT_DEVICE) |
Anthony Liguori | f80f9ec | 2009-05-20 18:38:09 -0500 | [diff] [blame] | 32 | #define machine_init(function) module_init(function, MODULE_INIT_MACHINE) |
Anthony Liguori | 0bfe3ca | 2009-05-14 19:29:53 +0100 | [diff] [blame] | 33 | |
| 34 | void register_module_init(void (*fn)(void), module_init_type type); |
| 35 | |
| 36 | void module_call_init(module_init_type type); |
| 37 | |
| 38 | #endif |