2 * NES, SNES, N64, MultiSystem, PSX gamepad driver for Linux
4 * Copyright (c) 1999-2004 Vojtech Pavlik <vojtech@suse.cz>
5 * Copyright (c) 2004 Peter Nelson <rufus-kernel@hackish.org>
7 * Based on the work of:
8 * Andree Borrmann John Dahlstrom
9 * David Kuder Nathan Hand
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
32 #include <linux/kernel.h>
33 #include <linux/delay.h>
34 #include <linux/module.h>
35 #include <linux/moduleparam.h>
36 #include <linux/init.h>
37 #include <linux/parport.h>
38 #include <linux/input.h>
39 #include <linux/mutex.h>
41 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
42 MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver");
43 MODULE_LICENSE("GPL");
45 #define GC_MAX_PORTS 3
46 #define GC_MAX_DEVICES 5
49 int args[GC_MAX_DEVICES + 1];
53 static struct gc_config gc[GC_MAX_PORTS] __initdata;
55 module_param_array_named(map, gc[0].args, int, &gc[0].nargs, 0);
56 MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<pad1>,<pad2>,..<pad5>)");
57 module_param_array_named(map2, gc[1].args, int, &gc[1].nargs, 0);
58 MODULE_PARM_DESC(map2, "Describes second set of devices");
59 module_param_array_named(map3, gc[2].args, int, &gc[2].nargs, 0);
60 MODULE_PARM_DESC(map3, "Describes third set of devices");
62 __obsolete_setup("gc=");
63 __obsolete_setup("gc_2=");
64 __obsolete_setup("gc_3=");
66 /* see also gs_psx_delay parameter in PSX support section */
79 #define GC_REFRESH_TIME HZ/100
83 struct input_dev *dev[GC_MAX_DEVICES];
84 struct timer_list timer;
85 unsigned char pads[GC_MAX + 1];
88 char phys[GC_MAX_DEVICES][32];
91 static struct gc *gc_base[3];
93 static int gc_status_bit[] = { 0x40, 0x80, 0x20, 0x10, 0x08 };
95 static char *gc_names[] = { NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick",
96 "Multisystem 2-button joystick", "N64 controller", "PSX controller",
97 "PSX DDR controller" };
102 static unsigned char gc_n64_bytes[] = { 0, 1, 13, 15, 14, 12, 10, 11, 2, 3 };
103 static short gc_n64_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TRIGGER, BTN_START };
105 #define GC_N64_LENGTH 32 /* N64 bit length, not including stop bit */
106 #define GC_N64_REQUEST_LENGTH 37 /* transmit request sequence is 9 bits long */
107 #define GC_N64_DELAY 133 /* delay between transmit request, and response ready (us) */
108 #define GC_N64_REQUEST 0x1dd1111111ULL /* the request data command (encoded for 000000011) */
109 #define GC_N64_DWS 3 /* delay between write segments (required for sound playback because of ISA DMA) */
110 /* GC_N64_DWS > 24 is known to fail */
111 #define GC_N64_POWER_W 0xe2 /* power during write (transmit request) */
112 #define GC_N64_POWER_R 0xfd /* power during read */
113 #define GC_N64_OUT 0x1d /* output bits to the 4 pads */
114 /* Reading the main axes of any N64 pad is known to fail if the corresponding bit */
115 /* in GC_N64_OUT is pulled low on the output port (by any routine) for more */
117 #define GC_N64_CLOCK 0x02 /* clock bits for read */
120 * gc_n64_read_packet() reads an N64 packet.
121 * Each pad uses one bit per byte. So all pads connected to this port are read in parallel.
124 static void gc_n64_read_packet(struct gc *gc, unsigned char *data)
130 * Request the pad to transmit data
133 local_irq_save(flags);
134 for (i = 0; i < GC_N64_REQUEST_LENGTH; i++) {
135 parport_write_data(gc->pd->port, GC_N64_POWER_W | ((GC_N64_REQUEST >> i) & 1 ? GC_N64_OUT : 0));
138 local_irq_restore(flags);
141 * Wait for the pad response to be loaded into the 33-bit register of the adapter
144 udelay(GC_N64_DELAY);
147 * Grab data (ignoring the last bit, which is a stop bit)
150 for (i = 0; i < GC_N64_LENGTH; i++) {
151 parport_write_data(gc->pd->port, GC_N64_POWER_R);
152 data[i] = parport_read_status(gc->pd->port);
153 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK);
157 * We must wait 200 ms here for the controller to reinitialize before the next read request.
158 * No worries as long as gc_read is polled less frequently than this.
163 static void gc_n64_process_packet(struct gc *gc)
165 unsigned char data[GC_N64_LENGTH];
167 struct input_dev *dev;
170 gc_n64_read_packet(gc, data);
172 for (i = 0; i < GC_MAX_DEVICES; i++) {
178 s = gc_status_bit[i];
180 if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) {
182 axes[0] = axes[1] = 0;
184 for (j = 0; j < 8; j++) {
185 if (data[23 - j] & s)
187 if (data[31 - j] & s)
191 input_report_abs(dev, ABS_X, axes[0]);
192 input_report_abs(dev, ABS_Y, -axes[1]);
194 input_report_abs(dev, ABS_HAT0X, !(s & data[6]) - !(s & data[7]));
195 input_report_abs(dev, ABS_HAT0Y, !(s & data[4]) - !(s & data[5]));
197 for (j = 0; j < 10; j++)
198 input_report_key(dev, gc_n64_btn[j], s & data[gc_n64_bytes[j]]);
209 #define GC_NES_DELAY 6 /* Delay between bits - 6us */
210 #define GC_NES_LENGTH 8 /* The NES pads use 8 bits of data */
211 #define GC_SNES_LENGTH 12 /* The SNES true length is 16, but the last 4 bits are unused */
213 #define GC_NES_POWER 0xfc
214 #define GC_NES_CLOCK 0x01
215 #define GC_NES_LATCH 0x02
217 static unsigned char gc_nes_bytes[] = { 0, 1, 2, 3 };
218 static unsigned char gc_snes_bytes[] = { 8, 0, 2, 3, 9, 1, 10, 11 };
219 static short gc_snes_btn[] = { BTN_A, BTN_B, BTN_SELECT, BTN_START, BTN_X, BTN_Y, BTN_TL, BTN_TR };
222 * gc_nes_read_packet() reads a NES/SNES packet.
223 * Each pad uses one bit per byte. So all pads connected to
224 * this port are read in parallel.
227 static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data)
231 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK | GC_NES_LATCH);
232 udelay(GC_NES_DELAY * 2);
233 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK);
235 for (i = 0; i < length; i++) {
236 udelay(GC_NES_DELAY);
237 parport_write_data(gc->pd->port, GC_NES_POWER);
238 data[i] = parport_read_status(gc->pd->port) ^ 0x7f;
239 udelay(GC_NES_DELAY);
240 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK);
244 static void gc_nes_process_packet(struct gc *gc)
246 unsigned char data[GC_SNES_LENGTH];
247 struct input_dev *dev;
250 gc_nes_read_packet(gc, gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH, data);
252 for (i = 0; i < GC_MAX_DEVICES; i++) {
258 s = gc_status_bit[i];
260 if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) {
261 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7]));
262 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5]));
265 if (s & gc->pads[GC_NES])
266 for (j = 0; j < 4; j++)
267 input_report_key(dev, gc_snes_btn[j], s & data[gc_nes_bytes[j]]);
269 if (s & gc->pads[GC_SNES])
270 for (j = 0; j < 8; j++)
271 input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]);
278 * Multisystem joystick support
281 #define GC_MULTI_LENGTH 5 /* Multi system joystick packet length is 5 */
282 #define GC_MULTI2_LENGTH 6 /* One more bit for one more button */
285 * gc_multi_read_packet() reads a Multisystem joystick packet.
288 static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data)
292 for (i = 0; i < length; i++) {
293 parport_write_data(gc->pd->port, ~(1 << i));
294 data[i] = parport_read_status(gc->pd->port) ^ 0x7f;
298 static void gc_multi_process_packet(struct gc *gc)
300 unsigned char data[GC_MULTI2_LENGTH];
301 struct input_dev *dev;
304 gc_multi_read_packet(gc, gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH, data);
306 for (i = 0; i < GC_MAX_DEVICES; i++) {
312 s = gc_status_bit[i];
314 if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) {
315 input_report_abs(dev, ABS_X, !(s & data[2]) - !(s & data[3]));
316 input_report_abs(dev, ABS_Y, !(s & data[0]) - !(s & data[1]));
317 input_report_key(dev, BTN_TRIGGER, s & data[4]);
320 if (s & gc->pads[GC_MULTI2])
321 input_report_key(dev, BTN_THUMB, s & data[5]);
330 * See documentation at:
331 * http://www.dim.com/~mackys/psxmemcard/ps-eng2.txt
332 * http://www.gamesx.com/controldata/psxcont/psxcont.htm
333 * ftp://milano.usal.es/pablo/
337 #define GC_PSX_DELAY 25 /* 25 usec */
338 #define GC_PSX_LENGTH 8 /* talk to the controller in bits */
339 #define GC_PSX_BYTES 6 /* the maximum number of bytes to read off the controller */
341 #define GC_PSX_MOUSE 1 /* Mouse */
342 #define GC_PSX_NEGCON 2 /* NegCon */
343 #define GC_PSX_NORMAL 4 /* Digital / Analog or Rumble in Digital mode */
344 #define GC_PSX_ANALOG 5 /* Analog in Analog mode / Rumble in Green mode */
345 #define GC_PSX_RUMBLE 7 /* Rumble in Red mode */
347 #define GC_PSX_CLOCK 0x04 /* Pin 4 */
348 #define GC_PSX_COMMAND 0x01 /* Pin 2 */
349 #define GC_PSX_POWER 0xf8 /* Pins 5-9 */
350 #define GC_PSX_SELECT 0x02 /* Pin 3 */
352 #define GC_PSX_ID(x) ((x) >> 4) /* High nibble is device type */
353 #define GC_PSX_LEN(x) (((x) & 0xf) << 1) /* Low nibble is length in bytes/2 */
355 static int gc_psx_delay = GC_PSX_DELAY;
356 module_param_named(psx_delay, gc_psx_delay, uint, 0);
357 MODULE_PARM_DESC(psx_delay, "Delay when accessing Sony PSX controller (usecs)");
359 __obsolete_setup("gc_psx_delay=");
361 static short gc_psx_abs[] = { ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_HAT0X, ABS_HAT0Y };
362 static short gc_psx_btn[] = { BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_A, BTN_B, BTN_X, BTN_Y,
363 BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR };
364 static short gc_psx_ddr_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3 };
367 * gc_psx_command() writes 8bit command and reads 8bit data from
371 static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_MAX_DEVICES])
375 for (i = 0; i < GC_MAX_DEVICES; i++)
378 for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) {
379 cmd = (b & 1) ? GC_PSX_COMMAND : 0;
380 parport_write_data(gc->pd->port, cmd | GC_PSX_POWER);
381 udelay(gc_psx_delay);
382 read = parport_read_status(gc->pd->port) ^ 0x80;
383 for (j = 0; j < GC_MAX_DEVICES; j++)
384 data[j] |= (read & gc_status_bit[j] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) ? (1 << i) : 0;
385 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER);
386 udelay(gc_psx_delay);
391 * gc_psx_read_packet() reads a whole psx packet and returns
392 * device identifier code.
395 static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES],
396 unsigned char id[GC_MAX_DEVICES])
398 int i, j, max_len = 0;
400 unsigned char data2[GC_MAX_DEVICES];
402 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); /* Select pad */
403 udelay(gc_psx_delay);
404 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER); /* Deselect, begin command */
405 udelay(gc_psx_delay);
407 local_irq_save(flags);
409 gc_psx_command(gc, 0x01, data2); /* Access pad */
410 gc_psx_command(gc, 0x42, id); /* Get device ids */
411 gc_psx_command(gc, 0, data2); /* Dump status */
413 for (i =0; i < GC_MAX_DEVICES; i++) /* Find the longest pad */
414 if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR]))
415 && (GC_PSX_LEN(id[i]) > max_len)
416 && (GC_PSX_LEN(id[i]) <= GC_PSX_BYTES))
417 max_len = GC_PSX_LEN(id[i]);
419 for (i = 0; i < max_len; i++) { /* Read in all the data */
420 gc_psx_command(gc, 0, data2);
421 for (j = 0; j < GC_MAX_DEVICES; j++)
422 data[j][i] = data2[j];
425 local_irq_restore(flags);
427 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER);
429 for(i = 0; i < GC_MAX_DEVICES; i++) /* Set id's to the real value */
430 id[i] = GC_PSX_ID(id[i]);
433 static void gc_psx_process_packet(struct gc *gc)
435 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES];
436 unsigned char id[GC_MAX_DEVICES];
437 struct input_dev *dev;
440 gc_psx_read_packet(gc, data, id);
442 for (i = 0; i < GC_MAX_DEVICES; i++) {
452 input_report_key(dev, BTN_THUMBL, ~data[i][0] & 0x04);
453 input_report_key(dev, BTN_THUMBR, ~data[i][0] & 0x02);
458 if (gc->pads[GC_DDR] & gc_status_bit[i]) {
459 for(j = 0; j < 4; j++)
460 input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j));
462 for (j = 0; j < 4; j++)
463 input_report_abs(dev, gc_psx_abs[j + 2], data[i][j + 2]);
465 input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128);
466 input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128);
469 for (j = 0; j < 8; j++)
470 input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j));
472 input_report_key(dev, BTN_START, ~data[i][0] & 0x08);
473 input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01);
480 if (gc->pads[GC_DDR] & gc_status_bit[i]) {
481 for(j = 0; j < 4; j++)
482 input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j));
484 input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128);
485 input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128);
487 /* for some reason if the extra axes are left unset they drift */
488 /* for (j = 0; j < 4; j++)
489 input_report_abs(dev, gc_psx_abs[j + 2], 128);
490 * This needs to be debugged properly,
491 * maybe fuzz processing needs to be done in input_sync()
496 for (j = 0; j < 8; j++)
497 input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j));
499 input_report_key(dev, BTN_START, ~data[i][0] & 0x08);
500 input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01);
506 case 0: /* not a pad, ignore */
513 * gc_timer() initiates reads of console pads data.
516 static void gc_timer(unsigned long private)
518 struct gc *gc = (void *) private;
521 * N64 pads - must be read first, any read confuses them for 200 us
524 if (gc->pads[GC_N64])
525 gc_n64_process_packet(gc);
531 if (gc->pads[GC_NES] || gc->pads[GC_SNES])
532 gc_nes_process_packet(gc);
535 * Multi and Multi2 joysticks
538 if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2])
539 gc_multi_process_packet(gc);
545 if (gc->pads[GC_PSX] || gc->pads[GC_DDR])
546 gc_psx_process_packet(gc);
548 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
551 static int gc_open(struct input_dev *dev)
553 struct gc *gc = dev->private;
556 err = mutex_lock_interruptible(&gc->mutex);
561 parport_claim(gc->pd);
562 parport_write_control(gc->pd->port, 0x04);
563 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
566 mutex_unlock(&gc->mutex);
570 static void gc_close(struct input_dev *dev)
572 struct gc *gc = dev->private;
574 mutex_lock(&gc->mutex);
576 del_timer_sync(&gc->timer);
577 parport_write_control(gc->pd->port, 0x00);
578 parport_release(gc->pd);
580 mutex_unlock(&gc->mutex);
583 static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
585 struct input_dev *input_dev;
591 if (pad_type < 1 || pad_type > GC_MAX) {
592 printk(KERN_WARNING "gamecon.c: Pad type %d unknown\n", pad_type);
596 gc->dev[idx] = input_dev = input_allocate_device();
598 printk(KERN_ERR "gamecon.c: Not enough memory for input device\n");
602 input_dev->name = gc_names[pad_type];
603 input_dev->phys = gc->phys[idx];
604 input_dev->id.bustype = BUS_PARPORT;
605 input_dev->id.vendor = 0x0001;
606 input_dev->id.product = pad_type;
607 input_dev->id.version = 0x0100;
608 input_dev->private = gc;
610 input_dev->open = gc_open;
611 input_dev->close = gc_close;
613 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
615 for (i = 0; i < 2; i++)
616 input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0);
618 gc->pads[0] |= gc_status_bit[idx];
619 gc->pads[pad_type] |= gc_status_bit[idx];
624 for (i = 0; i < 10; i++)
625 set_bit(gc_n64_btn[i], input_dev->keybit);
627 for (i = 0; i < 2; i++) {
628 input_set_abs_params(input_dev, ABS_X + i, -127, 126, 0, 2);
629 input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0);
635 for (i = 4; i < 8; i++)
636 set_bit(gc_snes_btn[i], input_dev->keybit);
638 for (i = 0; i < 4; i++)
639 set_bit(gc_snes_btn[i], input_dev->keybit);
643 set_bit(BTN_THUMB, input_dev->keybit);
645 set_bit(BTN_TRIGGER, input_dev->keybit);
649 for (i = 0; i < 6; i++)
650 input_set_abs_params(input_dev, gc_psx_abs[i], 4, 252, 0, 2);
651 for (i = 0; i < 12; i++)
652 set_bit(gc_psx_btn[i], input_dev->keybit);
657 for (i = 0; i < 4; i++)
658 set_bit(gc_psx_ddr_btn[i], input_dev->keybit);
659 for (i = 0; i < 12; i++)
660 set_bit(gc_psx_btn[i], input_dev->keybit);
668 static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
672 struct pardevice *pd;
676 pp = parport_find_number(parport);
678 printk(KERN_ERR "gamecon.c: no such parport\n");
683 pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
685 printk(KERN_ERR "gamecon.c: parport busy already - lp.o loaded?\n");
690 gc = kzalloc(sizeof(struct gc), GFP_KERNEL);
692 printk(KERN_ERR "gamecon.c: Not enough memory\n");
694 goto err_unreg_pardev;
697 mutex_init(&gc->mutex);
699 init_timer(&gc->timer);
700 gc->timer.data = (long) gc;
701 gc->timer.function = gc_timer;
703 for (i = 0; i < n_pads && i < GC_MAX_DEVICES; i++) {
707 sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i);
708 err = gc_setup_pad(gc, i, pads[i]);
712 err = input_register_device(gc->dev[i]);
718 printk(KERN_ERR "gamecon.c: No valid devices specified\n");
723 parport_put_port(pp);
727 input_free_device(gc->dev[i]);
731 input_unregister_device(gc->dev[i]);
735 parport_unregister_device(pd);
737 parport_put_port(pp);
742 static void gc_remove(struct gc *gc)
746 for (i = 0; i < GC_MAX_DEVICES; i++)
748 input_unregister_device(gc->dev[i]);
749 parport_unregister_device(gc->pd);
753 static int __init gc_init(void)
759 for (i = 0; i < GC_MAX_PORTS; i++) {
760 if (gc[i].nargs == 0 || gc[i].args[0] < 0)
763 if (gc[i].nargs < 2) {
764 printk(KERN_ERR "gamecon.c: at least one device must be specified\n");
769 gc_base[i] = gc_probe(gc[i].args[0], gc[i].args + 1, gc[i].nargs - 1);
770 if (IS_ERR(gc_base[i])) {
771 err = PTR_ERR(gc_base[i]);
781 gc_remove(gc_base[i]);
785 return have_dev ? 0 : -ENODEV;
788 static void __exit gc_exit(void)
792 for (i = 0; i < GC_MAX_PORTS; i++)
794 gc_remove(gc_base[i]);
797 module_init(gc_init);
798 module_exit(gc_exit);