Added a test for MUIA_Listview_SelectChange.
[AROS.git] / rom / kernel / statmemory.c
blob69a611e186ea147948de8bceb7fa69c1bc5e0463
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 */
8 #include <aros/config.h>
9 #include <exec/execbase.h>
10 #include <proto/arossupport.h>
11 #include <proto/exec.h>
12 #include <utility/tagitem.h>
14 #include <inttypes.h>
16 #include <kernel_base.h>
17 #include <kernel_mm.h>
19 /*****************************************************************************
21 NAME */
22 #include <proto/kernel.h>
24 AROS_LH2(ULONG, KrnStatMemoryA,
26 /* SYNOPSIS */
27 AROS_LHA(ULONG, flags, D0),
28 AROS_LHA(struct TagItem *, query, A0),
30 /* LOCATION */
31 struct KernelBase *, KernelBase, 32, Kernel)
33 /* FUNCTION
34 Get various statistics about memory usage
36 INPUTS
37 query - An array of TagItems containing query specification. Each
38 TagItem consists of tag ID and a pointer to a value of
39 specified type which will contain the result of the query.
41 Available tag IDs are:
43 KMS_Free (IPTR) - Get amount of free memory in bytes
44 KMS_Total (IPTR) - Get total amount of memory in bytes
45 KMS_LargestAlloc (IPTR) - Get size of the largest allocated chunk in bytes
46 KMS_SmallestAlloc (IPTR) - Get size of the smallest allocated chunk in bytes
47 KMS_LargestFree (IPTR) - Get size of the largest free chunk in bytes
48 KMS_SmallestFree (IPTR) - Get size of the smallest free chunk in bytes
49 KMS_NumAlloc (IPTR) - Get number of allocated chunks
50 KMS_NumFree (IPTR) - Get number of free chunks
51 KMS_PageSize (ULONG) - Get memory page size
53 flags - Flags which specify physical properties of the memory to query.
54 These are the same flags as passed to exec.library/AllocMem().
56 RESULT
57 TRUE if the function worked, FALSE if MMU is not up and running on the system.
58 If the function returns FALSE, values will stay uninitialized.
60 NOTES
61 For all unknown tag IDs result values will be set to 0.
63 EXAMPLE
65 BUGS
67 SEE ALSO
69 INTERNALS
71 ******************************************************************************/
73 AROS_LIBFUNC_INIT
75 #if USE_MMU
76 if (KernelBase->kb_PageSize)
78 struct TagItem *tag, *tstate = query;
79 struct MemHeader *mh;
80 BOOL do_traverse = FALSE;
82 while ((tag = LibNextTagItem(&tstate)))
84 switch (tag->ti_Tag)
86 case KMS_PageSize:
87 *((ULONG *)tag->ti_Data) = KernelBase->kb_PageSize;
88 break;
90 default:
91 /* Initialize all accumulated values to zero */
92 *((IPTR *)tag->ti_Data) = 0;
93 do_traverse = TRUE;
97 /* If we needed only page size, just return */
98 if (!do_traverse)
99 return TRUE;
101 /* Leave only flags that describe physical properties of the memory */
102 flags &= MEMF_PHYSICAL_MASK;
105 * Loop over MemHeader structures.
106 * We only add MemHeaders and never remove them, so i hope Forbid()/Permit()
107 * is not really necessary here.
109 ForeachNode(&SysBase->MemList, mh)
112 * Check for the right requirements and enough free memory.
113 * The requirements are OK if there's no bit in the
114 * 'flags' that isn't set in the 'mh->mh_Attributes'.
116 if (flags & ~mh->mh_Attributes)
117 continue;
119 /* Get statistics. Total values will be summed up. */
120 mm_StatMemHeader(mh, query, KernelBase);
123 return TRUE;
125 #endif
126 return FALSE;
128 AROS_LIBFUNC_EXIT