[PATCH 00/25] alsa-tools: efw-downloader: add initial version of firmwre downloader for Echo Audio Fireworks devices
Hi,
This patchset is for alsa-tool repository[1] to add a new command-line tool, efw-downloader. The tools is designed to operate on-board flash memory for devices based on Fireworks board module. The patches are also available in my personal repository in github.com[2].
Fireworks board module was designed by Echo Digital Audio corporation. The board module has on-board flash memory to store firmware blob and session data. The contents of flash memory can be operated by software by a pair of asynchronous transactions defined by Echo Digital Audio corporation.
Echo Digital Audio corporation also designed file format of firmware. Hardware Vendors including Echo Digital Audio corporation shipped several versions of firmware by the format in driver packages for Windows and macOS.
The goal of this tool is to operate the flash memory to download any version of firmware. In this patchset, limited functionalities are added; read from the flash memory, and parse the content of file. The other functionalities are planned to added in future work.
I thinks it possible to put actual firmware blobs into somewhere suitable for them (alsa-firmware or linux-firmware repositories). I think it better to prepare the files by reading on-board flash memory, with enough care of copyright of original firmware files shipped by vendor. In the case, it's preferable to use file format different from the original one. But it's my first time for this kind of work. I'd like to ask some advices to alsa developers.
[1] https://github.com/alsa-project/alsa-tools/ [2] https://github.com/takaswie/alsa-tools/tree/topic/efw-downloader
Takashi Sakamoto (25): efw-downloader: start a new project to operate on-board flash memory for Fireworks board module efw-downloader: efw-proto: define EfwProto as derived object of HinawaFwResp efw-downloader: efw-proto: add constructor, destructor, bind, unbind functions efw-downloader: efw-proto: add responded signal efw-downloader: efw-proto: add class virtual method to handle responded signal efw-downloader: efw-proto: add instance private structure efw-downloader: efw-proto: emit responded signal at receiving response efw-downloader: efw-proto: add function to finish transaction for command frame efw-downloader: efw-proto: add function to finish a pair of transactions efw-downloader: add parser for sub commands efw-downloader: subcmd-device: implement 'device' sub command to operate actual device efw-downloader: subcmd-device: open firewire character device by HinawaFwNode efw-downloader: config-rom: parse config rom to detect supported device efw-downloader: subcmd-device: check supported models or not efw-downloader: subcmd-device: bind Fireworks protocol efw-downloader: node_dispatcher: add event dispatcher utilizing GLib MainContext/MainLoop efw-downloader: subcmd-device: support debug output for response of Fireworks protocol efw-downloader: efw-commands: add support for a part of hardware command efw-downloader: efw-commands: add support for commands in flash category efw-downloader: subcmd-device: add read operation efw-downloader: file-cntr: add parser for data binary shipped by Echo Digital Audio corporation efw-downloader: subcmd-file: add 'file' sub command efw-downloader: subcmd-file: add parse operation efw-downloader: man: add online manual efw-downloader: add README formatted by reStructuredText
efw-downloader/COPYING | 674 ++++++++++++++++++ efw-downloader/README.rst | 167 +++++ efw-downloader/man/efw-downloader.1 | 162 +++++ efw-downloader/meson.build | 14 + efw-downloader/meson_options.txt | 5 + efw-downloader/src/config-rom.c | 60 ++ efw-downloader/src/config-rom.h | 26 + efw-downloader/src/efw-commands.c | 243 +++++++ efw-downloader/src/efw-commands.h | 57 ++ .../src/efw-proto-sigs-marshal.list | 1 + efw-downloader/src/efw-proto.c | 401 +++++++++++ efw-downloader/src/efw-proto.h | 80 +++ efw-downloader/src/file-cntr.c | 183 +++++ efw-downloader/src/file-cntr.h | 39 + efw-downloader/src/main.c | 54 ++ efw-downloader/src/meson.build | 54 ++ efw-downloader/src/node-dispatcher.c | 86 +++ efw-downloader/src/node-dispatcher.h | 21 + efw-downloader/src/op-device-read.c | 104 +++ efw-downloader/src/op-file-parse.c | 106 +++ efw-downloader/src/subcmd-device.c | 182 +++++ efw-downloader/src/subcmd-file.c | 87 +++ efw-downloader/src/subcmds.h | 16 + 23 files changed, 2822 insertions(+) create mode 100644 efw-downloader/COPYING create mode 100644 efw-downloader/README.rst create mode 100644 efw-downloader/man/efw-downloader.1 create mode 100644 efw-downloader/meson.build create mode 100644 efw-downloader/meson_options.txt create mode 100644 efw-downloader/src/config-rom.c create mode 100644 efw-downloader/src/config-rom.h create mode 100644 efw-downloader/src/efw-commands.c create mode 100644 efw-downloader/src/efw-commands.h create mode 100644 efw-downloader/src/efw-proto-sigs-marshal.list create mode 100644 efw-downloader/src/efw-proto.c create mode 100644 efw-downloader/src/efw-proto.h create mode 100644 efw-downloader/src/file-cntr.c create mode 100644 efw-downloader/src/file-cntr.h create mode 100644 efw-downloader/src/main.c create mode 100644 efw-downloader/src/meson.build create mode 100644 efw-downloader/src/node-dispatcher.c create mode 100644 efw-downloader/src/node-dispatcher.h create mode 100644 efw-downloader/src/op-device-read.c create mode 100644 efw-downloader/src/op-file-parse.c create mode 100644 efw-downloader/src/subcmd-device.c create mode 100644 efw-downloader/src/subcmd-file.c create mode 100644 efw-downloader/src/subcmds.h
Fireworks board module was designed by Echo Digital Audio corporation. The board module has on-board flash memory to store firmware blob and session data. The contents of flash memory can be operated by software by a pair of asynchronous transactions defined by Echo Digital Audio corporation.
The firmware blob is used by below ICs:
* Texus Instruments TSB43Cx43A (IceLynx Micro) * Texus Instruments TMS320C6713B (DSP) * Xilinx Spartan XC35250E (FPGA)
All of Fireworks models use the IceLynx Micro for packet processing on IEEE 1394 bus. On the other hand, a part of the models use the DSP and the others use FPGA. The vendors of models ships several versions of a set of firmware.
This project produces a command-line tool named as 'efw-downloader' to operate contents of on-board flash memory for firmware of the above ICs. This software is licensed under the GNU public license v3.0 or later. Meson build system is used to build the tool.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/COPYING | 674 +++++++++++++++++++++++++++++++++ efw-downloader/meson.build | 10 + efw-downloader/src/main.c | 8 + efw-downloader/src/meson.build | 11 + 4 files changed, 703 insertions(+) create mode 100644 efw-downloader/COPYING create mode 100644 efw-downloader/meson.build create mode 100644 efw-downloader/src/main.c create mode 100644 efw-downloader/src/meson.build
diff --git a/efw-downloader/COPYING b/efw-downloader/COPYING new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/efw-downloader/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. https://fsf.org/ + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see https://www.gnu.org/licenses/. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +https://www.gnu.org/licenses/. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +https://www.gnu.org/licenses/why-not-lgpl.html. diff --git a/efw-downloader/meson.build b/efw-downloader/meson.build new file mode 100644 index 0000000..9664100 --- /dev/null +++ b/efw-downloader/meson.build @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# Copyright (c) 2020 Takashi Sakamoto + +project('efw-downloader', 'c', + version: '0.1.0', + license: 'GPL-3.0+', + meson_version: '>= 0.46.0', +) + +subdir('src') diff --git a/efw-downloader/src/main.c b/efw-downloader/src/main.c new file mode 100644 index 0000000..31ac349 --- /dev/null +++ b/efw-downloader/src/main.c @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include <stdlib.h> + +int main(int argc, char **argv) +{ + return EXIT_SUCCESS; +} diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build new file mode 100644 index 0000000..b837e92 --- /dev/null +++ b/efw-downloader/src/meson.build @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# Copyright (c) 2020 Takashi Sakamoto + +sources = [ + 'main.c', +] + +executable('efw-downloader', + sources: sources, + install: true, +)
Echo Digital Audio corporation designed specific protocol to operate Fireworks board module. The protocol includes a pair of asynchronous transactions on IEEE 1394 bus to transfer command frame and receive response frame.
This commit adds EfwProto GObject object. This object inherits HinawaFwResp to receive the response frame from Linux 1394 OHCI driver, thus libglib-2.0, libgobject-2.0 and libhinawa 2.1 is added for build and runtime dependency.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/efw-proto.c | 25 +++++++++++++++++++++ efw-downloader/src/efw-proto.h | 40 ++++++++++++++++++++++++++++++++++ efw-downloader/src/meson.build | 21 +++++++++++++++++- 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 efw-downloader/src/efw-proto.c create mode 100644 efw-downloader/src/efw-proto.h
diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c new file mode 100644 index 0000000..63fd2c5 --- /dev/null +++ b/efw-downloader/src/efw-proto.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include "efw-proto.h" + +/** + * SECTION:efw_proto + * @Title: EfwProto + * @Short_description: Transaction implementation for Fireworks protocol + * @include: fw_fcp.h + * + * Fireworks board module from Echo Digital Audio corporation supports specific protocol based on + * a pair of asynchronous transactions in IEEE 1394 bus. The EfwProto class is an implementation + * for the protocol. + */ +G_DEFINE_TYPE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP) + +static void efw_proto_class_init(EfwProtoClass *klass) +{ + return; +} + +static void efw_proto_init(EfwProto *self) +{ + return; +} diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h new file mode 100644 index 0000000..83e52be --- /dev/null +++ b/efw-downloader/src/efw-proto.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __EFW_PROTO_H__ +#define __EFW_PROTO_H__ + +#include <glib.h> +#include <glib-object.h> + +#include <libhinawa/fw_resp.h> + +G_BEGIN_DECLS + +#define EFW_TYPE_PROTO (efw_proto_get_type()) + +#define EFW_PROTO(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), EFW_TYPE_PROTO, EfwProto)) +#define EFW_IS_PROTO(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), EFW_TYPE_PROTO)) + +#define EFW_PROTO_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), EFW_TYPE_PROTO, EfwProtoClass)) +#define EFW_IS_PROTO_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), EFW_TYPE_PROTO)) +#define EFW_PROTO_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), EFW_TYPE_PROTO, EfwProtoClass)) + +typedef struct _EfwProto EfwProto; +typedef struct _EfwProtoClass EfwProtoClass; + +struct _EfwProto { + HinawaFwResp parent_instance; +}; + +struct _EfwProtoClass { + HinawaFwRespClass parent_class; +}; + +G_END_DECLS + +#endif diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index b837e92..b7992a2 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -1,11 +1,30 @@ # SPDX-License-Identifier: GPL-3.0-or-later # Copyright (c) 2020 Takashi Sakamoto
+# Depends on glib-2.0 and gobject-2.0. +gobject = dependency('gobject-2.0', + version: '>=2.34.0', +) + +# Depends on libhinawa v2.1.0 or later. +hinawa = dependency('hinawa', + version: '>=2.1', +) + sources = [ 'main.c', + 'efw-proto.c', +] + +headers = [ + 'efw-proto.h', ]
executable('efw-downloader', - sources: sources, + sources: sources + headers, + dependencies: [ + gobject, + hinawa, + ], install: true, )
In Fireworks protocol, response frame from target device arrives at offset 0xecc080000000 on 1394 OHCI controller and the maximum size is 0x200U. It seems to be inspired by Function Control Protocol in IEC 61883-1.
This commit adds functions to construct and destruct the instance of EfwProto object, to bind and unbind the Fireworks protocol to the the given instance of HinawaFwNode. When calling the bind function, the instance requests Linux firewire subsystem to allocate the range of address. It's possible to encounter conflict in the case that the range of address is also allocated by ALSA fireworks driver, thus this tool can not be used when the driver is loaded.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/efw-proto.c | 62 ++++++++++++++++++++++++++++++++-- efw-downloader/src/efw-proto.h | 5 +++ 2 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index 63fd2c5..a6a6055 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -9,17 +9,73 @@ * @include: fw_fcp.h * * Fireworks board module from Echo Digital Audio corporation supports specific protocol based on - * a pair of asynchronous transactions in IEEE 1394 bus. The EfwProto class is an implementation - * for the protocol. + * a pair of asynchronous transactions in IEEE 1394 bus for command and response. The #EfwProto class + * is an implementation for the protocol. The Fireworks device transfers response against the + * command to a certain address region on 1394 OHCI controller. The instance of #EfwProto reserves + * the address region at call of #efw_proto_bind(), releases at call of #efw_proto_unbind(). */ G_DEFINE_TYPE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP)
+#define EFW_RESP_ADDR 0xecc080000000ull +#define EFW_MAX_FRAME_SIZE 0x200u + +static void proto_finalize(GObject *obj) +{ + EfwProto *self = EFW_PROTO(obj); + + efw_proto_unbind(self); + + G_OBJECT_CLASS(efw_proto_parent_class)->finalize(obj); +} + static void efw_proto_class_init(EfwProtoClass *klass) { - return; + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->finalize = proto_finalize; }
static void efw_proto_init(EfwProto *self) { return; } + +/** + * efw_proto_new: + * + * Instantiate and return #EfwProto object. + * + * Returns: An instance of #EfwProto. + */ +EfwProto *efw_proto_new() +{ + return g_object_new(EFW_TYPE_PROTO, NULL); +} + +/** + * efw_proto_bind: + * @self: A #EfwProto. + * @node: A #HinawaFwNode. + * @error: A #GError. The error can be generated with domain of #hinawa_fw_node_error_quark(). + * + * Bind to Fireworks protocol for communication to the given node. + */ +void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error) +{ + g_return_if_fail(EFW_IS_PROTO(self)); + + hinawa_fw_resp_reserve(HINAWA_FW_RESP(self), node, EFW_RESP_ADDR, EFW_MAX_FRAME_SIZE, error); +} + +/** + * efw_proto_unbind: + * @self: A #EfwProto. + * + * Unbind from Fireworks protocol. + */ +void efw_proto_unbind(EfwProto *self) +{ + g_return_if_fail(EFW_IS_PROTO(self)); + + hinawa_fw_resp_release(HINAWA_FW_RESP(self)); +} diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index 83e52be..b0e519d 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -35,6 +35,11 @@ struct _EfwProtoClass { HinawaFwRespClass parent_class; };
+EfwProto *efw_proto_new(); + +void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error); +void efw_proto_unbind(EfwProto *self); + G_END_DECLS
#endif
GObject has a feature of 'signal'. It's emitted in event dispatcher asynchronously to application which register own callback function in advance.
This commit adds 'responded' GObject signal to handle data in response frame. In future commit, the signal is emitted actually.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- .../src/efw-proto-sigs-marshal.list | 1 + efw-downloader/src/efw-proto.c | 32 +++++++++++++++++++ efw-downloader/src/efw-proto.h | 1 + efw-downloader/src/meson.build | 8 +++++ 4 files changed, 42 insertions(+) create mode 100644 efw-downloader/src/efw-proto-sigs-marshal.list
diff --git a/efw-downloader/src/efw-proto-sigs-marshal.list b/efw-downloader/src/efw-proto-sigs-marshal.list new file mode 100644 index 0000000..c489d58 --- /dev/null +++ b/efw-downloader/src/efw-proto-sigs-marshal.list @@ -0,0 +1 @@ +VOID:ENUM,UINT,UINT,UINT,POINTER,UINT diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index a6a6055..6502957 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later // Copyright (c) 2020 Takashi Sakamoto #include "efw-proto.h" +#include "efw-proto-sigs-marshal.h"
/** * SECTION:efw_proto @@ -19,6 +20,12 @@ G_DEFINE_TYPE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP) #define EFW_RESP_ADDR 0xecc080000000ull #define EFW_MAX_FRAME_SIZE 0x200u
+enum efw_proto_sig_type { + EFW_PROTO_SIG_TYPE_RESPONDED = 1, + EFW_PROTO_SIG_COUNT, +}; +static guint efw_proto_sigs[EFW_PROTO_SIG_COUNT] = { 0 }; + static void proto_finalize(GObject *obj) { EfwProto *self = EFW_PROTO(obj); @@ -33,6 +40,31 @@ static void efw_proto_class_init(EfwProtoClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
gobject_class->finalize = proto_finalize; + + /** + * EfwProto::responded: + * @self: A #EfwProto. + * @status: One of #HinawaSndEfwStatus. + * @seqnum: The sequence number of response. + * @category: The value of category field in the response. + * @command: The value of command field in the response. + * @frame: (array length=frame_size)(element-type guint32): The array with elements for + * quadlet data of response for Echo Fireworks protocol. + * @frame_size: The number of elements of the array. + * + * When the unit transfers asynchronous packet as response for Fireworks protocol, and the + * process successfully reads the content of response from ALSA Fireworks driver, the + * #EfwProto::responded signal handler is called with parameters of the response. + */ + efw_proto_sigs[EFW_PROTO_SIG_TYPE_RESPONDED] = + g_signal_new("responded", + G_OBJECT_CLASS_TYPE(klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + efw_proto_sigs_marshal_VOID__ENUM_UINT_UINT_UINT_POINTER_UINT, + G_TYPE_NONE, + 6, HINAWA_TYPE_SND_EFW_STATUS, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_POINTER, G_TYPE_UINT); }
static void efw_proto_init(EfwProto *self) diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index b0e519d..fbd4366 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -7,6 +7,7 @@ #include <glib-object.h>
#include <libhinawa/fw_resp.h> +#include <libhinawa/hinawa_enum_types.h>
G_BEGIN_DECLS
diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index b7992a2..ca894d9 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -20,6 +20,14 @@ headers = [ 'efw-proto.h', ]
+gnome = import('gnome') +marshallers = gnome.genmarshal('efw-proto-sigs-marshal', + prefix: 'efw_proto_sigs_marshal', + sources: 'efw-proto-sigs-marshal.list', + stdinc: true, +) +sources += marshallers + executable('efw-downloader', sources: sources + headers, dependencies: [
GObject allows applications to override class virtual method with own method implementation in inheritance.
This commit adds the class virtual method to handle 'responded' signal added in the former commit.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/efw-proto.c | 2 +- efw-downloader/src/efw-proto.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index 6502957..72b7655 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -60,7 +60,7 @@ static void efw_proto_class_init(EfwProtoClass *klass) g_signal_new("responded", G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, - 0, + G_STRUCT_OFFSET(EfwProtoClass, responded), NULL, NULL, efw_proto_sigs_marshal_VOID__ENUM_UINT_UINT_UINT_POINTER_UINT, G_TYPE_NONE, diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index fbd4366..fdbcbc8 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -34,6 +34,24 @@ struct _EfwProto {
struct _EfwProtoClass { HinawaFwRespClass parent_class; + + /** + * EfwProtoClass::responded: + * @self: A #EfwProto. + * @status: One of #HinawaSndEfwStatus. + * @seqnum: The sequence number of response. + * @category: The value of category field in the response. + * @command: The value of command field in the response. + * @frame: (array length=frame_size)(element-type guint32): The array with elements for + * quadlet data of response for Echo Fireworks protocol. + * @frame_size: The number of elements of the array. + * + * When the unit transfers asynchronous packet as response for Fireworks protocol, and the + * process successfully reads the content of response from ALSA Fireworks driver, the + * #EfwProto::responded signal handler is called with parameters of the response. + */ + void (*responded)(EfwProto *self, HinawaSndEfwStatus status, guint seqnum, + guint category, guint command, const guint32 *frame, guint frame_size); };
EfwProto *efw_proto_new();
GObject allows instance to have private data.
This commit adds private structure to EfwProto instance.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/efw-proto.c | 17 ++++++++++++++++- efw-downloader/src/efw-proto.h | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index 72b7655..72959ac 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -15,7 +15,10 @@ * command to a certain address region on 1394 OHCI controller. The instance of #EfwProto reserves * the address region at call of #efw_proto_bind(), releases at call of #efw_proto_unbind(). */ -G_DEFINE_TYPE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP) +struct _EfwProtoPrivate { + guint32 *buf; +}; +G_DEFINE_TYPE_WITH_PRIVATE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP)
#define EFW_RESP_ADDR 0xecc080000000ull #define EFW_MAX_FRAME_SIZE 0x200u @@ -94,9 +97,16 @@ EfwProto *efw_proto_new() */ void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error) { + EfwProtoPrivate *priv; + g_return_if_fail(EFW_IS_PROTO(self)); + priv = efw_proto_get_instance_private(self);
hinawa_fw_resp_reserve(HINAWA_FW_RESP(self), node, EFW_RESP_ADDR, EFW_MAX_FRAME_SIZE, error); + if (*error != NULL) + return; + + priv->buf = g_malloc0(EFW_MAX_FRAME_SIZE); }
/** @@ -107,7 +117,12 @@ void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error) */ void efw_proto_unbind(EfwProto *self) { + EfwProtoPrivate *priv; + g_return_if_fail(EFW_IS_PROTO(self)); + priv = efw_proto_get_instance_private(self);
hinawa_fw_resp_release(HINAWA_FW_RESP(self)); + + g_free(priv->buf); } diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index fdbcbc8..bc179dc 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -27,9 +27,12 @@ G_BEGIN_DECLS
typedef struct _EfwProto EfwProto; typedef struct _EfwProtoClass EfwProtoClass; +typedef struct _EfwProtoPrivate EfwProtoPrivate;
struct _EfwProto { HinawaFwResp parent_instance; + + EfwProtoPrivate *priv; };
struct _EfwProtoClass {
HinawaFwResp has class virtual method for applications to handle received frame on 1394 OHCI controller by overriding the method with own function implementation.
This commit overrides the class virtual method and emits 'responded' signal with the data of received response frame. The content of frame is aligned to host-endianness, then passed to signal handlers.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/efw-proto.c | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index 72959ac..bef81b3 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -3,6 +3,8 @@ #include "efw-proto.h" #include "efw-proto-sigs-marshal.h"
+#include <sound/firewire.h> + /** * SECTION:efw_proto * @Title: EfwProto @@ -38,12 +40,16 @@ static void proto_finalize(GObject *obj) G_OBJECT_CLASS(efw_proto_parent_class)->finalize(obj); }
+static HinawaFwRcode proto_handle_response(HinawaFwResp *resp, HinawaFwTcode tcode); + static void efw_proto_class_init(EfwProtoClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
gobject_class->finalize = proto_finalize;
+ HINAWA_FW_RESP_CLASS(klass)->requested = proto_handle_response; + /** * EfwProto::responded: * @self: A #EfwProto. @@ -126,3 +132,40 @@ void efw_proto_unbind(EfwProto *self)
g_free(priv->buf); } + +static HinawaFwRcode proto_handle_response(HinawaFwResp *resp, HinawaFwTcode tcode) +{ + EfwProto *self = EFW_PROTO(resp); + EfwProtoPrivate *priv = efw_proto_get_instance_private(self); + const guint8 *req_frame = NULL; + gsize length = 0; + const struct snd_efw_transaction *frame; + guint status; + guint seqnum; + guint category; + guint command; + guint param_count; + int i; + + hinawa_fw_resp_get_req_frame(resp, &req_frame, &length); + if (length < sizeof(*frame)) + return HINAWA_FW_RCODE_DATA_ERROR; + frame = (const struct snd_efw_transaction *)req_frame; + + status = GUINT32_FROM_BE(frame->status); + if (status > HINAWA_SND_EFW_STATUS_BAD_PARAMETER) + status = HINAWA_SND_EFW_STATUS_BAD; + + seqnum = GUINT32_FROM_BE(frame->seqnum); + category = GUINT32_FROM_BE(frame->category); + command = GUINT32_FROM_BE(frame->command); + param_count = GUINT32_FROM_BE(frame->length) - sizeof(*frame) / sizeof(guint32); + + for (i = 0; i < param_count; ++i) + priv->buf[i] = GUINT32_FROM_BE(frame->params[i]); + + g_signal_emit(self, efw_proto_sigs[EFW_PROTO_SIG_TYPE_RESPONDED], 0, + status, seqnum, category, command, priv->buf, param_count); + + return HINAWA_FW_RCODE_COMPLETE; +}
In Fireworks protocol, asynchronous transaction is used to deliver command frame from software to device. The transaction is done to offset 0xecc000000000 with variable length of data up to 0x200.
The transaction includes header and data in its payload. The header includes sequence field. The target device increments the value of sequence field, then transfers response frame with the value so that software can correspond the response frame with command frame according to the sequence numbers. The header also includes version field but version 1 is always used as long as I investigate. The header includes category and command field to determine the type of data. The status field is used to report operation result from the target device.
This commit adds a function to finish transaction for command frame.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/efw-proto.c | 86 +++++++++++++++++++++++++++++++++- efw-downloader/src/efw-proto.h | 4 ++ 2 files changed, 89 insertions(+), 1 deletion(-)
diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index bef81b3..cb8dad1 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -5,6 +5,8 @@
#include <sound/firewire.h>
+#include <libhinawa/fw_req.h> + /** * SECTION:efw_proto * @Title: EfwProto @@ -19,11 +21,16 @@ */ struct _EfwProtoPrivate { guint32 *buf; + guint32 seqnum; + HinawaFwNode *node; + GMutex mutex; }; G_DEFINE_TYPE_WITH_PRIVATE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP)
+#define EFW_CMD_ADDR 0xecc000000000ull #define EFW_RESP_ADDR 0xecc080000000ull #define EFW_MAX_FRAME_SIZE 0x200u +#define MINIMUM_VERSION 1
enum efw_proto_sig_type { EFW_PROTO_SIG_TYPE_RESPONDED = 1, @@ -34,9 +41,12 @@ static guint efw_proto_sigs[EFW_PROTO_SIG_COUNT] = { 0 }; static void proto_finalize(GObject *obj) { EfwProto *self = EFW_PROTO(obj); + EfwProtoPrivate *priv = efw_proto_get_instance_private(self);
efw_proto_unbind(self);
+ g_mutex_clear(&priv->mutex); + G_OBJECT_CLASS(efw_proto_parent_class)->finalize(obj); }
@@ -78,7 +88,10 @@ static void efw_proto_class_init(EfwProtoClass *klass)
static void efw_proto_init(EfwProto *self) { - return; + EfwProtoPrivate *priv = efw_proto_get_instance_private(self); + + priv->seqnum = 0; + g_mutex_init(&priv->mutex); }
/** @@ -113,6 +126,7 @@ void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error) return;
priv->buf = g_malloc0(EFW_MAX_FRAME_SIZE); + priv->node = node; }
/** @@ -131,6 +145,76 @@ void efw_proto_unbind(EfwProto *self) hinawa_fw_resp_release(HINAWA_FW_RESP(self));
g_free(priv->buf); + priv->buf = NULL; + priv->node = NULL; +} + +/** + * efw_proto_command: + * @self: A #EfwProto. + * @category: One of category for the transaction. + * @command: One of category for the transaction. + * @args: (array length=arg_count)(nullable): An array with elements for quadlet data as arguments + * for command. + * @arg_count: The number of quadlets in the args array. + * @resp_seqnum: (out): The sequence number for response transaction. + * @error: A #GError. Error can be generated with two domains of #hinawa_fw_req_error_quark() and + * #hinawa_fw_req_error_quark(). + * + * Transfer asynchronous transaction for command frame of Fireworks protocol. When receiving + * asynchronous transaction for response frame, #EfwProto::responded GObject signal is emitted. + */ +void efw_proto_command(EfwProto *self, guint category, guint command, + const guint32 *args, gsize arg_count, guint32 *resp_seqnum, + GError **error) +{ + EfwProtoPrivate *priv; + HinawaFwReq *req; + gsize length; + struct snd_efw_transaction *frame; + int i; + + g_return_if_fail(EFW_IS_PROTO(self)); + g_return_if_fail(sizeof(*args) * arg_count + sizeof(*frame) < EFW_MAX_FRAME_SIZE); + g_return_if_fail(resp_seqnum != NULL); + g_return_if_fail(error == NULL || *error == NULL); + + priv = efw_proto_get_instance_private(self); + + length = sizeof(*frame); + if (args != NULL) + length += sizeof(guint32) * arg_count; + + frame = g_malloc0(length); + + // Fill request frame for transaction. + frame->length = GUINT32_TO_BE(length / sizeof(guint32)); + frame->version = GUINT32_TO_BE(MINIMUM_VERSION); + frame->category = GUINT32_TO_BE(category); + frame->command = GUINT32_TO_BE(command); + if (args != NULL) { + for (i = 0; i < arg_count; ++i) + frame->params[i] = GUINT32_TO_BE(args[i]); + } + + // Increment the sequence number for next transaction. + g_mutex_lock(&priv->mutex); + frame->seqnum = GUINT32_TO_BE(priv->seqnum); + *resp_seqnum = priv->seqnum + 1; + priv->seqnum += 2; + if (priv->seqnum > SND_EFW_TRANSACTION_USER_SEQNUM_MAX) + priv->seqnum = 0; + g_mutex_unlock(&priv->mutex); + + // Send this request frame. + req = hinawa_fw_req_new(); + + hinawa_fw_req_transaction_sync(req, priv->node, HINAWA_FW_TCODE_WRITE_BLOCK_REQUEST, + EFW_CMD_ADDR, length, (guint8 *const *)&frame, &length, 100, + error); + + g_object_unref(req); + g_free(frame); }
static HinawaFwRcode proto_handle_response(HinawaFwResp *resp, HinawaFwTcode tcode) diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index bc179dc..94f4a94 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -62,6 +62,10 @@ EfwProto *efw_proto_new(); void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error); void efw_proto_unbind(EfwProto *self);
+void efw_proto_command(EfwProto *self, guint category, guint command, + const guint32 *args, gsize arg_count, guint32 *resp_seqnum, + GError **exception); + G_END_DECLS
#endif
In Fireworks protocol, the target device increments sequence number in command frame transferred by software, then transfers response frame with the number so that software can correspond the response frame to the command frame.
This commit adds function to finish the pair of transactions for command and response frames. The frames are matched according to sequence number.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/efw-proto.c | 146 +++++++++++++++++++++++++++++++++ efw-downloader/src/efw-proto.h | 9 ++ 2 files changed, 155 insertions(+)
diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index cb8dad1..f8c1d88 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -27,6 +27,15 @@ struct _EfwProtoPrivate { }; G_DEFINE_TYPE_WITH_PRIVATE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP)
+/** + * efw_proto_error_quark: + * + * Return the GQuark for error domain of GError which has code in #HinawaSndEfwStatus. + * + * Returns: A #GQuark. + */ +G_DEFINE_QUARK(efw-proto-error-quark, efw_proto_error) + #define EFW_CMD_ADDR 0xecc000000000ull #define EFW_RESP_ADDR 0xecc080000000ull #define EFW_MAX_FRAME_SIZE 0x200u @@ -217,6 +226,143 @@ void efw_proto_command(EfwProto *self, guint category, guint command, g_free(frame); }
+struct waiter { + guint32 seqnum; + + guint32 category; + guint32 command; + HinawaSndEfwStatus status; + guint32 *params; + gsize param_count; + + GCond cond; + GMutex mutex; +}; + +static void handle_responded_signal(EfwProto *self, HinawaSndEfwStatus status, guint32 seqnum, + guint category, guint command, + const guint32 *params, guint32 param_count, gpointer user_data) +{ + struct waiter *w = (struct waiter *)user_data; + + if (seqnum == w->seqnum) { + g_mutex_lock(&w->mutex); + + if (category != w->category || command != w->command) + status = HINAWA_SND_EFW_STATUS_BAD; + w->status = status; + + if (param_count > 0 && param_count <= w->param_count) + memcpy(w->params, params, param_count * sizeof(*params)); + w->param_count = param_count; + + g_cond_signal(&w->cond); + + g_mutex_unlock(&w->mutex); + } +} + +static const char *const err_msgs[] = { + [HINAWA_SND_EFW_STATUS_OK] = "The transaction finishes successfully", + [HINAWA_SND_EFW_STATUS_BAD] = "The request or response includes invalid header", + [HINAWA_SND_EFW_STATUS_BAD_COMMAND] = "The request includes invalid category or command", + [HINAWA_SND_EFW_STATUS_COMM_ERR] = "The transaction fails due to communication error", + [HINAWA_SND_EFW_STATUS_BAD_QUAD_COUNT] = "The number of quadlets in transaction is invalid", + [HINAWA_SND_EFW_STATUS_UNSUPPORTED] = "The request is not supported", + [HINAWA_SND_EFW_STATUS_TIMEOUT] = "The transaction is canceled due to response timeout", + [HINAWA_SND_EFW_STATUS_DSP_TIMEOUT] = "The operation for DSP did not finish within timeout", + [HINAWA_SND_EFW_STATUS_BAD_RATE] = "The request includes invalid value for sampling frequency", + [HINAWA_SND_EFW_STATUS_BAD_CLOCK] = "The request includes invalid value for source of clock", + [HINAWA_SND_EFW_STATUS_BAD_CHANNEL] = "The request includes invalid value for the number of channel", + [HINAWA_SND_EFW_STATUS_BAD_PAN] = "The request includes invalid value for panning", + [HINAWA_SND_EFW_STATUS_FLASH_BUSY] = "The on-board flash is busy and not operable", + [HINAWA_SND_EFW_STATUS_BAD_MIRROR] = "The request includes invalid value for mirroring channel", + [HINAWA_SND_EFW_STATUS_BAD_LED] = "The request includes invalid value for LED", + [HINAWA_SND_EFW_STATUS_BAD_PARAMETER] = "The request includes invalid value of parameter", + [HINAWA_SND_EFW_STATUS_LARGE_RESP] = "The size of response is larger than expected", +}; + +#define generate_error(error, code) \ + g_set_error_literal(error, EFW_PROTO_ERROR, code, err_msgs[code]) + +/** + * efw_proto_transaction: + * @self: A #EfwProto. + * @category: One of category for the transaction. + * @command: One of category for the transaction. + * @args: (array length=arg_count)(nullable): An array with elements for quadlet data as arguments + * for command. + * @arg_count: The number of quadlets in the args array. + * @params: (array length=param_count)(inout)(nullable): An array with elements for quadlet data to + * save parameters in response frame. + * @param_count: The number of quadlets in the params array. + * @timeout_ms: The timeout to wait for response of the transaction since request is initiated, in + * milliseconds. + * @error: A #GError. Error can be generated with two domains of #hinawa_fw_node_error_quark(), + * #hinawa_fw_req_error_quark(), and #efw_proto_error_quark(). + * + * Transfer asynchronous transaction for command frame of Fireworks protocol. When receiving + * asynchronous transaction for response frame, #EfwProto::responded GObject signal is emitted. + */ +void efw_proto_transaction(EfwProto *self, guint category, guint command, + const guint32 *args, gsize arg_count, + guint32 *const *params, gsize *param_count, + guint timeout_ms, GError **error) +{ + gulong handler_id; + struct waiter w; + guint64 expiration; + + g_return_if_fail(EFW_IS_PROTO(self)); + g_return_if_fail(param_count != NULL); + g_return_if_fail(error == NULL || *error == NULL); + + // This predicates against suprious wakeup. + w.status = 0xffffffff; + w.category = category; + w.command = command; + if (*param_count > 0) + w.params = *params; + else + w.params = NULL; + w.param_count = *param_count; + g_cond_init(&w.cond); + g_mutex_init(&w.mutex); + + handler_id = g_signal_connect(self, "responded", (GCallback)handle_responded_signal, &w); + + // Timeout is set in advance as a parameter of this object. + expiration = g_get_monotonic_time() + timeout_ms * G_TIME_SPAN_MILLISECOND; + + efw_proto_command(self, category, command, args, arg_count, &w.seqnum, error); + if (*error != NULL) { + g_signal_handler_disconnect(self, handler_id); + goto end; + } + + g_mutex_lock(&w.mutex); + while (w.status == 0xffffffff) { + // Wait for a response with timeout, waken by the response handler. + if (!g_cond_wait_until(&w.cond, &w.mutex, expiration)) + break; + } + g_signal_handler_disconnect(self, handler_id); + g_mutex_unlock(&w.mutex); + + if (w.status == 0xffffffff) + generate_error(error, HINAWA_SND_EFW_STATUS_TIMEOUT); + else if (w.status != HINAWA_SND_EFW_STATUS_OK) + generate_error(error, w.status); + else if (w.param_count > *param_count) + generate_error(error, HINAWA_SND_EFW_STATUS_LARGE_RESP); + else + *param_count = w.param_count; +end: + g_cond_clear(&w.cond); + g_mutex_clear(&w.mutex); +} + + static HinawaFwRcode proto_handle_response(HinawaFwResp *resp, HinawaFwTcode tcode) { EfwProto *self = EFW_PROTO(resp); diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index 94f4a94..0b700a8 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -57,6 +57,10 @@ struct _EfwProtoClass { guint category, guint command, const guint32 *frame, guint frame_size); };
+#define EFW_PROTO_ERROR efw_proto_error_quark() + +GQuark efw_proto_error_quark(); + EfwProto *efw_proto_new();
void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error); @@ -66,6 +70,11 @@ void efw_proto_command(EfwProto *self, guint category, guint command, const guint32 *args, gsize arg_count, guint32 *resp_seqnum, GError **exception);
+void efw_proto_transaction(EfwProto *self, guint category, guint command, + const guint32 *args, gsize arg_count, + guint32 *const *params, gsize *param_count, + guint timeout_ms, GError **error); + G_END_DECLS
#endif
This tool consists of sub commands for different functionalities.
This commit adds parser for sub commands. Actual implementation for each sub command will be added in future commits.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/main.c | 42 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/efw-downloader/src/main.c b/efw-downloader/src/main.c index 31ac349..499e67e 100644 --- a/efw-downloader/src/main.c +++ b/efw-downloader/src/main.c @@ -1,8 +1,48 @@ // SPDX-License-Identifier: GPL-3.0-or-later // Copyright (c) 2020 Takashi Sakamoto +#include <stdio.h> #include <stdlib.h> +#include <string.h> + +static void print_help() +{ + printf("Usage\n" + " efw-downloader SUBCOMMAND OPTIONS\n" + "\n" + "where:\n" + " SUBCOMMAND:\n" + " help: print help\n" + " OPTIONS: optional arguments dependent on the subcommand\n"); +}
int main(int argc, char **argv) { - return EXIT_SUCCESS; + static const struct { + const char *name; + size_t size; + int (*op)(int argc, char **argv); + } *entry, entries[] = { + }; + const char *subcmd; + int i; + + if (argc < 2) { + print_help(); + return EXIT_FAILURE; + } + subcmd = argv[1]; + + for (i = 0; i < sizeof(entries) / sizeof(entries[0]); ++i) { + entry = entries + i; + if (strncmp(subcmd, entry->name, entry->size) == 0) { + entry = &entries[i]; + break; + } + } + if (i == sizeof(entries) / sizeof(entries[0])) { + print_help(); + return EXIT_FAILURE; + } + + return entry->op(argc, argv); }
This commit implements 'device' sub command to operate the target device. This sub command consists of several operations and parser for the operation will be implemented in future commits.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/main.c | 4 ++ efw-downloader/src/meson.build | 2 + efw-downloader/src/subcmd-device.c | 77 ++++++++++++++++++++++++++++++ efw-downloader/src/subcmds.h | 8 ++++ 4 files changed, 91 insertions(+) create mode 100644 efw-downloader/src/subcmd-device.c create mode 100644 efw-downloader/src/subcmds.h
diff --git a/efw-downloader/src/main.c b/efw-downloader/src/main.c index 499e67e..e150cc8 100644 --- a/efw-downloader/src/main.c +++ b/efw-downloader/src/main.c @@ -4,6 +4,8 @@ #include <stdlib.h> #include <string.h>
+#include "subcmds.h" + static void print_help() { printf("Usage\n" @@ -11,6 +13,7 @@ static void print_help() "\n" "where:\n" " SUBCOMMAND:\n" + " device: operate for device for unit on IEEE 1394 bus\n" " help: print help\n" " OPTIONS: optional arguments dependent on the subcommand\n"); } @@ -22,6 +25,7 @@ int main(int argc, char **argv) size_t size; int (*op)(int argc, char **argv); } *entry, entries[] = { + { "device", sizeof("device"), subcmd_device }, }; const char *subcmd; int i; diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index ca894d9..07a6182 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -14,10 +14,12 @@ hinawa = dependency('hinawa', sources = [ 'main.c', 'efw-proto.c', + 'subcmd-device.c', ]
headers = [ 'efw-proto.h', + 'subcmds.h', ]
gnome = import('gnome') diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c new file mode 100644 index 0000000..739944e --- /dev/null +++ b/efw-downloader/src/subcmd-device.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <assert.h> + +#include "efw-proto.h" + +static int print_help() +{ + printf("Usage\n" + " efw-downloader device CDEV OPERATION ARGUMENTS\n" + "\n" + "where:\n" + " CDEV: The firewire character device corresponding to the node for transaction\n" + " OPERATION:\n" + " help: print this help message\n" + " ARGUMENTS:\n" + " depending on OPERATION\n" + "\n"); + return EXIT_FAILURE; +} + +static int parse_args(int argc, char **argv, const char **path, const char **op_name) +{ + if (argc < 2) + return -EINVAL; + assert(strncmp(argv[1], "device", sizeof("device")) == 0); + + if (argc < 3) + return -EINVAL; + *path = argv[2]; + + if (argc < 4) + return -EINVAL; + *op_name = argv[3]; + + return 0; +} + +int subcmd_device(int argc, char **argv) +{ + struct { + const char *name; + size_t size; + void (*op)(int argc, char **argv, EfwProto *proto, GError **error); + } *entry, entries[] = { + }; + GError *error = NULL; + const char *path; + const char *op_name; + EfwProto *proto; + int err; + int i; + + err = parse_args(argc, argv, &path, &op_name); + if (err < 0) + return print_help(0, NULL, NULL, NULL); + + for (i = 0; i < G_N_ELEMENTS(entries); ++i) { + entry = entries + i; + if (strncmp(op_name, entry->name, entry->size) == 0) + break; + } + if (i == G_N_ELEMENTS(entries)) + return print_help(); + + entry->op(argc, argv, proto, &error); + + if (error != NULL) { + g_clear_error(&error); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/efw-downloader/src/subcmds.h b/efw-downloader/src/subcmds.h new file mode 100644 index 0000000..f10c420 --- /dev/null +++ b/efw-downloader/src/subcmds.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __SUBCMDS_H__ +#define __SUBCMDS_H__ + +int subcmd_device(int argc, char **argv); + +#endif
In device sub command, all of operations require actual communication to the target device. Linux firewire subsystem allows applications to do it via call of ioctl to firewire character device.
This commit opens firewire character device, with assist of HinawaFwNode.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/subcmd-device.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index 739944e..e1be025 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -7,6 +7,10 @@
#include "efw-proto.h"
+#define report_error(error, msg) \ + fprintf(stderr, "Fail to %s: %s %d %s\n", \ + msg, g_quark_to_string(error->domain), error->code, error->message) + static int print_help() { printf("Usage\n" @@ -50,6 +54,7 @@ int subcmd_device(int argc, char **argv) GError *error = NULL; const char *path; const char *op_name; + HinawaFwNode *node; EfwProto *proto; int err; int i; @@ -66,8 +71,22 @@ int subcmd_device(int argc, char **argv) if (i == G_N_ELEMENTS(entries)) return print_help();
+ node = hinawa_fw_node_new(); + hinawa_fw_node_open(node, path, &error); + if (error != NULL) { + if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) + fprintf(stderr, "File not found: %s\n", path); + else if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_ACCES)) + fprintf(stderr, "Permission denied: %s\n", path); + else + report_error(error, "open the node"); + goto err; + } + entry->op(argc, argv, proto, &error);
+ g_object_unref(node); +err: if (error != NULL) { g_clear_error(&error); return EXIT_FAILURE;
In IEEE 1394 bus, each node exposes the range of address for data. The data is used by the other node to identify the node. The data is named as configuration rom.
This commit adds helper function to parse the configuration rom to detect supported models.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/config-rom.c | 60 +++++++++++++++++++++++++++++++++ efw-downloader/src/config-rom.h | 26 ++++++++++++++ efw-downloader/src/meson.build | 2 ++ 3 files changed, 88 insertions(+) create mode 100644 efw-downloader/src/config-rom.c create mode 100644 efw-downloader/src/config-rom.h
diff --git a/efw-downloader/src/config-rom.c b/efw-downloader/src/config-rom.c new file mode 100644 index 0000000..ce37037 --- /dev/null +++ b/efw-downloader/src/config-rom.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include "config-rom.h" + +gboolean config_rom_detect_vendor_and_model(const guint8 *rom, guint32 *vendor_id, guint32 *model_id) +{ + gboolean detected = FALSE; + + if (rom[24] != 0x03) + return FALSE; + + *vendor_id = (rom[25] << 16) | (rom[26] << 8) | rom[27]; + + if (rom[32] != 0x17) + return FALSE; + + *model_id = (rom[33] << 16) | (rom[34] << 8) | rom[35]; + + switch (*vendor_id) { + case VENDOR_LOUD: + switch (*model_id) { + case MODEL_ONYX400F: + case MODEL_ONYX1200F: + detected = TRUE; + break; + default: + break; + } + break; + case VENDOR_ECHO_AUDIO: + switch (*model_id) { + case MODEL_AF2: + case MODEL_AF4: + case MODEL_AF8: + case MODEL_AF8P: + case MODEL_AF12: + case MODEL_AF12HD: + case MODEL_AF12_APPLE: + case MODEL_FWHDMI: + detected = TRUE; + break; + default: + break; + } + break; + case VENDOR_GIBSON: + switch (*model_id) { + case MODELRIP: + case MODELAUDIOPUNK: + detected = TRUE; + break; + default: + break; + } + default: + break; + } + + return detected; +} diff --git a/efw-downloader/src/config-rom.h b/efw-downloader/src/config-rom.h new file mode 100644 index 0000000..59bdc14 --- /dev/null +++ b/efw-downloader/src/config-rom.h @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __CONFIG_ROM_H__ +#define __CONFIG_ROM_H__ + +#include <glib.h> + +#define VENDOR_LOUD 0x000ff2 +#define MODEL_ONYX400F 0x00400f +#define MODEL_ONYX1200F 0x01200f +#define VENDOR_ECHO_AUDIO 0x001486 +#define MODEL_AF2 0x000af2 +#define MODEL_AF4 0x000af4 +#define MODEL_AF8 0x000af8 +#define MODEL_AF8P 0x000af9 +#define MODEL_AF12 0x00af12 +#define MODEL_AF12HD 0x0af12d +#define MODEL_AF12_APPLE 0x0af12a +#define MODEL_FWHDMI 0x00afd1 +#define VENDOR_GIBSON 0x00075b +#define MODELRIP 0x00afb2 +#define MODELAUDIOPUNK 0x00afb9 + +gboolean config_rom_detect_vendor_and_model(const guint8 *rom, guint32 *vendor_id, guint32 *model_id); + +#endif diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index 07a6182..c006c8b 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -14,11 +14,13 @@ hinawa = dependency('hinawa', sources = [ 'main.c', 'efw-proto.c', + 'config-rom.c', 'subcmd-device.c', ]
headers = [ 'efw-proto.h', + 'config-rom.h', 'subcmds.h', ]
This commit checks whether the device for node is supported models or not. When it's unsupported, the runtime exits with EXIT_FAILURE.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/subcmd-device.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index e1be025..b93d62d 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -6,6 +6,7 @@ #include <assert.h>
#include "efw-proto.h" +#include "config-rom.h"
#define report_error(error, msg) \ fprintf(stderr, "Fail to %s: %s %d %s\n", \ @@ -55,6 +56,9 @@ int subcmd_device(int argc, char **argv) const char *path; const char *op_name; HinawaFwNode *node; + const guint8 *rom; + gsize length; + guint32 vendor_id, model_id; EfwProto *proto; int err; int i; @@ -83,8 +87,21 @@ int subcmd_device(int argc, char **argv) goto err; }
- entry->op(argc, argv, proto, &error); + hinawa_fw_node_get_config_rom(node, &rom, &length, &error); + if (error != NULL) { + report_error(error, "get config rom"); + goto err_node; + }
+ if (!config_rom_detect_vendor_and_model(rom, &vendor_id, &model_id)) { + fprintf(stderr, "The node is not for Fireworks device: %s\n", path); + g_set_error_literal(&error, G_FILE_ERROR, g_file_error_from_errno(ENXIO), + "The node is not for Fireworks device"); + goto err_node; + } + + entry->op(argc, argv, proto, &error); +err_node: g_object_unref(node); err: if (error != NULL) {
This commit binds Fireworks protocol for the given node.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/subcmd-device.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index b93d62d..1bfa1f2 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -100,7 +100,26 @@ int subcmd_device(int argc, char **argv) goto err_node; }
+ proto = efw_proto_new(); + efw_proto_bind(proto, node, &error); + if (error != NULL) { + if (g_error_matches(error, HINAWA_FW_NODE_ERROR, HINAWA_FW_NODE_ERROR_FAILED)) { + if (strstr(error->message, "16") != NULL) { + fprintf(stderr, "The range of address on 1394 OHCI controller already used by " + "ALSA fireworks driver.\n"); + } else { + report_error(error, "bind protocol"); + } + } else { + report_error(error, "bind protocol"); + } + goto err_node; + } + entry->op(argc, argv, proto, &error); + + efw_proto_unbind(proto); + g_object_unref(proto); err_node: g_object_unref(node); err:
HinawaFwNode creates GSource for GLib MainContext. It's easy to GLib MainLoop as event dispatcher.
This commit adds local application of GLib MainContext/MainLoop to dispatch events for HinawaFwNode.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/meson.build | 2 + efw-downloader/src/node-dispatcher.c | 86 ++++++++++++++++++++++++++++ efw-downloader/src/node-dispatcher.h | 21 +++++++ efw-downloader/src/subcmd-device.c | 10 ++++ 4 files changed, 119 insertions(+) create mode 100644 efw-downloader/src/node-dispatcher.c create mode 100644 efw-downloader/src/node-dispatcher.h
diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index c006c8b..c43c332 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -15,12 +15,14 @@ sources = [ 'main.c', 'efw-proto.c', 'config-rom.c', + 'node-dispatcher.c', 'subcmd-device.c', ]
headers = [ 'efw-proto.h', 'config-rom.h', + 'node-dispatcher.h', 'subcmds.h', ]
diff --git a/efw-downloader/src/node-dispatcher.c b/efw-downloader/src/node-dispatcher.c new file mode 100644 index 0000000..8394600 --- /dev/null +++ b/efw-downloader/src/node-dispatcher.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include "node-dispatcher.h" +#include <time.h> + +struct thread_arg { + GMainLoop *loop; + GCond cond; + GMutex mutex; +}; + +static gpointer run_node_dispatcher(gpointer data) +{ + struct thread_arg *args = (struct thread_arg *)data; + + g_mutex_lock(&args->mutex); + g_cond_signal(&args->cond); + g_mutex_unlock(&args->mutex); + + g_main_loop_run(args->loop); + + return NULL; +} + +void node_dispatcher_start(struct node_dispatcher *dispatcher, HinawaFwNode *node, GError **error) +{ + struct thread_arg args; + GSource *src; + + dispatcher->ctx = g_main_context_new(); + + hinawa_fw_node_create_source(node, &src, error); + if (*error != NULL) + return; + + g_source_attach(src, dispatcher->ctx); + g_source_unref(src); + + dispatcher->loop = g_main_loop_new(dispatcher->ctx, FALSE); + + args.loop = dispatcher->loop; + g_cond_init(&args.cond); + g_mutex_init(&args.mutex); + + dispatcher->th = g_thread_try_new("node-dispatcher", run_node_dispatcher, &args, error); + if (*error != NULL) { + g_main_loop_quit(dispatcher->loop); + g_main_loop_unref(dispatcher->loop); + dispatcher->loop = NULL; + + g_main_context_unref(dispatcher->ctx); + dispatcher->ctx = NULL; + + goto end; + } + + g_mutex_lock(&args.mutex); + while (!g_main_loop_is_running(dispatcher->loop)) + g_cond_wait(&args.cond, &args.mutex); + g_mutex_unlock(&args.mutex); +end: + g_cond_clear(&args.cond); + g_mutex_clear(&args.mutex); +} + +void node_dispatcher_stop(struct node_dispatcher *dispatcher) +{ + if (dispatcher->loop != NULL) + g_main_loop_quit(dispatcher->loop); + + if (dispatcher->th != NULL) { + g_thread_join(dispatcher->th); + g_thread_unref(dispatcher->th); + dispatcher->th = NULL; + } + + if (dispatcher->loop != NULL) { + g_main_loop_unref(dispatcher->loop); + dispatcher->loop = NULL; + } + + if (dispatcher->ctx != NULL) { + g_main_context_unref(dispatcher->ctx); + dispatcher->ctx = NULL; + } +} diff --git a/efw-downloader/src/node-dispatcher.h b/efw-downloader/src/node-dispatcher.h new file mode 100644 index 0000000..9e47e00 --- /dev/null +++ b/efw-downloader/src/node-dispatcher.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __NODE_DISPATCHER_H__ +#define __NODE_DISPATCHER_H__ + +#include <glib.h> +#include <glib-object.h> + +#include <libhinawa/fw_node.h> +#include <libhinawa/fw_resp.h> + +struct node_dispatcher { + GMainContext *ctx; + GMainLoop *loop; + GThread *th; +}; + +void node_dispatcher_start(struct node_dispatcher *dispatcher, HinawaFwNode *node, GError **error); +void node_dispatcher_stop(struct node_dispatcher *dispatcher); + +#endif diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index 1bfa1f2..5ac0ac6 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -7,6 +7,7 @@
#include "efw-proto.h" #include "config-rom.h" +#include "node-dispatcher.h"
#define report_error(error, msg) \ fprintf(stderr, "Fail to %s: %s %d %s\n", \ @@ -60,6 +61,7 @@ int subcmd_device(int argc, char **argv) gsize length; guint32 vendor_id, model_id; EfwProto *proto; + struct node_dispatcher dispatcher = {0}; int err; int i;
@@ -116,8 +118,16 @@ int subcmd_device(int argc, char **argv) goto err_node; }
+ node_dispatcher_start(&dispatcher, node, &error); + if (error != NULL) { + report_error(error, "begin dispatcher"); + goto err_proto; + } + entry->op(argc, argv, proto, &error);
+ node_dispatcher_stop(&dispatcher); +err_proto: efw_proto_unbind(proto); g_object_unref(proto); err_node:
It's helpful to dump communication result optionally.
This commit adds debug option for the purpose.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/subcmd-device.c | 40 ++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index 5ac0ac6..329eef0 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -28,8 +28,31 @@ static int print_help() return EXIT_FAILURE; }
-static int parse_args(int argc, char **argv, const char **path, const char **op_name) +static void handle_responded_signal(EfwProto *proto, HinawaSndEfwStatus status, guint seqnum, + guint category, guint command, const guint32 *frame, guint frame_size) { + gchar *label = g_enum_to_string(HINAWA_TYPE_SND_EFW_STATUS, status); + int i; + + printf("responded:\n"); + printf(" status: %s\n", label); + printf(" seqnum: %d\n", seqnum); + printf(" category; %d\n", category); + printf(" command: %d\n", command); + + if (frame_size > 0) { + printf(" frame:\n"); + for (i = 0; i < frame_size; ++i) + printf(" [%3x]: %08x\n", i, frame[i]); + } + + g_free(label); +} + +static int parse_args(int argc, char **argv, const char **path, const char **op_name, gboolean *debug) +{ + int i; + if (argc < 2) return -EINVAL; assert(strncmp(argv[1], "device", sizeof("device")) == 0); @@ -42,6 +65,15 @@ static int parse_args(int argc, char **argv, const char **path, const char **op_ return -EINVAL; *op_name = argv[3];
+ *debug = FALSE; + for (i = 0; i < argc; ++i) { + if (strncmp(argv[i], "--debug", sizeof(--debug)) == 0 || + strncmp(argv[i], "-d", sizeof(--debug)) == 0) { + *debug = TRUE; + break; + } + } + return 0; }
@@ -54,6 +86,7 @@ int subcmd_device(int argc, char **argv) } *entry, entries[] = { }; GError *error = NULL; + gboolean debug; const char *path; const char *op_name; HinawaFwNode *node; @@ -65,7 +98,7 @@ int subcmd_device(int argc, char **argv) int err; int i;
- err = parse_args(argc, argv, &path, &op_name); + err = parse_args(argc, argv, &path, &op_name, &debug); if (err < 0) return print_help(0, NULL, NULL, NULL);
@@ -103,6 +136,9 @@ int subcmd_device(int argc, char **argv) }
proto = efw_proto_new(); + if (debug) + g_signal_connect(proto, "responded", (GCallback)handle_responded_signal, NULL); + efw_proto_bind(proto, node, &error); if (error != NULL) { if (g_error_matches(error, HINAWA_FW_NODE_ERROR, HINAWA_FW_NODE_ERROR_FAILED)) {
Fireworks protocol includes command to retrieve information about hardware.
This commit implements the command and local helper functions.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/efw-commands.c | 30 +++++++++++++++++++++ efw-downloader/src/efw-commands.h | 45 +++++++++++++++++++++++++++++++ efw-downloader/src/meson.build | 2 ++ 3 files changed, 77 insertions(+) create mode 100644 efw-downloader/src/efw-commands.c create mode 100644 efw-downloader/src/efw-commands.h
diff --git a/efw-downloader/src/efw-commands.c b/efw-downloader/src/efw-commands.c new file mode 100644 index 0000000..08b0114 --- /dev/null +++ b/efw-downloader/src/efw-commands.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include <stdio.h> +#include <errno.h> +#include <time.h> + +#include "efw-commands.h" + +// Categories in Echo Audio Fireworks protocol. +#define CATEGORY_HW 0 + +// Commands in hardware category. +#define HW_CMD_INFO 0 + +#define TIMEOUT 200 + +#define CAP_HAS_DSP 0x00000010 +#define CAP_HAS_FPGA 0x00000020 + +void efw_hw_info(EfwProto *proto, struct hw_info *info, GError **error) +{ + gsize param_count = sizeof(*info) / sizeof(guint32); + efw_proto_transaction(proto, CATEGORY_HW, HW_CMD_INFO, NULL, 0, + (guint32 *const *)&info, ¶m_count, TIMEOUT, error); +} + +void efw_hw_info_has_fpga(struct hw_info *info, gboolean *has_fpga) +{ + *has_fpga = !!(info->flags & CAP_HAS_FPGA); +} diff --git a/efw-downloader/src/efw-commands.h b/efw-downloader/src/efw-commands.h new file mode 100644 index 0000000..fd2dbe3 --- /dev/null +++ b/efw-downloader/src/efw-commands.h @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __EFW_CMDS_H__ +#define __EFW_CMDS_H__ + +#include "efw-proto.h" + +struct hw_info { + guint32 flags; + guint32 guid_hi; + guint32 guid_lo; + guint32 type; + guint32 version; + guint32 vendor_name[8]; + guint32 model_name[8]; + guint32 supported_clocks; + guint32 amdtp_rx_pcm_channels; + guint32 amdtp_tx_pcm_channels; + guint32 phys_out; + guint32 phys_in; + guint32 phys_out_grp_count; + guint32 phys_out_grp[4]; + guint32 phys_in_grp_count; + guint32 phys_in_grp[4]; + guint32 midi_out_ports; + guint32 midi_in_ports; + guint32 max_sample_rate; + guint32 min_sample_rate; + guint32 dsp_version; + guint32 arm_version; + guint32 mixer_playback_channels; + guint32 mixer_capture_channels; + guint32 fpga_version; + guint32 amdtp_rx_pcm_channels_2x; + guint32 amdtp_tx_pcm_channels_2x; + guint32 amdtp_rx_pcm_channels_4x; + guint32 amdtp_tx_pcm_channels_4x; + guint32 reserved[16]; +}; + +void efw_hw_info(EfwProto *proto, struct hw_info *info, GError **error); + +void efw_hw_info_has_fpga(struct hw_info *info, gboolean *has_fpga); + +#endif diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index c43c332..73a0f36 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -16,6 +16,7 @@ sources = [ 'efw-proto.c', 'config-rom.c', 'node-dispatcher.c', + 'efw-commands.c', 'subcmd-device.c', ]
@@ -23,6 +24,7 @@ headers = [ 'efw-proto.h', 'config-rom.h', 'node-dispatcher.h', + 'efw-commands.h', 'subcmds.h', ]
Fireworks protocol includes command for software to operate on-board flash memory.
This commit implements the command and adds local helper functions.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/efw-commands.c | 213 ++++++++++++++++++++++++++++++ efw-downloader/src/efw-commands.h | 12 ++ 2 files changed, 225 insertions(+)
diff --git a/efw-downloader/src/efw-commands.c b/efw-downloader/src/efw-commands.c index 08b0114..b0a8320 100644 --- a/efw-downloader/src/efw-commands.c +++ b/efw-downloader/src/efw-commands.c @@ -8,10 +8,26 @@
// Categories in Echo Audio Fireworks protocol. #define CATEGORY_HW 0 +#define CATEGORY_FLASH 1
// Commands in hardware category. #define HW_CMD_INFO 0
+// Commands in flash category. +#define FLASH_CMD_ERASE 0 +#define FLASH_CMD_READ 1 +#define FLASH_CMD_WRITE 2 +#define FLASH_CMD_STATE 3 +#define FLASH_CMD_SESSION_BASE 4 +#define FLASH_CMD_LOCK 5 + +#define EFW_FLASH_FRAME_MAX_QUADS 64 + +// Between 0x00000000 - 0x00010000. +#define EFW_FLASH_BLOCK_SIZE_LOW 0x00002000 +// Between 0x00010000 - 0x00200000. +#define EFW_FLASH_BLOCK_SIZE_HIGH 0x00010000 + #define TIMEOUT 200
#define CAP_HAS_DSP 0x00000010 @@ -28,3 +44,200 @@ void efw_hw_info_has_fpga(struct hw_info *info, gboolean *has_fpga) { *has_fpga = !!(info->flags & CAP_HAS_FPGA); } + +int efw_flash_get_block_size(size_t offset, size_t *block_size) +{ + if (offset < 0x00010000) + *block_size = EFW_FLASH_BLOCK_SIZE_LOW; + else if (offset < 0x00200000) + *block_size = EFW_FLASH_BLOCK_SIZE_HIGH; + else + return -ENXIO; + + return 0; +} + +void efw_flash_erase(EfwProto *proto, size_t offset, GError **error) +{ + size_t block_size; + guint32 args[1] = {0}; + guint32 *params = (guint32 [1]){0}; + gsize param_count = 1; + int err; + + err = efw_flash_get_block_size(offset, &block_size); + if (err < 0) { + g_set_error(error, EFW_PROTO_ERROR, -err, + "%s %d: %s", __FILE__, __LINE__, strerror(-err)); + return; + } + + if (offset % block_size > 0) { + g_set_error(error, EFW_PROTO_ERROR, EINVAL, + "%s %d: %s", __FILE__, __LINE__, strerror(EINVAL)); + return; + } + + args[0] = offset; + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_ERASE, args, G_N_ELEMENTS(args), + (guint32 *const *)¶ms, ¶m_count, TIMEOUT, error); +} + +void efw_flash_erase_and_wait(EfwProto *proto, size_t offset, GError **error) +{ + efw_flash_erase(proto, offset, error); + if (*error != NULL) + return; + + while (TRUE) { + gboolean state; + struct timespec req = { + .tv_sec = 0, + .tv_nsec = 500000000, + }; + + efw_flash_state(proto, &state, error); + if (state == TRUE) + break; + + if (*error != NULL) + g_clear_error(error); + + clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL); + } +} + +void efw_flash_read(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error) +{ + guint32 args[2] = {0}; + guint32 *params = (guint32 [2 + EFW_FLASH_FRAME_MAX_QUADS]){0}; + gsize param_count = 2 + EFW_FLASH_FRAME_MAX_QUADS; + + if (quads > EFW_FLASH_FRAME_MAX_QUADS) { + g_set_error(error, EFW_PROTO_ERROR, EINVAL, + "%s %d: %s", __FILE__, __LINE__, strerror(EINVAL)); + return; + } + + args[0] = offset; + args[1] = quads; + + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_READ, args, G_N_ELEMENTS(args), + (guint32 *const *)¶ms, ¶m_count, TIMEOUT, error); + if (*error != NULL) + return; + + if (params[0] != offset || params[1] != quads) { + g_set_error(error, EFW_PROTO_ERROR, EIO, + "%s %d: %s", __FILE__, __LINE__, strerror(EIO)); + return; + } + + memcpy(buf, (const void *)¶ms[2], quads * sizeof(*buf)); +} + +void efw_flash_recursive_read(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error) +{ + while (quads > 0) { + size_t count = MIN(quads, EFW_FLASH_FRAME_MAX_QUADS); + + efw_flash_read(proto, offset, buf, count, error); + if (*error != NULL) + return; + + offset += count * 4; + quads -= count; + buf += count; + } +} + +void efw_flash_write(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error) +{ + guint32 args[2 + EFW_FLASH_FRAME_MAX_QUADS] = {0}; + guint32 *params = (guint32 [2]){0}; + gsize param_count = 2; + + if (quads > EFW_FLASH_FRAME_MAX_QUADS) { + g_set_error(error, EFW_PROTO_ERROR, EINVAL, + "%s %d: %s", __FILE__, __LINE__, strerror(EINVAL)); + return; + } + + args[0] = offset; + args[1] = quads; + memcpy((void *)&args[2], buf, quads * sizeof(*buf)); + + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_WRITE, args, G_N_ELEMENTS(args), + (guint32 *const *)¶ms, ¶m_count, TIMEOUT, error); +} + +void efw_flash_recursive_write(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error) +{ + while (quads > 0) { + size_t count = MIN(quads, EFW_FLASH_FRAME_MAX_QUADS); + gboolean state; + + efw_flash_write(proto, offset, buf, count, error); + if (*error != NULL) + return; + + offset += count * 4; + quads -= count; + buf += count; + + while (TRUE) { + struct timespec req = { + .tv_sec = 0, + .tv_nsec = 500000000, + }; + + efw_flash_state(proto, &state, error); + if (state == TRUE) + break; + + if (*error != NULL) + g_clear_error(error); + + clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL); + } + } +} + +void efw_flash_state(EfwProto *proto, gboolean *state, GError **error) +{ + gsize param_count = 0; + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_STATE, NULL, 0, NULL, ¶m_count, + TIMEOUT, error); + if (*error == NULL) { + *state = TRUE; + } else if (g_error_matches(*error, EFW_PROTO_ERROR, HINAWA_SND_EFW_STATUS_FLASH_BUSY)) { + *state = FALSE; + g_clear_error(error); + } +} + +void efw_flash_get_session_base(EfwProto *proto, size_t *offset, GError **error) +{ + guint32 *params = (guint32 [1]){0}; + gsize param_count = 1; + + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_SESSION_BASE, NULL, 0, + (guint32 *const *)¶ms, ¶m_count, TIMEOUT, error); + if (*error != NULL) + return; + + *offset = params[0]; +} + +// MEMO: Lock operation is additional to the combination of IceLynx Micro and FPGA. +void efw_flash_lock(EfwProto *proto, gboolean locked, GError **error) +{ + guint32 args[1] = {0}; + guint32 *params = (guint32 [1]){0}; + gsize param_count = 1; + + args[0] = locked; + + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_LOCK, args, G_N_ELEMENTS(args), + (guint32 *const *)¶ms, ¶m_count, TIMEOUT, error); +} diff --git a/efw-downloader/src/efw-commands.h b/efw-downloader/src/efw-commands.h index fd2dbe3..a25781b 100644 --- a/efw-downloader/src/efw-commands.h +++ b/efw-downloader/src/efw-commands.h @@ -42,4 +42,16 @@ void efw_hw_info(EfwProto *proto, struct hw_info *info, GError **error);
void efw_hw_info_has_fpga(struct hw_info *info, gboolean *has_fpga);
+void efw_flash_erase(EfwProto *proto, size_t offset, GError **error); +void efw_flash_read(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error); +void efw_flash_write(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error); +void efw_flash_state(EfwProto *proto, gboolean *state, GError **error); +void efw_flash_get_session_base(EfwProto *proto, size_t *offset, GError **error); +void efw_flash_lock(EfwProto *proto, gboolean locked, GError **error); + +int efw_flash_get_block_size(size_t offset, size_t *block_size); +void efw_flash_erase_and_wait(EfwProto *proto, size_t offset, GError **error); +void efw_flash_recursive_read(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error); +void efw_flash_recursive_write(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error); + #endif
This commit add read operation in device sub command. The arbitrary range of address in on-board flash memory is read and the content is dump in stdout.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/meson.build | 1 + efw-downloader/src/op-device-read.c | 104 ++++++++++++++++++++++++++++ efw-downloader/src/subcmd-device.c | 4 ++ efw-downloader/src/subcmds.h | 4 ++ 4 files changed, 113 insertions(+) create mode 100644 efw-downloader/src/op-device-read.c
diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index 73a0f36..8738d76 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -18,6 +18,7 @@ sources = [ 'node-dispatcher.c', 'efw-commands.c', 'subcmd-device.c', + 'op-device-read.c', ]
headers = [ diff --git a/efw-downloader/src/op-device-read.c b/efw-downloader/src/op-device-read.c new file mode 100644 index 0000000..a1fa0cf --- /dev/null +++ b/efw-downloader/src/op-device-read.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <assert.h> + +#include "efw-commands.h" + +static void print_help() +{ + printf("Usage\n" + " efw-downloader device CDEV read OFFSET LENGTH [OPTIONS]\n" + "\n" + "where:\n" + " CDEV: The firewire character device corresponding to the node for proto\n" + " OFFSET: The hexadecimal offset address in on-board flash memory\n" + " LENGTH: The hexadecimal number to read. The value is finally aligned to quadlet.\n" + " OPTIONS:\n" + " --help, -h: Print this help message and exit.\n" + " --debug: Output debug message to stderr\n"); +} + +static int parse_args(int argc, char **argv, size_t *offset, size_t *quads, gboolean *help) +{ + unsigned long val; + char *end; + int i; + + if (argc < 4) + return -EINVAL; + assert(strncmp(argv[3], "read", sizeof("read")) == 0); + + if (argc < 5) + return -EINVAL; + val = strtol(argv[4], &end, 16); + if (*end != '\0') { + printf("Invalid argument for offset address.\n"); + return -EINVAL; + } + *offset = (size_t)val; + + if (argc < 6) + return -EINVAL; + val = strtol(argv[5], &end, 16); + if (*end != '\0') { + printf("Invalid argument for quadlet count.\n"); + return -EINVAL; + } + *quads = (size_t)(val + 3) / 4; + + *help = FALSE; + for (i = 0; i < argc; ++i) { + if (strncmp(argv[i], "--help", sizeof("--help")) == 0 || + strncmp(argv[i], "-h", sizeof("-h")) == 0) { + *help = TRUE; + } + } + + return 0; +} + +void op_device_read(int argc, char **argv, EfwProto *proto, GError **error) +{ + size_t offset; + size_t quads; + guint32 *buf; + gboolean help; + int err; + int i; + + err = parse_args(argc, argv, &offset, &quads, &help); + if (err < 0) { + print_help(); + g_set_error_literal(error, G_FILE_ERROR, G_FILE_ERROR_INVAL, "Invalid arguments"); + return; + } + + if (help) { + print_help(); + return; + } + + buf = g_try_malloc0_n(quads, sizeof(*buf)); + if (buf == NULL) { + fprintf(stderr, "Memory allocation fails.\n"); + g_set_error_literal(error, G_FILE_ERROR, G_FILE_ERROR_NOSPC, "Memory allocation error"); + return; + } + + efw_flash_recursive_read(proto, offset, buf, quads, error); + if (*error != NULL) { + fprintf(stderr, + "Fail to read contents of flash memory: %s %d %s\n", + g_quark_to_string((*error)->domain), (*error)->code, (*error)->message); + goto end; + } + + for (i = 0; i < quads; ++i) + printf(" %08lx: %08x\n", offset + 4 * i, buf[i]); +end: + g_free(buf); +} diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index 329eef0..a11450c 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -9,6 +9,8 @@ #include "config-rom.h" #include "node-dispatcher.h"
+#include "subcmds.h" + #define report_error(error, msg) \ fprintf(stderr, "Fail to %s: %s %d %s\n", \ msg, g_quark_to_string(error->domain), error->code, error->message) @@ -21,6 +23,7 @@ static int print_help() "where:\n" " CDEV: The firewire character device corresponding to the node for transaction\n" " OPERATION:\n" + " read: read from on-board flash memory\n" " help: print this help message\n" " ARGUMENTS:\n" " depending on OPERATION\n" @@ -84,6 +87,7 @@ int subcmd_device(int argc, char **argv) size_t size; void (*op)(int argc, char **argv, EfwProto *proto, GError **error); } *entry, entries[] = { + { "read", sizeof("read"), op_device_read }, }; GError *error = NULL; gboolean debug; diff --git a/efw-downloader/src/subcmds.h b/efw-downloader/src/subcmds.h index f10c420..70cbb5a 100644 --- a/efw-downloader/src/subcmds.h +++ b/efw-downloader/src/subcmds.h @@ -3,6 +3,10 @@ #ifndef __SUBCMDS_H__ #define __SUBCMDS_H__
+#include "efw-proto.h" + int subcmd_device(int argc, char **argv);
+void op_device_read(int argc, char **argv, EfwProto *proto, GError **error); + #endif
Echo Digital Audio corporation designed data format of firmware. The format seems to be suitable for their SDK for customers and closed.
FFADO project implements the format parser in libffado2. Although the implementation is not enough in several points, it's good point to guess the format.
I captured asynchronous packet by bus analyzer during updating firmware by Windows driver, aggregated the content of packet by script, then compared it to content of firmware. Some points are cleared (but not all).
This commit adds parser for data binary shipped by Echo Digital Audio corporation. I note that driver package shipped by vendors for Fireworks based devices includes no EULA. I think this kind of reimplementation is not limited in the case.
The content of file consists of two parts; header after magic bytes, and payload. The header includes metadata about the data of payload. There are four kind of data; for DSP, for IceLynx Micro, for arbitrary data, and for FPGA.
The content except for magic bytes is hexadecimal string, therefore it's possible to print out by simple dump tool; cat(1) and less(1). The header includes CRC32 value of the decoded data and checksum of every bytes of the decoded data.
When the header includes a flag, the CRC32 value is written to the end of area for firmware.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/file-cntr.c | 183 +++++++++++++++++++++++++++++++++ efw-downloader/src/file-cntr.h | 39 +++++++ efw-downloader/src/meson.build | 5 + 3 files changed, 227 insertions(+) create mode 100644 efw-downloader/src/file-cntr.c create mode 100644 efw-downloader/src/file-cntr.h
diff --git a/efw-downloader/src/file-cntr.c b/efw-downloader/src/file-cntr.c new file mode 100644 index 0000000..1e159f7 --- /dev/null +++ b/efw-downloader/src/file-cntr.c @@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +#include <zlib.h> + +#include "file-cntr.h" + +#define MAGIC_BYTES "1651 1 0 0 0\r\n" +#define PAYLOAD_OFFSET_QUADS 0x3f + +static int parse_entry(FILE *handle, uint32_t *val) +{ + char buf[16]; + char *end; + size_t len; + int err = 0; + + if (fgets(buf, sizeof(buf), handle) != buf) { + if (ferror(handle)) + err = -errno; + else + err = INT_MAX; // Use the value for EOF. + return err; + } + + len = strlen(buf); + if (buf[0] != '0' || buf[1] != 'x' || buf[len - 2] != '\r' || buf[len - 1] != '\n') + return -EPROTO; + buf[len - 2] = '\0'; + + *val = strtoul(buf, &end, 16); + if (*end != '\0') + return -EPROTO; + + return err; +} + +static int parse_header(FILE *handle, struct file_cntr_header *header) +{ + uint32_t *buf = (uint32_t *)header; + int err = 0; + int i; + + for (i = 0; i < 8; ++i) { + uint32_t val; + + err = parse_entry(handle, &val); + if (err != 0) + break; + + buf[i] = val; + } + + if (err == INT_MAX) + err = -ENODATA; + + return err; +} + +static int parse_payload(FILE *handle, unsigned int quads, uint32_t *blob) +{ + int err = 0; + int i; + + for (i = 0; i < quads; ++i) { + uint32_t val; + + err = parse_entry(handle, &val); + if (err != 0) + break; + + blob[i] = val; + } + + if (i != quads || err == INT_MAX) + err = -ENODATA; + + return err; +} + +static int check_crc32(struct file_cntr *cntr) +{ + uint32_t blob_crc32; + + blob_crc32 = crc32(0ul, (const uint8_t *)cntr->payload.blob, + cntr->payload.count * sizeof(*cntr->payload.blob)); + if (blob_crc32 != cntr->header.blob_crc32) + return -EINVAL; + + return 0; +} + +static int check_checksum(struct file_cntr *cntr) +{ + uint32_t checksum = 0; + int i, j; + + for (i = 0; i < cntr->payload.count; ++i) { + for (j = 3; j >= 0; --j) + checksum += (cntr->payload.blob[i] >> (j * 8)) & 0xff; + } + + if (checksum != cntr->header.blob_checksum) + return -EINVAL; + + return 0; +} + +int file_cntr_parse(struct file_cntr *cntr, const char *filepath) +{ + FILE *handle; + char buf[16]; + size_t till_data; + int err = 0; + + handle = fopen(filepath, "r"); + if (handle == NULL) + return -errno; + + // Check magic bytes. + if (fgets(buf, sizeof(buf), handle) != buf) { + if (ferror(handle)) + err = -errno; + else + err = -ENODATA; + goto end; + } + + if (memcmp(buf, MAGIC_BYTES, sizeof(MAGIC_BYTES))) { + err = -EPROTO; + goto end; + } + + // Parse header. + err = parse_header(handle, &cntr->header); + if (err < 0) + goto end; + + // Skip to area for data. + till_data = (PAYLOAD_OFFSET_QUADS - 7) * 12; + if (fseek(handle, till_data, SEEK_CUR) < 0) { + err = -errno; + goto end; + } + + cntr->payload.blob = calloc(cntr->header.blob_quads, sizeof(*cntr->payload.blob)); + if (cntr->payload.blob == NULL) { + err = -ENOMEM; + goto end; + } + cntr->payload.count = cntr->header.blob_quads; + + err = parse_payload(handle, cntr->header.blob_quads, cntr->payload.blob); + if (err < 0) { + free(cntr->payload.blob); + goto end; + } + + err = check_crc32(cntr); + if (err < 0) { + free(cntr->payload.blob); + goto end; + } + + err = check_checksum(cntr); + if (err < 0) + free(cntr->payload.blob); +end: + fclose(handle); + + return err; +} + +void file_cntr_release(struct file_cntr *cntr) +{ + if (cntr->payload.blob != NULL) + free(cntr->payload.blob); + cntr->payload.blob = NULL; +} diff --git a/efw-downloader/src/file-cntr.h b/efw-downloader/src/file-cntr.h new file mode 100644 index 0000000..c4657f1 --- /dev/null +++ b/efw-downloader/src/file-cntr.h @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __FILE_CNTR__ +#define __FILE_CNTR__ + +#include <stdint.h> + +enum blob_type { + BLOB_TYPE_DSP = 0, + BLOB_TYPE_ICELYNX = 1, + BLOB_TYPE_DATA = 2, + BLOB_TYPE_FPGA = 3, +}; + +struct file_cntr_header { + enum blob_type type; + uint32_t offset_addr; + uint32_t blob_quads; + uint32_t blob_crc32; + uint32_t blob_checksum; + uint32_t version; + uint32_t crc_in_region_end; + uint32_t cntr_quads; +}; + +struct file_cntr_payload { + uint32_t *blob; + size_t count; +}; + +struct file_cntr { + struct file_cntr_header header; + struct file_cntr_payload payload; +}; + +int file_cntr_parse(struct file_cntr *cntr, const char *filepath); +void file_cntr_release(struct file_cntr *cntr); + +#endif diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index 8738d76..05d491d 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -11,12 +11,15 @@ hinawa = dependency('hinawa', version: '>=2.1', )
+zlib = dependency('zlib') + sources = [ 'main.c', 'efw-proto.c', 'config-rom.c', 'node-dispatcher.c', 'efw-commands.c', + 'file-cntr.c', 'subcmd-device.c', 'op-device-read.c', ] @@ -26,6 +29,7 @@ headers = [ 'config-rom.h', 'node-dispatcher.h', 'efw-commands.h', + 'file-cntr.h', 'subcmds.h', ]
@@ -42,6 +46,7 @@ executable('efw-downloader', dependencies: [ gobject, hinawa, + zlib, ], install: true, )
This commit adds 'file' subcommand to handle firmware files.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/meson.build | 1 + efw-downloader/src/subcmd-file.c | 85 ++++++++++++++++++++++++++++++++ efw-downloader/src/subcmds.h | 2 + 3 files changed, 88 insertions(+) create mode 100644 efw-downloader/src/subcmd-file.c
diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index 05d491d..7d11332 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -22,6 +22,7 @@ sources = [ 'file-cntr.c', 'subcmd-device.c', 'op-device-read.c', + 'subcmd-file.c', ]
headers = [ diff --git a/efw-downloader/src/subcmd-file.c b/efw-downloader/src/subcmd-file.c new file mode 100644 index 0000000..0ee7653 --- /dev/null +++ b/efw-downloader/src/subcmd-file.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <assert.h> + +#include "subcmds.h" + +static void print_help() +{ + printf("Usage\n" + " efw-downloader file FILEPATH OPERATION ARGUMENTS\n" + "\n" + "where:\n" + " FILEPATH: The path to file.\n" + " OPERATION:\n" + " help: print this help message\n" + " ARGUMENTS:\n" + " depending on the OPERATION\n"); +} + +static int parse_args(int argc, char **argv, const char **filepath, const char **op_name) +{ + if (argc < 2) + return -EINVAL; + assert(strncmp(argv[1], "file", sizeof("file")) == 0); + + if (argc < 3) + return -EINVAL; + *filepath = argv[2]; + + if (argc < 4) + return -EINVAL; + *op_name = argv[3]; + + return 0; +} + +int subcmd_file(int argc, char **argv) +{ + struct { + const char *name; + size_t size; + int (*op)(int argc, char **argv, struct file_cntr *cntr); + } *entry, entries[] = { + }; + const char *op_name; + const char *filepath; + struct file_cntr cntr = {0}; + int err; + int i; + + err = parse_args(argc, argv, &filepath, &op_name); + if (err < 0) { + print_help(); + return EXIT_FAILURE; + } + + for (i = 0; i < sizeof(entries) / sizeof(entries[0]); ++i) { + entry = entries + i; + if (strncmp(op_name, entry->name, entry->size) == 0) + break; + } + if (i == sizeof(entries) / sizeof(entries[0])) { + print_help(); + return EXIT_FAILURE; + } + + err = file_cntr_parse(&cntr, filepath); + if (err < 0) { + printf("Fail to parse: %s\n", strerror(-err)); + return EXIT_FAILURE; + } + + err = entry->op(argc, argv, &cntr); + + file_cntr_release(&cntr); + + if (err < 0) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} diff --git a/efw-downloader/src/subcmds.h b/efw-downloader/src/subcmds.h index 70cbb5a..b1810b3 100644 --- a/efw-downloader/src/subcmds.h +++ b/efw-downloader/src/subcmds.h @@ -4,8 +4,10 @@ #define __SUBCMDS_H__
#include "efw-proto.h" +#include "file-cntr.h"
int subcmd_device(int argc, char **argv); +int subcmd_file(int argc, char **argv);
void op_device_read(int argc, char **argv, EfwProto *proto, GError **error);
This commit adds parse operation in file sub command to dump contents of firmware files.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/main.c | 2 + efw-downloader/src/meson.build | 1 + efw-downloader/src/op-file-parse.c | 106 +++++++++++++++++++++++++++++ efw-downloader/src/subcmd-file.c | 2 + efw-downloader/src/subcmds.h | 2 + 5 files changed, 113 insertions(+) create mode 100644 efw-downloader/src/op-file-parse.c
diff --git a/efw-downloader/src/main.c b/efw-downloader/src/main.c index e150cc8..a9b52eb 100644 --- a/efw-downloader/src/main.c +++ b/efw-downloader/src/main.c @@ -14,6 +14,7 @@ static void print_help() "where:\n" " SUBCOMMAND:\n" " device: operate for device for unit on IEEE 1394 bus\n" + " file: operate for firmware file" " help: print help\n" " OPTIONS: optional arguments dependent on the subcommand\n"); } @@ -26,6 +27,7 @@ int main(int argc, char **argv) int (*op)(int argc, char **argv); } *entry, entries[] = { { "device", sizeof("device"), subcmd_device }, + { "file", sizeof("file"), subcmd_file }, }; const char *subcmd; int i; diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index 7d11332..8f7e363 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -23,6 +23,7 @@ sources = [ 'subcmd-device.c', 'op-device-read.c', 'subcmd-file.c', + 'op-file-parse.c', ]
headers = [ diff --git a/efw-downloader/src/op-file-parse.c b/efw-downloader/src/op-file-parse.c new file mode 100644 index 0000000..c9c81d2 --- /dev/null +++ b/efw-downloader/src/op-file-parse.c @@ -0,0 +1,106 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include <stdio.h> +#include <stddef.h> +#include <stdbool.h> +#include <errno.h> +#include <string.h> +#include <assert.h> + +#include "file-cntr.h" + +static void print_help() +{ + printf("Usage\n" + " efw-downloader file PATH parse [--help | -h]\n" + "\n" + "where:\n" + " --help, -h: print this help message\n"); +} + +static const char *get_blob_type_name(enum blob_type type) +{ + const char *name; + + switch (type) { + case BLOB_TYPE_DSP: + name = "DSP"; + break; + case BLOB_TYPE_ICELYNX: + name = "IceLynx"; + break; + case BLOB_TYPE_DATA: + name = "data"; + break; + case BLOB_TYPE_FPGA: + name = "FPGA"; + break; + default: + name = "invalid"; + break; + } + + return name; +} + +static void file_cntr_dump_header(const struct file_cntr *cntr) +{ + printf("Container header:\n"); + printf(" type: %d (%s)\n", cntr->header.type, get_blob_type_name(cntr->header.type)); + printf(" offset_addr: 0x%08x\n", cntr->header.offset_addr); + printf(" blob_quads: %u\n", cntr->header.blob_quads); + printf(" blob_crc32: 0x%08x\n", cntr->header.blob_crc32); + printf(" blob_checksum: 0x%08x\n", cntr->header.blob_checksum); + printf(" version: 0x%08x\n", cntr->header.version); + printf(" crc_in_region_end: %d\n", cntr->header.crc_in_region_end); + printf(" total_quads: %d\n", cntr->header.cntr_quads); +} + +static void file_cntr_dump_payload(const struct file_cntr *cntr) +{ + int i; + + printf("Container payload:\n"); + for (i = 0; i < cntr->payload.count; ++i) + printf(" %08x: %08x\n", cntr->header.offset_addr + i * 4, cntr->payload.blob[i]); +} + +static int parse_args(int argc, char **argv, bool *help) +{ + int i; + + if (argc < 4) + return -EINVAL; + assert(!strncmp(argv[3], "parse", sizeof("parse"))); + + *help = false; + for (i = 0; i < argc; ++i) { + if (strncmp(argv[i], "--help", sizeof("--help")) == 0 || + strncmp(argv[i], "-h", sizeof("-h")) == 0) { + *help = true; + break; + } + } + + return 0; +} + +int op_file_parse(int argc, char **argv, struct file_cntr *cntr) +{ + bool help = false; + int err; + + err = parse_args(argc, argv, &help); + if (err < 0) + return err; + + if (help) { + print_help(); + return 0; + } + + file_cntr_dump_header(cntr); + file_cntr_dump_payload(cntr); + + return 0; +} diff --git a/efw-downloader/src/subcmd-file.c b/efw-downloader/src/subcmd-file.c index 0ee7653..a61378c 100644 --- a/efw-downloader/src/subcmd-file.c +++ b/efw-downloader/src/subcmd-file.c @@ -16,6 +16,7 @@ static void print_help() "where:\n" " FILEPATH: The path to file.\n" " OPERATION:\n" + " parse: parse and dump binary blob released by Echo Audio\n" " help: print this help message\n" " ARGUMENTS:\n" " depending on the OPERATION\n"); @@ -45,6 +46,7 @@ int subcmd_file(int argc, char **argv) size_t size; int (*op)(int argc, char **argv, struct file_cntr *cntr); } *entry, entries[] = { + { "parse", sizeof("parse"), op_file_parse }, }; const char *op_name; const char *filepath; diff --git a/efw-downloader/src/subcmds.h b/efw-downloader/src/subcmds.h index b1810b3..99d3bef 100644 --- a/efw-downloader/src/subcmds.h +++ b/efw-downloader/src/subcmds.h @@ -11,4 +11,6 @@ int subcmd_file(int argc, char **argv);
void op_device_read(int argc, char **argv, EfwProto *proto, GError **error);
+int op_file_parse(int argc, char **argv, struct file_cntr *cntr); + #endif
This commit adds online manual. Additionally, this commit adds 'man' meson option to decide whether installing the manual or not.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/man/efw-downloader.1 | 162 ++++++++++++++++++++++++++++ efw-downloader/meson.build | 4 + efw-downloader/meson_options.txt | 5 + 3 files changed, 171 insertions(+) create mode 100644 efw-downloader/man/efw-downloader.1 create mode 100644 efw-downloader/meson_options.txt
diff --git a/efw-downloader/man/efw-downloader.1 b/efw-downloader/man/efw-downloader.1 new file mode 100644 index 0000000..5b38c28 --- /dev/null +++ b/efw-downloader/man/efw-downloader.1 @@ -0,0 +1,162 @@ +.TH EFW-DOWNLOADER 1 "20 Aug 2020" "alsa-tools" + +.SH NAME +efw-downloader - operate on-board flash memory for Fireworks board module + +.SH SYNOPSIS + +.B efw-downloader +.I subcommand +.I options ... + +subcommand = +.B device +| +.B file + +options = ( depends on +.I subcommand +) + +.SH DESCRIPTION + +The +.B efw-downloader +is a command-line tool to operate on-board flash memory for Fireworks board +module by Fireworks protocol. + +.SH SUBCOMMAND + +.SS device +Operate on-board flash memory by Fireworks protocol. + +.SS file +Operate firmware files. + +.SH OPTIONS + +.SS For device subcommand + +.B efw-downloader device +.I path +.I operation +.I arguments + +.TP +.B path +The path to special file for firewire character device corresponding to +node of Fireworks board module. + +.TP +.B operation +One of +.I read +, and +.I help +operations. + +.TP +.B arguments for read operation + +.B efw-downloader device +.I path +read +.I offset +.I size +[ +.I --debug +| +.I --help +| +.I -h +] + +The +.I offset +argument is the hexadecimal number of offset on flash memory. + +The +.I size +argument is +the hexadecimal number of size to read, aligned to quadlet automatically. + +The optional +.I --debug +argument is to enable debug output for Fireworks protocol. + +The optional +.I --help +and +.I -h +arguments are for help message. + +.TP +.B arguments for help operation + +.B efw-downloader device +.I path +help + +The help operation have no arguments. + +.SS For file subcommand + +.B efw-downloader file +.I filepath +.I operation +.I arguments + +.TP +.B filepath +The path to file of firmware blob included in driver package shipped by vendors. + +.TP +.B operation +One of +.I parse +, and +.I help +operations. + +.TP +.B arguments for parse operation + +.B efw-downloader file +.I filepath +.I parse +[ +.I --help +| +.I -h +] + +The +.I --help +and +.I -h +argument is for help message. + +.TP +.B arguments for help operation + +.B efw-downloder file +.I filepath +.I help + +The help operation have no arguments. + +.SH EXIT_STATUS + +.I EXIT_SUCCESS +(0) if run time successfully finished, else +.I EXIT_FAILURE +(1). + +.SH REPORTING BUGS +Report any bugs to mailing list in ALSA community +<alsa-devel@alsa-project.org> where the development and maintenance is +primarily discussed. Bug tracking service of alsa-tools repository on +github.com is also available. + +.SH AUTHOR +Takashi Sakamoto <o-takashi@sakamocchi.jp> diff --git a/efw-downloader/meson.build b/efw-downloader/meson.build index 9664100..bd7ce21 100644 --- a/efw-downloader/meson.build +++ b/efw-downloader/meson.build @@ -8,3 +8,7 @@ project('efw-downloader', 'c', )
subdir('src') + +if get_option('man') + install_man('man/efw-downloader.1') +endif diff --git a/efw-downloader/meson_options.txt b/efw-downloader/meson_options.txt new file mode 100644 index 0000000..83ac978 --- /dev/null +++ b/efw-downloader/meson_options.txt @@ -0,0 +1,5 @@ +option('man', + type: 'boolean', + value: true, + description: 'install online manual', +)
This commit adds README so that developers and users can get description about this tool easily.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/README.rst | 167 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 efw-downloader/README.rst
diff --git a/efw-downloader/README.rst b/efw-downloader/README.rst new file mode 100644 index 0000000..8d35ee3 --- /dev/null +++ b/efw-downloader/README.rst @@ -0,0 +1,167 @@ +============== +efw-downloader +============== + +2020/08/21 +Takashi Sakamoto + +Introduction +============ + +This tool is designed to operate on-board flash memory for devices with Fireworks board module. The +goal is to download firmware for the module. + +At present, the tool can perform read operation from flash memory, and parse operation for firmware +file, therefore it's unlikely to make your device bricked. + +Target devices +============== + +* LOUD Audio, LLC (Mackie) + + * Onyx 400F + * Onyx 1200F + +* Echo Digital Audio corporation + + * Audiofire 12 (with DSP) + * Audiofire 12 (with FPGA) + * Audiofire 8 (with DSP) + * Audiofire 8 (with FPGA) + * Audiofire 2 + * Audiofire 4 + * Audiofire Pre8 + +* Gibson guitar corporation + + * Robot Interface Pack (RIP) + +Background +========== + +Echo Digital Audio corporation shipped Fireworks board module. This module is designed for audio and +music units on IEEE 1394 bus with rich features for direct monitoring, on-board routing, and so on. + +The module consists of two combinations of two ICs: + +* A combination: + + * Texus Instruments TSB43Cx43A (IceLynx Micro) + * Texus Instruments TMS320C6713B (DSP) + +* Another combination: + + * Texus Instruments TSB43Cx43A (IceLynx Micro) + * Xilinx Spartan XC35250E (FPGA) + +The module has on-board flash memory to store firmware for the above ICs and allows software to +read, erase, and write to the memory by Fireworks protocol. + +For your information, Echo Digital Audio corporation have US patent. The patent describes that two +processors are used for data processing in IEEE 1394 bus, and for sample processing from/to DAC/ADC. +These two processors independently run via memory bank. I guess that IceLynx Micro is used for the +former role, and DSP/FPGA is used for the latter role. + +Echo Digital Audio corporation provided a series of firmware blob to their customers and bundled the +firmware to driver package for Windows and macOS. The firmware blob has specific structure designed +by Echo Digital Audio corporation. + +Prerequities +============ + +Dependencies for build and runtime +------------------------------------- + +* libglib-2.0 and libgobject v2.34 or later. (https://gitlab.gnome.org/GNOME/glib) +* libhinawa v2.1 or later (https://github.com/alsa-project/libhinawa) +* zlib (https://zlib.net/) + +For build +--------- + +* Meson Build system (https://mesonbuild.com/) is used. + +For runtime +----------- + +* ALSA fireworks driver uses the same address space on 1394 OHCI controller for Fireworks protocol, + therefore it's better to unload the driver in advance of using the tool. +* FFADO applications should be stopped to avoid misfortune. + +Build and Install +================= + +:: + + $ meson (--prefix=xxx, -Dman=false). build + $ cd build + $ ninja + $ meson install + +* The ``man`` meson option is to install online manual for the tool. Default is ``true``. + +Instruction +=========== + +The tool consists of two sub commands; ``device`` and ``file``. The former is to operate on-board +flash memory, and the latter is to handle file of firmware blob. +:: + + efw-downloader SUBCOMMAND OPTIONS ... + + SUBCOMMAND = device | file + + OPTIONS = ( depends on subcommand ) + +The ``device`` sub command consists of several operations. At present, ``read`` operation is just +supported but the other operations are planned to add for future release. +:: + + efw-downloader device PATH OPERATION ARGUMENTS + + PATH The path to special file for firewire character device corresponding to node of Fireworks board module. + + OPERATION + One of read , and help operations. + + ARGUMENTS for read operation + + efw-downloader device PATH read OFFSET SIZE [ --debug | --help | -h ] + + The offset argument is the hexadecimal number of offset on flash memory. + + The size argument is the hexadecimal number of size to read, aligned to quadlet automatically. + + The optional --debug argument is to enable debug output for Fireworks protocol. + + The optional --help and -h arguments are for help message. + + ARGUMENTS for help operation + + efw-downloader device PATH help + + The help operation have no arguments. + +The ``file`` sub command consists of several operations as well. At present, ``parse`` operation is +just supported but the other operations are planned to add for future release. +:: + + efw-downloader file FILEPATH OPERATION ARGUMENTS + + FILEPATH + The path to file of firmware blob included in driver package shipped by vendors. + + OPERATION + One of parse , and help operations. + + ARGUMENTS for parse operation + + efw-downloader file FILEPATH parse [ --help | -h ] + + The --help and -h argument is for help message. + + ARGUMENTS for help operation + + efw-downloder file FILEPATH help + + The help operation have no arguments.
Hi,
Would I expect any reaction by maintainers of alsa-tools repository for the patches?
On Fri, Aug 21, 2020 at 04:30:46PM +0900, Takashi Sakamoto wrote:
Hi,
This patchset is for alsa-tool repository[1] to add a new command-line tool, efw-downloader. The tools is designed to operate on-board flash memory for devices based on Fireworks board module. The patches are also available in my personal repository in github.com[2].
Fireworks board module was designed by Echo Digital Audio corporation. The board module has on-board flash memory to store firmware blob and session data. The contents of flash memory can be operated by software by a pair of asynchronous transactions defined by Echo Digital Audio corporation.
Echo Digital Audio corporation also designed file format of firmware. Hardware Vendors including Echo Digital Audio corporation shipped several versions of firmware by the format in driver packages for Windows and macOS.
The goal of this tool is to operate the flash memory to download any version of firmware. In this patchset, limited functionalities are added; read from the flash memory, and parse the content of file. The other functionalities are planned to added in future work.
I thinks it possible to put actual firmware blobs into somewhere suitable for them (alsa-firmware or linux-firmware repositories). I think it better to prepare the files by reading on-board flash memory, with enough care of copyright of original firmware files shipped by vendor. In the case, it's preferable to use file format different from the original one. But it's my first time for this kind of work. I'd like to ask some advices to alsa developers.
[1] https://github.com/alsa-project/alsa-tools/ [2] https://github.com/takaswie/alsa-tools/tree/topic/efw-downloader
Takashi Sakamoto (25): efw-downloader: start a new project to operate on-board flash memory for Fireworks board module efw-downloader: efw-proto: define EfwProto as derived object of HinawaFwResp efw-downloader: efw-proto: add constructor, destructor, bind, unbind functions efw-downloader: efw-proto: add responded signal efw-downloader: efw-proto: add class virtual method to handle responded signal efw-downloader: efw-proto: add instance private structure efw-downloader: efw-proto: emit responded signal at receiving response efw-downloader: efw-proto: add function to finish transaction for command frame efw-downloader: efw-proto: add function to finish a pair of transactions efw-downloader: add parser for sub commands efw-downloader: subcmd-device: implement 'device' sub command to operate actual device efw-downloader: subcmd-device: open firewire character device by HinawaFwNode efw-downloader: config-rom: parse config rom to detect supported device efw-downloader: subcmd-device: check supported models or not efw-downloader: subcmd-device: bind Fireworks protocol efw-downloader: node_dispatcher: add event dispatcher utilizing GLib MainContext/MainLoop efw-downloader: subcmd-device: support debug output for response of Fireworks protocol efw-downloader: efw-commands: add support for a part of hardware command efw-downloader: efw-commands: add support for commands in flash category efw-downloader: subcmd-device: add read operation efw-downloader: file-cntr: add parser for data binary shipped by Echo Digital Audio corporation efw-downloader: subcmd-file: add 'file' sub command efw-downloader: subcmd-file: add parse operation efw-downloader: man: add online manual efw-downloader: add README formatted by reStructuredText
efw-downloader/COPYING | 674 ++++++++++++++++++ efw-downloader/README.rst | 167 +++++ efw-downloader/man/efw-downloader.1 | 162 +++++ efw-downloader/meson.build | 14 + efw-downloader/meson_options.txt | 5 + efw-downloader/src/config-rom.c | 60 ++ efw-downloader/src/config-rom.h | 26 + efw-downloader/src/efw-commands.c | 243 +++++++ efw-downloader/src/efw-commands.h | 57 ++ .../src/efw-proto-sigs-marshal.list | 1 + efw-downloader/src/efw-proto.c | 401 +++++++++++ efw-downloader/src/efw-proto.h | 80 +++ efw-downloader/src/file-cntr.c | 183 +++++ efw-downloader/src/file-cntr.h | 39 + efw-downloader/src/main.c | 54 ++ efw-downloader/src/meson.build | 54 ++ efw-downloader/src/node-dispatcher.c | 86 +++ efw-downloader/src/node-dispatcher.h | 21 + efw-downloader/src/op-device-read.c | 104 +++ efw-downloader/src/op-file-parse.c | 106 +++ efw-downloader/src/subcmd-device.c | 182 +++++ efw-downloader/src/subcmd-file.c | 87 +++ efw-downloader/src/subcmds.h | 16 + 23 files changed, 2822 insertions(+) create mode 100644 efw-downloader/COPYING create mode 100644 efw-downloader/README.rst create mode 100644 efw-downloader/man/efw-downloader.1 create mode 100644 efw-downloader/meson.build create mode 100644 efw-downloader/meson_options.txt create mode 100644 efw-downloader/src/config-rom.c create mode 100644 efw-downloader/src/config-rom.h create mode 100644 efw-downloader/src/efw-commands.c create mode 100644 efw-downloader/src/efw-commands.h create mode 100644 efw-downloader/src/efw-proto-sigs-marshal.list create mode 100644 efw-downloader/src/efw-proto.c create mode 100644 efw-downloader/src/efw-proto.h create mode 100644 efw-downloader/src/file-cntr.c create mode 100644 efw-downloader/src/file-cntr.h create mode 100644 efw-downloader/src/main.c create mode 100644 efw-downloader/src/meson.build create mode 100644 efw-downloader/src/node-dispatcher.c create mode 100644 efw-downloader/src/node-dispatcher.h create mode 100644 efw-downloader/src/op-device-read.c create mode 100644 efw-downloader/src/op-file-parse.c create mode 100644 efw-downloader/src/subcmd-device.c create mode 100644 efw-downloader/src/subcmd-file.c create mode 100644 efw-downloader/src/subcmds.h
-- 2.25.1
Thanks
Takashi Sakamoto
On Wed, 26 Aug 2020 11:32:58 +0200, Takashi Sakamoto wrote:
Hi,
Would I expect any reaction by maintainers of alsa-tools repository for the patches?
I'm reviewing those patches now.
Since it's based on meson build, it'll be tricky to include this in alsa-tools whether others are all autoconf. The tarball creation is done in the top directory and that assumes the execution of "make alsa-dist" in each subdirectory. Without this integration, the directory won't be included in the release.
Could you work on it, too?
thanks,
Takashi
On Fri, Aug 21, 2020 at 04:30:46PM +0900, Takashi Sakamoto wrote:
Hi,
This patchset is for alsa-tool repository[1] to add a new command-line tool, efw-downloader. The tools is designed to operate on-board flash memory for devices based on Fireworks board module. The patches are also available in my personal repository in github.com[2].
Fireworks board module was designed by Echo Digital Audio corporation. The board module has on-board flash memory to store firmware blob and session data. The contents of flash memory can be operated by software by a pair of asynchronous transactions defined by Echo Digital Audio corporation.
Echo Digital Audio corporation also designed file format of firmware. Hardware Vendors including Echo Digital Audio corporation shipped several versions of firmware by the format in driver packages for Windows and macOS.
The goal of this tool is to operate the flash memory to download any version of firmware. In this patchset, limited functionalities are added; read from the flash memory, and parse the content of file. The other functionalities are planned to added in future work.
I thinks it possible to put actual firmware blobs into somewhere suitable for them (alsa-firmware or linux-firmware repositories). I think it better to prepare the files by reading on-board flash memory, with enough care of copyright of original firmware files shipped by vendor. In the case, it's preferable to use file format different from the original one. But it's my first time for this kind of work. I'd like to ask some advices to alsa developers.
[1] https://github.com/alsa-project/alsa-tools/ [2] https://github.com/takaswie/alsa-tools/tree/topic/efw-downloader
Takashi Sakamoto (25): efw-downloader: start a new project to operate on-board flash memory for Fireworks board module efw-downloader: efw-proto: define EfwProto as derived object of HinawaFwResp efw-downloader: efw-proto: add constructor, destructor, bind, unbind functions efw-downloader: efw-proto: add responded signal efw-downloader: efw-proto: add class virtual method to handle responded signal efw-downloader: efw-proto: add instance private structure efw-downloader: efw-proto: emit responded signal at receiving response efw-downloader: efw-proto: add function to finish transaction for command frame efw-downloader: efw-proto: add function to finish a pair of transactions efw-downloader: add parser for sub commands efw-downloader: subcmd-device: implement 'device' sub command to operate actual device efw-downloader: subcmd-device: open firewire character device by HinawaFwNode efw-downloader: config-rom: parse config rom to detect supported device efw-downloader: subcmd-device: check supported models or not efw-downloader: subcmd-device: bind Fireworks protocol efw-downloader: node_dispatcher: add event dispatcher utilizing GLib MainContext/MainLoop efw-downloader: subcmd-device: support debug output for response of Fireworks protocol efw-downloader: efw-commands: add support for a part of hardware command efw-downloader: efw-commands: add support for commands in flash category efw-downloader: subcmd-device: add read operation efw-downloader: file-cntr: add parser for data binary shipped by Echo Digital Audio corporation efw-downloader: subcmd-file: add 'file' sub command efw-downloader: subcmd-file: add parse operation efw-downloader: man: add online manual efw-downloader: add README formatted by reStructuredText
efw-downloader/COPYING | 674 ++++++++++++++++++ efw-downloader/README.rst | 167 +++++ efw-downloader/man/efw-downloader.1 | 162 +++++ efw-downloader/meson.build | 14 + efw-downloader/meson_options.txt | 5 + efw-downloader/src/config-rom.c | 60 ++ efw-downloader/src/config-rom.h | 26 + efw-downloader/src/efw-commands.c | 243 +++++++ efw-downloader/src/efw-commands.h | 57 ++ .../src/efw-proto-sigs-marshal.list | 1 + efw-downloader/src/efw-proto.c | 401 +++++++++++ efw-downloader/src/efw-proto.h | 80 +++ efw-downloader/src/file-cntr.c | 183 +++++ efw-downloader/src/file-cntr.h | 39 + efw-downloader/src/main.c | 54 ++ efw-downloader/src/meson.build | 54 ++ efw-downloader/src/node-dispatcher.c | 86 +++ efw-downloader/src/node-dispatcher.h | 21 + efw-downloader/src/op-device-read.c | 104 +++ efw-downloader/src/op-file-parse.c | 106 +++ efw-downloader/src/subcmd-device.c | 182 +++++ efw-downloader/src/subcmd-file.c | 87 +++ efw-downloader/src/subcmds.h | 16 + 23 files changed, 2822 insertions(+) create mode 100644 efw-downloader/COPYING create mode 100644 efw-downloader/README.rst create mode 100644 efw-downloader/man/efw-downloader.1 create mode 100644 efw-downloader/meson.build create mode 100644 efw-downloader/meson_options.txt create mode 100644 efw-downloader/src/config-rom.c create mode 100644 efw-downloader/src/config-rom.h create mode 100644 efw-downloader/src/efw-commands.c create mode 100644 efw-downloader/src/efw-commands.h create mode 100644 efw-downloader/src/efw-proto-sigs-marshal.list create mode 100644 efw-downloader/src/efw-proto.c create mode 100644 efw-downloader/src/efw-proto.h create mode 100644 efw-downloader/src/file-cntr.c create mode 100644 efw-downloader/src/file-cntr.h create mode 100644 efw-downloader/src/main.c create mode 100644 efw-downloader/src/meson.build create mode 100644 efw-downloader/src/node-dispatcher.c create mode 100644 efw-downloader/src/node-dispatcher.h create mode 100644 efw-downloader/src/op-device-read.c create mode 100644 efw-downloader/src/op-file-parse.c create mode 100644 efw-downloader/src/subcmd-device.c create mode 100644 efw-downloader/src/subcmd-file.c create mode 100644 efw-downloader/src/subcmds.h
-- 2.25.1
Thanks
Takashi Sakamoto
Hi,
On Wed, Aug 26, 2020 at 01:31:53PM +0200, Takashi Iwai wrote:
On Wed, 26 Aug 2020 11:32:58 +0200, Takashi Sakamoto wrote:
Hi,
Would I expect any reaction by maintainers of alsa-tools repository for the patches?
I'm reviewing those patches now.
Thanks for your review.
Since it's based on meson build, it'll be tricky to include this in alsa-tools whether others are all autoconf. The tarball creation is done in the top directory and that assumes the execution of "make alsa-dist" in each subdirectory. Without this integration, the directory won't be included in the release.
Could you work on it, too?
I didn't have enough care of distributing the package. Thank you for the indication.
Although it's possible to write configure.ac/Makefile.am for efw-downloader, I'd like to use meson.build for my convenience, especially for the convenience of gnome module[1] in meson (Nowadays software in GNOME project including GLib is mostly build by meson).
As long as I know, the concept of release creation in GNU Autotools is different from the one in meson build system. GNU Autotools distributes scripts generated from Makefile.am/configure.ac and so. On the other hand, meson distributes files maintained by git or mercurial.
If we have a space to make enough arrangement for alsa-tools, the top-level Makefile should be changed to have two variables for subdirectories which includes software built by GNU Autotools and the others, then be changed further for configure/install/alsa-dist/clean targets.
Nevertheless, the idea to mix all of software built by several types of build system into one repository is not so convenient itself. I'll take more time to investigate further for better packaging of alsa-tools. (Tools like Android repo is a bit over-engineering in the case, mmm)
I decline the patchset for now.
[1] https://mesonbuild.com/Gnome-module.html
Thanks
Takashi Sakamoto
On Thu, 27 Aug 2020 14:24:42 +0200, Takashi Sakamoto wrote:
Hi,
On Wed, Aug 26, 2020 at 01:31:53PM +0200, Takashi Iwai wrote:
On Wed, 26 Aug 2020 11:32:58 +0200, Takashi Sakamoto wrote:
Hi,
Would I expect any reaction by maintainers of alsa-tools repository for the patches?
I'm reviewing those patches now.
Thanks for your review.
Since it's based on meson build, it'll be tricky to include this in alsa-tools whether others are all autoconf. The tarball creation is done in the top directory and that assumes the execution of "make alsa-dist" in each subdirectory. Without this integration, the directory won't be included in the release.
Could you work on it, too?
I didn't have enough care of distributing the package. Thank you for the indication.
Although it's possible to write configure.ac/Makefile.am for efw-downloader, I'd like to use meson.build for my convenience, especially for the convenience of gnome module[1] in meson (Nowadays software in GNOME project including GLib is mostly build by meson).
As long as I know, the concept of release creation in GNU Autotools is different from the one in meson build system. GNU Autotools distributes scripts generated from Makefile.am/configure.ac and so. On the other hand, meson distributes files maintained by git or mercurial.
If we have a space to make enough arrangement for alsa-tools, the top-level Makefile should be changed to have two variables for subdirectories which includes software built by GNU Autotools and the others, then be changed further for configure/install/alsa-dist/clean targets.
Nevertheless, the idea to mix all of software built by several types of build system into one repository is not so convenient itself. I'll take more time to investigate further for better packaging of alsa-tools. (Tools like Android repo is a bit over-engineering in the case, mmm)
I decline the patchset for now.
OK. It's indeed awkward to mix up both auto-tools and meson. So the more suitable option would be either to modernize everything with meson, or just create a configure.ac for efw-downloader. Maybe the latter is easier, as the dependency would be only about hinawa and the check via pkgconfig is trivial even with automake. But, obviously, modernization is more appealing (with a risk of breakage, as always :)
thanks,
Takashi
Hi,
On Thu, Aug 27, 2020 at 02:57:04PM +0200, Takashi Iwai wrote:
On Thu, 27 Aug 2020 14:24:42 +0200, Takashi Sakamoto wrote:
On Wed, Aug 26, 2020 at 01:31:53PM +0200, Takashi Iwai wrote:
Since it's based on meson build, it'll be tricky to include this in alsa-tools whether others are all autoconf. The tarball creation is done in the top directory and that assumes the execution of "make alsa-dist" in each subdirectory. Without this integration, the directory won't be included in the release.
Could you work on it, too?
I didn't have enough care of distributing the package. Thank you for the indication.
Although it's possible to write configure.ac/Makefile.am for efw-downloader, I'd like to use meson.build for my convenience, especially for the convenience of gnome module[1] in meson (Nowadays software in GNOME project including GLib is mostly build by meson).
As long as I know, the concept of release creation in GNU Autotools is different from the one in meson build system. GNU Autotools distributes scripts generated from Makefile.am/configure.ac and so. On the other hand, meson distributes files maintained by git or mercurial.
If we have a space to make enough arrangement for alsa-tools, the top-level Makefile should be changed to have two variables for subdirectories which includes software built by GNU Autotools and the others, then be changed further for configure/install/alsa-dist/clean targets.
Nevertheless, the idea to mix all of software built by several types of build system into one repository is not so convenient itself. I'll take more time to investigate further for better packaging of alsa-tools. (Tools like Android repo is a bit over-engineering in the case, mmm)
I decline the patchset for now.
OK. It's indeed awkward to mix up both auto-tools and meson. So the more suitable option would be either to modernize everything with meson, or just create a configure.ac for efw-downloader. Maybe the latter is easier, as the dependency would be only about hinawa and the check via pkgconfig is trivial even with automake. But, obviously, modernization is more appealing (with a risk of breakage, as always :)
The modernization is itself preferrable, but the idea of everything with meson is not better since we have several build systems in the world. In my opinion, the preferrable way is to enable developers to add software without limitations about its build system and dependency.
As a quick glance, below applications have dependency to Gtk+2 or Gtk+3. For them, replacement with meson build system is reasonable:
* echomixer * envy24control * hdajackretask * rmedigicontrol
As you know, Gtk+2 is already obsoleted, thus the above should be ported to Gtk4[1].
Qlo10k1 is only an application of Qt3. I guess CMake is more preferrable than GNU Autotools in the case. As well as Gtk+2, Gt3 is already obsoleted.
Hwmixvolume is written by Python 3, thus it's better to follow the standard way in Python world (setup.py).
For the other software, it doesn't matter still to use GNU autotools.
However, ld10k1 includes tools (ld10k1/lo10k1/dl10k1) seem to depend on local library (liblo10k1) but Makefile seems not to describe the dependency appropriately.
At present, I have no proposal for the issue, but it's possible to split the software into several repositories depending on build system, like:
* alsa-tools-meson * alsa-tools-cmake * alsa-tools-python * alsa-tools-autotools
Then put release script to alsa-tools repository with git-submodules for them.
[1] Debian Bug report logs - #967250 alsa-tools: depends on deprecated GTK 2 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=967250
Regards
Takashi Sakamoto
participants (2)
-
Takashi Iwai
-
Takashi Sakamoto