/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos72L src/bos/usr/include/POWER/execargs.h 1.16.1.3                   */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 1989,2017              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)50	1.16.1.3  src/bos/usr/include/POWER/execargs.h, sysproc, bos72L, l2017_27A4 6/26/17 13:44:25 */
/*
 * COMPONENT_NAME: (SYSPROC) Process Management 
 *
 * FUNCTIONS: 
 *
 * ORIGINS: 3, 6, 27
 *
 */

#ifndef _H_EXECARGS
#define _H_EXECARGS

/*
 * This include file permits ps to print the command line for
 * a process.  Given the address of the argument vector for
 * the command, the shell uses the newargs() macro to put the
 * address of the argument vector where ps can find it.
 */

#include <sys/param.h>
extern int _errno;

#if defined(__64BIT_KERNEL) && defined(_KERNEL)
typedef unsigned int	__cptrp32_64_t;
#else
typedef char **		__cptrp32_64_t;
#endif 

struct	top_of_stack {
	ulong32int64_t	main_reg[NGPRS];
	ulong32int64_t	lr;
	__cptrp32_64_t	environ;
#ifdef errno
	int	tos_errno;
#else
	int	errno;
#endif
#if defined(__64BIT__) && !defined(_KERNEL) 
	uint			reserved1;
	ulong			reserved2;
	void *			usla_cblk;
	ulong			reserved3;
#endif
};

typedef struct top_of_stack TopOfStack;

#define TopOfBaseStack	((struct top_of_stack *)((long)&_errno	 \
					- sizeof(__cptrp32_64_t) \
					- sizeof(ulong32int64_t) \
					- sizeof(ulong32int64_t[NGPRS])))

#define TopOfBaseStackOffset(EP) \
			((struct top_of_stack *)((long)(EP) 	 \
					- sizeof(__cptrp32_64_t) \
					- sizeof(ulong32int64_t) \
					- sizeof(ulong32int64_t[NGPRS])))

#define ARGC_value	(&(TopOfBaseStack->main_reg[3]))
#define ARGS_loc	(&(TopOfBaseStack->main_reg[4]))
#define ENVS_loc	(&(TopOfBaseStack->main_reg[5]))
#define newargs(argv)	(*(__cptrp32_64_t *)ARGS_loc = (argv))

#ifdef __TOS
typedef struct tos32 {
	unsigned int		tos_main_reg[NGPRS];
	unsigned int		tos_lr;
	unsigned int		tos_environ;
	int		 	tos_errno;
	unsigned int		tos_errnop;
} tos32_t;

typedef struct tos64 {
	unsigned long long	tos_main_reg[NGPRS];
	unsigned long long	tos_lr;
	unsigned long long	tos_environ;
	int		 	tos_errno;
	unsigned int		tos_reserved1;
	unsigned long long	tos_errnop;
	unsigned long long	tos_usla_cblk;
	unsigned long long	tos_reserved3;
} tos64_t;
#endif

#endif /* _H_EXECARGS */
