Blame src/init/ntux_init_vrfs.c

407aec
/***********************************************************/
407aec
/*  ntux: native translation und extension                 */
407aec
/*  Copyright (C) 2016--2018  Z. Gilboa                    */
407aec
/*  Released under GPLv2 and GPLv3; see COPYING.NTUX.      */
407aec
/***********************************************************/
407aec
12e960
#ifndef PE_LDSO
12e960
#define PE_LDSO 1
12e960
#endif
7f9860
eb2163
#include <ntapi/nt_status.h>
eb2163
#include <ntapi/nt_process.h>
eb2163
407aec
#include <psxtypes/psxtypes.h>
407aec
#include <pemagine/pemagine.h>
407aec
#include <psxscl/psxglue.h>
407aec
#include <ntux/ntux.h>
407aec
407aec
#ifdef NTUX_STANDALONE
407aec
407aec
/* framework (rtdata) abi */
407aec
static const struct pe_guid  __ldsoabi  = NT_PROCESS_GUID_RTDATA;
407aec
407aec
/* loader standalone (single directory) name */
407aec
static const unsigned short __sdldso[] = {'l','i','b','p','s','x','s','c','l',
407aec
				          '.','s','o',0};
407aec
407aec
/* pty server standalone name */
407aec
static const unsigned short __sdctty[] = {'n','t','c','t','t','y',
407aec
				          '.','e','x','e',0};
407aec
407aec
/* system call layer init context */
32e604
static struct __psx_context ctx = {sizeof(ctx),0,0,0,0,0,0,0,0,0,0,0,0};
407aec
407aec
/* ldso buffer */
407aec
static uintptr_t	__attribute__((section(".dsodata")))
407aec
			__dsodata[65536/sizeof(unsigned long)];
407aec
407aec
int ntux_entry_routine(
407aec
	int(*__psx_init_routine)(int *,char ***,char ***,void *),
407aec
	struct __psx_context * ctx);
407aec
42bda7
static int ntux_usrmain(void)
42bda7
{
42bda7
	return 0;
42bda7
}
42bda7
407aec
void ntux_entry_point(void)
407aec
{
407aec
	int		status;
407aec
	void *		hroot;
407aec
	void *		hdsodir;
407aec
	void *		ldsobase;
407aec
	int  		(*__psx_init)(
407aec
				int *,char ***,char ***,
407aec
				void *);
407aec
407aec
	if ((status = __ldso_load_framework_loader_ex(
407aec
			&ldsobase,&hroot,&hdsodir,
407aec
			&__ldsoabi,
407aec
			__sdldso,0,ntux_main,
407aec
			__dsodata,sizeof(__dsodata),
407aec
			PE_LDSO_STANDALONE_EXECUTABLE,
407aec
			&(unsigned int){0})))
407aec
		__ldso_terminate_current_process(status);
407aec
407aec
	if (!(__psx_init = __ldso_get_procedure_address(
407aec
			ldsobase,"__psx_init")))
407aec
		__ldso_terminate_current_process(NT_STATUS_NOINTERFACE);
407aec
407aec
	ctx.options = __PSXOPT_VRFS;
407aec
	ctx.ctty    = __sdctty;
42bda7
	ctx.usrmain = ntux_usrmain;
407aec
407aec
	ntux_entry_routine(__psx_init,&ctx;;
407aec
}
407aec
407aec
#endif