@@ -64,7 +64,7 @@
#define THREADS_PER_CORE 8
-static enum backend backend = KERNEL;
+static enum backend backend = DEFAULT_BACKEND;
static char const *device_node;
static int i2c_addr = 0x50;
@@ -607,17 +607,6 @@ static bool target_selection(void)
return false;
}
- if (pathsel_count) {
- if (!path_target_parse(pathsel, pathsel_count))
- return false;
- }
-
- if (!path_target_present()) {
- printf("No valid targets found or specified. Try adding -p/-c/-t options to specify a target.\n");
- printf("Alternatively run 'pdbg -a probe' to get a list of all valid targets\n");
- return false;
- }
-
return true;
}
@@ -677,9 +666,7 @@ int main(int argc, char *argv[])
optcmd_cmd_t *cmd;
struct pdbg_target *target;
- backend = default_backend();
-
- if (!device_node)
+ if (backend && !device_node)
device_node = default_target(backend);
if (!parse_options(argc, argv))
@@ -690,9 +677,29 @@ int main(int argc, char *argv[])
return 1;
}
- /* Disable unselected targets */
- if (!target_selection())
+ if (backend) {
+ fprintf(stderr, "WARNING: Explicit backend selection should no longer be required\n");
+ fprintf(stderr, " and will be deprecated in a future release.\n");
+ fprintf(stderr, " Removing -b/-d command line options will remove this warning.\n");
+ fprintf(stderr, " An explicit device-tree can still be selected using the\n");
+ fprintf(stderr, " LPDBG_DTB environment variable instead.\n");
+
+ if (!target_selection())
+ return 1;
+ } else {
+ pdbg_targets_init(NULL);
+ }
+
+ if (pathsel_count) {
+ if (!path_target_parse(pathsel, pathsel_count))
+ return false;
+ }
+
+ if (!path_target_present()) {
+ printf("No valid targets found or specified. Try adding -p/-c/-t options to specify a target.\n");
+ printf("Alternatively run 'pdbg -a probe' to get a list of all valid targets\n");
return 1;
+ }
/* Probe all selected targets */
for_each_path_target(target) {
@@ -19,7 +19,7 @@
#include <libpdbg.h>
-enum backend { FSI, I2C, KERNEL, FAKE, HOST };
+enum backend { DEFAULT_BACKEND = 0, FSI, I2C, KERNEL, FAKE, HOST };
static inline bool target_is_disabled(struct pdbg_target *target)
{
@@ -14,9 +14,6 @@
* limitations under the License.
*/
-/* Default backend on this platform */
-enum backend default_backend(void);
-
/* Print all possible backends on this platform */
void print_backends(FILE *stream);
@@ -28,20 +28,6 @@
#define CHIP_ID_P9 0xd1
#define CHIP_ID_P8P 0xd3
-enum backend default_backend(void)
-{
- int rc;
- rc = access(AMI_BMC, F_OK);
- if (rc == 0) /* AMI BMC */
- return I2C;
-
- rc = access(OPENFSI_BMC, F_OK);
- if (rc == 0) /* Kernel interface. OpenBMC */
- return KERNEL;
-
- return FAKE;
-}
-
void print_backends(FILE *stream)
{
fprintf(stream, "Valid backends: i2c kernel fsi fake\n");
@@ -17,11 +17,6 @@
#include <stdio.h>
#include "main.h"
-enum backend default_backend(void)
-{
- return FAKE;
-}
-
void print_backends(FILE *stream)
{
fprintf(stream, "Valid backends: fake\n");
@@ -21,11 +21,6 @@
static const char p8[] = "p8";
static const char p9[] = "p9";
-enum backend default_backend(void)
-{
- return HOST;
-}
-
void print_backends(FILE *stream)
{
fprintf(stream, "Valid backends: host fake\n");
Now that libpdbg can automatically select the correct device-tree the pdbg application doesn't need code to do the same thing. By default pdbg can just rely on the device-tree selected by libpdbg. Unfortunately to maintain backwards compatibility for users explicitly selecting a device-tree and device-tree node we need to retain most of the code and continue linking the device-trees into the application. It would be good to remove these one day so print a deprecation warning when a user does explicitly select a backend. Signed-off-by: Alistair Popple <alistair@popple.id.au> --- src/main.c | 41 ++++++++++++++++++++++++----------------- src/main.h | 2 +- src/options.h | 3 --- src/options_arm.c | 14 -------------- src/options_def.c | 5 ----- src/options_ppc.c | 5 ----- 6 files changed, 25 insertions(+), 45 deletions(-)