Skip to content

device drivers

1 message · Luke Tierney

#
Unless you are maintaining a device driver for R, you can ignore this
note.

If you are, two issues have come up: the need to make sure there is a
slot available for a device before allocating it and, on unix at
least, the need to turn off interrupts during device initialization.

Currently typical device driver code starts the device something like this:

	if (!(dd = (DevDesc *) malloc(sizeof(DevDesc))))
	    return 0;
	...
	addDevice(dd);
	initDisplayList(dd);

To address these two problems in a device driver for R 1.2 this should
be changed to

    R_CheckDeviceAvailable();
    BEGIN_SUSPEND_INTERRUPTS {
	if (!(dd = (DevDesc *) malloc(sizeof(DevDesc))))
	    return 0;
        ...
	addDevice(dd);
	initDisplayList(dd);
    } END_SUSPEND_INTERRUPTS;

[Better yet, in case this changes before release, have a look at the
corresponding section of do_PS in the released sources.]

luke