diff --git a/env/ehrenberg/platform.h b/env/ehrenberg/platform.h index 0f82b0a..e22538c 100644 --- a/env/ehrenberg/platform.h +++ b/env/ehrenberg/platform.h @@ -40,6 +40,7 @@ #define msgif PERIPH(mkcontrolclusterstreamcontroller_t, APB_BASE + 0xC0000) #include "ehrenberg/devices/flexki_messages.h" +#include "ehrenberg/devices/fki_cluster_info.h" #define XIP_START_LOC 0xE0040000 #define RAM_START_LOC 0x80000000 diff --git a/include/ehrenberg/devices/fki_cluster_info.h b/include/ehrenberg/devices/fki_cluster_info.h new file mode 100644 index 0000000..406cce6 --- /dev/null +++ b/include/ehrenberg/devices/fki_cluster_info.h @@ -0,0 +1,316 @@ +#pragma once +#ifndef _FKI_CLUSTER_INFO_H +#define _FKI_CLUSTER_INFO_H + + +static uint8_t fki_ccc(uint8_t cluster); +static uint8_t fki_dma(uint8_t cluster); +static uint8_t fki_axi2stream(uint8_t cluster); +static uint8_t fki_stream2axi(uint8_t cluster); +static uint8_t fki_dma_adapter(uint8_t cluster); +static uint64_t fki_addr_ccc_peMapping(uint8_t cluster); +static uint64_t fki_addr_sram1(uint8_t cluster); +static uint64_t fki_addr_ccc_configMem(uint8_t cluster); +static uint64_t fki_addr_sram2(uint8_t cluster); +static uint64_t fki_addr_cntrl_cva5(uint8_t cluster); +static uint64_t fki_addr_cntrl_tgc(uint8_t cluster); +static uint64_t fki_addr_ccc_idxTasks(uint8_t cluster); +static uint64_t fki_addr_ccc_idxJobs(uint8_t cluster); +static uint64_t fki_addr_aes_adapter(uint8_t cluster); +static uint64_t fki_addr_ut_adapter(uint8_t cluster); +static uint64_t fki_addr_sram0(uint8_t cluster); +static uint64_t fki_addr_sram3(uint8_t cluster); +static uint64_t fki_addr_hide_adapter(uint8_t cluster); + +#define Compute0 2 +#define Compute0_ccc 2,0 +#define Compute0_stream2axi 2,1 +#define Compute0_axi2stream 2,2 +#define Compute0_dma 2,4 +#define Compute0_dma_adapter 2,5 +#define ADDR_Compute0_ccc_idxJobs 0x80004000 +#define ADDR_Compute0_ccc_idxTasks 0x80005000 +#define ADDR_Compute0_ccc_configMem 0x80000000 +#define ADDR_Compute0_ccc_peMapping 0x80006000 +#define ADDR_Compute0_aes_adapter 0x80007000 +#define ADDR_Compute0_hide_adapter 0x80008000 +#define ADDR_Compute0_cntrl_cva5 0x80009000 +#define ADDR_Compute0_cntrl_tgc 0x8000a000 +#define ADDR_Compute0_ut_adapter 0x8000b000 +#define ADDR_Compute0_sram0 0x8000c000 +#define ADDR_Compute0_sram1 0x8010c000 +#define ADDR_Compute0_sram2 0x8018c000 +#define ADDR_Compute0_sram3 0x8020c000 +#define Compute1 3 +#define Compute1_ccc 3,0 +#define Compute1_stream2axi 3,1 +#define Compute1_axi2stream 3,2 +#define Compute1_dma 3,4 +#define Compute1_dma_adapter 3,5 +#define ADDR_Compute1_ccc_idxJobs 0x90004000 +#define ADDR_Compute1_ccc_idxTasks 0x90005000 +#define ADDR_Compute1_ccc_configMem 0x90000000 +#define ADDR_Compute1_ccc_peMapping 0x90006000 +#define ADDR_Compute1_aes_adapter 0x90007000 +#define ADDR_Compute1_hide_adapter 0x90008000 +#define ADDR_Compute1_cntrl_cva5 0x90009000 +#define ADDR_Compute1_cntrl_tgc 0x9000a000 +#define ADDR_Compute1_ut_adapter 0x9000b000 +#define ADDR_Compute1_sram0 0x9000c000 +#define ADDR_Compute1_sram1 0x9010c000 +#define ADDR_Compute1_sram2 0x9018c000 +#define ADDR_Compute1_sram3 0x9020c000 + +static uint8_t fki_ccc(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0; + } + case 3: { + return 0; + } + default: { + return -1; + } + } +} + +static uint8_t fki_dma(uint8_t cluster) { + switch(cluster) { + case 3: { + return 4; + } + case 2: { + return 4; + } + default: { + return -1; + } + } +} + +static uint8_t fki_axi2stream(uint8_t cluster) { + switch(cluster) { + case 3: { + return 2; + } + case 2: { + return 2; + } + default: { + return -1; + } + } +} + +static uint8_t fki_stream2axi(uint8_t cluster) { + switch(cluster) { + case 3: { + return 1; + } + case 2: { + return 1; + } + default: { + return -1; + } + } +} + +static uint8_t fki_dma_adapter(uint8_t cluster) { + switch(cluster) { + case 2: { + return 5; + } + case 3: { + return 5; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_ccc_peMapping(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0x80006000; + } + case 3: { + return 0x90006000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_sram1(uint8_t cluster) { + switch(cluster) { + case 3: { + return 0x9010c000; + } + case 2: { + return 0x8010c000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_ccc_configMem(uint8_t cluster) { + switch(cluster) { + case 3: { + return 0x90000000; + } + case 2: { + return 0x80000000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_sram2(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0x8018c000; + } + case 3: { + return 0x9018c000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_cntrl_cva5(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0x80009000; + } + case 3: { + return 0x90009000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_cntrl_tgc(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0x8000a000; + } + case 3: { + return 0x9000a000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_ccc_idxTasks(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0x80005000; + } + case 3: { + return 0x90005000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_ccc_idxJobs(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0x80004000; + } + case 3: { + return 0x90004000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_aes_adapter(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0x80007000; + } + case 3: { + return 0x90007000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_ut_adapter(uint8_t cluster) { + switch(cluster) { + case 3: { + return 0x9000b000; + } + case 2: { + return 0x8000b000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_sram0(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0x8000c000; + } + case 3: { + return 0x9000c000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_sram3(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0x8020c000; + } + case 3: { + return 0x9020c000; + } + default: { + return -1; + } + } +} + +static uint64_t fki_addr_hide_adapter(uint8_t cluster) { + switch(cluster) { + case 2: { + return 0x80008000; + } + case 3: { + return 0x90008000; + } + default: { + return -1; + } + } +} + +#endif //_FKI_CLUSTER_INFO_H \ No newline at end of file diff --git a/include/ehrenberg/devices/flexki_messages.h b/include/ehrenberg/devices/flexki_messages.h index a836dd1..a54c39f 100644 --- a/include/ehrenberg/devices/flexki_messages.h +++ b/include/ehrenberg/devices/flexki_messages.h @@ -1,6 +1,8 @@ #ifndef _FLEXKI_MESSAGES_H #define _FLEXKI_MESSAGES_H +#include "fki_cluster_info.h" + #include static void send_msg(uint32_t cluster, uint32_t component, uint32_t msg_len, uint32_t msg_id, uint32_t* words) { @@ -41,6 +43,14 @@ static void send_msg(uint32_t cluster, uint32_t component, uint32_t msg_len, uin set_mkcontrolclusterstreamcontroller_REG_SEND(msgif, 1); } +static uint32_t check_response() { + while (true) { + if (get_mkcontrolclusterstreamcontroller_REG_ACK_PENDING_RESPONSE(msgif) != 0) { + return get_mkcontrolclusterstreamcontroller_REG_RECV_ID_RECV_ID(msgif); + } + } +} + static uint32_t wait_response(uint32_t msg_id) { while (true) { if (get_mkcontrolclusterstreamcontroller_REG_ACK_PENDING_RESPONSE(msgif) != 0) { @@ -54,4 +64,14 @@ static uint32_t wait_response(uint32_t msg_id) { return response_payload; } +static void fki_dma_transfer(uint32_t cluster, uint32_t msg_id, uint32_t srcAddr, uint32_t destAddr, uint32_t bytes) { + uint32_t values[] = { + 0, + srcAddr, + destAddr, + bytes + }; + send_msg(cluster, fki_dma(cluster), 4, msg_id, values); +} + #endif /* _FLEXKI_MESSAGES_H */ \ No newline at end of file