h6. [[OS SWI Calls]] h6(. » [[OS_Memory]] h6((. » OS_Memory 18 h2. OS_Memory 18 h5. (SWI &68) |_<^{width:4em}. Entry | | |<^. R0 |<^. 18 (reason code) | |/8<^. R1 |<^. Desired permission flag values: | |<^. Bit 0: Executable in user mode | |<^. Bit 1: Writable in user mode | |<^. Bit 2: Readable in user mode | |<^. Bit 3: Executable in privileged modes | |<^. Bit 4: Writable in privileged modes | |<^. Bit 5: Readable in privileged modes | |<^. Bits 6+: Reserved | |<^. R2 |<^. Mask of which bits in R1 are specified | |_<^{width:4em}. Exit | | |<^. R0 |<^. Number of the closest [[Memory Map Page Access|access privilege]], or error | |<^. R2 |<^. Permission flags of that access privilege. Preserved on error. | h4. Use This call allows you to find the access privilege number that provides the closest match to the permissions you specify. The searches for an AP which satisfies the constraint of @((permissions AND R2) == R1)@, and which grants the least extra permissions over those that were requested. E.g. to only allow AP values where user mode code has no access, bits 0-2 of R1 must be clear and bits 0-2 of R2 must be set. If the system is unable to find an AP which satisfies the constraints of R1 and R2 then an error will be returned. h4. Notes R1 must be a subset of R2, i.e. you must not have a bit set in R1 if the same bit is not set in R2. Extra permissions are weighted as follows (least acceptable first): * User write * User execute * User read * Privileged write * Privileged execute * Privileged read This call was introduced in RISC OS 5.23. For the permissions supported by earlier RISC OS versions, see [[Memory Map Page Access]]. [[OS_Memory 17]] can be used to enumerate the available access privileges and read their permissions. h4. See also * [[OS_Memory]] * [[OS_Memory 17]] * [[Memory Map Page Access]]