Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions cpu/src/kernel/service/svc_dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ under the terms of the GNU Affero General Public License as published by
/*----- Macros -------------------------------------------------------*/

#define MSG_START 0xf0
#define SYSTEM_PROFILE_PAYLOAD_LENGTH 12

/*----- Typedefs -----------------------------------------------------*/

Expand Down Expand Up @@ -88,7 +89,7 @@ typedef void (*t_module_param_value_callback)(uint16_t module_id,
typedef void (*t_system_port_state_callback)(uint16_t port_f, uint16_t port_g,
uint16_t port_h);

typedef void (*t_system_profile_callback)(uint32_t period, uint32_t cycles);
typedef void (*t_system_profile_callback)(uint32_t period, uint64_t cycles);

static t_module_param_value_callback p_module_param_value_callback;
static t_system_port_state_callback p_system_port_state_callback;
Expand Down Expand Up @@ -541,13 +542,23 @@ static t_status _handle_system_port_state(uint8_t *payload, uint8_t length) {

static t_status _handle_system_profile(uint8_t *payload, uint8_t length) {

if (p_system_profile_callback != NULL) {
if (length < SYSTEM_PROFILE_PAYLOAD_LENGTH) {
return ERROR;
}

uint32_t period = (payload[3] << 24 | payload[2] << 16 |
payload[1] << 8 | payload[0]);
if (p_system_profile_callback != NULL) {

uint32_t cycles = (payload[7] << 24 | payload[6] << 16 |
payload[5] << 8 | payload[4]);
uint32_t period = (uint32_t)payload[3] << 24 |
(uint32_t)payload[2] << 16 |
(uint32_t)payload[1] << 8 | payload[0];

uint64_t cycles = (uint64_t)payload[11] << 56 |
(uint64_t)payload[10] << 48 |
(uint64_t)payload[9] << 40 |
(uint64_t)payload[8] << 32 |
(uint64_t)payload[7] << 24 |
(uint64_t)payload[6] << 16 |
(uint64_t)payload[5] << 8 | payload[4];

p_system_profile_callback(period, cycles);
}
Expand Down
2 changes: 1 addition & 1 deletion dsp/src/kernel/knl_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ t_profile knl_profile_stats(void) {
static t_profile stats;

stats.period = (uint32_t)sport0_period();
stats.cycles = (uint32_t)g_module_cycles;
stats.cycles = g_module_cycles;

return stats;
}
Expand Down
2 changes: 1 addition & 1 deletion dsp/src/kernel/knl_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extern "C" {

typedef struct {
uint32_t period;
uint32_t cycles;
uint64_t cycles;

} t_profile;

Expand Down
5 changes: 4 additions & 1 deletion dsp/src/kernel/service/svc_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ under the terms of the GNU Affero General Public License as published by
/*----- Macros -------------------------------------------------------*/

#define MSG_START 0xf0
#define SYSTEM_PROFILE_PAYLOAD_LENGTH 12

/*----- Typedefs -----------------------------------------------------*/

Expand Down Expand Up @@ -505,10 +506,12 @@ static t_status _respond_system_profile(t_profile stats) {
(stats.period >> 16) & 0xff, (stats.period >> 24) & 0xff,
stats.cycles & 0xff, (stats.cycles >> 8) & 0xff,
(stats.cycles >> 16) & 0xff, (stats.cycles >> 24) & 0xff,
(stats.cycles >> 32) & 0xff, (stats.cycles >> 40) & 0xff,
(stats.cycles >> 48) & 0xff, (stats.cycles >> 56) & 0xff,
};

_transmit_message(MSG_TYPE_SYSTEM, SYSTEM_PROFILE, payload,
sizeof(payload));
SYSTEM_PROFILE_PAYLOAD_LENGTH);

return SUCCESS;
}
Expand Down