summaryrefslogtreecommitdiff
path: root/pylibfdt
Commit message (Collapse)AuthorAgeFilesLines
...
* pylibfdt: Add support for the rest of the header functionsSimon Glass2018-06-091-3/+68
| | | | | | | Export all of these through Python. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Add support for fdt_next_node()Simon Glass2018-06-081-0/+33
| | | | | | | | This function requires a bit of typemap effort to get the depth parameter to work correctly. Add support for it, along with a test. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Reorder functions to match libfdt.hSimon Glass2018-06-081-72/+72
| | | | | | | | | | | The ordering of the Python functions loosely matches the corresponding function in the C header file, but not exactly. As we add more functions it is easier to track what is missing if they are in the same order. Move some functions around to achieve this. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Return string instead of bytearray from getprop()Simon Glass2018-06-081-2/+3
| | | | | | | | | The return value is not actually mutable, so it seems more correct to return bytes rather than a bytearray. Suggested-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Make Property a subclass of bytearraySimon Glass2018-06-041-3/+4
| | | | | | | | | | | | It is annoying to have to add .value when we want the value of a Property. Make Property a subclass of bytearray so that it can be used directly when the value is required. Fix the Property class comment while we are here. Suggested-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Add a method to access the device tree directlySimon Glass2018-06-041-0/+11
| | | | | | | | | | | | | When calling libfdt functions which are not supported by the Fdt class it is necessary to get direct access to the device tree data. At present this requries using the internal _fdt member. Add a new method to provide public access to this, without allowing the data to be changed. Note that a bytearray type is returned rather than str, since the swig types are set up for bytearray to map correctly to const void *. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Use Python2 explicitlyDavid Gibson2017-09-271-1/+1
| | | | | | | | | | | | | | | | The pylibfdt code is written for Python2, not Python3. So, it's safer to explicitly request Python2 in our scripts and when checking pkg-config. On Arch Linux at least, there isn't actually a plain "python" link, just "python2" and "python3", so the current setup won't work at all. According to https://www.python.org/dev/peps/pep-0394/ using "python2" should work, and is preferred. Updating pylibfdt to work with Python3 would be nice, but is a problem for another day. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Add support for fdt_subnode_offset()Simon Glass2017-08-211-0/+17
| | | | | | | Add this into the class to simplify use of this function. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Add support for fdt_node_offset_by_phandle()Simon Glass2017-08-211-0/+14
| | | | | | | Add this into the class to simplify use of this function. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Add support for fdt_parent_offset()Simon Glass2017-08-211-0/+15
| | | | | | | Add this into the class to simplify use of this function. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Add support for fdt_get_phandle()Simon Glass2017-08-211-0/+12
| | | | | | | Add this into the class to simplify use of this function. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Add stdint include to fix uint32_tSimon Glass2017-08-151-0/+2
| | | | | | | | | | | | | | | | | | Some types used by libfdt.h are not understood the Python module since they are defined outside it. An example is an attempt to do this: import libfdt result = libfdt.fdt_node_offset_by_phandle(fdt, phandle) This results in: TypeError: in method 'fdt_node_offset_by_phandle', argument 2 of type 'uint32_t' Include the standard integer header file to fix this. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Use setup.py to build the swig fileSimon Glass2017-04-081-9/+5
| | | | | | | | | Since we are using the standard .i extension for the swig file, we can use setup.py to build the wrapper. Drop the existing build code since it is not needed. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Use Makefile constructs to implement NO_PYTHONSimon Glass2017-04-081-7/+0
| | | | | | | | | The current mechanism uses a shell construct, but it seems better to use a Makefile approach. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Allow setup.py to operate stand-aloneSimon Glass2017-04-082-9/+98
| | | | | | | | | | | | | | | | | | | | | | | | At present we require that setup.py is executed from the Makefile, which sets up various important things like the list of files to build and the version number. However many installation systems expect to be able to change to the directory containing setup.py and run it. This allows them to support (for example) building/installing for multiple Python versions, varying installation paths, particular C flags, etc. The problem in implementing this is that we don't want to duplicate the information in the Makefile. A common solution (so I am told) is to parse the Makefile to obtain the required information. Update the setup.py script to read a few Makefiles when it does not see the required information in its environment. This allows installation using: ./pylibfdt/setup.py install Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Fix code style in setup.pySimon Glass2017-04-071-8/+9
| | | | | | | | We should follow PEP8 even for our setup() call. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Rename libfdt.swig to libfdt.iSimon Glass2017-04-072-1/+1
| | | | | | | | | The .i extension allows Python distutils to automatically handle the swig file. Rename it. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Use the call function to simplify the MakefileSimon Glass2017-03-291-7/+7
| | | | | | | | This is in a separate patch since I not sure if GNU make features are permitted in the Makefile. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Use the correct libfdt version in the moduleSimon Glass2017-03-292-2/+4
| | | | | | | | | | | Use the same version number in the module as with the rest of libfdt. This can be examined with: import pkg_resources print pkg_resources.require('libfdt')[0].version Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Enable installation of Python moduleSimon Glass2017-03-291-0/+14
| | | | | | | | | | Adjust the setup script to support installation, and call it from the Makefile if enabled. It will be disabled if we were unable to build the module (e.g. due to swig being missing), or the NO_PYTHON environment variable is set. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Use package_dir to set the package directorySimon Glass2017-03-272-2/+4
| | | | | | | | At present we manually move _libfdt.so into the correct place. Provide a package directory so we can avoid needing to do this. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Use environment to pass C flags and filesSimon Glass2017-03-272-11/+8
| | | | | | | | | | At present setup.py adjusts its command line when running, so that the C flags and file list can be passed as arguments. Pass them in environment variables instead, so we can avoid this messiness. It also allows us to support the 'install' command. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Add an initial Python library for libfdtSimon Glass2017-03-214-0/+487
Add Python bindings for a bare-bones set of libfdt functions. These allow navigating the tree and reading node names and properties. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>