NOTE => NOTES
[AROS.git] / arch / m68k-all / kernel / setprotection.c
blobfb4af6f13441013f4bdb65357a05f428a3c86553
1 #include <aros/kernel.h>
2 #include <aros/libcall.h>
4 #include <kernel_base.h>
5 #include <kernel_intern.h>
7 /*****************************************************************************
9 NAME */
10 #include <proto/kernel.h>
12 AROS_LH3(void, KrnSetProtection,
14 /* SYNOPSIS */
15 AROS_LHA(void *, address, A0),
16 AROS_LHA(uint32_t, length, D0),
17 AROS_LHA(KRN_MapAttr, flags, D1),
19 /* LOCATION */
20 struct KernelBase *, KernelBase, 21, Kernel)
22 /* FUNCTION
24 INPUTS
26 RESULT
28 NOTES
30 EXAMPLE
32 BUGS
34 SEE ALSO
36 INTERNALS
38 ******************************************************************************/
40 AROS_LIBFUNC_INIT
42 BOOL invalid = (flags & (MAP_Readable | MAP_Writable | MAP_Executable)) == 0;
43 BOOL readonly = (flags & MAP_Writable) == 0;
44 BOOL supervisor = (flags & MAP_Supervisor) != 0;
45 UBYTE cm = (flags & MAP_CacheInhibit) ? CM_SERIALIZED : ((flags & MAP_WriteThrough) ? CM_WRITETHROUGH : CM_COPYBACK);
47 /* We need MAP_Supervisor and MAP_CacheInhibitSerialized */
49 if ((ULONG)address < 0x00200000 && cm == CM_SERIALIZED)
50 cm = CM_NONCACHEABLE; /* Chip RAM does not need to be non-cacheable + serialized, only noncacheable */
52 map_region(KernelBase, address, NULL, length, invalid, readonly, supervisor, cm);
54 AROS_LIBFUNC_EXIT