Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
Mock Turtle
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Mock Turtle
Commits
e5042047
Commit
e5042047
authored
Mar 22, 2019
by
Federico Vaga
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/debugger-mmap' into develop
parents
67ce2658
e0e57217
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1359 additions
and
0 deletions
+1359
-0
mockturtle_addresses.h
software/include/hw/mockturtle_addresses.h
+2
-0
Makefile
software/kernel/Makefile
+2
-0
mockturtle-compat.c
software/kernel/mockturtle-compat.c
+45
-0
mockturtle-compat.h
software/kernel/mockturtle-compat.h
+17
-0
mockturtle-dbg.c
software/kernel/mockturtle-dbg.c
+55
-0
mockturtle-drv.h
software/kernel/mockturtle-drv.h
+2
-0
.gitignore
software/tools/.gitignore
+1
-0
Makefile
software/tools/Makefile
+1
-0
mockturtle-gdbserver.c
software/tools/mockturtle-gdbserver.c
+1234
-0
No files found.
software/include/hw/mockturtle_addresses.h
View file @
e5042047
...
...
@@ -6,6 +6,8 @@
/* Host addresses. */
#define TRTL_ADDR_OFFSET_HMQ 0x00000000
#define TRTL_ADDR_OFFSET_CSR 0x0000C000
/* FIXME update memorymap to have DBG PAGE_ALIGNED */
#define TRTL_ADDR_OFFSET_DBG TRTL_ADDR_OFFSET_CSR
#define TRTL_ADDR_OFFSET_CONFIG_ROM 0x0000E000
#define TRTL_ADDR_OFFSET_SHM 0x00010000
...
...
software/kernel/Makefile
View file @
e5042047
...
...
@@ -26,6 +26,8 @@ mockturtle-y += mockturtle-cpu.o
mockturtle-y
+=
mockturtle-hmq.o
mockturtle-y
+=
mockturtle-tty.o
mockturtle-y
+=
mockturtle-dbg.o
mockturtle-y
+=
mockturtle-dbg.o
mockturtle-y
+=
mockturtle-compat.o
all modules
:
...
...
software/kernel/mockturtle-compat.c
0 → 100644
View file @
e5042047
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2014-2019 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
*/
#include <linux/version.h>
#include <linux/mm.h>
#include "mockturtle-compat.h"
#if KERNEL_VERSION(3, 9, 0) > LINUX_VERSION_CODE
/* Copied from v3.10 */
int
vm_iomap_memory
(
struct
vm_area_struct
*
vma
,
phys_addr_t
start
,
unsigned
long
len
)
{
unsigned
long
vm_len
,
pfn
,
pages
;
/* Check that the physical memory area passed in looks valid */
if
(
start
+
len
<
start
)
return
-
EINVAL
;
/*
* You *really* shouldn't map things that aren't page-aligned,
* but we've historically allowed it because IO memory might
* just have smaller alignment.
*/
len
+=
start
&
~
PAGE_MASK
;
pfn
=
start
>>
PAGE_SHIFT
;
pages
=
(
len
+
~
PAGE_MASK
)
>>
PAGE_SHIFT
;
if
(
pfn
+
pages
<
pfn
)
return
-
EINVAL
;
/* We start the mapping 'vm_pgoff' pages into the area */
if
(
vma
->
vm_pgoff
>
pages
)
return
-
EINVAL
;
pfn
+=
vma
->
vm_pgoff
;
pages
-=
vma
->
vm_pgoff
;
/* Can we fit all of the mapping? */
vm_len
=
vma
->
vm_end
-
vma
->
vm_start
;
if
(
vm_len
>>
PAGE_SHIFT
>
pages
)
return
-
EINVAL
;
/* Ok, let it rip */
return
io_remap_pfn_range
(
vma
,
vma
->
vm_start
,
pfn
,
vm_len
,
vma
->
vm_page_prot
);
}
#endif
software/kernel/mockturtle-compat.h
0 → 100644
View file @
e5042047
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2014-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
*/
#ifndef __TRTL_COMPAT_H__
#define __TRTL_COMPAT_H__
#include <linux/version.h>
#if KERNEL_VERSION(3, 9, 0) > LINUX_VERSION_CODE
int
vm_iomap_memory
(
struct
vm_area_struct
*
vma
,
phys_addr_t
start
,
unsigned
long
len
);
#endif
#endif
software/kernel/mockturtle-dbg.c
View file @
e5042047
...
...
@@ -8,9 +8,11 @@
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/seq_file.h>
#include <linux/mm.h>
#include <hw/mockturtle_cpu_csr.h>
#include "mockturtle-drv.h"
#include "mockturtle-compat.h"
static
int
trtl_dbg_info_seq_read
(
struct
seq_file
*
s
,
void
*
data
)
{
...
...
@@ -83,6 +85,47 @@ static const struct file_operations trtl_dbg_info_ops = {
.
release
=
single_release
,
};
#define TRTL_DBG_PORT_SIZE PAGE_SIZE
/* FIXME */
static
int
trtl_dbg_debugger_mmap
(
struct
file
*
file
,
struct
vm_area_struct
*
vma
)
{
struct
trtl_dev
*
trtl
=
file
->
private_data
;
unsigned
long
vsize
;
int
ret
;
struct
platform_device
*
pdev
=
to_platform_device
(
trtl
->
dev
.
parent
);
struct
resource
*
r
;
if
(
vma
->
vm_pgoff
>
0
)
{
dev_err
(
&
trtl
->
dev
,
"Debug Port mapping does not accept offsets
\n
"
);
return
-
EINVAL
;
}
vsize
=
vma
->
vm_end
-
vma
->
vm_start
;
if
(
vsize
>
TRTL_DBG_PORT_SIZE
)
{
dev_err
(
&
trtl
->
dev
,
"Debug Port mapping can't map more that %lu bytes (%lu)
\n
"
,
TRTL_DBG_PORT_SIZE
,
vsize
);
return
-
EINVAL
;
}
vma
->
vm_flags
|=
VM_IO
|
VM_DONTCOPY
|
VM_DONTEXPAND
;
vma
->
vm_page_prot
=
pgprot_noncached
(
vma
->
vm_page_prot
);
r
=
platform_get_resource
(
pdev
,
IORESOURCE_MEM
,
TRTL_MEM_BASE
);
return
vm_iomap_memory
(
vma
,
r
->
start
+
TRTL_ADDR_OFFSET_DBG
,
TRTL_DBG_PORT_SIZE
);
return
ret
;
}
static
const
struct
file_operations
trtl_dbg_debugger_ops
=
{
.
owner
=
THIS_MODULE
,
.
open
=
simple_open
,
.
mmap
=
trtl_dbg_debugger_mmap
,
};
/**
* It creates the debug info file
...
...
@@ -90,6 +133,8 @@ static const struct file_operations trtl_dbg_info_ops = {
*/
void
trtl_debugfs_init
(
struct
trtl_dev
*
trtl
)
{
char
name
[
20
];
trtl
->
dbg_dir
=
debugfs_create_dir
(
dev_name
(
&
trtl
->
dev
),
NULL
);
if
(
IS_ERR_OR_NULL
(
trtl
->
dbg_dir
))
{
dev_err
(
&
trtl
->
dev
,
"Cannot create debugfs
\n
"
);
...
...
@@ -106,6 +151,16 @@ void trtl_debugfs_init(struct trtl_dev *trtl)
PTR_ERR
(
trtl
->
dbg_info
));
trtl
->
dbg_info
=
NULL
;
}
snprintf
(
name
,
20
,
"%s-dbg"
,
dev_name
(
&
trtl
->
dev
));
trtl
->
debugger
=
debugfs_create_file
(
name
,
0664
,
trtl
->
dbg_dir
,
trtl
,
&
trtl_dbg_debugger_ops
);
if
(
IS_ERR_OR_NULL
(
trtl
->
debugger
))
{
dev_err
(
&
trtl
->
dev
,
"Cannot create debugfs file: %ld
\n
"
,
PTR_ERR
(
trtl
->
debugger
));
trtl
->
debugger
=
NULL
;
}
}
...
...
software/kernel/mockturtle-drv.h
View file @
e5042047
...
...
@@ -259,6 +259,7 @@ struct trtl_cpu {
* single IRQ. It regulates the HMQ IRQ handler
* @last_seq: last sequence number used. The same seq number cannot be used
* on different HMQ on the same CPU
* @debugger: debugfs interface for gdbserver
*/
struct
trtl_dev
{
struct
device
dev
;
...
...
@@ -280,6 +281,7 @@ struct trtl_dev {
struct
dentry
*
dbg_info
;
unsigned
int
max_irq_loop
;
uint32_t
last_seq
;
struct
dentry
*
debugger
;
};
static
inline
u32
trtl_ioread
(
struct
trtl_dev
*
trtl
,
void
*
addr
)
...
...
software/tools/.gitignore
View file @
e5042047
...
...
@@ -7,3 +7,4 @@ mockturtle-smem
mockturtle-ping
mockturtle-variable
mockturtle-buffer
mockturtle-gdbserver
\ No newline at end of file
software/tools/Makefile
View file @
e5042047
...
...
@@ -27,6 +27,7 @@ PROGS += mockturtle-smem
PROGS
+=
mockturtle-ping
PROGS
+=
mockturtle-variable
PROGS
+=
mockturtle-buffer
PROGS
+=
mockturtle-gdbserver
all
:
$(PROGS)
...
...
software/tools/mockturtle-gdbserver.c
0 → 100644
View file @
e5042047
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment