From owner-freebsd-drivers@FreeBSD.ORG Mon Oct 13 14:59:55 2014 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B087D68B for ; Mon, 13 Oct 2014 14:59:55 +0000 (UTC) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7C776E68 for ; Mon, 13 Oct 2014 14:59:55 +0000 (UTC) Received: by mail-pa0-f47.google.com with SMTP id rd3so6020318pab.34 for ; Mon, 13 Oct 2014 07:59:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=WuIOjPD+GrQqdRKFr6T4VoP/e6oTuCRewODZY4oGECQ=; b=GHNOjj6wG2Iw2r34nnmjGiGNvkBzFYr9Ys5fkG5IDdVGLq4wlweX45/4Iz8EnXXd5T ADu/1Xyc30lm8Gpidg+7Ordh1r1gBQHXHy2Fn2YbQnFj0v0NYSVne4IruyUPQNebAeAM mIM11CNpEZ/GY7t1u3hlLwMKtGf5LCy2Wi5TLyRibhfZdV54pj3o71vlzdgwN8cPds9V +NzEpeoP8t7bHJPpscb1cTBtYTzws0Ey/2/qSfmVKuBxfnmJpWEvXzfFmYGLT3TjHb8E Ms6BYx7Z3PxcFAmVjyVGt0gIhsNUbDPNWlG5ow8pYtBxTH2+7jwCDFHgZ02IOk9yk7gm qncQ== X-Gm-Message-State: ALoCoQmWmJrFwP8PZk2pPIRxPlAZ4adAaR9awU7ojcy6zYX+nbMDxz/ZTwk82k2iC88gDXL58c4c X-Received: by 10.70.98.132 with SMTP id ei4mr23910102pdb.102.1413212080752; Mon, 13 Oct 2014 07:54:40 -0700 (PDT) Received: from [10.64.26.87] (dc1-prod.netflix.com. [69.53.236.251]) by mx.google.com with ESMTPSA id xf1sm9134491pbb.18.2014.10.13.07.54.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 Oct 2014 07:54:40 -0700 (PDT) Sender: Warner Losh Content-Type: multipart/signed; boundary="Apple-Mail=_85784895-D37F-4028-B498-FF41133E5A5D"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: How the FreeBSD developers solve problems that are not resolved by Assembly? From: Warner Losh In-Reply-To: Date: Mon, 13 Oct 2014 08:54:37 -0600 Message-Id: References: To: =?iso-8859-1?Q?fran=E7ai_s?= X-Mailer: Apple Mail (2.1878.6) Cc: freebsd-drivers@freebsd.org X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2014 14:59:55 -0000 --Apple-Mail=_85784895-D37F-4028-B498-FF41133E5A5D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 On Oct 13, 2014, at 6:50 AM, fran=E7ai s wrote: > I think that the only case where you have to resort to writing binary = code > manually > is when the assembler cannot output the desired code for some reason. > If I recall correctly, there is only one such case in the HelenOS > sources: >=20 > = http://trac.helenos.org/browser/mainline/kernel/arch/mips32/include/debug.= h?rev=3Dmainline%2C1446.3.1 >=20 > Here they manually encode the opcodes of five special debugging > instructions for the MSIM MIPS simulator (these instructions are not > part of the standard MIPS ISA, thus the assembler does not know them). >=20 > But the developers of FreeBSD not write binary code manually. >=20 > How the FreeBSD developers solve problems that are not resolved by = Assembly? More or less the same way. We either create a macro expands to something = like ".word =93 or sometimes the .word is just hard coded = inline when there=92s only going to be one of them. Sometimes we expose = them both in assembly and in C code, in which case what we do varies a = bit to accommodate the different language=92s syntax. It is rare, but = has happened, that we only expose it to C code. Generally, though, we try to add support for the opcodes to gas so that = we get the constraint testing it does (making sure the opcode is = supported at the level you are compiling, making sure it isn=92t in a = delay slot or violating some other precondition for its use). Warner --Apple-Mail=_85784895-D37F-4028-B498-FF41133E5A5D Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJUO+etAAoJEGwc0Sh9sBEA5/sQAKiV+3YkNVc3qxPKoFo6RqBC KEd6f38YKBTA4DrqwZ1AsU7Y8/U66lsyYKFXkWvmLhE+eqV0pvquXBQ3+AN+eDRN Rjsb4kMKgkp5x3FqA6lW+yS9Z+Z8UucbBXfbv4TGjY8qZ1jW/Xx8L08sAmCXtde0 bfpVqlipR7hlfXtSycVtqDB4Si92RdclRPqmH6AFn5/yP6ZbQ1SR0cwzMn/mEupc Hsxe8TC1cepPI5brnRNkr55jZJsbi51y/+AFD0GZN80WmgJRAkJikd8pyc5hunTB z4TEI8/bYHRQ0uRmS1ElBLPo94xwSaxsdkgdqdVRQbh831c09oxQwU+Ayc1MkEqH UHXNRocjzDnnM0dk/xfeBzNCpk3c4slxZgQytNOW/rgPDnCNL7LuZh5Yz/rKARU9 mupbtSCVpO4scAG4tJHoV0NpMo6PUo6qZvnbm8Q0Q9jEm9T9L2ytfGRojxG+vOdX 8KEEeP4zf7butECHH+aawpi0TMTwB6wBB619hqdeh8RDjcQDYc8fY+UxWXJMjCO8 dWFELzwzjZr9KEdzz7BfNk7yxJg2xPSYUzvdzWt5l9wSediC9kFtrdrna68EO2e3 LhQaHqxXzzVx0viur2K8yM47ojwXBdMoFLHSHNtR5qvYukbn0nT0BKlGwakMwyK1 ncTDcj2O5w2Y5aHFPKpe =C24h -----END PGP SIGNATURE----- --Apple-Mail=_85784895-D37F-4028-B498-FF41133E5A5D--