All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Ziureaev <andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
To: robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [RFC PATCH 0/4] dtc: Add a plugin interface
Date: Tue, 21 Jul 2020 16:58:56 +0100	[thread overview]
Message-ID: <20200721155900.9147-1-andrei.ziureaev@arm.com> (raw)

This is one possible implementation of a plugin interface for dtc.

A plugin interface would allow us to add checks in languages other than
C. Specifically, it would allow dtc to parse dts files, validate them
using DT Schema (which is written in Python), and output dtb files, all
in one command. The command would look something like:

dtc -O dtb -o test.dtb -Lplugins/ \
	-ldt-validate,u,./Documentation/devicetree/bindings \
	-ldt-validate,p,./Documentation/devicetree/bindings/processed-schema.yaml \
	test.dts

DT Schema would also be able to access dts source line information. If
we don't end up having a plugin interface, the alternative would be to
add source annotations to dtc's yaml output.

The plugin interface exports the live tree, making it an ABI. This is
the part I'm most unsure about. Right now, I just cut-and-pasted some
definitions that might be useful for plugins into dtc-plugin.h. This
means the whole live tree structure is exposed and plugins can change it
in any way they want.

I guess a better option would be to make a standard library for live
trees, and have that separate from what dtc uses internally. Some
functions from livetree.c seem useful (although I haven't looked too
much into it yet).

There's also a question of whether we should relicense dtc-plugin.h to
dual BSD to be able call Python code.

Patch 1 fixes a small header issue.
Patch 2 contains an overview of what I have in mind.
Patch 3 isn't very exciting.
Patch 4 is the implementation.

TODO:
- add tests
- improve dtc-plugin.h
- write a DT Schema plugin

Any thoughts would be much appreciated.

Thanks,
Andrei.

Andrei Ziureaev (4):
  dtc: Include stdlib.h in util.h
  dtc: Add plugin documentation and examples
  dtc: Move some definitions into dtc-plugin.h
  dtc: Add a plugin interface

 Documentation/manual.txt         |  74 ++++++++++++
 Makefile                         |  32 ++++-
 dtc-plugin.h                     | 200 +++++++++++++++++++++++++++++++
 dtc.c                            | 139 ++++++++++++++++++++-
 dtc.h                            | 192 ++++++++---------------------
 plugins/example/Makefile.example |  19 +++
 plugins/example/example.c        |  29 +++++
 treesource.c                     |  21 ----
 util.h                           |   1 +
 9 files changed, 540 insertions(+), 167 deletions(-)
 create mode 100644 dtc-plugin.h
 create mode 100644 plugins/example/Makefile.example
 create mode 100644 plugins/example/example.c

-- 
2.17.1


             reply	other threads:[~2020-07-21 15:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21 15:58 Andrei Ziureaev [this message]
     [not found] ` <20200721155900.9147-1-andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
2020-07-21 15:58   ` [RFC PATCH 1/4] dtc: Include stdlib.h in util.h Andrei Ziureaev
     [not found]     ` <20200721155900.9147-2-andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
2020-07-22  6:41       ` David Gibson
2020-07-21 15:58   ` [RFC PATCH 2/4] dtc: Add plugin documentation and examples Andrei Ziureaev
     [not found]     ` <20200721155900.9147-3-andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
2020-08-03  8:08       ` David Gibson
     [not found]         ` <20200803080808.GD7553-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-08-03 14:09           ` Andrei Ziureaev
     [not found]             ` <b2f04d65-736a-802a-7e49-648ed6784a09-5wv7dgnIgG8@public.gmane.org>
2020-08-03 14:23               ` Andrei Ziureaev
2020-07-21 15:58   ` [RFC PATCH 3/4] dtc: Move some definitions into dtc-plugin.h Andrei Ziureaev
     [not found]     ` <20200721155900.9147-4-andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
2020-07-23 14:16       ` Rob Herring
2020-07-21 15:59   ` [RFC PATCH 4/4] dtc: Add a plugin interface Andrei Ziureaev
     [not found]     ` <20200721155900.9147-5-andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
2020-07-23 14:46       ` Rob Herring
     [not found]         ` <CAL_JsqL47ykA82LdeXV0ZkfC9s=-aBJ0mkmJqB-t4+Jpeev7Pg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-07-23 18:22           ` Andrei Ziureaev
     [not found]             ` <9b0a289f-fd39-9ed7-0866-03390f7188c2-5wv7dgnIgG8@public.gmane.org>
2020-07-24 21:26               ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200721155900.9147-1-andrei.ziureaev@arm.com \
    --to=andrei.ziureaev-5wv7dgnigg8@public.gmane.org \
    --cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.