Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/68250 )
Change subject: flashrom.c: Drop programmer global singleton handle [WIP]
......................................................................
flashrom.c: Drop programmer global singleton handle [WIP]
What is remaining:
[ ] - delay framework patches still need to land.
[?] - do something about programmer name printing?
Change-Id: I23061ef2f965cf59d74fc3f29952c09117ef6c4f
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M flashrom.c
1 file changed, 17 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/50/68250/1
diff --git a/flashrom.c b/flashrom.c
index 7996e6b..695c3f0 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -37,8 +37,6 @@
const char flashrom_version[] = FLASHROM_VERSION;
const char *chip_to_probe = NULL;
-static const struct programmer_entry *programmer = NULL;
-
/*
* Programmers supporting multiple buses can have differing size limits on
* each bus. Store the limits for each bus in a common struct.
@@ -133,7 +131,6 @@
msg_perr("Invalid programmer specified!\n");
return -1;
}
- programmer = prog;
/* Initialize all programmer specific data. */
/* Default to unlimited decode sizes. */
max_rom_decode = (const struct decode_sizes) {
@@ -863,8 +860,11 @@
if (master_uses_physmap(mst))
msg_cinfo("mapped at physical address 0x%0*" PRIxPTR ".\n",
PRIxPTR_WIDTH, flash->physical_memory);
+#if 0
+ /* TODO(quasisec): No good ideas, maybe just delete the else branch??? */
else
msg_cinfo("on %s.\n", programmer->name);
+#endif
/* Flash registers may more likely not be mapped if the chip was forced.
* Lock info may be stored in registers, so avoid lock info printing. */
--
To view, visit https://review.coreboot.org/c/flashrom/+/68250
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I23061ef2f965cf59d74fc3f29952c09117ef6c4f
Gerrit-Change-Number: 68250
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-MessageType: newchange
Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/68249 )
Change subject: flashrom.c: Use programmer_init() func params over global
......................................................................
flashrom.c: Use programmer_init() func params over global
The 'programmer' intended to be used in the control flow
of 'programmer_init()' is a parameter to the function. Therefore
use that symbol directly over the global copy of it.
Change-Id: I71e61f0633bac2fc472971249910bf3bf57cd0eb
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M flashrom.c
1 file changed, 16 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/49/68249/1
diff --git a/flashrom.c b/flashrom.c
index e0fcf6e..7996e6b 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -161,8 +161,8 @@
cfg.params = NULL;
}
- msg_pdbg("Initializing %s programmer\n", programmer->name);
- ret = programmer->init(&cfg);
+ msg_pdbg("Initializing %s programmer\n", prog->name);
+ ret = prog->init(&cfg);
if (cfg.params && strlen(cfg.params)) {
if (ret != 0) {
/* It is quite possible that any unhandled programmer parameter would have been valid,
--
To view, visit https://review.coreboot.org/c/flashrom/+/68249
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I71e61f0633bac2fc472971249910bf3bf57cd0eb
Gerrit-Change-Number: 68249
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-MessageType: newchange
Attention is currently required from: Felix Singer, Thomas Heijligen, Anastasia Klimchuk.
Hello Felix Singer, build bot (Jenkins), Thomas Heijligen, Anastasia Klimchuk,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/67476
to look at the new patch set (#2).
Change subject: flashrom.c: Embed is_internal state within the flashctx
......................................................................
flashrom.c: Embed is_internal state within the flashctx
This avoids a fragil stack pointer check and another reliance
upon the 'programmer' handle as a global state.
Change-Id: I25717afc3a8f61ca9f4dfb4bb60d6cb048a2ad37
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M cli_classic.c
M flashrom.c
M include/flash.h
M include/programmer.h
M internal.c
5 files changed, 23 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/76/67476/2
--
To view, visit https://review.coreboot.org/c/flashrom/+/67476
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I25717afc3a8f61ca9f4dfb4bb60d6cb048a2ad37
Gerrit-Change-Number: 67476
Gerrit-PatchSet: 2
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: newpatchset
Attention is currently required from: Thomas Heijligen, Angel Pons, Anastasia Klimchuk.
Felix Singer has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/68162 )
Change subject: meson: Move programmer test sources into programmer definition
......................................................................
Patch Set 10:
(1 comment)
File tests/meson.build:
https://review.coreboot.org/c/flashrom/+/68162/comment/644c655c_81276543
PS10, Line 32: p_data += {
: 'testsrc' : p_data.get('testsrc', []),
: }
: srcs += p_data.get('testsrc')
> Since not every programmer has tests, we would have to define an empty list of testsrc in the progra […]
See also line 440 in the top-level meson file. It's done the same way there. We could add the corresponding lines from here too so that the list of fields is "complete". So this meson file would only iterate over the programmers and add the source files to the srcs list.
What do you think? :)
--
To view, visit https://review.coreboot.org/c/flashrom/+/68162
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I307faaf8a9f7ae3c54bd96e7d871a3abb8aadea3
Gerrit-Change-Number: 68162
Gerrit-PatchSet: 10
Gerrit-Owner: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Mon, 10 Oct 2022 04:26:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Felix Singer <felixsinger(a)posteo.net>
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: comment
Felix Singer has submitted this change. ( https://review.coreboot.org/c/flashrom/+/66684 )
(
9 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: flashrom.c: create is_internal_programmer() helper
......................................................................
flashrom.c: create is_internal_programmer() helper
As suggested by Angel Pons, add the function `is_internal_programmer`
to cut down on some pre-processor usage by moving it into the new
function.
The function then checks if the internal programmer is the
selected one. If the internal programmer is not built in, then it
just returns false.
Change-Id: I43243b990192077583a9a3a95d35844923d9c158
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66684
Reviewed-by: Angel Pons <th3fanbus(a)gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org>
Reviewed-by: Felix Singer <felixsinger(a)posteo.net>
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
---
M flashrom.c
1 file changed, 35 insertions(+), 7 deletions(-)
Approvals:
build bot (Jenkins): Verified
Felix Singer: Looks good to me, approved
Angel Pons: Looks good to me, but someone else must approve
Anastasia Klimchuk: Looks good to me, approved
diff --git a/flashrom.c b/flashrom.c
index c5f712a..088d804 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1345,18 +1345,25 @@
return 0;
}
+static bool is_internal_programmer()
+{
+#if CONFIG_INTERNAL == 1
+ return programmer == &programmer_internal;
+#else
+ return false;
+#endif
+}
+
static void nonfatal_help_message(void)
{
msg_gerr("Good, writing to the flash chip apparently didn't do anything.\n");
-#if CONFIG_INTERNAL == 1
- if (programmer == &programmer_internal)
+ if (is_internal_programmer())
msg_gerr("This means we have to add special support for your board, programmer or flash\n"
"chip. Please report this to the mailing list at flashrom(a)flashrom.org or on\n"
"IRC (see https://www.flashrom.org/Contact for details), thanks!\n"
"-------------------------------------------------------------------------------\n"
"You may now reboot or simply leave the machine running.\n");
else
-#endif
msg_gerr("Please check the connections (especially those to write protection pins) between\n"
"the programmer and the flash chip. If you think the error is caused by flashrom\n"
"please report this to the mailing list at flashrom(a)flashrom.org or on IRC (see\n"
@@ -1366,14 +1373,12 @@
void emergency_help_message(void)
{
msg_gerr("Your flash chip is in an unknown state.\n");
-#if CONFIG_INTERNAL == 1
- if (programmer == &programmer_internal)
+ if (is_internal_programmer())
msg_gerr("Get help on IRC (see https://www.flashrom.org/Contact) or mail\n"
"flashrom(a)flashrom.org with the subject \"FAILED: <your board name>\"!"
"-------------------------------------------------------------------------------\n"
"DO NOT REBOOT OR POWEROFF!\n");
else
-#endif
msg_gerr("Please report this to the mailing list at flashrom(a)flashrom.org or\n"
"on IRC (see https://www.flashrom.org/Contact for details), thanks!\n");
}
@@ -1709,7 +1714,7 @@
}
#if CONFIG_INTERNAL == 1
- if (programmer == &programmer_internal && cb_check_image(newcontents, flash_size) < 0) {
+ if (is_internal_programmer() && cb_check_image(newcontents, flash_size) < 0) {
if (flashctx->flags.force_boardmismatch) {
msg_pinfo("Proceeding anyway because user forced us to.\n");
} else {
--
To view, visit https://review.coreboot.org/c/flashrom/+/66684
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I43243b990192077583a9a3a95d35844923d9c158
Gerrit-Change-Number: 66684
Gerrit-PatchSet: 12
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-MessageType: merged
Attention is currently required from: Thomas Heijligen.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/66684 )
Change subject: flashrom.c: create is_internal_programmer() helper
......................................................................
Patch Set 10:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/66684/comment/a72faecf_671c475d
PS9, Line 9: This has the added benefit of cutting down one some
: pre-processor usage as suggested by Angel Pons as the
: function is always defined.
> I find this a bit confusing. Suggestion: […]
Done with some grammatical fixes.
--
To view, visit https://review.coreboot.org/c/flashrom/+/66684
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I43243b990192077583a9a3a95d35844923d9c158
Gerrit-Change-Number: 66684
Gerrit-PatchSet: 10
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Comment-Date: Mon, 10 Oct 2022 04:18:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Felix Singer <felixsinger(a)posteo.net>
Gerrit-MessageType: comment
Attention is currently required from: Thomas Heijligen, Edward O'Callaghan.
Hello Felix Singer, build bot (Jenkins), Thomas Heijligen, Angel Pons, Anastasia Klimchuk,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/66684
to look at the new patch set (#10).
Change subject: flashrom.c: create is_internal_programmer() helper
......................................................................
flashrom.c: create is_internal_programmer() helper
As suggested by Angel Pons, add the function `is_internal_programmer`
to cut down on some pre-processor usage by moving it into the new
function.
The function then checks if the internal programmer is the
selected one. If the internal programmer is not built in, then it
just returns false.
Change-Id: I43243b990192077583a9a3a95d35844923d9c158
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M flashrom.c
1 file changed, 30 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/84/66684/10
--
To view, visit https://review.coreboot.org/c/flashrom/+/66684
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I43243b990192077583a9a3a95d35844923d9c158
Gerrit-Change-Number: 66684
Gerrit-PatchSet: 10
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-MessageType: newpatchset
Attention is currently required from: Thomas Heijligen, Angel Pons, Anastasia Klimchuk.
Felix Singer has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/68162 )
Change subject: meson: Move programmer test sources into programmer definition
......................................................................
Patch Set 10:
(1 comment)
File tests/meson.build:
https://review.coreboot.org/c/flashrom/+/68162/comment/dd4c039f_e1c7bd83
PS10, Line 32: p_data += {
: 'testsrc' : p_data.get('testsrc', []),
: }
: srcs += p_data.get('testsrc')
> The idea is great, thank you! […]
Since not every programmer has tests, we would have to define an empty list of testsrc in the programmer definition, but that doesn't make much sense. It's just code that does nothing. Though, we can't iterate over all programmers when the field doesn't exist.
Thus, line 32-34 add the field testsrc to the programmers data if doesn't exist yet, but depending on if it exists or not it is filled with the existing data or with an empty list. This is needed so that we don't have to define empty lists at every programmer that doesn't have test sources defined yet.
Line 35 adds the content of testsrc to the list of sources that should be compiled.
--
To view, visit https://review.coreboot.org/c/flashrom/+/68162
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I307faaf8a9f7ae3c54bd96e7d871a3abb8aadea3
Gerrit-Change-Number: 68162
Gerrit-PatchSet: 10
Gerrit-Owner: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Mon, 10 Oct 2022 04:15:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: comment
Attention is currently required from: Felix Singer.
Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/68197 )
Change subject: tests/meson.build: Turn file list into list of file objects
......................................................................
Patch Set 3: Code-Review+1
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/68197/comment/fce2a6e1_6b112a0b
PS3, Line 12: as it is done elsewhere
I would say the main reason : as it gives better, more useful error message. (even if it wasn't done elsewhere)
--
To view, visit https://review.coreboot.org/c/flashrom/+/68197
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I0b9144a6b76c1772833817b4e6873818dcf36b05
Gerrit-Change-Number: 68197
Gerrit-PatchSet: 3
Gerrit-Owner: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Comment-Date: Mon, 10 Oct 2022 03:33:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment