From owner-freebsd-hackers@freebsd.org Thu Apr 18 03:04:04 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4AB21584D57 for ; Thu, 18 Apr 2019 03:04:03 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound2m.ore.mailhop.org (outbound2m.ore.mailhop.org [54.149.155.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 34FDC72416 for ; Thu, 18 Apr 2019 03:04:03 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1555556641; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=MGAO7FBS0BDvaTk9uTPu+cSiWnG36g9qfpyvZY7AUhsBuMTPR9H6wTzjYHDE4DorJSHrHwkq59MGI 7NjsI1H/WjZPGRnK2DqoWdQFtf7WifhXnq+1Oe9i/gHHcovc502ENe2iXDr5ruMwmeoUI76RbL6mB7 D332EcBydDnZosMkh+PDh+ycmND9SgexilXCqk9YnXz9bzFlhS85pHn9AIB1pfVxMOFkhJSiZke9BD VW938uSkSodTFJgOFACG4nErWKlYNIjuucp6d7WzXuTAZ1U+jumwh0bxIY7esdkMcLhij1ovPLy+en H1Vlcy9dQ4Q/iAAG7ivt8VJ92XaEfVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:dkim-signature:from; bh=9XgXOcvFK2ER3w9uq6ATa03Smq7v1zVk6LMLFGja4V4=; b=ZySKjHgXA/GsAlYaVfzkcWeN6aWG3aRAKT+mihs5wmP6WZTDwvpO0X7r0XzB3rZ7vht873epYvdO0 xzcqxx2PrTc9t7TwEXWbx+kFqfELnCGrfHuF3d4cyfmDg/VX9/ukipQ2soMp9A7wweCycdSJajpnre maR1gG0sVpzPTfDi9yHWM4E9Dky+xgtAaxBu8O5wHAyNzvQAcHfrZ6mOQ80vIJvvFP7lYhCRJKS0aS gBP/g03Py1gZKCFbCROdJCVa+66peJ9Q42bbQSM5qVNA8Muhxcw4ukEnt86PSbQ+lGaKVsKqWmmpyw +yPL7IP78DyTwK5+kn9yyPMeWsvZaEw== ARC-Authentication-Results: i=1; outbound4.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:from; bh=9XgXOcvFK2ER3w9uq6ATa03Smq7v1zVk6LMLFGja4V4=; b=Mg6iQrIm94o1oN8r/W4vJaacDxxKLCiGteP5bM6Kt5PQHLlIDWIKHdo5BKHyjYSxtIEaBZL1p4ycr SnVwq6LSQO8MCXM0La0uVnQ5grsxtfDtZ4KBYHFv0FUTvTgOgDCY43XSbG66Y6r9sVBBPxEUfMKPHR 54BzY7GfZMc73aN8BelkM0qTGvQsZ4QWSkxQhPVVg9g1MEl1gwga1WbGDabqWSOih0vJXrX1Sy/Tl5 Ulx89AI6jLLvxWJjmzDiBnJIEpcSJ1K4sC2U0B7QY3Y1/eBkEQGryyojDMy8YygXro/Nyid2NDatM0 oXtAzsqHx2SOxKSMrYUUkdWaveOZG/Q== X-MHO-RoutePath: aGlwcGll X-MHO-User: 9cb10092-6186-11e9-919f-112c64a8cf29 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound4.ore.mailhop.org (Halon) with ESMTPSA id 9cb10092-6186-11e9-919f-112c64a8cf29; Thu, 18 Apr 2019 03:04:00 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id x3I33xSk049129; Wed, 17 Apr 2019 21:03:59 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <173b3741db8be891cff8b7005b2058a416d43115.camel@freebsd.org> Subject: Re: What code loads kernel modules at boot? From: Ian Lepore To: Lee D , FreeBSD Hackers Date: Wed, 17 Apr 2019 21:03:59 -0600 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 34FDC72416 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:16509, ipnet:54.148.0.0/15, country:US] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Apr 2019 03:04:04 -0000 On Wed, 2019-04-17 at 20:52 -0400, Lee D wrote: > A couple of years ago I wrote a FreeBSD bootloader for Zynq (Arm32). > It's been working well, but now I need to add the ability to load > kernel modules at boot. This is for 11.0.1 (updating to 12 soon, > hopefully). > > Can anyone point me to the code that actually loads a kernel module > for arm? I got lost reading the source in /src/sys/boot/common, and > can't quite figure out what routine is actually called. > > I assume I need to parse the sections out of the .ko file and place > them carefully in memory, like I do with the kernel image. > > Also, if you're feeling loquacious, where do I put the darn thing and > how do I tell the kernel how to find it (part of the MODINFO stuff I > assume)? > > This is all in the context of loading custom real time clock and I2C > drivers so they are available at boot time. > > Thanks, > > The bulk of the module-loading code (the arch-independent part of it) is in src/stand/common/module.c. There is also archsw.arch_loadaddr, which figures out where to put the modules (handling arch-specific things like alignment requirements). For some reason, I thought Zynq used u-boot. That would allow using either ubldr or the arm uefi loader (depending on how old the u-boot is); those are just flavors of loader(8) that would get you module handling and all the other loader goodness. -- Ian