From owner-freebsd-hackers@freebsd.org Thu Apr 18 03:45: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 ECC171586434 for ; Thu, 18 Apr 2019 03:45:03 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E4EA073CC8 for ; Thu, 18 Apr 2019 03:45:02 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x843.google.com with SMTP id x12so749865qts.7 for ; Wed, 17 Apr 2019 20:45:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/RWuQ2vuaswiR304noCZ5QzQsIdpN+4Qi3vl8C+6LX4=; b=NL9tK4M3/2kplgKAamHqKPkNOEXvPuDRXkQiHps+GAEfodDNecelDTBHdiaayOAxvV evf1F8oCD+ZJuQjgU+w79udleinNZM1CXFnFxQYkpSH727D/xLKedcbjc4HRbzjO1m4b pf/G7RkdFnsaM6YrVW4yrfAiWLtl4IpJjJzXgTluyS2FGALYC28QPzBz6oFAozQHtoz3 ehZzBHjnIUc6Ne0j36u652FPLAicvU1FkvU1rtypNKgygqgHk/4oTbTFz+zglv4CnY+w bidcrqVNoyTdzsXJdC2MSz9hCYyfYPZgSi5Hp8kcoV3B3vD3UnjLEnzzL1Hxqht67o1i h5GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/RWuQ2vuaswiR304noCZ5QzQsIdpN+4Qi3vl8C+6LX4=; b=LM/ML+zFFIq41nRs0zwqs+qxHZwgco4eFKHy1McgFfIVkB/qnPLUpZCEVdIok02IbL +YoUzvLXNWiAXBfgOQ1LyLlYwiDGngbtXGTYPdG2M4RcFEJXYh2eAVXcWAU1roRCgOTr mJF7nNQCbU8u+3gYv8BuPXalHtuN5MFyundYetPB3lk5AdeKT9hF/Ryc9mExlkUIKL8Q LRTvCAsJUgmEDxXLoGgdN4FZeYjPSrPVdIgln3Y1FtkoIPBbk1SgYsJlY51EFZAbiF+s TmmYI5Peh7dOEdwd82Tml+h5luvMAHIvamZ638hJ7mX0uOTb3hf99UxefZlS5BHCC7Lr NVZQ== X-Gm-Message-State: APjAAAXoSh6tOWQL+EvqSUATmyDi/k+zmRajGKCTwxo/zl/9r3/YWJDk B92345gO+7rfyECa51GT2i0Nfj/17ZB830OodEeJ7w== X-Google-Smtp-Source: APXvYqy9qC5SQara+pZULXsLnJnyw6WQQAzzRw+rqfpj2+cV/bBOYwL1fKZ3FEZ9k0xP0G1ZZYb5N60vhiqnWt4GOSs= X-Received: by 2002:a0c:d2fc:: with SMTP id x57mr74830327qvh.214.1555559102299; Wed, 17 Apr 2019 20:45:02 -0700 (PDT) MIME-Version: 1.0 References: <173b3741db8be891cff8b7005b2058a416d43115.camel@freebsd.org> In-Reply-To: <173b3741db8be891cff8b7005b2058a416d43115.camel@freebsd.org> From: Warner Losh Date: Wed, 17 Apr 2019 21:44:51 -0600 Message-ID: Subject: Re: What code loads kernel modules at boot? To: Ian Lepore Cc: Lee D , FreeBSD Hackers X-Rspamd-Queue-Id: E4EA073CC8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=NL9tK4M3 X-Spamd-Result: default: False [-2.42 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(-0.71)[ip: (1.81), ipnet: 2607:f8b0::/32(-3.05), asn: 15169(-2.23), country: US(-0.06)]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; NEURAL_HAM_LONG(-1.00)[-0.996,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; MX_GOOD(-0.01)[cached: ALT1.aspmx.l.google.com]; RCVD_IN_DNSWL_NONE(0.00)[3.4.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_SHORT(-0.71)[-0.709,0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; SUBJECT_ENDS_QUESTION(1.00)[]; MIME_TRACE(0.00)[0:+,1:+]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_CC(0.00)[gmail.com] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:45:04 -0000 On Wed, Apr 17, 2019 at 9:07 PM Ian Lepore wrote: > 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). > That code gets called from the command line commands, as well as indirectly in the .conf file parsing each of the interpretive languages have. > 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. > Yea, if the loader that he's written loads /boot/loader, he doesn't need to do anything. if it loads the kernel and modules, he'll need to do what the code in src/stand/common/module does in terms of laying out memory and passing the proper meta-data to the kernel. Warner