diff options
author | Alistair Popple <alistair@popple.id.au> | 2017-07-13 13:45:27 +1000 |
---|---|---|
committer | Alistair Popple <alistair@popple.id.au> | 2017-07-13 13:45:27 +1000 |
commit | 4b55a9664d33a9ea3bab87e9668c71ac3c3f877d (patch) | |
tree | 9e83ac5712f42f4030d1c87e19032e2a0dca2f25 /libpdbg | |
parent | 7970779cfa59b94923e00b3f2898da0badbd4bcf (diff) | |
download | pdbg-4b55a9664d33a9ea3bab87e9668c71ac3c3f877d.tar.gz pdbg-4b55a9664d33a9ea3bab87e9668c71ac3c3f877d.zip |
libpdbg: Add a more complete fake backend
The fake backend we had couldn't be used as src/main.c was missing the option to
enable it. It was also missing an implementation of a fake pib so add that too.
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Diffstat (limited to 'libpdbg')
-rw-r--r-- | libpdbg/fake.c | 66 | ||||
-rw-r--r-- | libpdbg/fakepib.c | 38 |
2 files changed, 66 insertions, 38 deletions
diff --git a/libpdbg/fake.c b/libpdbg/fake.c new file mode 100644 index 0000000..5e5571c --- /dev/null +++ b/libpdbg/fake.c @@ -0,0 +1,66 @@ +/* copyright 2016 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 "operations.h" +#include <stdio.h> +#include <inttypes.h> + +static int fake_fsi_read(struct fsi *fsi, uint32_t addr, uint32_t *value) +{ + *value = 0xfeed0cfa; + printf("fake_fsi_read(0x%04" PRIx32 ", 0x%04" PRIx32 ")\n", addr, *value); + return 0; +} + +static int fake_fsi_write(struct fsi *fsi, uint32_t addr, uint32_t value) +{ + printf("fake_fsi_write(0x%04" PRIx32 ", 0x%04" PRIx32 ")\n", addr, value); + return 0; +} + +struct fsi fake_fsi = { + .target = { + .name = "Fake FSI", + .compatible = "ibm,fake-fsi", + .class = "fsi", + }, + .read = fake_fsi_read, + .write = fake_fsi_write, +}; +DECLARE_HW_UNIT(fake_fsi); + +static int fake_pib_read(struct pib *pib, uint64_t addr, uint64_t *value) +{ + *value = 0xdeadbeef; + printf("fake_pib_read(0x%08" PRIx64 ", 0x%08" PRIx64 ")\n", addr, *value); + return 0; +} + +static int fake_pib_write(struct pib *pib, uint64_t addr, uint64_t value) +{ + printf("fake_pib_write(0x%08" PRIx64 ", 0x%08" PRIx64 ")\n", addr, value); + return 0; +} + +struct pib fake_pib = { + .target = { + .name = "Fake PIB", + .compatible = "ibm,fake-pib", + .class = "pib", + }, + .read = fake_pib_read, + .write = fake_pib_write, +}; +DECLARE_HW_UNIT(fake_pib); diff --git a/libpdbg/fakepib.c b/libpdbg/fakepib.c deleted file mode 100644 index 22ea3e7..0000000 --- a/libpdbg/fakepib.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2016 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 "operations.h" - -static int fake_read(struct pib *pib, uint64_t addr, uint64_t *value) -{ - *value = 0xdeadbeef; - return 0; -} - -static int fake_write(struct pib *pib, uint64_t addr, uint64_t value) -{ - return 0; -} - -struct pib fake_pib = { - .target = { - .name = "Fake PIB", - .compatible = "ibm,fake-fsi", - .class = "fsi", - }, - .read = fake_read, - .write = fake_write, -}; -DECLARE_HW_UNIT(fake_pib); |