-
Notifications
You must be signed in to change notification settings - Fork 95
morello: Add support for QEMU platform #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
heshamelmatary
wants to merge
1
commit into
seL4:master
Choose a base branch
from
CTSRD-CHERI:morello_aarch64
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
libplatsupport/plat_include/morello-qemu/platsupport/plat/clock.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) | ||
| * | ||
| * SPDX-License-Identifier: BSD-2-Clause | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| enum clk_id { | ||
| CLK_MASTER, | ||
| /* ----- */ | ||
| NCLOCKS, | ||
| /* Custom clock */ | ||
| CLK_CUSTOM, | ||
| }; | ||
|
|
||
| enum clock_gate { | ||
| NCLKGATES | ||
| }; |
11 changes: 11 additions & 0 deletions
11
libplatsupport/plat_include/morello-qemu/platsupport/plat/i2c.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /* | ||
| * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) | ||
| * | ||
| * SPDX-License-Identifier: BSD-2-Clause | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| enum i2c_id { | ||
| NI2C | ||
| }; |
22 changes: 22 additions & 0 deletions
22
libplatsupport/plat_include/morello-qemu/platsupport/plat/serial.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) | ||
| * | ||
| * SPDX-License-Identifier: BSD-2-Clause | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #define UART0_PADDR 0x9000000 | ||
|
|
||
| #define UART0_IRQ 33 | ||
|
|
||
| enum chardev_id { | ||
| PL001_UART0, | ||
| /* Aliases */ | ||
| PS_SERIAL0 = PL001_UART0, | ||
| /* defaults */ | ||
| PS_SERIAL_DEFAULT = PL001_UART0 | ||
| }; | ||
|
|
||
| #define DEFAULT_SERIAL_PADDR UART0_PADDR | ||
| #define DEFAULT_SERIAL_INTERRUPT UART0_IRQ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) | ||
| * | ||
| * SPDX-License-Identifier: BSD-2-Clause | ||
| */ | ||
|
|
||
| /** | ||
| * Contains the definition for all character devices on this platform. | ||
| * Currently this is just a simple patch. | ||
| */ | ||
|
|
||
| #include "../../chardev.h" | ||
| #include "../../common.h" | ||
| #include <utils/util.h> | ||
|
|
||
| #include "../../chardev.h" | ||
|
|
||
| static const int uart0_irqs[] = {UART0_IRQ, -1}; | ||
|
|
||
| #define UART_DEFN(devid) { \ | ||
| .id = PL001_UART##devid, \ | ||
| .paddr = UART##devid##_PADDR, \ | ||
| .size = BIT(12), \ | ||
| .irqs = uart##devid##_irqs, \ | ||
| .init_fn = &uart_init \ | ||
| } | ||
|
|
||
| static const struct dev_defn dev_defn[] = { | ||
| UART_DEFN(0), | ||
| }; | ||
|
|
||
| struct ps_chardevice *ps_cdev_init(enum chardev_id id, const ps_io_ops_t *o, struct ps_chardevice *d) | ||
| { | ||
| unsigned int i; | ||
| for (i = 0; i < ARRAY_SIZE(dev_defn); i++) { | ||
| if (dev_defn[i].id == id) { | ||
| return (dev_defn[i].init_fn(dev_defn + i, o, d)) ? NULL : d; | ||
| } | ||
| } | ||
| return NULL; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) | ||
| * | ||
| * SPDX-License-Identifier: BSD-2-Clause | ||
| */ | ||
|
|
||
| /* Mostly copy/paste from the HiKey plat. | ||
| * Should be moved to a common driver file for PL011 */ | ||
|
|
||
| #include <string.h> | ||
| #include <stdlib.h> | ||
| #include <platsupport/serial.h> | ||
| #include "../../chardev.h" | ||
|
|
||
| #define RHR_MASK MASK(8) | ||
| #define UARTDR 0x000 | ||
| #define UARTFR 0x018 | ||
| #define UARTIMSC 0x038 | ||
| #define UARTICR 0x044 | ||
| #define PL011_UARTFR_TXFF BIT(5) | ||
| #define PL011_UARTFR_RXFE BIT(4) | ||
|
|
||
| #define REG_PTR(base, off) ((volatile uint32_t *)((base) + (off))) | ||
|
|
||
| int uart_getchar(ps_chardevice_t *d) | ||
| { | ||
| int ch = EOF; | ||
|
|
||
| if ((*REG_PTR(d->vaddr, UARTFR) & PL011_UARTFR_RXFE) == 0) { | ||
| ch = *REG_PTR(d->vaddr, UARTDR) & RHR_MASK; | ||
| } | ||
| return ch; | ||
| } | ||
|
|
||
| int uart_putchar(ps_chardevice_t *d, int c) | ||
| { | ||
| if (c == '\n' && (d->flags & SERIAL_AUTO_CR)) { | ||
| uart_putchar(d, '\r'); | ||
| } | ||
|
|
||
| while ((*REG_PTR(d->vaddr, UARTFR) & PL011_UARTFR_TXFF) != 0); | ||
|
|
||
| *REG_PTR(d->vaddr, UARTDR) = c; | ||
|
|
||
| return c; | ||
| } | ||
|
|
||
| static void uart_handle_irq(ps_chardevice_t *dev) | ||
| { | ||
| *REG_PTR(dev->vaddr, UARTICR) = 0x7f0; | ||
| } | ||
|
|
||
| int uart_init(const struct dev_defn *defn, | ||
| const ps_io_ops_t *ops, | ||
| ps_chardevice_t *dev) | ||
| { | ||
| memset(dev, 0, sizeof(*dev)); | ||
| void *vaddr = chardev_map(defn, ops); | ||
| if (vaddr == NULL) { | ||
| return -1; | ||
| } | ||
|
|
||
| /* Set up all the device properties. */ | ||
| dev->id = defn->id; | ||
| dev->vaddr = (void *)vaddr; | ||
| dev->read = &uart_read; | ||
| dev->write = &uart_write; | ||
| dev->handle_irq = &uart_handle_irq; | ||
| dev->irqs = defn->irqs; | ||
| dev->ioops = *ops; | ||
| dev->flags = SERIAL_AUTO_CR; | ||
|
|
||
| *REG_PTR(dev->vaddr, UARTIMSC) = 0x50; | ||
| return 0; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.