monreader.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*
  2. * drivers/s390/char/monreader.c
  3. *
  4. * Character device driver for reading z/VM *MONITOR service records.
  5. *
  6. * Copyright 2004 IBM Corporation, IBM Deutschland Entwicklung GmbH.
  7. *
  8. * Author: Gerald Schaefer <geraldsc@de.ibm.com>
  9. */
  10. #include <linux/module.h>
  11. #include <linux/moduleparam.h>
  12. #include <linux/init.h>
  13. #include <linux/errno.h>
  14. #include <linux/types.h>
  15. #include <linux/kernel.h>
  16. #include <linux/miscdevice.h>
  17. #include <linux/ctype.h>
  18. #include <linux/spinlock.h>
  19. #include <linux/interrupt.h>
  20. #include <asm/uaccess.h>
  21. #include <asm/ebcdic.h>
  22. #include <asm/extmem.h>
  23. #include <linux/poll.h>
  24. #include <net/iucv/iucv.h>
  25. //#define MON_DEBUG /* Debug messages on/off */
  26. #define MON_NAME "monreader"
  27. #define P_INFO(x...) printk(KERN_INFO MON_NAME " info: " x)
  28. #define P_ERROR(x...) printk(KERN_ERR MON_NAME " error: " x)
  29. #define P_WARNING(x...) printk(KERN_WARNING MON_NAME " warning: " x)
  30. #ifdef MON_DEBUG
  31. #define P_DEBUG(x...) printk(KERN_DEBUG MON_NAME " debug: " x)
  32. #else
  33. #define P_DEBUG(x...) do {} while (0)
  34. #endif
  35. #define MON_COLLECT_SAMPLE 0x80
  36. #define MON_COLLECT_EVENT 0x40
  37. #define MON_SERVICE "*MONITOR"
  38. #define MON_IN_USE 0x01
  39. #define MON_MSGLIM 255
  40. static char mon_dcss_name[9] = "MONDCSS\0";
  41. struct mon_msg {
  42. u32 pos;
  43. u32 mca_offset;
  44. struct iucv_message msg;
  45. char msglim_reached;
  46. char replied_msglim;
  47. };
  48. struct mon_private {
  49. struct iucv_path *path;
  50. struct mon_msg *msg_array[MON_MSGLIM];
  51. unsigned int write_index;
  52. unsigned int read_index;
  53. atomic_t msglim_count;
  54. atomic_t read_ready;
  55. atomic_t iucv_connected;
  56. atomic_t iucv_severed;
  57. };
  58. static unsigned long mon_in_use = 0;
  59. static unsigned long mon_dcss_start;
  60. static unsigned long mon_dcss_end;
  61. static DECLARE_WAIT_QUEUE_HEAD(mon_read_wait_queue);
  62. static DECLARE_WAIT_QUEUE_HEAD(mon_conn_wait_queue);
  63. static u8 user_data_connect[16] = {
  64. /* Version code, must be 0x01 for shared mode */
  65. 0x01,
  66. /* what to collect */
  67. MON_COLLECT_SAMPLE | MON_COLLECT_EVENT,
  68. /* DCSS name in EBCDIC, 8 bytes padded with blanks */
  69. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  70. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  71. };
  72. static u8 user_data_sever[16] = {
  73. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  74. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  75. };
  76. /******************************************************************************
  77. * helper functions *
  78. *****************************************************************************/
  79. /*
  80. * Create the 8 bytes EBCDIC DCSS segment name from
  81. * an ASCII name, incl. padding
  82. */
  83. static void dcss_mkname(char *ascii_name, char *ebcdic_name)
  84. {
  85. int i;
  86. for (i = 0; i < 8; i++) {
  87. if (ascii_name[i] == '\0')
  88. break;
  89. ebcdic_name[i] = toupper(ascii_name[i]);
  90. };
  91. for (; i < 8; i++)
  92. ebcdic_name[i] = ' ';
  93. ASCEBC(ebcdic_name, 8);
  94. }
  95. /*
  96. * print appropriate error message for segment_load()/segment_type()
  97. * return code
  98. */
  99. static void mon_segment_warn(int rc, char* seg_name)
  100. {
  101. switch (rc) {
  102. case -ENOENT:
  103. P_WARNING("cannot load/query segment %s, does not exist\n",
  104. seg_name);
  105. break;
  106. case -ENOSYS:
  107. P_WARNING("cannot load/query segment %s, not running on VM\n",
  108. seg_name);
  109. break;
  110. case -EIO:
  111. P_WARNING("cannot load/query segment %s, hardware error\n",
  112. seg_name);
  113. break;
  114. case -ENOTSUPP:
  115. P_WARNING("cannot load/query segment %s, is a multi-part "
  116. "segment\n", seg_name);
  117. break;
  118. case -ENOSPC:
  119. P_WARNING("cannot load/query segment %s, overlaps with "
  120. "storage\n", seg_name);
  121. break;
  122. case -EBUSY:
  123. P_WARNING("cannot load/query segment %s, overlaps with "
  124. "already loaded dcss\n", seg_name);
  125. break;
  126. case -EPERM:
  127. P_WARNING("cannot load/query segment %s, already loaded in "
  128. "incompatible mode\n", seg_name);
  129. break;
  130. case -ENOMEM:
  131. P_WARNING("cannot load/query segment %s, out of memory\n",
  132. seg_name);
  133. break;
  134. case -ERANGE:
  135. P_WARNING("cannot load/query segment %s, exceeds kernel "
  136. "mapping range\n", seg_name);
  137. break;
  138. default:
  139. P_WARNING("cannot load/query segment %s, return value %i\n",
  140. seg_name, rc);
  141. break;
  142. }
  143. }
  144. static inline unsigned long mon_mca_start(struct mon_msg *monmsg)
  145. {
  146. return *(u32 *) &monmsg->msg.rmmsg;
  147. }
  148. static inline unsigned long mon_mca_end(struct mon_msg *monmsg)
  149. {
  150. return *(u32 *) &monmsg->msg.rmmsg[4];
  151. }
  152. static inline u8 mon_mca_type(struct mon_msg *monmsg, u8 index)
  153. {
  154. return *((u8 *) mon_mca_start(monmsg) + monmsg->mca_offset + index);
  155. }
  156. static inline u32 mon_mca_size(struct mon_msg *monmsg)
  157. {
  158. return mon_mca_end(monmsg) - mon_mca_start(monmsg) + 1;
  159. }
  160. static inline u32 mon_rec_start(struct mon_msg *monmsg)
  161. {
  162. return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 4));
  163. }
  164. static inline u32 mon_rec_end(struct mon_msg *monmsg)
  165. {
  166. return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 8));
  167. }
  168. static int mon_check_mca(struct mon_msg *monmsg)
  169. {
  170. if ((mon_rec_end(monmsg) <= mon_rec_start(monmsg)) ||
  171. (mon_rec_start(monmsg) < mon_dcss_start) ||
  172. (mon_rec_end(monmsg) > mon_dcss_end) ||
  173. (mon_mca_type(monmsg, 0) == 0) ||
  174. (mon_mca_size(monmsg) % 12 != 0) ||
  175. (mon_mca_end(monmsg) <= mon_mca_start(monmsg)) ||
  176. (mon_mca_end(monmsg) > mon_dcss_end) ||
  177. (mon_mca_start(monmsg) < mon_dcss_start) ||
  178. ((mon_mca_type(monmsg, 1) == 0) && (mon_mca_type(monmsg, 2) == 0)))
  179. {
  180. P_DEBUG("READ, IGNORED INVALID MCA\n\n");
  181. return -EINVAL;
  182. }
  183. return 0;
  184. }
  185. static int mon_send_reply(struct mon_msg *monmsg,
  186. struct mon_private *monpriv)
  187. {
  188. int rc;
  189. P_DEBUG("read, REPLY: pathid = 0x%04X, msgid = 0x%08X, trgcls = "
  190. "0x%08X\n\n",
  191. monpriv->path->pathid, monmsg->msg.id, monmsg->msg.class);
  192. rc = iucv_message_reply(monpriv->path, &monmsg->msg,
  193. IUCV_IPRMDATA, NULL, 0);
  194. atomic_dec(&monpriv->msglim_count);
  195. if (likely(!monmsg->msglim_reached)) {
  196. monmsg->pos = 0;
  197. monmsg->mca_offset = 0;
  198. monpriv->read_index = (monpriv->read_index + 1) %
  199. MON_MSGLIM;
  200. atomic_dec(&monpriv->read_ready);
  201. } else
  202. monmsg->replied_msglim = 1;
  203. if (rc) {
  204. P_ERROR("read, IUCV reply failed with rc = %i\n\n", rc);
  205. return -EIO;
  206. }
  207. return 0;
  208. }
  209. static void mon_free_mem(struct mon_private *monpriv)
  210. {
  211. int i;
  212. for (i = 0; i < MON_MSGLIM; i++)
  213. if (monpriv->msg_array[i])
  214. kfree(monpriv->msg_array[i]);
  215. kfree(monpriv);
  216. }
  217. static struct mon_private *mon_alloc_mem(void)
  218. {
  219. int i;
  220. struct mon_private *monpriv;
  221. monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL);
  222. if (!monpriv) {
  223. P_ERROR("no memory for monpriv\n");
  224. return NULL;
  225. }
  226. for (i = 0; i < MON_MSGLIM; i++) {
  227. monpriv->msg_array[i] = kzalloc(sizeof(struct mon_msg),
  228. GFP_KERNEL);
  229. if (!monpriv->msg_array[i]) {
  230. P_ERROR("open, no memory for msg_array\n");
  231. mon_free_mem(monpriv);
  232. return NULL;
  233. }
  234. }
  235. return monpriv;
  236. }
  237. static inline void mon_read_debug(struct mon_msg *monmsg,
  238. struct mon_private *monpriv)
  239. {
  240. #ifdef MON_DEBUG
  241. u8 msg_type[2], mca_type;
  242. unsigned long records_len;
  243. records_len = mon_rec_end(monmsg) - mon_rec_start(monmsg) + 1;
  244. memcpy(msg_type, &monmsg->msg.class, 2);
  245. EBCASC(msg_type, 2);
  246. mca_type = mon_mca_type(monmsg, 0);
  247. EBCASC(&mca_type, 1);
  248. P_DEBUG("read, mon_read_index = %i, mon_write_index = %i\n",
  249. monpriv->read_index, monpriv->write_index);
  250. P_DEBUG("read, pathid = 0x%04X, msgid = 0x%08X, trgcls = 0x%08X\n",
  251. monpriv->path->pathid, monmsg->msg.id, monmsg->msg.class);
  252. P_DEBUG("read, msg_type = '%c%c', mca_type = '%c' / 0x%X / 0x%X\n",
  253. msg_type[0], msg_type[1], mca_type ? mca_type : 'X',
  254. mon_mca_type(monmsg, 1), mon_mca_type(monmsg, 2));
  255. P_DEBUG("read, MCA: start = 0x%lX, end = 0x%lX\n",
  256. mon_mca_start(monmsg), mon_mca_end(monmsg));
  257. P_DEBUG("read, REC: start = 0x%X, end = 0x%X, len = %lu\n\n",
  258. mon_rec_start(monmsg), mon_rec_end(monmsg), records_len);
  259. if (mon_mca_size(monmsg) > 12)
  260. P_DEBUG("READ, MORE THAN ONE MCA\n\n");
  261. #endif
  262. }
  263. static inline void mon_next_mca(struct mon_msg *monmsg)
  264. {
  265. if (likely((mon_mca_size(monmsg) - monmsg->mca_offset) == 12))
  266. return;
  267. P_DEBUG("READ, NEXT MCA\n\n");
  268. monmsg->mca_offset += 12;
  269. monmsg->pos = 0;
  270. }
  271. static struct mon_msg *mon_next_message(struct mon_private *monpriv)
  272. {
  273. struct mon_msg *monmsg;
  274. if (!atomic_read(&monpriv->read_ready))
  275. return NULL;
  276. monmsg = monpriv->msg_array[monpriv->read_index];
  277. if (unlikely(monmsg->replied_msglim)) {
  278. monmsg->replied_msglim = 0;
  279. monmsg->msglim_reached = 0;
  280. monmsg->pos = 0;
  281. monmsg->mca_offset = 0;
  282. P_WARNING("read, message limit reached\n");
  283. monpriv->read_index = (monpriv->read_index + 1) %
  284. MON_MSGLIM;
  285. atomic_dec(&monpriv->read_ready);
  286. return ERR_PTR(-EOVERFLOW);
  287. }
  288. return monmsg;
  289. }
  290. /******************************************************************************
  291. * IUCV handler *
  292. *****************************************************************************/
  293. static void mon_iucv_path_complete(struct iucv_path *path, u8 ipuser[16])
  294. {
  295. struct mon_private *monpriv = path->private;
  296. P_DEBUG("IUCV connection completed\n");
  297. P_DEBUG("IUCV ACCEPT (from *MONITOR): Version = 0x%02X, Event = "
  298. "0x%02X, Sample = 0x%02X\n",
  299. ipuser[0], ipuser[1], ipuser[2]);
  300. atomic_set(&monpriv->iucv_connected, 1);
  301. wake_up(&mon_conn_wait_queue);
  302. }
  303. static void mon_iucv_path_severed(struct iucv_path *path, u8 ipuser[16])
  304. {
  305. struct mon_private *monpriv = path->private;
  306. P_ERROR("IUCV connection severed with rc = 0x%X\n", ipuser[0]);
  307. iucv_path_sever(path, NULL);
  308. atomic_set(&monpriv->iucv_severed, 1);
  309. wake_up(&mon_conn_wait_queue);
  310. wake_up_interruptible(&mon_read_wait_queue);
  311. }
  312. static void mon_iucv_message_pending(struct iucv_path *path,
  313. struct iucv_message *msg)
  314. {
  315. struct mon_private *monpriv = path->private;
  316. P_DEBUG("IUCV message pending\n");
  317. memcpy(&monpriv->msg_array[monpriv->write_index]->msg,
  318. msg, sizeof(*msg));
  319. if (atomic_inc_return(&monpriv->msglim_count) == MON_MSGLIM) {
  320. P_WARNING("IUCV message pending, message limit (%i) reached\n",
  321. MON_MSGLIM);
  322. monpriv->msg_array[monpriv->write_index]->msglim_reached = 1;
  323. }
  324. monpriv->write_index = (monpriv->write_index + 1) % MON_MSGLIM;
  325. atomic_inc(&monpriv->read_ready);
  326. wake_up_interruptible(&mon_read_wait_queue);
  327. }
  328. static struct iucv_handler monreader_iucv_handler = {
  329. .path_complete = mon_iucv_path_complete,
  330. .path_severed = mon_iucv_path_severed,
  331. .message_pending = mon_iucv_message_pending,
  332. };
  333. /******************************************************************************
  334. * file operations *
  335. *****************************************************************************/
  336. static int mon_open(struct inode *inode, struct file *filp)
  337. {
  338. struct mon_private *monpriv;
  339. int rc;
  340. /*
  341. * only one user allowed
  342. */
  343. rc = -EBUSY;
  344. if (test_and_set_bit(MON_IN_USE, &mon_in_use))
  345. goto out;
  346. rc = -ENOMEM;
  347. monpriv = mon_alloc_mem();
  348. if (!monpriv)
  349. goto out_use;
  350. /*
  351. * Connect to *MONITOR service
  352. */
  353. monpriv->path = iucv_path_alloc(MON_MSGLIM, IUCV_IPRMDATA, GFP_KERNEL);
  354. if (!monpriv->path)
  355. goto out_priv;
  356. rc = iucv_path_connect(monpriv->path, &monreader_iucv_handler,
  357. MON_SERVICE, NULL, user_data_connect, monpriv);
  358. if (rc) {
  359. P_ERROR("iucv connection to *MONITOR failed with "
  360. "IPUSER SEVER code = %i\n", rc);
  361. rc = -EIO;
  362. goto out_path;
  363. }
  364. /*
  365. * Wait for connection confirmation
  366. */
  367. wait_event(mon_conn_wait_queue,
  368. atomic_read(&monpriv->iucv_connected) ||
  369. atomic_read(&monpriv->iucv_severed));
  370. if (atomic_read(&monpriv->iucv_severed)) {
  371. atomic_set(&monpriv->iucv_severed, 0);
  372. atomic_set(&monpriv->iucv_connected, 0);
  373. rc = -EIO;
  374. goto out_path;
  375. }
  376. P_INFO("open, established connection to *MONITOR service\n\n");
  377. filp->private_data = monpriv;
  378. return nonseekable_open(inode, filp);
  379. out_path:
  380. kfree(monpriv->path);
  381. out_priv:
  382. mon_free_mem(monpriv);
  383. out_use:
  384. clear_bit(MON_IN_USE, &mon_in_use);
  385. out:
  386. return rc;
  387. }
  388. static int mon_close(struct inode *inode, struct file *filp)
  389. {
  390. int rc, i;
  391. struct mon_private *monpriv = filp->private_data;
  392. /*
  393. * Close IUCV connection and unregister
  394. */
  395. rc = iucv_path_sever(monpriv->path, user_data_sever);
  396. if (rc)
  397. P_ERROR("close, iucv_sever failed with rc = %i\n", rc);
  398. else
  399. P_INFO("close, terminated connection to *MONITOR service\n");
  400. atomic_set(&monpriv->iucv_severed, 0);
  401. atomic_set(&monpriv->iucv_connected, 0);
  402. atomic_set(&monpriv->read_ready, 0);
  403. atomic_set(&monpriv->msglim_count, 0);
  404. monpriv->write_index = 0;
  405. monpriv->read_index = 0;
  406. for (i = 0; i < MON_MSGLIM; i++)
  407. kfree(monpriv->msg_array[i]);
  408. kfree(monpriv);
  409. clear_bit(MON_IN_USE, &mon_in_use);
  410. return 0;
  411. }
  412. static ssize_t mon_read(struct file *filp, char __user *data,
  413. size_t count, loff_t *ppos)
  414. {
  415. struct mon_private *monpriv = filp->private_data;
  416. struct mon_msg *monmsg;
  417. int ret;
  418. u32 mce_start;
  419. monmsg = mon_next_message(monpriv);
  420. if (IS_ERR(monmsg))
  421. return PTR_ERR(monmsg);
  422. if (!monmsg) {
  423. if (filp->f_flags & O_NONBLOCK)
  424. return -EAGAIN;
  425. ret = wait_event_interruptible(mon_read_wait_queue,
  426. atomic_read(&monpriv->read_ready) ||
  427. atomic_read(&monpriv->iucv_severed));
  428. if (ret)
  429. return ret;
  430. if (unlikely(atomic_read(&monpriv->iucv_severed)))
  431. return -EIO;
  432. monmsg = monpriv->msg_array[monpriv->read_index];
  433. }
  434. if (!monmsg->pos) {
  435. monmsg->pos = mon_mca_start(monmsg) + monmsg->mca_offset;
  436. mon_read_debug(monmsg, monpriv);
  437. }
  438. if (mon_check_mca(monmsg))
  439. goto reply;
  440. /* read monitor control element (12 bytes) first */
  441. mce_start = mon_mca_start(monmsg) + monmsg->mca_offset;
  442. if ((monmsg->pos >= mce_start) && (monmsg->pos < mce_start + 12)) {
  443. count = min(count, (size_t) mce_start + 12 - monmsg->pos);
  444. ret = copy_to_user(data, (void *) (unsigned long) monmsg->pos,
  445. count);
  446. if (ret)
  447. return -EFAULT;
  448. monmsg->pos += count;
  449. if (monmsg->pos == mce_start + 12)
  450. monmsg->pos = mon_rec_start(monmsg);
  451. goto out_copy;
  452. }
  453. /* read records */
  454. if (monmsg->pos <= mon_rec_end(monmsg)) {
  455. count = min(count, (size_t) mon_rec_end(monmsg) - monmsg->pos
  456. + 1);
  457. ret = copy_to_user(data, (void *) (unsigned long) monmsg->pos,
  458. count);
  459. if (ret)
  460. return -EFAULT;
  461. monmsg->pos += count;
  462. if (monmsg->pos > mon_rec_end(monmsg))
  463. mon_next_mca(monmsg);
  464. goto out_copy;
  465. }
  466. reply:
  467. ret = mon_send_reply(monmsg, monpriv);
  468. return ret;
  469. out_copy:
  470. *ppos += count;
  471. return count;
  472. }
  473. static unsigned int mon_poll(struct file *filp, struct poll_table_struct *p)
  474. {
  475. struct mon_private *monpriv = filp->private_data;
  476. poll_wait(filp, &mon_read_wait_queue, p);
  477. if (unlikely(atomic_read(&monpriv->iucv_severed)))
  478. return POLLERR;
  479. if (atomic_read(&monpriv->read_ready))
  480. return POLLIN | POLLRDNORM;
  481. return 0;
  482. }
  483. static const struct file_operations mon_fops = {
  484. .owner = THIS_MODULE,
  485. .open = &mon_open,
  486. .release = &mon_close,
  487. .read = &mon_read,
  488. .poll = &mon_poll,
  489. };
  490. static struct miscdevice mon_dev = {
  491. .name = "monreader",
  492. .fops = &mon_fops,
  493. .minor = MISC_DYNAMIC_MINOR,
  494. };
  495. /******************************************************************************
  496. * module init/exit *
  497. *****************************************************************************/
  498. static int __init mon_init(void)
  499. {
  500. int rc;
  501. if (!MACHINE_IS_VM) {
  502. P_ERROR("not running under z/VM, driver not loaded\n");
  503. return -ENODEV;
  504. }
  505. /*
  506. * Register with IUCV and connect to *MONITOR service
  507. */
  508. rc = iucv_register(&monreader_iucv_handler, 1);
  509. if (rc) {
  510. P_ERROR("failed to register with iucv driver\n");
  511. return rc;
  512. }
  513. P_INFO("open, registered with IUCV\n");
  514. rc = segment_type(mon_dcss_name);
  515. if (rc < 0) {
  516. mon_segment_warn(rc, mon_dcss_name);
  517. goto out_iucv;
  518. }
  519. if (rc != SEG_TYPE_SC) {
  520. P_ERROR("segment %s has unsupported type, should be SC\n",
  521. mon_dcss_name);
  522. rc = -EINVAL;
  523. goto out_iucv;
  524. }
  525. rc = segment_load(mon_dcss_name, SEGMENT_SHARED,
  526. &mon_dcss_start, &mon_dcss_end);
  527. if (rc < 0) {
  528. mon_segment_warn(rc, mon_dcss_name);
  529. rc = -EINVAL;
  530. goto out_iucv;
  531. }
  532. dcss_mkname(mon_dcss_name, &user_data_connect[8]);
  533. rc = misc_register(&mon_dev);
  534. if (rc < 0 ) {
  535. P_ERROR("misc_register failed, rc = %i\n", rc);
  536. goto out;
  537. }
  538. P_INFO("Loaded segment %s from %p to %p, size = %lu Byte\n",
  539. mon_dcss_name, (void *) mon_dcss_start, (void *) mon_dcss_end,
  540. mon_dcss_end - mon_dcss_start + 1);
  541. return 0;
  542. out:
  543. segment_unload(mon_dcss_name);
  544. out_iucv:
  545. iucv_unregister(&monreader_iucv_handler, 1);
  546. return rc;
  547. }
  548. static void __exit mon_exit(void)
  549. {
  550. segment_unload(mon_dcss_name);
  551. WARN_ON(misc_deregister(&mon_dev) != 0);
  552. iucv_unregister(&monreader_iucv_handler, 1);
  553. return;
  554. }
  555. module_init(mon_init);
  556. module_exit(mon_exit);
  557. module_param_string(mondcss, mon_dcss_name, 9, 0444);
  558. MODULE_PARM_DESC(mondcss, "Name of DCSS segment to be used for *MONITOR "
  559. "service, max. 8 chars. Default is MONDCSS");
  560. MODULE_AUTHOR("Gerald Schaefer <geraldsc@de.ibm.com>");
  561. MODULE_DESCRIPTION("Character device driver for reading z/VM "
  562. "monitor service records.");
  563. MODULE_LICENSE("GPL");