h6. [[Filer_Action]] h6(. » [[Free SWI Calls|SWI Calls]] h6((. » Free Routine Entry h2. Free Routine Entry h4. Routines available |_<^{width:4em}. R0 |_<^. Use | |_<^. 0 |<^. No Op - this entry point does nothing, and all registers should be returned preserved. | |_<^. 1 |<^. Get device name - you should place the device name at R2 and the length of the name in R0. | |_<^. 2 |<^. Get free space for device - used to find the free space on a device, which should be written to the buffer. Reason code 4 is is now the preferred option to achieve this. | |_<^. 3 |<^. Compare device - used to check if a file exists on a particular drive. A fast filing system such as RAMFS is allowed to always return Z set. | |_<^. 4 |<^. Get free space for device (64 bit) - used to find the free space on a device. From RISC OS 3.60, this call is used rather than 2. If R0 is non-zero on exit, or if an error occurs, then reason code 2 is called. Thus your routine must give an error for both reason codes 4 and 2 before Free will believe it. | h4. Reason code 0 - No Op |_<^{width:4em}. Entry | | |<^. R0 |<^. 0 (reason code) | |_<^{width:4em}. Exit | | |<^. |<^. All Register Preserved | h4. Reason code 1 - Get device name |_<^{width:4em}. Entry | | |<^. R0 |<^. 1 (reason code) | |<^. R1 |<^. [[Filing System Numbers]] | |<^. R2 |<^. Pointer to buffer | |<^. R3 |<^. Pointer to device or ID | |_<^{width:4em}. Exit | | |<^. R0 |<^. Length of name, including terminator | |<^. R1 |<^. Preserved | |<^. R2 |<^. Preserved | |<^. R3 |<^. Preserved | h4. Reason code 2 - Get free space for device |_<^{width:4em}. Entry | | |<^. R0 |<^. 2 (reason code) | |<^. R1 |<^. [[Filing System Numbers]] | |<^. R2 |<^. Pointer to 3 word buffer (See below) | |<^. R3 |<^. Pointer to device or ID | |_\2<^. 3 word buffer | |_<^{width:4em}. Offset |_<^. Meaning | |<^. +0 |<^. Total size of device (0 if unchanged) | |<^. +4 |<^. Free space on device | |<^. +8 |<^. Used space on device | |_<^{width:4em}. Exit | | |<^. R0 |<^. Preserved | |<^. R1 |<^. Preserved | |<^. R2 |<^. Buffer provided upon entry is updated | |<^. R3 |<^. Preserved | h4. Reason code 3 - Compare Device |_<^{width:4em}. Entry | | |<^. R0 |<^. 3 (reason code) | |<^. R1 |<^. [[Filing System Numbers]] | |<^. R2 |<^. Pointer to filename | |<^. R3 |<^. Pointer to device or ID | |<^. R6 |<^. Pointer to special field | |_<^{width:4em}. Exit | | |<^. R0 |<^. Preserved | |<^. R1 |<^. Preserved | |<^. R2 |<^. Preserved | |<^. R3 |<^. Preserved | |<^. R6 |<^. Preserved | Z flag is set if R2, R6 point to a file on R3. h4. Reason code 4 - Get free space (64 bit) |_<^{width:4em}. Entry | | |<^. R0 |<^. 4 (reason code) | |<^. R1 |<^. [[Filing System Numbers]] | |<^. R2 |<^. Pointer to 6 word buffer | |<^. R3 |<^. Pointer to device name or ID | |_\2<^. 6 word buffer | |_<^{width:4em}. Offset |_<^. Meaning | |<^. 0, 4 |<^. Total size of device (0 if unchanged) | |<^. 8, 12 |<^. Free space on device | |<^. 16, 20 |<^. Used space on device | Note: * Word 0 is bits 0 - 31 * Word 1 is bits 32 - 63 |_<^{width:4em}. Exit | | |<^. R0 |<^. 0 | |<^. R1 |<^. Preserved | |<^. R2 |<^. Buffer provided upon entry is updated | |<^. R3 |<^. Preserved | |<^. R6 |<^. Preserved | h4. Use The routine will be called in User mode with a stack consisting only of the return address (no other use should be made of it). The routine can either: * Construct a new stack. * Use the SVC stack by calling OS_EnterOS, remembering to return to User mode before returning. * Do all the hard work with a SWI ([[OS_FSControl 49]] for reason 2, but this still alters registers that must be preserved somewhere...). The routine should exit using: * <code> LDMIA R13!,{PC} </code> h4. Notes Don't return an error for unused reason codes, instead return with registers preserved, to allow for future extensions to be handled in the same manner as reason code 4 was added. h4. See also * [[OS_EnterOS]] * [[OS_FSControl 49]] * [[Filing System Numbers]] * [[Free_Register]]