grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / nonvolatile / getnvinfo.c
blobdbcecbd360191e09b60c83fb591a6ebd9d00734c
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
5 #include <dos/dosextens.h>
6 #include <exec/memory.h>
7 #include <proto/exec.h>
8 #include <proto/nvdisk.h>
10 #include LC_LIBDEFS_FILE
12 /*****************************************************************************
14 NAME */
15 #include <libraries/nonvolatile.h>
17 AROS_LH1(struct NVInfo *, GetNVInfo,
19 /* SYNOPSIS */
21 AROS_LHA(BOOL, killRequesters, D1),
23 /* LOCATION */
25 struct Library *, nvBase, 9, Nonvolatile)
27 /* FUNCTION
29 Report information on the user's preferred nonvolatile storage device.
31 INPUTS
33 killRequesters -- if TRUE no system requesters will be displayed during
34 the operation of this function
36 RESULT
38 Pointer to an NVInfo structure containing the information on the nonvolatile
39 storage device currently in use. Returns NULL in case of a failure.
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 FreeNVData(), StoreNV(), <libraries/nonvolatile.h>
51 INTERNALS
53 ******************************************************************************/
56 AROS_LIBFUNC_INIT
58 struct Process *me = (struct Process *)FindTask(NULL);
59 APTR oldReq = me->pr_WindowPtr;
60 struct NVInfo *info;
62 info = AllocVec(sizeof(struct NVInfo), MEMF_ANY);
63 if(info == NULL)
64 return NULL;
66 if(killRequesters)
67 me->pr_WindowPtr = (APTR)-1;
69 /* Try to get the information from the HIDD */
70 if(MemInfoNVD(info))
72 /* Round down to nearest 10 bytes */
73 info->nvi_MaxStorage = (info->nvi_MaxStorage/10)*10;
74 info->nvi_FreeStorage = (info->nvi_FreeStorage/10)*10;
76 else
78 FreeVec(info);
79 info = NULL;
82 if(killRequesters)
83 me->pr_WindowPtr = oldReq;
85 return info;
87 AROS_LIBFUNC_EXIT
88 } /* GetNVInfo */