From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 9 15:25:00 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8568C16A420 for ; Tue, 9 Aug 2005 15:25:00 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from mv.twc.weather.com (mv.twc.weather.com [65.212.71.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9CC0043D48 for ; Tue, 9 Aug 2005 15:24:59 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from [10.50.40.201] (Not Verified[65.202.103.25]) by mv.twc.weather.com with NetIQ MailMarshal (v6, 0, 3, 8) id ; Tue, 09 Aug 2005 11:39:46 -0400 From: John Baldwin To: freebsd-hackers@freebsd.org Date: Tue, 9 Aug 2005 11:03:04 -0400 User-Agent: KMail/1.8 References: <20050808202039.C988B43D48@mx1.FreeBSD.org> <20050809101409.Y73394@fledge.watson.org> <20050809133109.GA15300@skatecity> In-Reply-To: <20050809133109.GA15300@skatecity> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200508091103.04881.jhb@FreeBSD.org> Cc: Subject: Re: Using sysarch specific syscalls in assembly? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Aug 2005 15:25:00 -0000 On Tuesday 09 August 2005 09:31 am, alexander wrote: > On Tue Aug 9 05, Robert Watson wrote: > > In general, it is much preferable that applications link against libc to > > get the system call stubs than that they directly invoke system calls. > > That way, if compatibility interfaces are introduced, etc, the > > application will continue to function. For example, there was at one > > point a migration away from explicit system calls to set certain kernel > > parameters, such as hostname and domainname, towards using sysctl, with > > the system calls being marked obsolete. The C library still provides a > > sethostname() interface, which is actually a wrapper in user space around > > sysctl(). So invoking the C function provided by libc for a system call > > will generally be preferred, even if the originating code is assembly. > > > > Robert N M Watson > > Thx. I'll try that. > > Unfortunately I'm experiencing some problems right now. From time to time > I'm getting a > > 'Bus error: 10 (core dumped)' > > This however appears randomly. One time I run the app everything works > fine,the next time it core dumps. Are there any errors in my code? > > %define SYSARCH 165 ; syscall sysarch(2) > %define I386_SET_IOPERM 4 ; i386_set_ioperm(2) number > > ioperm_args dd 378h > dd 3 > dd 1 > > OpenIO: > push byte ioperm_args > push dword I386_SET_IOPERM > mov eax,SYSARCH > Call _syscall > lea esp,[esp+8] > ret Just change this to: push byte ioperm_args ; this might be wrong, you need ; to be pushing a 32-bit pointer ; to the ioperm_args structure, not ; a byte push dword I386_SET_IOPERM call sysarch addl $8,%esp ret To use the sysarch() function in libc. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org