Hi Joursoir,
It is awesome to have you interested in doing a project for flashrom! Please keep going! :)
A reminder from me, is that we want you to send a small patch if you want to get accepted for a project. Have a look at the guidelines https://www.flashrom.org/GSoC You can of course ask questions if you have any. Good luck!
On Sat, Apr 2, 2022 at 8:19 PM Thomas Heijligen src@posteo.de wrote:
Hi Joursoir,
I'm going to reply to your questions on Monday. Sorry for the delay, I'm currently not in reach of my Computer and want to look a few things up before answering.
-- Thomas
On 1 April 2022 20:43:10 WEST, Joursoir chat@joursoir.net wrote:
Hello Thomas,
I went ahead and started looking into shutdown functions. Almost of them use global variables, but I already have ideas on how to rewrite it. Now I start coding a prototype and want to implement struct example_data. But I have run into a problem with its initialization:
- In theory, we can declare a static variable within each programmer's
file. It would be convenient, but this method has a big disadvantage. We allocate private_data for every programmers but use only one.
static struct example_data { ... } private_data;
- It's not possible to add a variable to struct programmer_entry
because the structure is read only (structures in programmer.h are declared as const).
- Use a static global variable in flashrom.c. Lesser of two evils
principle as they say
static const struct programmer_entry *programmer = NULL; static const char *programmer_param = NULL; static void *programmer_data = NULL;
The next issue is the initialization of programmer_data:
a) Do it inside programmer->init(). The problem here is the duplication of programmer_data init code in each function.
b) Do it outside programmer->init(). The problem here is that we can't find out the size of example_data (it can be drkaised_data, it85spi_data and etc)
programmer_data = calloc(1, sizeof(EXAMPLE_DATA)); if (!data) { ... } ... ret = programmer->init(&programmer_data);
Perhaps there is some simpler solution, but I don't notice it.