From owner-freebsd-current@freebsd.org Tue Feb 4 17:40:34 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D85A722D1EB for ; Tue, 4 Feb 2020 17:40:34 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound3d.ore.mailhop.org (outbound3d.ore.mailhop.org [54.186.57.195]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48BsRQ3Rcpz4C8M for ; Tue, 4 Feb 2020 17:40:34 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1580838033; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=f2Ljcz8sJGy2C/CQSMNVjLHd3LYj5K4NzsxKAegvFI/G2oDmPrb56DLSJJjq/JMGPJECQQKueYiD4 21AMhWZ+h/+VYms/IA6GC7Xw+bff9lOoZ1EdAWtYWL/aZoWqpUbVQv6FgSNUcdpnPnslNWN3gYxKY3 HbRni9uBj9IE8S44rRInASLBWMKovTCsSV2gxf0H9WK2/udrY5OWofaXdfoG3PQQYuwn9FWJu3WZ98 dZN2Z+n/faPYRNlHwO18lExHpWQlZRGramTFRY/gNz+GO8YVSWWDFW+UqZTh1KBR/6kg16sI+D5j6a DSVk56dnyoVoHSwXoqW0R7DoK9yfukQ== 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:cc:to:from:subject:message-id:dkim-signature:from; bh=IwQwmoy02cG0WsU9rOCUxjEeoaiMN0ndz8XgapbLhAs=; b=LteQ5wJAtuPmS+gKrB94Zp0ipaHUCSGSqeKfMhG5ktW+NzpJ4zUCWuNcn08TsnQmpy+7kjMr9bfv9 ry798rTcms3NYW+2izK7wHmN5yPQsVv5OG9EwbTKBv+LhjLt0uJfchGWUNWYw8RyAdOd9/BHyQ8cjK eD8geJw4L1J6g3emqFleEXJDZLj02UQ3h5Erl9bIwnUupxiNy4F/ibrpopwXD8wvcI041yqRDE3Omx 775W9j7/dpGPmUPoieMHVNxn3IgE4XwbyyAhCbQif3W2hc7O/39zjd73R7VA6XxVJmuws8C1Rus+cd 8PenhwG6dfo/ZyrYJ92jgo/YQbJrueg== ARC-Authentication-Results: i=1; outbound3.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:cc:to:from:subject:message-id:from; bh=IwQwmoy02cG0WsU9rOCUxjEeoaiMN0ndz8XgapbLhAs=; b=THBok1PaQPWgVlEQTIySS/EeuW76C2zuIcn+o6pcLR3e15gi3oHuShOWS0BLWRLUCJm96wFrZQtr8 z3JlY8WNnYzwKEPODwBkXSniU2/WlBKMmttKes+buIpR8JO0w5FudjeL7uvh7U3cJAdx9U6wkNXZaG MOC6yCn2XKhtgqA+URiAKaslOuuangrRPXkGFUsSuWF63xPOi9H+lecyHlKJczluz0un9FMf+Z8+l0 M1Xhx08YdGYsnHrGL6bF1eatcDsdW/p4jRAWagzmHAxllwo8TREr2e1sqp9B4fe5EHkBu8tdRFBqAj XFxWWFqGp81lU4ze5OaAmElHHk0cv1A== X-MHO-RoutePath: aGlwcGll X-MHO-User: 708813b0-4775-11ea-b80d-052b4a66b6b2 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 outbound3.ore.mailhop.org (Halon) with ESMTPSA id 708813b0-4775-11ea-b80d-052b4a66b6b2; Tue, 04 Feb 2020 17:40:32 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 014HeV4A042442; Tue, 4 Feb 2020 10:40:31 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <73de083548264f526a27676bc3677c03fd889f51.camel@freebsd.org> Subject: Re: OFWBUS: How does autoconfiguration work? From: Ian Lepore To: Niteesh Cc: "freebsd-current@freebsd.org" Date: Tue, 04 Feb 2020 10:40:30 -0700 In-Reply-To: References: Content-Type: text/plain; charset="ASCII" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 48BsRQ3Rcpz4C8M X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-1.80 / 15.00]; TAGGED_RCPT(0.00)[]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.81)[-0.814,0]; ASN(0.00)[asn:16509, ipnet:54.186.0.0/15, country:US]; NEURAL_HAM_LONG(-0.99)[-0.988,0] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Feb 2020 17:40:34 -0000 On Tue, 2020-02-04 at 19:09 +0530, Niteesh wrote: > I am working on an operating systems project at my university, which > currently > uses lazy driver initialization i.e. that is the drivers initialize the > hardware only > during the first invocation, for example, the UART hardware is initialized > only during the first call to output_char. > > Currently, we have multiple BSP's to support different variants even though > they are quite similar. For example, we have two BSPs to support BeagleBone > Black > and white. We are trying to avoid this by using device tree files. Our goal > is to parse the > DTB at boot time and call all the registered drivers to initialize the > hardware. By registered > drivers, I mean drivers which are statically linked to executable. > > I am trying to add a system, which will parse the DTB files and initialize > them by calling > the appropriate drivers. I want a system similar to FreeBSD or Linux > a probe and attach method for device drivers. It doesn't have to be as > complex as FreeBSD > but a simple one will do. > > If you have any other questions please let me know :) > > Thanks, > Niteesh > I don't think there is anything much in the freebsd code that will help you with that. The book "The Design and Implementation of the FreeBSD Operating System 2nd ed." describes the freebsd autoconfiguration mechanisms. Those mechanisms are designed to solve problems a lot more complex than parsing a simple hierarchical dtb to find active devices, it supports a mix of buses that can identify the devices on the bus (USB, PCI), buses that are described with metadata (ACPI, fdt simplebus, ISA bus with PNP data), and drivers that can just force a bus to adopt them by using an identify() method. Resource management (interrupts and mmio ranges, mostly) are also part of the scheme. FDT data adds another wrinkle by creating cross-hierarchy links between devices using phandles, and there are sideband subsystems in freebsd to handle that stuff separately from the normal hiearchical parent/child bus relationships. There just isn't much that can reasonably be separated out and used in another project, I think. -- Ian