diff options
author | Cyril Bur <cyrilbur@gmail.com> | 2018-02-09 15:38:34 +1100 |
---|---|---|
committer | Alistair Popple <alistair@popple.id.au> | 2018-02-12 14:50:47 +1100 |
commit | e995715ad4a9522c4040c2ac7e06b5c8d33977b8 (patch) | |
tree | 591a50d78674fceb2a222e0e14ced1b30e3dd801 | |
parent | 9367b72880bdc88a0e74e651f206554911236ae8 (diff) | |
download | pdbg-e995715ad4a9522c4040c2ac7e06b5c8d33977b8.tar.gz pdbg-e995715ad4a9522c4040c2ac7e06b5c8d33977b8.zip |
main: Pull cfam functions out of main.c
Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | src/cfam.c | 43 | ||||
-rw-r--r-- | src/cfam.h | 19 | ||||
-rw-r--r-- | src/main.c | 20 |
4 files changed, 64 insertions, 20 deletions
diff --git a/Makefile.am b/Makefile.am index 3c266d2..f148ef9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,7 +11,7 @@ ACLOCAL_AMFLAGS = -Im4 AM_CFLAGS = -I$(top_srcdir)/ccan/array_size -Wall -Werror pdbg_SOURCES = \ - src/main.c + src/main.c src/cfam.c pdbg_LDADD = fake.dtb.o p8-fsi.dtb.o p8-i2c.dtb.o p9w-fsi.dtb.o p8-host.dtb.o \ p9z-fsi.dtb.o p9r-fsi.dtb.o p9-kernel.dtb.o libpdbg.la libfdt.la \ p9-host.dtb.o \ diff --git a/src/cfam.c b/src/cfam.c new file mode 100644 index 0000000..8120e20 --- /dev/null +++ b/src/cfam.c @@ -0,0 +1,43 @@ +/* Copyright 2017 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include <stdio.h> +#include <inttypes.h> + +#include <target.h> + +int getcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused) +{ + uint32_t value; + + if (fsi_read(target, *addr, &value)) + return 0; + + printf("p%d:0x%x = 0x%08x\n", index, (uint32_t) *addr, value); + + return 1; +} + +int putcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data) +{ + if (fsi_write(target, *addr, *data)) + return 0; + + return 1; +} + + + + diff --git a/src/cfam.h b/src/cfam.h new file mode 100644 index 0000000..80354e4 --- /dev/null +++ b/src/cfam.h @@ -0,0 +1,19 @@ +/* Copyright 2017 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include <inttypes.h> + +int getcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused); +int putcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data); @@ -31,6 +31,7 @@ #include <libpdbg.h> #include "bitutils.h" +#include "cfam.h" #undef PR_DEBUG #define PR_DEBUG(...) @@ -427,25 +428,6 @@ static int for_each_target(char *class, int (*cb)(struct pdbg_target *, uint32_t return rc; } -static int getcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused) -{ - uint32_t value; - - if (fsi_read(target, *addr, &value)) - return 0; - - printf("p%d:0x%x = 0x%08x\n", index, (uint32_t) *addr, value); - - return 1; -} - -static int putcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data) -{ - if (fsi_write(target, *addr, *data)) - return 0; - - return 1; -} static int getscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused) { |