ibcs2_sysvec.c revision 74927
1492SN/A/*
21345Sihse * Copyright (c) 1995 Steven Wallace
3492SN/A * All rights reserved.
4492SN/A *
5492SN/A * Redistribution and use in source and binary forms, with or without
6492SN/A * modification, are permitted provided that the following conditions
7492SN/A * are met:
8492SN/A * 1. Redistributions of source code must retain the above copyright
9492SN/A *    notice, this list of conditions and the following disclaimer.
10492SN/A * 2. Redistributions in binary form must reproduce the above copyright
11492SN/A *    notice, this list of conditions and the following disclaimer in the
12492SN/A *    documentation and/or other materials provided with the distribution.
13492SN/A * 3. All advertising materials mentioning features or use of this software
14492SN/A *    must display the following acknowledgement:
15492SN/A *      This product includes software developed by Steven Wallace.
16492SN/A * 4. The name of the author may not be used to endorse or promote products
17492SN/A *    derived from this software without specific prior written permission.
18492SN/A *
19492SN/A * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20492SN/A * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21492SN/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22492SN/A * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23492SN/A * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24492SN/A * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25492SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
261120Schegar * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
271120Schegar * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
281120Schegar * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
291410Sihse *
301120Schegar * $FreeBSD: head/sys/i386/ibcs2/ibcs2_sysvec.c 74927 2001-03-28 11:52:56Z jhb $
311120Schegar */
321120Schegar
33492SN/A#include <sys/param.h>
341410Sihse#include <sys/kernel.h>
351410Sihse#include <sys/lock.h>
361410Sihse#include <sys/module.h>
371410Sihse#include <sys/sysent.h>
38492SN/A#include <sys/signalvar.h>
39492SN/A#include <sys/proc.h>
40492SN/A
411410Sihse#include <i386/ibcs2/ibcs2_syscall.h>
421120Schegar#include <i386/ibcs2/ibcs2_signal.h>
43837SN/A
44910SihseMODULE_VERSION(ibcs2, 1);
451862Serikj
461862Serikjextern int bsd_to_ibcs2_errno[];
471131Serikjextern struct sysent ibcs2_sysent[IBCS2_SYS_MAXSYSCALL];
48492SN/Aextern int szsigcode;
491120Schegarextern char sigcode[];
501236Sihse
511120Schegarstruct sysentvec ibcs2_svr3_sysvec = {
521120Schegar        sizeof (ibcs2_sysent) / sizeof (ibcs2_sysent[0]),
531120Schegar        ibcs2_sysent,
54968Sihse        0xFF,
55968Sihse        IBCS2_SIGTBLSZ,
56492SN/A        bsd_to_ibcs2_sig,
571120Schegar        ELAST + 1,
581804Serikj        bsd_to_ibcs2_errno,
591120Schegar	0,              /* trap-to-signal translation function */
601120Schegar	0,		/* fixup */
611120Schegar	sendsig,
621120Schegar	sigcode,	/* use generic trampoline */
631120Schegar	&szsigcode,	/* use generic trampoline size */
641120Schegar	0,		/* prepsyscall */
651120Schegar	"IBCS2 COFF",
661120Schegar	NULL,		/* we don't have a COFF coredump function */
671120Schegar	NULL,
681120Schegar	IBCS2_MINSIGSTKSZ
691120Schegar};
701223Schegar
711223Schegar/*
721223Schegar * Create an "ibcs2" module that does nothing but allow checking for
731120Schegar * the presence of the subsystem.
741120Schegar */
751120Schegarstatic int
761120Schegaribcs2_modevent(module_t mod, int type, void *unused)
771120Schegar{
781120Schegar	struct proc *p = NULL;
791600Snaoto	int rval = 0;
801600Snaoto
811600Snaoto	switch(type) {
821223Schegar	case MOD_UNLOAD:
831862Serikj		/* if this was an ELF module we'd use elf_brand_inuse()... */
841120Schegar		sx_slock(&allproc_lock);
851659Serikj		LIST_FOREACH(p, &allproc, p_list) {
861600Snaoto			if (p->p_sysent == &ibcs2_svr3_sysvec) {
871120Schegar				rval = EBUSY;
881120Schegar				break;
891120Schegar			}
901120Schegar		}
911120Schegar		sx_sunlock(&allproc_lock);
921120Schegar	default:
93492SN/A	        /* do not care */
941120Schegar	}
951120Schegar	return (rval);
961120Schegar}
971735Sbobvstatic moduledata_t ibcs2_mod = {
981735Sbobv	"ibcs2",
991735Sbobv	ibcs2_modevent,
1001735Sbobv	0
101492SN/A};
1021120SchegarDECLARE_MODULE(ibcs2, ibcs2_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
1031120Schegar