2 * This file contains the main routine for retrieval of the kernel information
3 * page, as well as abstraction routines for retrieval of specific values from
4 * this kernel-mapped user information structure. These routines may be used
5 * from both userland and system services, and their accesses are considered to
6 * establish part of the userland ABI. Do not add routines here that are not
7 * for retrieval of userland ABI fields (e.g., clock information)! Also, since
8 * these functions are MINIX3 specific, their names should contain - preferably
9 * be prefixed with - "minix_".
14 #include <sys/cdefs.h>
15 #include "namespace.h"
17 #include <minix/param.h>
20 extern struct minix_kerninfo
*_minix_kerninfo
;
23 * Get a pointer to the kernel information page.
25 struct minix_kerninfo
*
26 get_minix_kerninfo(void)
29 assert(_minix_kerninfo
!= NULL
);
31 return _minix_kerninfo
;
35 * Obtain the initial stack pointer for a new userland process. This value
36 * is used by routines that set up the stack when executing a new program.
37 * It is used for userland exec(2) and in various system services.
40 minix_get_user_sp(void)
42 struct minix_kerninfo
*ki
;
44 /* All information is obtained from the kernel information page. */
45 ki
= get_minix_kerninfo();
48 * Check whether we can retrieve the user stack pointer value from the
49 * kuserinfo structure. In general, this test is the correct one to
50 * see whether the kuserinfo structure has a certain field.
52 if ((ki
->ki_flags
& MINIX_KIF_USERINFO
) &&
53 KUSERINFO_HAS_FIELD(ki
->kuserinfo
, kui_user_sp
)) {
54 return ki
->kuserinfo
->kui_user_sp
;
58 * Otherwise, fall back to legacy support: retrieve the value from the
59 * kinfo structure. This field will eventually be removed.
61 return ki
->kinfo
->user_sp
;