Commit Graph

96 Commits

Author SHA1 Message Date
Richard Hughes
faa35e430b Show a warning if the device has no GType and the plugin has no default
This also renames a symbol to make it clear that you can call it more than once.

Fixes https://github.com/fwupd/fwupd/issues/3148
2021-04-15 16:52:56 +01:00
Mario Limonciello
1f9c035788 trivial: fix some trailing whitespace problems across the project 2021-04-09 16:02:20 +01:00
Richard Hughes
b333e0045c Split out a shared system context
There is a lot of code in fwupd that just assigns a shared object type to
a FuPlugin, and then for each device on that plugin assigns that same shared
object to each FuDevice.

Rather than proxy several kinds of information stores over two different levels
of abstraction create a 'context' which contains the shared *system* state
between the daemon, the plugins and the daemon.

This will allow us to hold other per-machine state in the future, for instance
the system battery level or AC state.
2021-04-01 21:11:29 +01:00
David Chiu
98328679ab synaptics-rmi: Force the hardware into IEP mode as required 2021-03-22 07:51:06 +00:00
David Chiu
02404b0797 synaptics-rmi: Fix regression when setting edpAuxStatusRequest 2021-03-22 07:51:06 +00:00
David Chiu
09ad3a7f93 synaptics-rmi: Allow failure when writing and erasing 2021-03-22 07:51:06 +00:00
David Chiu
f9a0b04389 synaptics-rmi: Validate the firmware signature correctly 2021-03-22 07:51:06 +00:00
David Chiu
b15f393494 synaptics-rmi: Reduce the idle wait time 2021-03-22 07:51:06 +00:00
Richard Hughes
52441f28a4 Allow objects to deserialize to XML
This makes a lot more sense; we can parse a firmware and export the same XML
we would use in a .builder.xml file. This allows us to two two things:

 * Check we can round trip from XML -> binary -> XML

 * Using a .builder.xml file we can check ->write() is endian safe
2021-03-15 12:07:30 +00:00
Richard Hughes
2667e4bdc1 synaptics-rmi: Never create a zero-sized v10 container 2021-03-10 21:00:18 +00:00
Richard Hughes
b86eac9034 synaptics-rmi: Write files with valid checksum data 2021-03-10 19:18:28 +00:00
Richard Hughes
1981c63d58 Remove FuFirmwareImage and just use FuFirmware instead
This allows us to 'nest' firmware formats, and removes a ton of duplication.

The aim here is to deprecate FuFirmwareImage -- it's almost always acting
as a 'child' FuFirmware instance, and even copies most of the vfuncs to allow
custom types. If I'm struggling to work out what should be a FuFirmware and
what should be a FuFirmwareImage then a plugin author has no hope.

For simple payloads we were adding bytes into an image and then the image into
a firmware. This gets really messy when most plugins are treating the FuFirmware
*as* the binary firmware file.

The GBytes saved in the FuFirmware would be considered the payload with the
aim of not using FuFirmwareImage in the single-image case.
2021-03-09 21:14:12 +00:00
David Chiu
5abbb85e58 synaptics-rmi: Fix firmware update of pointing device on Lenovo ThinkPad Nano 2021-03-03 16:07:05 +00:00
Richard Hughes
7d132b728c Simplify the quirk file format
The best way of not getting something wrong is to not require it in the first
place...

