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
9228e8fa
Commit
9228e8fa
authored
Apr 26, 2018
by
Federico Vaga
Committed by
Federico Vaga
Apr 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw:rt: move common.h function in general header
Signed-off-by:
Federico Vaga
<
federico.vaga@vaga.pv.it
>
parent
35d684a3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
156 deletions
+132
-156
mockturtle-rt-common.c
software/rt/lib/mockturtle-rt-common.c
+1
-1
mockturtle-rt-common.h
software/rt/lib/mockturtle-rt-common.h
+0
-155
mockturtle-rt.h
software/rt/lib/mockturtle-rt.h
+131
-0
No files found.
software/rt/lib/mockturtle-rt-common.c
View file @
9228e8fa
...
...
@@ -10,7 +10,7 @@
#include <stdint.h>
#include <string.h>
#include "mockturtle-rt
-common
.h"
#include "mockturtle-rt.h"
int
putchar
(
int
c
)
{
...
...
software/rt/lib/mockturtle-rt-common.h
deleted
100644 → 0
View file @
35d684a3
/**
* @defgroup library-utilities Common Utilities
* @{
* @ingroup library
* @brief Common utilities
* @copyright (C) 2013-2016 CERN (www.cern.ch)
* @author Federico Vaga <federico.vaga@cern.ch>
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef __TRTL_RT_COMMON_H
#define __TRTL_RT_COMMON_H
#include <stdint.h>
#include <stdio.h>
#include <hw/mockturtle_addresses.h>
#include "hw/mockturtle_cpu_lr.h"
#include <mockturtle.h>
#include "mockturtle-rt-serial.h"
/**
* Read a 32bit word value from the given address
* @param[in] addr source address
* @return the value fromt the register
*/
static
inline
uint32_t
readl
(
void
*
addr
)
{
return
*
(
volatile
uint32_t
*
)
(
addr
);
}
/**
* Write a 32bit word value to the given address
* @param[in] value value to write
* @param[in] addr destination address
*/
static
inline
void
writel
(
uint32_t
value
,
void
*
addr
)
{
*
(
volatile
uint32_t
*
)
(
addr
)
=
value
;
}
/**
* Read a 32bit word value from the Dedicated Peripheral address space
* @param[in] reg register offset within the Dedicated Peripheral
* @return the value fromt the register
*/
static
inline
uint32_t
dp_readl
(
uint32_t
reg
)
{
return
readl
(
TRTL_ADDR_DP
(
reg
));
}
/**
* Write a 32bit word value to the Dedicated Peripheral address space
* @param[in] value value to write
* @param[in] reg register offset within the Dedicated Peripheral
*/
static
inline
void
dp_writel
(
uint32_t
value
,
uint32_t
reg
)
{
writel
(
value
,
TRTL_ADDR_DP
(
reg
));
}
/**
* Read 32bit word value from the CPU Local Registers address space
* @param[in] reg register offset within the Local Registers
* @return the value fromt the register
*/
static
inline
uint32_t
lr_readl
(
uint32_t
reg
)
{
return
readl
(
TRTL_ADDR_LR
(
reg
));
}
/**
* Write 32bit word value to the CPU Local Registers address space
* @param[in] value value to write
* @param[in] reg register offset within the Local Registers
*/
static
inline
void
lr_writel
(
uint32_t
value
,
uint32_t
reg
)
{
writel
(
value
,
TRTL_ADDR_LR
(
reg
));
}
/**
* Set a bit in the CPU GPIO Register
* @param[in] pin GPIO pin to set
*/
static
inline
void
gpio_set
(
int
pin
)
{
lr_writel
((
1
<<
pin
),
MT_CPU_LR_REG_GPIO_SET
);
}
/**
* Clear a bit in the CPU GPIO Register
* @param[in] pin GPIO pin to clear
*/
static
inline
void
gpio_clear
(
int
pin
)
{
lr_writel
((
1
<<
pin
),
MT_CPU_LR_REG_GPIO_CLEAR
);
}
/**
* Wait n cycles
* @todo: use Timing Unit, compute it accoring to CPU frequency
* @param[in] n number of cycles to wait
*/
static
inline
void
delay
(
int
n
)
{
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
asm
volatile
(
"nop"
);
}
/**
* It returns a pointer to the config ROM
*/
static
inline
const
struct
trtl_config_rom
*
trtl_config_rom_get
(
void
)
{
return
(
const
struct
trtl_config_rom
*
)(
TRTL_ADDR_CONFIG_ROM_BASE
);
}
/**
* It generates a notification signal (IRQ) to ask the HOST CPU
* to take some action.
*/
static
inline
void
trtl_notify_send
(
enum
trtl_cpu_notification
id
)
{
lr_writel
(
1
,
MT_CPU_LR_REG_NTF_INT
);
}
/**
* It returns the core ID on which the firmware is running
* @return the core ID
*/
static
inline
uint32_t
trtl_get_core_id
(
void
)
{
return
lr_readl
(
0
);
}
#endif
/**@}*/
software/rt/lib/mockturtle-rt.h
View file @
9228e8fa
...
...
@@ -18,5 +18,136 @@
#include "mockturtle-rt-smem.h"
#include "mockturtle-rt-serial.h"
/**
* Read a 32bit word value from the given address
* @param[in] addr source address
* @return the value fromt the register
*/
static
inline
uint32_t
readl
(
void
*
addr
)
{
return
*
(
volatile
uint32_t
*
)
(
addr
);
}
/**
* Write a 32bit word value to the given address
* @param[in] value value to write
* @param[in] addr destination address
*/
static
inline
void
writel
(
uint32_t
value
,
void
*
addr
)
{
*
(
volatile
uint32_t
*
)
(
addr
)
=
value
;
}
/**
* Read a 32bit word value from the Dedicated Peripheral address space
* @param[in] reg register offset within the Dedicated Peripheral
* @return the value fromt the register
*/
static
inline
uint32_t
dp_readl
(
uint32_t
reg
)
{
return
readl
(
TRTL_ADDR_DP
(
reg
));
}
/**
* Write a 32bit word value to the Dedicated Peripheral address space
* @param[in] value value to write
* @param[in] reg register offset within the Dedicated Peripheral
*/
static
inline
void
dp_writel
(
uint32_t
value
,
uint32_t
reg
)
{
writel
(
value
,
TRTL_ADDR_DP
(
reg
));
}
/**
* Read 32bit word value from the CPU Local Registers address space
* @param[in] reg register offset within the Local Registers
* @return the value fromt the register
*/
static
inline
uint32_t
lr_readl
(
uint32_t
reg
)
{
return
readl
(
TRTL_ADDR_LR
(
reg
));
}
/**
* Write 32bit word value to the CPU Local Registers address space
* @param[in] value value to write
* @param[in] reg register offset within the Local Registers
*/
static
inline
void
lr_writel
(
uint32_t
value
,
uint32_t
reg
)
{
writel
(
value
,
TRTL_ADDR_LR
(
reg
));
}
/**
* Set a bit in the CPU GPIO Register
* @param[in] pin GPIO pin to set
*/
static
inline
void
gpio_set
(
int
pin
)
{
lr_writel
((
1
<<
pin
),
MT_CPU_LR_REG_GPIO_SET
);
}
/**
* Clear a bit in the CPU GPIO Register
* @param[in] pin GPIO pin to clear
*/
static
inline
void
gpio_clear
(
int
pin
)
{
lr_writel
((
1
<<
pin
),
MT_CPU_LR_REG_GPIO_CLEAR
);
}
/**
* Wait n cycles
* @todo: use Timing Unit, compute it accoring to CPU frequency
* @param[in] n number of cycles to wait
*/
static
inline
void
delay
(
int
n
)
{
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
asm
volatile
(
"nop"
);
}
/**
* It returns a pointer to the config ROM
* @return pointer to the configuration ROM
*/
static
inline
const
struct
trtl_config_rom
*
trtl_config_rom_get
(
void
)
{
return
(
const
struct
trtl_config_rom
*
)(
TRTL_ADDR_CONFIG_ROM_BASE
);
}
/**
* It generates a notification signal (IRQ) to ask the HOST CPU
* to take some action.
* @param[in] id CPU notification identifier
*/
static
inline
void
trtl_notify_send
(
enum
trtl_cpu_notification
id
)
{
lr_writel
(
1
,
MT_CPU_LR_REG_HOST_INT
);
}
/**
* It returns the core ID on which the firmware is running
* @return the core ID
* @todo implement me
*/
static
inline
uint32_t
trtl_get_core_id
(
void
)
{
return
lr_readl
(
0
);
}
#endif
/**@}*/
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