====== device_getinfo ====== ---- The device_getinfo functions are used by MESS to get additional info about the devices used in a system. They are generally located in the systems/.c file. ==== Syntax ==== ---- All data that you want to return must be copied into the info union. A switch is used to selected the info MESS wants. Possible states are: **DEVINFO_INT_IMAGE_TYPE** The type of the device. Possible values are: * IO_FLOPPY (Floppy drives) * IO_PRINTER (Printer) * … **DEVINFO_INT_IMAGE_READABLE** Boolean value whether this device can read data. Possible values: * 1 - Data can be read from the device (example: floppy drive) * 0 - Data cannot be read from the device (example: printer) **DEVINFO_INT_IMAGE_WRITEABLE** Boolean value whether this device can write data. Possible values: * 1 - Data can be written to the device (example: printer) * 0 - Data cannot be written to the device (example: CD-ROM) **DEVINFO_INT_IMAGE_CREATABLE** Boolean value whether new files can be created for use with this device or not. Possible values: * 1 - A new file can be created for use with this device (example: empty floppy) * 0 - New files cannot be created for the device (example: CD-ROM) **DEVINFO_INT_IMAGE_CREATE_OPTCOUNT** The number of devices of this type this system can possibly use (example: 2 floppy drives). **DEVINFO_FCT_IMAGE_LOAD** This is a pointer to the function which is called when the user mounts a new file for use with this device. **DEVINFO_STR_IMAGE_FILE_EXTENSIONS** This is a comma separated list representing the possible file extensions for this device. ===== Example ===== ---- This could be the function for a floppy drive: static DEVICE_GET_INFO( mydriver_floppy ) { /* floppy */ switch(state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_IMAGE_TYPE: info->i = IO_FLOPPY; break; case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break; case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break; case DEVINFO_INT_IMAGE_CREATABLE: info->i = 1; break; case DEVINFO_INT_IMAGE_CREATE_OPTCOUNT: info->i = 2; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mydriver_floppy); break; case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(mydriver_floppy); break; case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(mydriver_floppy); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "Floppy Disk"); break; case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: strcpy(info->s, "dsk"); break; } } In this example, we create a device of type IO_FLOPPY, that is readable, writable and creatable. The system supports two floppy drives. The function device_load_mydriver_floppy is called when the user mounts a new file (we don't actually write this function as is, we use the macro [[reference:DEVICE_LOAD]]). The file extension is just ''dsk''.