Tested and debugged ToolTypes.
[AROS.git] / rom / kernel / freepages.c
blob6e82f0ec0a85875afd84e65917d141128f2933b2
1 #include <aros/config.h>
2 #include <exec/alerts.h>
3 #include <exec/execbase.h>
4 #include <proto/exec.h>
6 #include <kernel_base.h>
7 #include <kernel_debug.h>
8 #include "memory_intern.h"
10 #define D(x)
12 /*****************************************************************************
14 NAME */
15 #include <proto/kernel.h>
17 AROS_LH2(void, KrnFreePages,
19 /* SYNOPSIS */
20 AROS_LHA(void *, addr, A0),
21 AROS_LHA(uintptr_t, length, D0),
23 /* LOCATION */
24 struct KernelBase *, KernelBase, 28, Kernel)
26 /* FUNCTION
28 INPUTS
30 RESULT
32 NOTES
33 This function works only on systems with MMU support.
35 EXAMPLE
37 BUGS
39 SEE ALSO
41 INTERNALS
43 ******************************************************************************/
45 AROS_LIBFUNC_INIT
47 #if USE_MMU
48 struct MemHeader *mh;
50 ForeachNode(&SysBase->MemList, mh)
52 D(bug("[KrnFreePages] Checking MemHeader 0x%p... ", mh));
54 /* Test if the memory belongs to this MemHeader. */
55 if (mh->mh_Lower <= addr && mh->mh_Upper > addr)
57 D(bug("[KrnFreePages] Match!\n"));
59 /* Test if it really fits into this MemHeader. */
60 if ((addr + length) > mh->mh_Upper)
61 /* Something is completely wrong. */
62 Alert(AN_MemCorrupt|AT_DeadEnd);
64 krnFree(mh, addr, length, KernelBase);
65 break;
68 D(bug("[KrnFreePages] No match!\n"));
70 #endif
72 AROS_LIBFUNC_EXIT