All plugins now use DeviceInstanceId-style quirk matches and we can just drop
the prefix in all files. We were treating HwId=, Guid= and DeviceInstanceId= in
exactly the same way -- they're just converted to GUIDs when building the silo!
2021-03-03 08:30:34 +00:00
Richard Hughes
b3f9841924 Support more than one protocol for a given device
Devices may want to support more than one protocol, and for some devices
(e.g. Unifying peripherals stuck in bootloader mode) you might not even be able
to query for the correct protocol anyway.
2021-03-01 16:14:36 +00:00
blueue
03ed377dc6
Add a function to access private member variable to let it be modified (#2947)
* Add a function to access private member variable to let it be modified in ps2 flow.
2021-02-26 07:57:08 +00:00
Richard Hughes
078beafb2d Add a new internal flag to opt-in to GUID matching
It is far too easy to forget to set FWUPD_DEVICE_FLAG_NO_GUID_MATCHING for new
plugins, and without it it all works really well *until* a user has two devices
of the same type installed at the same time and then one 'disappears' for hard
to explain reasons. Typically we only need it for replug anyway!

Explicitly opt-in to this rarely-required behaviour, with the default to just
use the physical and logical IDs. Also document the update behavior for each
plugin to explain why the flag is being used.

This allows you to have two identical Unifying plugged in without one of them
being hidden from the user, at the same time allowing a HIDRAW<->USB transition
when going to and from bootloader and runtime modes.

This removes the workaround added in 99eb3f06b6.

Fixes https://github.com/fwupd/fwupd/issues/2915
2021-02-25 15:47:25 +00:00
Richard Hughes
ed4ca92eb3 synaptics-rmi: Read the PDT by calling the correct setup function 2021-02-23 12:05:28 +00:00
Richard Hughes
2e1245728f Call the superclass directly from subclassed devices
This allows a device subclass to call the parent method after doing an initial
action, or even deliberately not call the *generic* parent method at all.

It also simplifies the plugins; you no longer have to remember what the plugin
is deriving from and accidentally clobber the wrong superclass method.
2021-02-18 16:18:34 +00:00
Richard Hughes
a22c13c637 Move the plugin build logic to the plugins themselves 2021-02-18 14:46:20 +00:00
Richard Hughes
54bc512388 Add firmware flags for presence of CRC and VID/PID 2021-02-11 20:27:20 +00:00
Richard Hughes
b1e4a23597 synaptics-rmi: Read from the device in a more safe way 2021-02-10 16:29:57 +00:00
Richard Hughes
a45d807a08 synaptics-rmi: Limit the number of containers to a sane value
Using hongfuzz we managed to build a valid firmware with 246625043 containers,
which took over 60 seconds to parse.
2021-02-10 15:27:42 +00:00
Richard Hughes
84176c9e1a synaptics-rmi: Be more careful when parsing invalid firmware 2021-02-10 15:27:42 +00:00
Richard Hughes
b0cf709f9b synaptics-rmi: Fix a memory leak when parsing invalid firmware 2021-02-10 15:27:42 +00:00
Richard Hughes
01a30aa6de Add support for oss-fuzz 2021-02-08 09:17:03 +00:00
Richard Hughes
d99f86023f trivial: Add getters to FuChunk
At the moment FuChunks are sometimes mutable, and sometimes immutable, and it's
all a bit too low level for comfort.

Before we can do any kind of optimisation or verification we need plugins to
stop reading directly from the C structure. The aim here is to make FuChunk
optionally mutable without making assumptions about the memory model, and also
to be able to introspect it for the docs.
2021-01-28 16:42:54 +00:00
Mario Limonciello
75835b4a0b Use FWUPD_COMPILATION define to indicate an in tree build
When this is done, include:
* Including the hash
* Including anything that is not ABI stable in plugins yet

Suggested-by: Simon McVittie <smcv@debian.org>
2021-01-22 14:01:25 -06:00
Richard Hughes
70ded56f8a synaptics-rmi: Add some support for PS2 devices
With much help from David Chiu <david.chiu@tw.synaptics.com>, many thanks.
2021-01-18 21:18:02 +00:00
Richard Hughes
a5deffb184 synaptics-rmi: Allow the device to enter a firmware mode that allows programming 2021-01-18 21:18:02 +00:00
Richard Hughes
1974adaa04 synaptics-rmi: Query the build ID and ProjectID to work around a HW bug
The build ID is set and the product ID is parsed in a different way for a PS/2 device.
2021-01-18 21:18:02 +00:00
Richard Hughes
8b1ca08332 synaptics-rmi: Write bus select zero when detaching
This has no effect for HID devices.
2021-01-18 21:18:02 +00:00
Richard Hughes
ff82d005d7 synaptics-rmi: Use the correct delay when erasing v5 firmware 2021-01-18 21:18:02 +00:00
Richard Hughes
a0dd0e2be2 synaptics-rmi: Split out the HID specific parts to FuSynapticsRmiDevice 2021-01-18 21:18:02 +00:00
Richard Hughes
edc0c08065 synaptics-rmi: Support parsing and writing signed firmware
Validate the firmware signature if provided
2021-01-18 21:18:02 +00:00
Richard Hughes
643d7b16b1 synaptics-rmi: Do not assign the class vfuncs during setup
We fixed this problem in logitech-hidpp and this plugin will suffer the same bug.
2021-01-18 21:18:02 +00:00
Richard Hughes
a2798213ee synaptics-rmi: Do not set the page to the existing value 2021-01-18 21:18:02 +00:00
Richard Hughes
2773476884 synaptics-rmi: Do not match all HIDRAW\VEN_06CB devices
Apparently, some devices will not respond well to probing.
2021-01-18 21:18:02 +00:00
Richard Hughes
5c9b1fcc81 Only include the start year in the copyright header
The end year is legally and functionally redundant, and more importantly causes
cherry-pick conflicts when trying to maintain old branches. Use git for history.
2021-01-07 14:48:16 +00:00
Richard Hughes
e002f21066 trivial: Prevent a crash when parsing corrupt RMI firmware
Using fu_common_bytes_new_offset() is much safer as it checks the source size.
2021-01-06 10:08:45 +00:00
Richard Hughes
64e9f6bd92 trivial: Fix up some NULL/FALSE confusion 2021-01-04 16:32:50 +00:00
Richard Hughes
c2a0259fe6 Remove now-unused synaptics_rmi_dump fuzzing target generator
We can implement firmware->build and firmware->write and then use the shared
firmware.builder.xml functionality.
2021-01-04 15:42:17 +00:00
Richard Hughes
9f71fe3dc9 Make the 'id' for fu_plugin_add_firmware_gtype() optional
We can work out the correct value automatically in all cases but one, and it's
less for the plugin author to get wrong...
2021-01-04 15:27:10 +00:00
Richard Hughes
c4ca8e25d1 Use honggfuzz to fuzz firmware rather than AFL
This has better multi-core performance and can run in persistent mode -- which
allows us to construct a test harness of all the parsers (which takes time) and
then just reuse the process for lots of different data.
2020-12-11 09:37:42 +00:00
Richard Hughes
bfabf5c81f synaptics-rmi: Do not add zero sized container images
This prevents a DoS when parsing corrupt firmware.
2020-12-10 14:58:11 +00:00
Richard Hughes
056dfff741 synaptics-rmi: Fix possible buffer over-read for corrupt firmware 2020-12-09 15:25:04 +00:00
Richard Hughes
c79e76d2aa synaptics-rmi: Fix a tiny memory leak when parsing firmware 2020-12-08 20:07:27 +00:00
Richard Hughes
b7ca257c6d synaptics-rmi: Don't crash if calling ->to_string() before ->setup() 2020-12-01 14:15:33 +00:00
Richard Hughes
58993ac005 trivial: Fix some error prefixes 2020-11-06 09:57:03 +00:00
Mario Limonciello
8aa5d41eb7 Add external interface messages 2020-10-26 12:05:20 -05:00