Topic : TOS - The Operating System Author : Version : tos.hyp (December 19, 2008) Subject : Programmieren/Atari Nodes : 3010 Index Size : 93790 HCP-Version : 5 Compiled on : Atari @charset : atarist @lang : @default : Title @help : @options : +g -i -s +x +zz -t4 @width : 70 View Ref-File11.5.16.39.9 dev_stat TOS Name: »dev_stat« Parameters: a0 = FD *file a1 = MAGX_UNSEL *unselect oder NULL d0 = int rwflag d1 = long apcode -> d0 = long status Description: dev_stat specifies the read/write status of the file. It is called for Fselect (or for Cconos/Cconis etc.) for instance. In contrast to MiNT, it is left to the driver here whether it is interrupt-capable or not, i.e. whether it is able to call a waiting application in interrupt again or not. rwflag specifies whether the write or read status is inquired for. unselect is either NULL or a pointer to the following structure: typedef struct { union { void (*unsel) (MAGX_UNSEL *un); long status; } long param; } MAGX_UNSEL; Procedure: Generally the following applies: If unselect is non-0, the return value must be returned not only as the function result (in d0.L) but also in unselect->status. This applies for all kinds of return values. One can optionally store a parameter in unsel->param. If apcode == NULL, polling will be performed, i.e. the application is not put to sleep. So the return will be: 0 = Not ready, 1 = Ready, <0 = Error. If apcode ! = NULL (then unselect != NULL as well) then the return will be: <0 Error 0 Not ready, device can only be polled 1 Ready >0 Perhaps a pointer to a function that deinstalls the awakening interrupt again (corresonds more or less to unselect in MiNT) If the device is not ready and is interrupt-capable, then one proceeds as follows: 1. Initialize unselect with the address of the clean- up routine and an optional parameter; prototype on the lines of: void unselect( a0 = MAGX_UNSEL *un,a1 = void *ap_code ); 2. Install interrupt for awakening, pass it unselect (and with it also the optional parameter) and appl 3. Return pointer to the clean-up routine in d0 The interrupt routine does the following: 1. The interrupt arrives 2. unselect->status has 1 (OK) or < 0 (not OK) written to it and the interrupt is deactivated! The application is awakened with: kernel->appl_IOcomplete( a0 = APPL *ap ); The clean-up routine does the following: 1. The interrupt is deactivated. 2. If it has not happened already, unsel->status will have a 1 (arrived) or a 0 (not arrived) or < 0 (error) entered into it. One must ensure that no IOcomplete and no write access to unsel can follow subsequently. A value that is not 1 but greater than zero is always interpreted as the address of the clean-up routine; this still has to be called if the interrupt has not arrived. If the interrupt entered a value of 2L, say, the kernel would assume that the interrupt has not arrived and that the address of the clean-up routine is still contained in the MAGX_UNSEL structure. A jump to address 2 however is then deadly rather quickly! The DOS functions Finstat and Foutstat at first attempt to execute the call as Fcntl} (FIONREAD or FIONWRITE). If this subfunction of dev_ioctl does not exist (the file driver has to return EINVFN!), then dev_stat is called. In that case one can state either that a 'character is available' (value == 1) or 'no character is available' (value == 0). The file driver installed by DOS_XFS passes on the call directly to the MX_DDEV subdriver. Group: Workstation driver See also: -