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
5136d4ad
Commit
5136d4ad
authored
Apr 27, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw:rt: move all headers to mockturtle-rt.h
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
12b0d558
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
511 additions
and
572 deletions
+511
-572
mockturtle-rt-mqueue.h
software/rt/lib/mockturtle-rt-mqueue.h
+0
-210
mockturtle-rt-serial.h
software/rt/lib/mockturtle-rt-serial.h
+0
-145
mockturtle-rt-smem.h
software/rt/lib/mockturtle-rt-smem.h
+0
-210
mockturtle-rt.h
software/rt/lib/mockturtle-rt.h
+510
-5
printf.c
software/rt/lib/printf.c
+1
-2
No files found.
software/rt/lib/mockturtle-rt-mqueue.h
deleted
100644 → 0
View file @
12b0d558
/**
* @defgroup library-message-queue Message Queue
* @{
* @ingroup library
* @brief Message Queues definitions and functions
* @copyright (C) 2013-2016 CERN (www.cern.ch)
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Federico Vaga <federico.vaga@cern.ch>
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef __TRTL_FW_MQUEUE_H
#define __TRTL_FW_MQUEUE_H
#include <hw/mockturtle_addresses.h>
#include <hw/mockturtle_queue.h>
#include <hw/mockturtle_cpu_lr.h>
#include "mockturtle-rt-common.h"
#define TRTL_MQ_SLOT_IN(slot) (TRTL_MQ_BASE_IN + ((slot) << 16))
// Outgoung slot base address, relative to BASE_HMQ
#define TRTL_MQ_SLOT_OUT(slot) (TRTL_MQ_BASE_OUT + ((slot) << 16))
/**
* List of Message Queue types
*/
enum
trtl_mq_type
{
TRTL_HMQ
=
0
,
/**< Host Message Queue - Host-Firmware communication */
TRTL_RMQ
,
/**< Remote Message Queue - Network-Firmware communication */
__TRTL_MAX_MQ_TYPE
,
};
/**
* It gets the Message Queue base address
* @param[in] type MQ type
*/
static
inline
void
*
trtl_mq_base_address
(
enum
trtl_mq_type
type
)
{
return
(
void
*
)(
type
==
TRTL_HMQ
?
TRTL_ADDR_HMQ_BASE
:
TRTL_ADDR_RMQ_BASE
);
}
/**
* It writes on a Message Queue register
* @param[in] type MQ type to use
* @param[val] value to write
* @param[reg] reg register offset
*/
static
inline
void
mq_writel
(
enum
trtl_mq_type
type
,
uint32_t
val
,
uint32_t
reg
)
{
*
(
volatile
uint32_t
*
)(
trtl_mq_base_address
(
type
)
+
reg
)
=
val
;
}
/**
* It gets the output slot data field pointer
* @param[in] type MQ type to use
* @param[in] slot slot number
* @return pointer to the input buffer
*/
static
inline
void
*
mq_map_out_buffer
(
enum
trtl_mq_type
type
,
int
slot
)
{
return
(
void
*
)
(
trtl_mq_base_address
(
type
)
+
TRTL_MQ_SLOT_OUT
(
slot
)
+
TRTL_MQ_SLOT_DATA_START
);
}
/**
* It gets the input slot data field pointer
* @param[in] type MQ type to use
* @param[in] slot slot number
* @return pointer to the input buffer
*/
static
inline
void
*
mq_map_in_buffer
(
enum
trtl_mq_type
type
,
int
slot
)
{
return
(
void
*
)
(
trtl_mq_base_address
(
type
)
+
TRTL_MQ_SLOT_IN
(
slot
)
+
TRTL_MQ_SLOT_DATA_START
);
}
/**
* It gets the output slot header field pointer
* @param[in] type MQ type to use
* @param[in] slot slot number
* @return pointer to the output header
*/
static
inline
void
*
mq_map_out_header
(
enum
trtl_mq_type
type
,
int
slot
)
{
return
(
void
*
)
(
trtl_mq_base_address
(
type
)
+
TRTL_MQ_SLOT_OUT
(
slot
)
+
TRTL_MQ_SLOT_HEADER_START
);
}
/**
* It gets the input slot header field pointer
* @param[in] type MQ type to use
* @param[in] slot slot number
* @return pointer to the input header
*/
static
inline
void
*
mq_map_in_header
(
enum
trtl_mq_type
type
,
int
slot
)
{
return
(
void
*
)
(
trtl_mq_base_address
(
type
)
+
TRTL_MQ_SLOT_IN
(
slot
)
+
TRTL_MQ_SLOT_HEADER_START
);
}
/**
* @copydoc TRTL_MQ_CMD_CLAIM
* @param[in] type MQ type to use
* @param[in] slot slot number
*/
static
inline
void
mq_claim
(
enum
trtl_mq_type
type
,
int
slot
)
{
mq_writel
(
type
,
TRTL_MQ_CMD_CLAIM
,
TRTL_MQ_SLOT_OUT
(
slot
)
+
TRTL_MQ_SLOT_COMMAND
);
}
/**
* @copydoc TRTL_MQ_CMD_PURGE
* @param[in] type MQ type to use
* @param[in] slot slot number
*/
static
inline
void
mq_purge
(
enum
trtl_mq_type
type
,
int
slot
)
{
mq_writel
(
type
,
TRTL_MQ_CMD_PURGE
,
TRTL_MQ_SLOT_OUT
(
slot
)
+
TRTL_MQ_SLOT_COMMAND
);
mq_writel
(
type
,
TRTL_MQ_CMD_PURGE
,
TRTL_MQ_SLOT_IN
(
slot
)
+
TRTL_MQ_SLOT_COMMAND
);
}
/**
* @copydoc TRTL_MQ_CMD_READY
* @param[in] type MQ type to use
* @param[in] slot slot number
*/
static
inline
void
mq_send
(
enum
trtl_mq_type
type
,
int
slot
)
{
mq_writel
(
type
,
TRTL_MQ_CMD_READY
,
TRTL_MQ_SLOT_OUT
(
slot
)
+
TRTL_MQ_SLOT_COMMAND
);
}
/**
* @copydoc TRTL_MQ_CMD_DISCARD
* @param[in] type MQ type to use
* @param[in] slot slot number
*/
static
inline
void
mq_discard
(
enum
trtl_mq_type
type
,
int
slot
)
{
mq_writel
(
type
,
TRTL_MQ_CMD_DISCARD
,
TRTL_MQ_SLOT_IN
(
slot
));
}
/**
* It maps a given MQ for outcoming messages
* @param[in] type MQ type to use
* @param[in] idx_mq MQ index
* @param[out] msg where to map the message
*/
static
inline
void
mq_map_out_message
(
enum
trtl_mq_type
type
,
unsigned
idx_mq
,
struct
trtl_msg
*
msg
)
{
msg
->
header
=
mq_map_out_header
(
type
,
idx_mq
);
msg
->
payload
=
mq_map_out_buffer
(
type
,
idx_mq
);
}
/**
* It maps a given MQ for incoming messages
* @param[in] type MQ type to use
* @param[in] idx_mq MQ index
* @param[out] msg where to map the message
*/
static
inline
void
mq_map_in_message
(
enum
trtl_mq_type
type
,
unsigned
idx_mq
,
struct
trtl_msg
*
msg
)
{
msg
->
header
=
mq_map_in_header
(
type
,
idx_mq
);
msg
->
payload
=
mq_map_in_buffer
(
type
,
idx_mq
);
}
/**
* It gets the current MQ input status
* @return message queues input status bitmask
*/
static
inline
uint32_t
mq_poll_in
(
enum
trtl_mq_type
type
)
{
uint32_t
poll
=
lr_readl
(
MT_CPU_LR_REG_HMQ_STAT
+
(
type
*
4
));
/* HMQ and RMQ have the same format -> use the same mask */
return
((
poll
&
MT_CPU_LR_HMQ_STAT_IN_MASK
)
>>
MT_CPU_LR_HMQ_STAT_IN_SHIFT
);
}
/**
* It gets the current MQ output status
* @return message queues output status bitmask
*/
static
inline
uint32_t
mq_poll_out
(
enum
trtl_mq_type
type
)
{
uint32_t
poll
=
lr_readl
(
MT_CPU_LR_REG_HMQ_STAT
+
(
type
*
4
));
/* HMQ and RMQ have the same format -> use the same mask */
return
((
poll
&
MT_CPU_LR_HMQ_STAT_OUT_MASK
)
>>
MT_CPU_LR_HMQ_STAT_OUT_SHIFT
);
}
#endif
/**@}*/
software/rt/lib/mockturtle-rt-serial.h
deleted
100644 → 0
View file @
12b0d558
/**
* @defgroup library-serial Serial Console
* @{
* @ingroup library
* @brief Serial Console functions
* @copyright (C) 2013-2016 CERN (www.cern.ch)
* @author Alessandro Rubini <rubini@gnudd.com>
* @author Federico Vaga <federico.vaga@cern.ch>
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef __TRTL_FW_PP_PRINTF_H
#define __TRTL_FW_PP_PRINTF_H
#include <stdarg.h>
#include <generated/autoconf.h>
/**
* Print buffer size. This means that your printf string
* should not exceed this value. If the string exceed this value
* then it will be trouncated.
*/
#define CONFIG_PRINT_BUFSIZE 128
/**
* It prints a string on the serial interface.
* Internally, it uses the puts() function.
* @param[in] fmt string format
* @param[in] ... argument according to the string format
* @return number of printed characters
*/
#if HAS_MOCKTURTLE_LIBRARY_PRINT_ENABLE == 1
extern
int
pp_printf
(
const
char
*
fmt
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
#else
static
inline
int
pp_printf
(
const
char
*
fmt
,
...)
{
return
0
;
}
#endif
/**
* It creates a new string according to the given format
* @param[out] s output string
* @param[in] fmt string format
* @param[in] ... argument according to the string format
* @return number of printed characters
*/
#if HAS_MOCKTURTLE_LIBRARY_PRINT_ENABLE == 1
extern
int
pp_sprintf
(
char
*
s
,
const
char
*
fmt
,
...)
__attribute__
((
format
(
printf
,
2
,
3
)));
#else
static
inline
int
pp_sprintf
(
char
*
s
,
const
char
*
fmt
,
...)
{
return
0
;
}
#endif
/**
* It prints a string on the serial interface.
* Internally, it uses the puts() function.
* @param[in] fmt string format
* @param[in] args list of arguments according to the string format
* @return number of printed characters
*/
#if HAS_MOCKTURTLE_LIBRARY_PRINT_ENABLE
extern
int
pp_vprintf
(
const
char
*
fmt
,
va_list
args
);
#else
static
inline
int
pp_vprintf
(
const
char
*
fmt
,
va_list
args
)
{
return
0
;
}
#endif
/**
* It creates a new string according to the given format
* @param[out] buf output string
* @param[in] fmt string format
* @param[in] args list of arguments according to the string format
* @return number of printed characters
*/
#if HAS_MOCKTURTLE_LIBRARY_PRINT_ENABLE == 1
extern
int
pp_vsprintf
(
char
*
buf
,
const
char
*
,
va_list
args
)
__attribute__
((
format
(
printf
,
2
,
0
)));
#else
static
inline
int
pp_vsprintf
(
char
*
buf
,
const
char
*
fmt
,
va_list
args
)
{
return
0
;
}
#endif
/**
* It prints a string on the serial interface only when the support
* for error messages is enable.
*
* Kconfig ->CONFIG_MOCKTURTLE_LIBRARY_PRINT_DEBUG_ENABLE
*
* Internally, it uses the puts() function.
* @param[in] fmt string format
* @param[in] ... argument according to the string format
* @return number of printed characters
*/
#if (HAS_MOCKTURTLE_LIBRARY_PRINT_ENABLE == 1) && (HAS_MOCKTURTLE_LIBRARY_PRINT_DEBUG_ENABLE == 1)
extern
int
pr_debug
(
const
char
*
fmt
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
#else
static
inline
int
pr_debug
(
const
char
*
fmt
,
...)
{
return
0
;
}
#endif
/**
* It prints a string on the serial interface only when the support
* for error messages is enable.
*
* Kconfig -> CONFIG_MOCKTURTLE_LIBRARY_PRINT_ERROR_ENABLE
*
* Internally, it uses the puts() function.
* @param[in] fmt string format
* @param[in] ... argument according to the string format
* @return number of printed characters
*/
#if (HAS_MOCKTURTLE_LIBRARY_PRINT_ENABLE == 1) && (HAS_MOCKTURTLE_LIBRARY_PRINT_ERROR_ENABLE == 1)
extern
int
pr_error
(
const
char
*
fmt
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
#else
static
inline
int
pr_error
(
const
char
*
fmt
,
...)
{
return
0
;
}
#endif
extern
int
putchar
(
int
c
);
extern
int
puts
(
const
char
*
p
);
/**@}*/
#endif
software/rt/lib/mockturtle-rt-smem.h
deleted
100644 → 0
View file @
12b0d558
/**
* @defgroup library-shared-memory Shared Memory Utilities
* @{
* @ingroup library
* @brief Shared Memory definitions & API
* @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_FW_SMEM_H
#define __TRTL_FW_SMEM_H
/**
* Shared Memory Size
*/
#define TRTL_SMEM_SIZE 0x10000
/**
* Shared Memory address for the
* @copydoc TRTL_SMEM_TYPE_BASE
* memory access
*/
#define TRTL_SMEM_RANGE_BASE 0x00000
/**
* It generates the SHM address range for a given SHM type
*/
#define TRTL_SMEM_TYPE_TO_RANGE(_type) \
(TRTL_SMEM_RANGE_BASE + (_type) * TRTL_SMEM_SIZE)
/**
* Shared Memory base address for the
* @copydoc TRTL_SMEM_TYPE_ADD
* memory access
*/
#define TRTL_SMEM_RANGE_ADD \
TRTL_SMEM_TYPE_TO_RANGE(TRTL_SMEM_TYPE_ADD)
/**
* Shared Memory base address for the
* @copydoc TRTL_SMEM_TYPE_SUB
* memory access
*/
#define TRTL_SMEM_RANGE_SUB \
TRTL_SMEM_TYPE_TO_RANGE(TRTL_SMEM_TYPE_SUB)
/**
* Shared Memory address for the
* @copydoc TRTL_SMEM_TYPE_SET
* memory access
*/
#define TRTL_SMEM_RANGE_SET \
TRTL_SMEM_TYPE_TO_RANGE(TRTL_SMEM_TYPE_SET)
/**
* Shared Memory address for the
* @copydoc TRTL_SMEM_TYPE_CLR
* memory access
*/
#define TRTL_SMEM_RANGE_CLEAR \
TRTL_SMEM_TYPE_TO_RANGE(TRTL_SMEM_TYPE_CLR)
/**
* Shared Memory address for the
* @copydoc TRTL_SMEM_TYPE_FLP
* memory access
*/
#define TRTL_SMEM_RANGE_FLIP \
TRTL_SMEM_TYPE_TO_RANGE(TRTL_SMEM_TYPE_FLP)
/**
* Shared Memory address for the
* @copydoc TRTL_SMEM_TYPE_TST_SET
* memory access
*/
#define TRTL_SMEM_RANGE_TEST_AND_SET \
TRTL_SMEM_TYPE_TO_RANGE(TRTL_SMEM_TYPE_TST_SET)
/**
* Compiler attribute to allocate variable on the Share Memory.
* Add this to the variable declaration to put it on the Shared Memory.
*
* SMEM int x;
*/
#define SMEM volatile __attribute__((section(".smem")))
/**
* It performs an operations on the shared memory. What the function
* performs can be summerized as:
*
* (*p) = (*p) <operation-type> x
*
* Use this function only when the operation type that you want to use
* is not supported yet by the library directly. Otherwise,
* use the other functions.
*
* @param[in] p address on the shared memory of the first operator and store location
* @param[in] x second operation argument
* @param[in] type operation type
*/
static
inline
void
__smem_atomic_op
(
volatile
int
*
p
,
int
x
,
enum
trtl_smem_type
type
)
{
*
(
volatile
int
*
)(
p
+
(
TRTL_SMEM_TYPE_TO_RANGE
(
type
)
>>
2
))
=
x
;
}
/**
* It performs an
* @copydoc TRTL_SMEM_TYPE_ADD
*
* (*p) = (*p) + x
*
* @param[in] p address on the shared memory of the first operator and store location
* @param[in] x second operation argument
*/
static
inline
void
smem_atomic_add
(
volatile
int
*
p
,
int
x
)
{
__smem_atomic_op
(
p
,
x
,
TRTL_SMEM_TYPE_ADD
);
}
/**
* It performs an
* @copydoc TRTL_SMEM_TYPE_SUB
*
* (*p) = (*p) - x
*
* @param[in] p address on the shared memory of the first operator and store location
* @param[in] x second operation argument
*/
static
inline
void
smem_atomic_sub
(
volatile
int
*
p
,
int
x
)
{
__smem_atomic_op
(
p
,
x
,
TRTL_SMEM_TYPE_SUB
);
}
/**
* It performs an
* @copydoc TRTL_SMEM_TYPE_SET
*
* (*p) = (*p) | x
*
* @param[in] p address on the shared memory of the first operator and store location
* @param[in] x second operation argument
*/
static
inline
void
smem_atomic_or
(
volatile
int
*
p
,
int
x
)
{
__smem_atomic_op
(
p
,
x
,
TRTL_SMEM_TYPE_SET
);
}
/**
* It performs an
* @copydoc TRTL_SMEM_TYPE_CLR
*
* (*p) = (*p) & (~x)
*
* @param[in] p address on the shared memory of the first operator and store location
* @param[in] x second operation argument
*/
static
inline
void
smem_atomic_and_not
(
volatile
int
*
p
,
int
x
)
{
__smem_atomic_op
(
p
,
x
,
TRTL_SMEM_TYPE_CLR
);
}
/**
* It performs an
* @copydoc TRTL_SMEM_TYPE_FLP
*
* (*p) = (*p) ^ x
*
* @param[in] p address on the shared memory of the first operator and store location
* @param[in] x second operation argument
*/
static
inline
void
smem_atomic_xor
(
int
*
p
,
int
x
)
{
__smem_atomic_op
(
p
,
x
,
TRTL_SMEM_TYPE_FLP
);
}
/**
* It performs an:
* @copydoc TRTL_SMEM_TYPE_TST_SET
*
* val = (*p);
* if (val == 0) {
* (*p) = 1;
* }
* return val;
*
* This is useful to implement mutex
*
* @param[in] p address on the shared memory
* @return the value before the set
*/
static
inline
int
smem_atomic_test_and_set
(
int
*
p
)
{
/* shift right translates range in bytes into range in words */
return
*
(
volatile
int
*
)(
p
+
(
TRTL_SMEM_TYPE_TST_SET
>>
2
));
}
#endif
/**@}*/
software/rt/lib/mockturtle-rt.h
View file @
5136d4ad
This diff is collapsed.
Click to expand it.
software/rt/lib/printf.c
View file @
5136d4ad
...
...
@@ -11,8 +11,7 @@
#include <stdarg.h>
#include <mockturtle-rt-common.h>
#include <mockturtle-rt-serial.h>
#include <mockturtle-rt.h>
#if HAS_MOCKTURTLE_LIBRARY_PRINT_ENABLE == 1
...
...
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