From owner-freebsd-amd64@FreeBSD.ORG Thu Jan 13 07:16:07 2005 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D352216A4CE for ; Thu, 13 Jan 2005 07:16:07 +0000 (GMT) Received: from will.iki.fi (will.iki.fi [217.169.64.20]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8AE7D43D45 for ; Thu, 13 Jan 2005 07:16:07 +0000 (GMT) (envelope-from will@exomi.com) Received: from [192.168.1.29] (ZMCXLI.dsl.saunalahti.fi [85.76.70.242]) by will.iki.fi (Postfix) with ESMTP id 25BE6C3; Thu, 13 Jan 2005 09:16:06 +0200 (EET) From: Ville-Pertti Keinonen To: freebsd-amd64@freebsd.org In-Reply-To: <20050112233323.GA29445@dragon.nuxi.com> References: <1105569437.670.45.camel@localhost> <20050112233323.GA29445@dragon.nuxi.com> Content-Type: text/plain Date: Thu, 13 Jan 2005 09:15:59 +0200 Message-Id: <1105600559.662.56.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.0.3 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit cc: wpaul@windriver.com Subject: Re: RFC: if_ndis on amd64 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2005 07:16:07 -0000 On Wed, 2005-01-12 at 15:33 -0800, David O'Brien wrote: > What are "calling conventions that everyone else uses"?? Such things > really don't exist as x86 CPU's don't force a particular way. It is up > to the compiler writer to do what he wants. Note that I didn't even try to claim "standard" calling conventions; however AFAIK all of the released operating systems that run on amd64 (*BSD, Linux, Solaris) use the same C ABI (SysV (ELF) ABI). Often at least the basic C calling conventions are compatible across ABIs. > Both the AMD64 ELF and AMD64 PE (mswin) ABI's specify that the first X > parameters are passed in registers (beyond that on the stack). So both > ELF (ie, FreeBSD) and MSwin passes parameters differently on 32-bit > "i386" vs. 64-bit AMD64. The different i386 conventions are at least partly to historical reasons. Since 64-bit mode is inevitably incompatible with 32-bit mode, I was hoping 64-bit mode would be somewhat more consistent. Anyhow, having to create wrappers isn't that bad, and should be possible to be coerced to work correctly. The varargs kludge I used should be possible to eliminate by transforming the arguments into a va_list instead of trying to preserve it as a varargs call. Something like: ENTRY(sprintf_x64) subq $40,%rsp mov %rdi,32(%rsp) mov %rsi,24(%rsp) mov %r8,40+8+16(%rsp) mov %r9,40+8+24(%rsp) movl $48,(%rsp) movl $0,4(%rsp) lea 40+8+16(%rsp),%rax mov %rax,8(%rsp) mov %rax,16(%rsp) mov %rcx,%rdi mov %rdx,%rsi mov %rsp,%rdx call vsprintf mov 32(%rsp),%rdi mov 24(%rsp),%rsi addq $40,%rsp ret