From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 9 07:42:03 2004 Return-Path: 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 101AA16A4CE for ; Tue, 9 Nov 2004 07:42:03 +0000 (GMT) Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [194.125.244.127]) by mx1.FreeBSD.org (Postfix) with ESMTP id EAFBF43D49 for ; Tue, 9 Nov 2004 07:41:59 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from pm514-9.comsys.ntu-kpi.kiev.ua (pm514-9.comsys.ntu-kpi.kiev.ua [10.18.54.109]) (authenticated bits=0)iA97fsPD036189 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 9 Nov 2004 09:41:55 +0200 (EET) Received: by pm514-9.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1000) id B47F9141; Tue, 9 Nov 2004 09:41:25 +0200 (EET) Date: Tue, 9 Nov 2004 09:41:25 +0200 From: Andrey Simonenko To: Dan Strick Message-ID: <20041109074125.GB238@pm514-9.comsys.ntu-kpi.kiev.ua> References: <200411081857.iA8Iv725000576@mist.nodomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200411081857.iA8Iv725000576@mist.nodomain> User-Agent: Mutt/1.4.2.1i cc: freebsd-hackers@freebsd.org Subject: Re: Where is the source to the system calls? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 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 Nov 2004 07:42:03 -0000 On Mon, Nov 08, 2004 at 10:57:07AM -0800, Dan Strick wrote: > > Perhaps I did not make it clear that I was looking for the definitions > of the subroutines in libc that converted C-language function calls, > such as open(), into assembler language system calls. For example, in > version 7 pdp11 unix, the open() system call was defined in the very > straight forward assembler language program /usr/src/libc/sys/open.s: [ skipped ] Almost the same is done in FreeBSD, but under i386 int $0x80 is a trap gate for system calls (search int0x80_syscall in /sys/i386/i386/exception.s). If that SYS.h is unclear for you for the first time, so read paragraphs about x86 Assembler and syscalls in Developers' Handbook. > I still don't understand all the details but I do understand enough > to realize that I don't want to understand any more. Assembler sources for syscalls are created from the src/lib/libc/sys/ Makefile.inc file. Find #include "SYS.h" in this file. The names of syscalls are generated from the /sys/sys/syscall.mk, which is generated from sys/kern/syscalls.master. Try to discover how this works backtracing Makefile.inc from the line with #include "SYS.h".