Coder Social home page Coder Social logo

lab2 elective 2 about osc2021 HOT 1 CLOSED

grasslab avatar grasslab commented on June 9, 2024
lab2 elective 2

from osc2021.

Comments (1)

t0037799 avatar t0037799 commented on June 9, 2024
import dtb
def uart_probe(device_node):
  if 'uart' not in device_node.compatible:
    return
  uart_init(device_node, ...)

def rtx3080ti_probe(device_node):
  if 'rtx3080ti' not in device_node.compatible:
    return
  rtx3080ti_init(device_node, ...)

driver_probe_funcs = [uart_probe,  rtx3080ti_probe, ...] 
dtb.init()
for f in driver_probe_funcs:
  dtb.foreach_node(f)

The above pseudocode is a possible implementation and how to use it.
The device tree module provides a function to walk all device nodes in dtb and call the provided callback functions with the device node.
In the example, because uart is in rpi3's dtb, so it'll be matched when walking the device tree.
After the device node and the driver matches, the driver can use the device node's property for initialization.
On the other hand, rtx3080ti is not in rpi3's dtb so, it's callback function never find matched device node and never get initialized.

You can either parse dtb ahead of time to construct a device tree, or on the fly when someone calls dtb.foreach_node().

Finally, if you have any problem with the documentation, please submit issue at documentation's repository

from osc2021.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.