main.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /* main.c: Rx RPC interface
  2. *
  3. * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/sched.h>
  14. #include <rxrpc/rxrpc.h>
  15. #include <rxrpc/krxiod.h>
  16. #include <rxrpc/krxsecd.h>
  17. #include <rxrpc/krxtimod.h>
  18. #include <rxrpc/transport.h>
  19. #include <rxrpc/connection.h>
  20. #include <rxrpc/call.h>
  21. #include <rxrpc/message.h>
  22. #include "internal.h"
  23. MODULE_DESCRIPTION("Rx RPC implementation");
  24. MODULE_AUTHOR("Red Hat, Inc.");
  25. MODULE_LICENSE("GPL");
  26. __be32 rxrpc_epoch;
  27. /*****************************************************************************/
  28. /*
  29. * initialise the Rx module
  30. */
  31. static int __init rxrpc_initialise(void)
  32. {
  33. int ret;
  34. /* my epoch value */
  35. rxrpc_epoch = htonl(xtime.tv_sec);
  36. /* register the /proc interface */
  37. #ifdef CONFIG_PROC_FS
  38. ret = rxrpc_proc_init();
  39. if (ret<0)
  40. return ret;
  41. #endif
  42. /* register the sysctl files */
  43. #ifdef CONFIG_SYSCTL
  44. ret = rxrpc_sysctl_init();
  45. if (ret<0)
  46. goto error_proc;
  47. #endif
  48. /* start the krxtimod daemon */
  49. ret = rxrpc_krxtimod_start();
  50. if (ret<0)
  51. goto error_sysctl;
  52. /* start the krxiod daemon */
  53. ret = rxrpc_krxiod_init();
  54. if (ret<0)
  55. goto error_krxtimod;
  56. /* start the krxsecd daemon */
  57. ret = rxrpc_krxsecd_init();
  58. if (ret<0)
  59. goto error_krxiod;
  60. kdebug("\n\n");
  61. return 0;
  62. error_krxiod:
  63. rxrpc_krxiod_kill();
  64. error_krxtimod:
  65. rxrpc_krxtimod_kill();
  66. error_sysctl:
  67. #ifdef CONFIG_SYSCTL
  68. rxrpc_sysctl_cleanup();
  69. error_proc:
  70. #endif
  71. #ifdef CONFIG_PROC_FS
  72. rxrpc_proc_cleanup();
  73. #endif
  74. return ret;
  75. } /* end rxrpc_initialise() */
  76. module_init(rxrpc_initialise);
  77. /*****************************************************************************/
  78. /*
  79. * clean up the Rx module
  80. */
  81. static void __exit rxrpc_cleanup(void)
  82. {
  83. kenter("");
  84. __RXACCT(printk("Outstanding Messages : %d\n",
  85. atomic_read(&rxrpc_message_count)));
  86. __RXACCT(printk("Outstanding Calls : %d\n",
  87. atomic_read(&rxrpc_call_count)));
  88. __RXACCT(printk("Outstanding Connections: %d\n",
  89. atomic_read(&rxrpc_connection_count)));
  90. __RXACCT(printk("Outstanding Peers : %d\n",
  91. atomic_read(&rxrpc_peer_count)));
  92. __RXACCT(printk("Outstanding Transports : %d\n",
  93. atomic_read(&rxrpc_transport_count)));
  94. rxrpc_krxsecd_kill();
  95. rxrpc_krxiod_kill();
  96. rxrpc_krxtimod_kill();
  97. #ifdef CONFIG_SYSCTL
  98. rxrpc_sysctl_cleanup();
  99. #endif
  100. #ifdef CONFIG_PROC_FS
  101. rxrpc_proc_cleanup();
  102. #endif
  103. __RXACCT(printk("Outstanding Messages : %d\n",
  104. atomic_read(&rxrpc_message_count)));
  105. __RXACCT(printk("Outstanding Calls : %d\n",
  106. atomic_read(&rxrpc_call_count)));
  107. __RXACCT(printk("Outstanding Connections: %d\n",
  108. atomic_read(&rxrpc_connection_count)));
  109. __RXACCT(printk("Outstanding Peers : %d\n",
  110. atomic_read(&rxrpc_peer_count)));
  111. __RXACCT(printk("Outstanding Transports : %d\n",
  112. atomic_read(&rxrpc_transport_count)));
  113. kleave("");
  114. } /* end rxrpc_cleanup() */
  115. module_exit(rxrpc_cleanup);
  116. /*****************************************************************************/
  117. /*
  118. * clear the dead space between task_struct and kernel stack
  119. * - called by supplying -finstrument-functions to gcc
  120. */
  121. #if 0
  122. void __cyg_profile_func_enter (void *this_fn, void *call_site)
  123. __attribute__((no_instrument_function));
  124. void __cyg_profile_func_enter (void *this_fn, void *call_site)
  125. {
  126. asm volatile(" movl %%esp,%%edi \n"
  127. " andl %0,%%edi \n"
  128. " addl %1,%%edi \n"
  129. " movl %%esp,%%ecx \n"
  130. " subl %%edi,%%ecx \n"
  131. " shrl $2,%%ecx \n"
  132. " movl $0xedededed,%%eax \n"
  133. " rep stosl \n"
  134. :
  135. : "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info))
  136. : "eax", "ecx", "edi", "memory", "cc"
  137. );
  138. }
  139. void __cyg_profile_func_exit(void *this_fn, void *call_site)
  140. __attribute__((no_instrument_function));
  141. void __cyg_profile_func_exit(void *this_fn, void *call_site)
  142. {
  143. asm volatile(" movl %%esp,%%edi \n"
  144. " andl %0,%%edi \n"
  145. " addl %1,%%edi \n"
  146. " movl %%esp,%%ecx \n"
  147. " subl %%edi,%%ecx \n"
  148. " shrl $2,%%ecx \n"
  149. " movl $0xdadadada,%%eax \n"
  150. " rep stosl \n"
  151. :
  152. : "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info))
  153. : "eax", "ecx", "edi", "memory", "cc"
  154. );
  155. }
  156. #endif