-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add boilerplate for sifive,trace 'uart' driver
Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
- Loading branch information
1 parent
2444567
commit 2df07a2
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,23 @@ | ||
/* Copyright 2019 SiFive, Inc */ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
|
||
#ifndef METAL__DRIVERS__SIFIVE_TRACE_H | ||
#define METAL__DRIVERS__SIFIVE_TRACE_H | ||
|
||
#include <metal/io.h> | ||
#include <metal/uart.h> | ||
#include <metal/compiler.h> | ||
|
||
struct __metal_driver_vtable_sifive_trace { | ||
const struct metal_uart_vtable uart; | ||
}; | ||
|
||
struct __metal_driver_sifive_trace; | ||
|
||
__METAL_DECLARE_VTABLE(__metal_driver_vtable_sifive_trace) | ||
|
||
struct __metal_driver_sifive_trace { | ||
struct metal_uart uart; | ||
}; | ||
|
||
#endif /* METAL__DRIVERS__SIFIVE_TRACE_H */ |
This file contains 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,44 @@ | ||
/* Copyright 2019 SiFive, Inc */ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
|
||
#include <metal/machine/platform.h> | ||
|
||
#ifdef METAL_SIFIVE_TRACE | ||
|
||
#include <metal/drivers/sifive_trace.h> | ||
#include <metal/machine.h> | ||
|
||
#define TRACE_REG(base, offset) (((unsigned long)base + offset)) | ||
#define TRACE_REGB(base, offset) (__METAL_ACCESS_ONCE((__metal_io_u8 *)TRACE_REG(base, offset))) | ||
#define TRACE_REGW(base, offset) (__METAL_ACCESS_ONCE((__metal_io_u32 *)TRACE_REG(base, offset))) | ||
|
||
int __metal_driver_sifive_trace_putc(struct metal_uart *trace, unsigned char c) | ||
{ | ||
long base = __metal_driver_sifive_trace_base(trace); | ||
return 0; | ||
} | ||
|
||
int __metal_driver_sifive_trace_getc(struct metal_uart *trace, unsigned char *c) | ||
{ | ||
long base = __metal_driver_sifive_trace_base(trace); | ||
return 0; | ||
} | ||
|
||
void __metal_driver_sifive_trace_init(struct metal_uart *trace, int baud_rate) | ||
{ | ||
long base = __metal_driver_sifive_trace_base(trace); | ||
} | ||
|
||
__METAL_DEFINE_VTABLE(__metal_driver_vtable_sifive_trace) = { | ||
.uart.init = __metal_driver_sifive_trace_init, | ||
.uart.putc = __metal_driver_sifive_trace_putc, | ||
.uart.getc = __metal_driver_sifive_trace_getc, | ||
|
||
.uart.get_baud_rate = NULL, | ||
.uart.set_baud_rate = NULL, | ||
|
||
.uart.controller_interrupt = NULL, | ||
.uart.get_interrupt_id = NULL, | ||
}; | ||
|
||
#endif /* METAL_SIFIVE_TRACE */ |